advanced action script

22
February 23, 2009 Advanced ActionScript Concepts IT 7220 1 Sunday, February 22, 2009

Upload: indiana-state-university

Post on 22-Jan-2015

1.007 views

Category:

Education


0 download

DESCRIPTION

WSU IT7220 Week 6

TRANSCRIPT

  • 1. Advanced ActionScript Concepts IT 7220February 23, 2009 Sunday, February 22, 20091

2. Agenda Syllabus Updates Game Assessment Papers Rosenzweig - ActionScript 3.0/Game Programming University Building Game Elements in ActionScript 3.0 HOT Lab - Flash Components and Forms Work in Project Teams Sunday, February 22, 20092 3. Rosenzweig GP University Flash Game University (http://ashgameu.com/) Companion Website to Book Source code for all games referenced in text Video tutorials Blog Forums Sunday, February 22, 2009 3 4. Rosenzweig Chap 1 Overview Review of Flash Interface ActionScript in timeline and using document class les Condition statements Loops - For, While, Do Use of Flash ActionScript Debugger Game Programming Checklist Sunday, February 22, 2009 4 5. Simple ActionScript Program HelloWorld1.a ActionScript in timeline, output using Trace Function Sunday, February 22, 20095 6. Placing Objects on Stage HelloWorld2.a Still working with ActionScript in the TimelineCreate text eld object Assign a value to it Place on stage (in display list) No text parameters for control Stageover placement or appearance (Display Object Container)of object Main Timeline (Display Object Container)TextField (Display Object) Sunday, February 22, 20096 7. Document Class Library HelloWorld3.as All document classes are derived from either theMovieClip or Sprite classMovieClip class is a container class which includes thestage and timeline with eachinstance createdThis allows the text object to be added to the movie clipDocument class must then be added to the Flash project leusing the properties panelSunday, February 22, 2009 7 8. Rosenzweig Chap 2 Overview Creating and working with visual objects Player input Controlling animation with ActionScript Player Interaction via the Keyboard Accessing external data Arrays Sunday, February 22, 2009 8 9. Visual Objects - Movie Clips We can add movie clips to our project by dragging them from the library to the stage, and then adjusting appearance using theproperties panel It is also possible to add movie clips from the library solely with ActionScript, by setting the symbol linkage properties Lets take a look at the mascot movie clip in UsingMovieClips.a The MC timeline has four layers to make it easier to change the animation a single part of the movie Sunday, February 22, 20099 10. Create MC Objects - Flash Interface Drag as many instances of a movie clip symbol onto the stage as you want Position using select tool/properties Scale and rotate using free transform tool Sunday, February 22, 200910 11. Create MC Objects - ActionScriptFirst, we make the movie clip accessible to ActionScript by setting the Linkage properties (see Fig 2.2, p 43): enter Class name and selectExport for ActionScript Next we use ActionScript to create a single instance on the stage at x=275, y=150, and rotating the movie clip 10 to the right Finally, using a For loop, we create 10 additional instances of the movie clip at y=300, spaced 150 pixels apart from each other, scaled at50% of the size of the symbol classSunday, February 22, 200911 12. Button Creation in ActionScriptButtons can be made from either movie clips or button symbols stored in the library As we have seen, an event listener: objectName.addEventListener(MouseEvent.CLICK, objectFunction);is then used to link a button to an action Lets take a look at MakingButtons.a Sunday, February 22, 2009 12 13. Simple Shapes in ActionScriptIt is possible to create simple graphics entirely withinActionScript such as lines,rectangles, circles, and ellipses Closed shapes can also be lled in Lets take a look at DrawingShapes.aSunday, February 22, 200913 14. Using Sprites in ActionScript The Sprite class is a basic display list building block: a display list node that can display graphics and can also contain children. A Sprite object is similar to a movie clip, but does not have a timeline. Sprite is an appropriate base class for objects that do not requiretimelines. For example, Sprite would be a logical base class for userinterface (UI) components that typically do not use the timeline. The Sprite class is new in ActionScript 3.0. Lets take a look at CreatingSpriteGroups.a Sunday, February 22, 200914 15. Managing the Display ListAs we add objects to the display list, the last object added appears in front of previously added objects We manage the position of children on the stage using setChildIndex (rst position is 0) Lets take a look at SettingSpriteDepth.a Sunday, February 22, 200915 16. User Input in ActionScript Mouse Input Use event listener to track mouse movement and rollover MouseInput.aKeyboard Input Use event listeners to detect key press (requires ASCII codes) KeyboardInput.aText Input Using AS to set input type, properties and actions TextInput.a Sunday, February 22, 2009 16 17. User Interaction in ActionScriptMany games allow interaction with an object using the arrow keys MovingSprites.a Another common method of interaction is dragging an object using the mouse. The example creates an instance of the Point() class totrack movement.DraggingSprites.a Sunday, February 22, 2009 17 18. Rosenzweig - Wrap-up Chapter 2 covers a lot things you can do with ActionScript for creating games Be sure to review the additional sections: Random numbers and Shufing an Array Accessing external data Collision detection Animation examples Sunday, February 22, 2009 18 19. HOT - Components and Forms You can create a form in html that includes text entry elds, check boxes, radio button, combo boxes, lists, etc. You can also set the taborder for the form elements to aid in usability. The contents of theform may then be submitted using either a form post method or bycalling a script. Submitting form contents is generally via server-side script to tell what to do with the form contents. Scripts may be in JavaScript, Perl,ASP.NET, Visual Basic, or other scripting languages. Flash allows the creation of Forms, creating rich-content user applications using a set of pre-dened component classes which maybe instantiated using the stage or through ActionScript.Sunday, February 22, 2009 19 20. HOT - Working with ComponentsChap 15 builds a form in Flash using the Flash UI Components in ActionScript 3.0 Components are accessed via the Components Panel and are automatically added to the Library when they are dragged to thestage In the example, components are congured using the Properties/ Parameters panel, although this could also be done using theComponent Properties panel or in ActionScriptSunday, February 22, 200920 21. HOT - Creating a Form Take a look at: orderForm_Final.a orderForm.a Sunday, February 22, 2009 21 22. Team Activity Begin working on storyboard What role with prototypes play? Finalize project plan Sunday, February 22, 200922