Viewers: in countries Watching now:
In ActionScript 3.0 in Flash Professional CS5 Essential Training, Todd Perkins shows Flash designers how to incorporate ActionScript code into their projects and create interactive presentations and applications. The course includes a review of ActionScript language basics and the object-oriented programming (OOP) methodology, a tour of those Flash Professional CS5 features designed for developers, such as code hinting and the Code Snippets panel, and instructions on interacting with objects in the Library and placing code on the Timeline. Exercise files are included with the course.
Variables are to properties as functions are to methods. In other words, methods are functions that are connected to objects. Just like accessing properties of an object, accessing an object's methods requires simple dot syntax. Consider this boarder on the Stage. Again, its instance name is boarder_mc. If I test the movie, you'll see that it animates to make him fall down. That's because I removed the stop action in his first frame, so if I double-click the movie clip, you won't see any action on the first frame.
So the animation plays, and then there is a stop action on the last frame, as you can see right here. Just ignore the other code for now. We'll talk about that later. So I go back to scene one, and let's say I wanted him to stop on frame 1. Go to the first key from the actions layer, and open up the Actions panel. Now you may want to access to code hinting, so let's just type 'var boarder,' and datatype him as a MovieClip, and we'll set it equal to boarder_mc. Now remember this means exactly the same thing.
We could just type boarder_mc instead of boarder, but this is just going to give us access to code hintings. So you can do this whatever way you want. So go down a few lines and type 'boarder.' and then start to type stop, and you'll see it highlighted in the Code Hinting window. Double-click that. Flash types the open parenthesis for you. You can close it out and add a semicolon. So instead of just stop, like when you want to stop the main Timeline, you type the objects name, a dot and then stop, and you are sending a command to that object to stop playing.
So when I test the movie now, the boarder won't animate. So let's say I wanted to have the boarder stop. I want it at a later frame. So let's say I want it to stop at frame 30, or something like that. I can use to gotoAndStop command, so boarder.gotoAnd, and then capital S, and Flash will highlight gotoAndStop, and press Return, and Flash tells me which values that I need to pass into the method. The only one I need a pass in is called Frame.
So I can just type in a frame number. So I'll type in 30, close up the parentheses and the test movie, and there is the boarder on the ground. I can also type gotoAndPlay, so I'll just change Stop to Play, capital P, and then let's say frame 2, and then you'll see the boarder animate again. Let's say you wanted the boarder to fall down when you clicked on him. So the first thing we'll do is to make him stop. So right above gotoAndPlay, I'll type boarder.stop. Make sure to close out the parenthesis and add a semicolon, and then we'll go down a few lines and type boarder.addEventListener.
This is actually another method that the boarder has, and the event is going to be MouseEvent.CLICK. As I type MouseEvent, you'll to start to see MouseEvent.CLICK highlighted, so might as well type that and have Flash write the rest of the code for you. And then type a comma and then type clickedBoarder. Go down a few more lines and create the event handler function, so function clickedBoarder, some parentheses, inside of the parentheses, evt:MouseEvent.
After the parentheses, type :void, all lowercase, wrap boarder.gotoAndPlay(2) inside of the curly braces. So now this code will be executed only when you click on the boarder, because we've attached this function to an eventListener. So we'll test the movie, click on the boarder, watch him fall. So using dot syntax, you can access methods of an object and get all the code hinting you need to run methods without errors.
Find answers to the most frequently asked questions about ActionScript 3.0 in Flash Professional CS5 Essential Training .
Here are the FAQs that matched your search "" :
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.