• Save
ARTDM 170, Week 5: Intro To Flash
Upcoming SlideShare
Loading in...5
×
 

ARTDM 170, Week 5: Intro To Flash

on

  • 1,004 views

 

Statistics

Views

Total Views
1,004
Views on SlideShare
989
Embed Views
15

Actions

Likes
1
Downloads
0
Comments
0

1 Embed 15

http://www.gilbertguerrero.com 15

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

ARTDM 170, Week 5: Intro To Flash ARTDM 170, Week 5: Intro To Flash Presentation Transcript

  • ARTDM 170, Week 5: Intro to Adobe Flash Gilbert Guerrero gguerrero@dvc.edu gilbertguerrero.com/blog/artdm-170
  • Homework • Please turn in your homework
  • Adobe Flash Open Flash and create a new ActionScript 3.0 document...
  • Basic Setup • Click the first Keyframe in the timeline to select it • Open the ActionScript window by going to Window > Actions
  • Trace output • Add a call to the trace function: trace(“Hello World!”); • Go to Control > Test Movie to test out your ActionScript • Trace helps troubleshoot code by sending notes to you in the Output window
  • Screen Output • var myText: TextField = new TextField(); myText.text = "Hello World!"; addChild(myText); • The first line creates a new area to display the text, a textfield • The second line puts your text in the textfield • The third line adds the textfield to the
  • Your first ActionScript class • Save your ActionScript file • Go to New... > ActionScript File to create a new external AS file • Save the file using the same name as your Flash file, example: HelloWorld2.as
  • ActionScript Class • package { import flash.display.*; import flash.text.*; • public class HelloWorld extends MovieClip { • public function HelloWorld() { var myText: TextField = new TextField(); myText.text = "Hello World!"; addChild(myText); } } }
  • ActionScript Class Class file declaration • package { Library classes needed import flash.display.*; import flash.text.*; Class definition • public class HelloWorld2 extends MovieClip { • public function HelloWorld2() { var myText: TextField = new TextField(); myText.text = "Hello World!"; addChild(myText); } } Constructor }
  • Constructors package { import flash.disp • Function that import flash.text executes as soon as the class loads public class Hell • Must be named the same as theMovieClip { class • Other functions public function come afterward var myText: T
  • Putting it together • To use the class in your Flash movie you must associate it with the movie. • In the Properties panel associate the external AS file with HelloWorld.fla by typing the filename into the class field
  • Display Objects • Visual elements that appear in ActionScript • Such as textfields, graphics, buttons, movie clips, and user interface components • Example: var myText: TextField = new TextField();
  • Object Properties • Objects have properties • Each object has itʼs own properties • Properties of the objects can be changed directly • Example: myText.text = "Hello World!";
  • Display Lists • Creating objects does not add them to the stage. You must place them directly. • Example: addChild(myText);
  • The Stage • The main movie area where everything takes place that the user will see
  • The Library • Where youʼll store all the media thatʼs associated with your Flash movie
  • The Timeline • Frames • Keyframes • In-between Frames • Empty Keyframes • Labels • Layers
  • Writing ActionScript
  • ActionScript Window • Wonʼt use most of the buttons until you get used to ActionScript • Use the Show/Hide Toolbox button to collapse the left column • Disable Script Assist for now
  • Comments • To add a comment: // single comment /* multi-line comment */ • Comments are notes you can add for yourself or other developers • Comments can also be used to “turn off” code
  • Use descriptive naming • Variable names: tennisBall, userRacket, userScore • Function names: hitBall( ), calcScore( ), headPunch( )
  • Use functions • Use functions for repetitive tasks or tasks that appear in many places • Example: public function showTime() { timeDisplay.text = “Time: ” + timeElapsed; } showTime();
  • ActionScript Logic
  • if-else statements if (this is true) {     then do this }
  • if-else statements if (this is true) {     then do this } else {     do this }
  • if-else statements if (this is true) {     then do this } else if (this is true) {     then do this } else {     do this }
  • Equal, not equal, or... • Assume this: a = 1; b = 2; c = 1; • These are true statements: (a == c)  a is equal to c (a != b)   a is not equal to b (a == 1 || c == 1)  a is equal to 1 or c is equal to 1 (b > a)  b is greater than a (a >= c) a is greater than or equal to c (a + c == b) a plus c is equal to b
  • Variable Types • When they first appear, they must be declared using var • Variable type must also be declared (after the colon): var moveX:Number = 10;
  • Variable types Primitive: Complex:  Boolean Object int Array null Date Number Error Function String RegExp uint XML undefined  XMLList • Declare any data type using an asterisk (*): var myX:*;
  • Placement • An instance of a movie clip can be moved to any location using x and y as coordinates: myClip.x = 300; myClip.y = 200;
  • Movement • An instance of a movie clip can be told to move by adding a value to x or y: // Setup the values var moveX:Number = 10; var moveY:Number = 10; // Move the clips myClip.x = myClip.x + moveX; myClip.y = myClip.y + moveY;
  • Event Listeners • By using an event listener that's triggered by ENTER_FRAME the movie clip instance will move on it's own addEventListener(Event.ENTER_FRAME, myFunction); myBtn.addEventListener(MouseEvent.CLICK, myFunction);
  • Homework, due Sept 23 • Read Chapter 1, p1-42 in the ActionScript 3.0 Cookbook
  • Thank You