Advanced Action Script

1,255 views

Published on

WSU IT7220 Week 6

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,255
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
36
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Advanced Action Script

  1. 1. Advanced ActionScript Concepts IT 7220 February 23, 2009 Sunday, February 22, 2009 1
  2. 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, 2009 2
  3. 3. Rosenzweig GP University Flash Game University (http://flashgameu.com/) ✤ Companion Website to Book ✤ Source code for all games referenced in text ✤ Video tutorials ✤ Blog ✤ Forums ✤ Sunday, February 22, 2009 3
  4. 4. Rosenzweig Chap 1 Overview Review of Flash Interface ✤ ActionScript in timeline and using document class files ✤ Condition statements ✤ Loops - For, While, Do ✤ Use of Flash ActionScript Debugger ✤ Game Programming Checklist ✤ Sunday, February 22, 2009 4
  5. 5. Simple ActionScript Program HelloWorld1.fla ✤ ActionScript in timeline, output using Trace Function ✤ Sunday, February 22, 2009 5
  6. 6. Placing Objects on Stage HelloWorld2.fla ✤ Still working with ✤ ActionScript in the Timeline Create text field object ✤ Assign a value to it ✤ Place on stage (in display list) ✤ No text parameters for control ✤ Stage over placement or appearance (Display Object Container) of object Main Timeline (Display Object Container) TextField (Display Object) Sunday, February 22, 2009 6
  7. 7. Document Class Library HelloWorld3.as ✤ All document classes are ✤ derived from either the MovieClip or Sprite class MovieClip class is a container ✤ class which includes the stage and timeline with each instance created This allows the text object to ✤ be added to the movie clip Document class must then be ✤ added to the Flash project file using the properties panel Sunday, February 22, 2009 7
  8. 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. 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 the properties 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.fla ✤ The MC timeline has four layers to make it easier to change the ✤ animation a single part of the movie Sunday, February 22, 2009 9
  10. 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, 2009 10
  11. 11. Create MC Objects - ActionScript First, we make the movie clip accessible to ActionScript by setting the ✤ Linkage properties (see Fig 2.2, p 43): enter Class name and select Export 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 at 50% of the size of the symbol class Sunday, February 22, 2009 11
  12. 12. Button Creation in ActionScript Buttons 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.fla ✤ Sunday, February 22, 2009 12
  13. 13. Simple Shapes in ActionScript It is possible to create simple ✤ graphics entirely within ActionScript such as lines, rectangles, circles, and ellipses Closed shapes can also be filled ✤ in Lets take a look at ✤ DrawingShapes.fla Sunday, February 22, 2009 13
  14. 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 require timelines. For example, Sprite would be a logical base class for user interface (UI) components that typically do not use the timeline. The Sprite class is new in ActionScript 3.0. ✤ Lets take a look at CreatingSpriteGroups.fla ✤ Sunday, February 22, 2009 14
  15. 15. Managing the Display List As 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 (first position is 0) Lets take a look at SettingSpriteDepth.fla ✤ Sunday, February 22, 2009 15
  16. 16. User Input in ActionScript Mouse Input ✤ Use event listener to track mouse movement and rollover ✤ MouseInput.fla Keyboard Input ✤ Use event listeners to detect key press (requires ASCII codes) ✤ KeyboardInput.fla Text Input ✤ Using AS to set input type, properties and actions ✤ TextInput.fla Sunday, February 22, 2009 16
  17. 17. User Interaction in ActionScript Many games allow interaction with an object using the arrow keys ✤ MovingSprites.fla Another common method of interaction is dragging an object using ✤ the mouse. The example creates an instance of the Point() class to track movement. DraggingSprites.fla Sunday, February 22, 2009 17
  18. 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 Shuffling an Array ✤ Accessing external data ✤ Collision detection ✤ Animation examples ✤ Sunday, February 22, 2009 18
  19. 19. HOT - Components and Forms You can create a form in html that includes text entry fields, check ✤ boxes, radio button, combo boxes, lists, etc. You can also set the tab order for the form elements to aid in usability. The contents of the form may then be submitted using either a form post method or by calling 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-defined component classes which may be instantiated using the stage or through ActionScript. Sunday, February 22, 2009 19
  20. 20. HOT - Working with Components Chap 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 the stage In the example, components are configured using the Properties/ ✤ Parameters panel, although this could also be done using the Component Properties panel or in ActionScript Sunday, February 22, 2009 20
  21. 21. HOT - Creating a Form Take a look at: ✤ orderForm_Final.fla ✤ orderForm.fla ✤ Sunday, February 22, 2009 21
  22. 22. Team Activity Begin working on storyboard ✤ What role with prototypes play? ✤ Finalize project plan ✤ Sunday, February 22, 2009 22

×