1 / 40

Using ActionScript and Creating Templates

Macromedia Flash Design & Application. Chapter 7. Using ActionScript and Creating Templates. Performance Objectives. Define the terms object-oriented programming, object, method, action, event, and parameters. List general guidelines for creating ActionScript in movies.

kalea
Télécharger la présentation

Using ActionScript and Creating Templates

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Macromedia FlashDesign & Application Chapter 7 Using ActionScript and Creating Templates

  2. Performance Objectives • Define the terms object-oriented programming, object, method, action, event, and parameters. • List general guidelines for creating ActionScript in movies. • Switch between Normal mode and Expert mode in the Actions panel and describe the difference between the two modes. • Add actions to keyframes, buttons, and movie clips. • Use the goto and stop actions to control movie playback. • Add labels and comments to frames. • Create a preloader animation. • Perform a conditional test on a movie property.

  3. Performance Objectives • Create buttons to toggle the playback of a stream soundtrack on and off. • Use the with action to target start and stop actions at a movie clip instance. • Use the getURL action to open a Web page during a movie. • Use the fscommand action to control a projector window. • Create and use a Flash template. • Use the Movie Explorer. • List Web resources for learning more about Flash. • COMMANDS REVIEW

  4. Understanding ActionScript Concepts and Terms • ActionScript is a scripting language • scripts are a series of commands that provide instruction to the computer • commands are generally carried out in sequence • generally easy to understand • Learning ActionScript involves: • learning the keywords • using proper syntax

  5. Object-Oriented Programming • ActionScript is an object-oriented scripting language • similar to JavaScript • Classes are defined with a set of properties and methods • defines the object's characteristics and behavior • instances of a class are referred to as objects • Existing code can be reused • more efficient and easier to maintain

  6. Actions, Events, and Parameters • Actions • statements that instruct Flash on what to do with a target object • listed in the toolbox in the Actions panel • Events • an event can be a mouse movement, a key pressed on the keyboard, or the loading of a movie clip • the event triggers the action • actions applied to a button or movie clip instance execute when an event occurs • Parameters • also called arguments • provide the variable information for the action statement

  7. General Guidelines for Writing ActionScript • Before starting to write ActionScript code you should have: • a clear definition of the goal of the movie • a flow chart diagramming the movie's actions • a plan as to which objects will require ActionScript statements • Use comments to document what is happening at key points • Focus on one section at a time until it is working correctly • then save as a separate version as a backup • Object and variable names should be descriptive labels • easily identify the element

  8. The Actions Panel inNormal Mode Flash assists you with the programming. The proper syntax for each statement is inserted. Window, Actions or F9 Step 1 Double-click action in toolbox. Flash builds the code for you. Step 2 Add parameters if the action has any.

  9. The Actions Panel inExpert Mode The parameters area is replaced with a larger ActionScript area. Check Syntax Show Code Hint Code Hint show next code hint Flash does not build the statement for you. Use code hints to view available parameters for the current action. Step 1 Double-click action in toolbox. Step 2 Key parameters using proper syntax. Switching from Expert mode to Normal code causes Flash to check the syntax.

  10. Controlling Movie Playback

  11. Goto • Moves the playhead to a different frame in the Timeline • Destination parameter can be specified using a frame number or a frame label • using frame labels is preferable since the label stays with the frame when editing • Includes two choices when it reaches the destination • Go to and Play • Go to and Stop

  12. On • Dimmed unless a button instance is active • Creates the event handler that specifies to which mouse event you want the action to respond • multiple events can be selected

  13. Play, Stop, and StopAllSounds • Play • uses no parameters • instructs Flash to begin playing the movie at the point in the Timeline at which the action is executed • Stop • uses no parameters • instructs Flash to stop playing the movie • StopAllSounds • stops all sounds that are currently playing • stream sounds will resume playing when the playhead reaches the frame in which it has been associated

  14. Assigning Labels to a Keyframe -to reference the destination by name instead of number -if frames are added, moved, or removed, no change is required to the ActionScript. key a name frame label displays next to a red flag

  15. Assigning Comments to a Keyframe -helps you to remember what is happening in segments of the Timeline -editing is made easier precede comment text with two forward slashes usually entered in a separate layer two green slashes display in front of comment text Comments can also be added in ActionScript code.

  16. Creating a Preloader Animation • A simple animation at the beginning of a movie that loops until the download is completed • Key concepts: • small animation at the beginning that contains simple text such as a Loading message • ActionScript is added at the end to create a loop • ActionScript is added at the first frame that performs a conditional test

  17. Performing a Conditional Test • Use the if action • Can have two possible outcomes • true • false • A false action is not required since Flash will simply skip the actions in the curly braces and move to the next line of code if the conditional test proves false if (conditional test) { action to be performed if test is true }

  18. Adding an Else Statement • Use to specify a false action • Add immediately after the if action if (frames loaded = all frames) { gotoAndPlay(main movie); } else { gotoAndPlay(preloader animation); }

  19. Nesting If Statements • To perform a test that has more than two possible outcomes • Add an else if action after the initial if block if (frames loaded = all frames) { gotoAndPlay(main movie); } else if (frames loaded > 10) { gotoAndPlay(preloader animation B); } else { gotoAndPlay(preloader animation A); }

  20. Testing for Status of Frames Loaded • Each movie Timeline has a set of properties identified with an underscore character in front of the property name that can be checked or modified • _framesloaded property returns the number of frames that have been downloaded • _totalframes property returns a value representing the total number of frames within a movie

  21. Testing for Status of Frames Loaded…/2 • Properties are identified with an underscore character at the beginning • Two equals symbols (equality operator) tells Flash to check if the value for the property on the left equals the value for the property on the right (_framesloaded == _totalframes)

  22. Adding Actions for a Preloader Animation insert a new layer cut, paste, and clear frames as necessary use the drawing tools to create the preloader in frame 1 insert a keyframe and delete the drawn preloader

  23. Adding Actions for a Preloader Animation…/2 insert a new layer insert a keyframe double-click goto This action will create a loop in which frames 1-11 will continually replay.

  24. Adding Actions for a Preloader Animation…/3 click if in frame 1 of the Actions layer double-click properties to add to text box -key spaces andequals signs double-click goto key frame number This action will move the playhead to frame 12 when all of the frames have been downloaded.

  25. Adding Actions for a Preloader Animation…/4 click frame 12 in the Actions layer double-click This action causes Flash to stop playing the main movie Timeline.

  26. Using Buttons to Toggle the Playing of a Soundtrack On and Off • A streamed soundtrack in a movie clip symbol can be the target action for start and stop sound buttons • provides the user with the ability to turn sound on or off during the movie playback • Requires ActionScript using the with statement

  27. With Statement targets a named instance of a movie clip stop playing the sound upon pressing and releasing the mouse over the button start playing the sound upon pressing and releasing the mouse over the button

  28. Using the getURL Action to Open a Web Page During a Movie • The URL parameter can be an absolute or relative address for a Web page or document • Window parameters: • _self: opens within the current window replacing the movie from which it originated • _blank: opens in a new browser window • _parent: opens in the browser in the parent of the current frame • _top: opens in the top-level frame of the current browser window

  29. Using the getURL Action to Open a Web Page During a Movie…/2 -publish the movie as HTML and as a projector file File, Publish Settings or Ctrl + Shift + F12 click click

  30. Using the fscommand to Control the Player Window • Used to control the environment in the window hosting the movie • Commands for standalone player include fullscreen, allowscale, showmenu, trapallkeys, exec, and quit

  31. Creating a Template -saves time and ensures consistency -include standard elements such as a company logo, colors, and publishing options File, Save As Template preview appears key a name choose or add a category key a brief description of the standardized elements click Save

  32. Using a Template File, New From Template click category name click template name description is displayed click Create

  33. Using the Movie Explorer Panel -a tool with which you can locate or view objects in a movie in a hierarchical display Window, Movie Explorer or Alt + F3 Show Text Show Buttons, Movie Clips and Graphics Show Action Scripts Show Video, Sounds and Bitmaps Show Frames and Layers Expand to view ActionScript statements Customize which Items to Show

  34. Finding Information About Flash on the Web • Go to the Source • Macromedia maintains tech notes and tutorials on the Flash support center that provide articles on Flash features including step-by-step instructions • www.macromedia.com/support/flash • Flashkit.com Flash Developer Resource Site • a Web site for developers that includes several resources including forums and free downloads to assist with building Flash movies • www.flashkit.com • Flash Magazine • a Web site maintained by volunteer Flash developers from around the world with articles and tutorials on using Flash • www.flashmagazine.com

  35. Commands Review How do you display the Actions panel? Window, Actions or F9

  36. Commands Review How do you display the Movie Explorer panel? Window, Movie Explorer or Alt + F3

  37. Commands Review How do you create a new document based on a template? File, New From Template

  38. Commands Review How do you display the Publish Settings dialog box? File, Publish Settings or Ctrl + Shift + F12

  39. Commands Review How do you save a document as a template? File, Save As Template

  40. Questions?

More Related