Today we are going to learn about action script 3.
An Event Listener is an “if/then” statement which tells flash things like “if this event happens, then do “x.” An example would be if you clicked on a button then the event listener would tell the button what to do.
Like go to another frame.
AS3: In this class, to use action script 3, create a new layer on your timeline and label it AS3.
Do the following:
Open flash and make these layers:
AS3
Rocket
Button
Sky
Copy and paste the action script below in frame one of layer one.... by clicking on the AS3 layer and pressing F9. Paste the script into the large text box area and then close the editor.
Make a movie clip symbol of a rocket with moving flames coming out of the tail. The rocket may look like you want it, but it must have at least red and orange flames, and at least three fins. Name this movie clip Rocket.
On the Rocket layer:
Put a blank key frame on frame one, and a key frame on frame two. Put the rocket on this layer and move it from the bottom of the page to the top of the page on a guide. Remember, you are just making a simple motion tween with a guide so you will have to think about how to do that! It is easy!
On the button layer, make a button symbol,name it ”button launch.” This button must have a new layer named TEXT and you must have the words “Go” on the “up” stage through the down stage. Do this by inserting a key frame at each state of the button, and change the state of the button at each stage ( color, or shape )
Put an instance of the button on the stage ( drag a copy of your button symbol to the scene 1 ). Look at the properties inspector box at the bottom of the screne. Now click on your new button once and You must tell flash what you want, and you want to tell it to line everything you’ve done up to work, so in your action script, you put “launch_button” so type that into the rectangle under the word “button” at the bottom of the screne area, and it must be lower case letters.
On the Sky layer, Import/create a sky background. Remember to use keyframes the length of your movie! The sky must have at least three different elements, make it interesting.
On the AS3 layer : Do the following
Click on frame one of this layer, then press F9. This opens up the action script dialogue box.
Copy / Paste this into the text dialog box area.
stop( );
launch_button.addEventListener(MouseEvent.CLICK,launchRocket);
function launchRocket(event:MouseEvent) {
gotoAndPlay(2);
}
Look at the script. It uses an event listener with directions to tell flash that once the button named launch_button is pressed, to stop what is going on and go to and play the second frame, which starts the rocket.
Everything should work when you "test" this movie. If there are problems, wine LOUDLY to Mr. Warren and say “this doesn’t work 10 times “ in a high pitched voice BEFORE he can say anything.
Check your button properties and make sure the instance of the button is named correctly. ( lower case letters with the underscore )
NOW: Snazz it up. Make your rocket beautiful by using Photoshop to create it.
For you GT people, I will define beauty, but I will tell you this, it will take time to create. Have the fire FLOW. Make Giraffes waving.
Make your button move so you can have a game trying to hit it. Make the rocket have a button as well which ejects the driver.
What will you do to it?
Enrichment: Make your own button when pressed blows up a building.
Project: 3 days in flash.
Monday, March 22, 2010
Monday, March 8, 2010
buttons
Buttons work like a movie in flash.
They need action script, which we will dabble in.
DO. Make a button with all four stages.
Go to insert and create a new button. Name the button.
You will have 4 requirements: Up, over, down and hit.
Up is the normal stage of the button, over is what the button looks like when you go over it, down is what the button looks like when you click it, and the hit area is where the button is "live"
Put keyframes in each of these stages and change the button.
Press F9 to open the action script. Copy and past this action script:
var numPressed:Number = 0;
btnCount.addEventListener(MouseEvent.CLICK, countUp);
function countUp(evt:MouseEvent):void { numPressed++; trace("Button was pressed " + String(numPressed) + " times.");}
Show the teacher what you have done for credit. Put on your blog "Success!!" when complete.
They need action script, which we will dabble in.
DO. Make a button with all four stages.
Go to insert and create a new button. Name the button.
You will have 4 requirements: Up, over, down and hit.
Up is the normal stage of the button, over is what the button looks like when you go over it, down is what the button looks like when you click it, and the hit area is where the button is "live"
Put keyframes in each of these stages and change the button.
Press F9 to open the action script. Copy and past this action script:
var numPressed:Number = 0;
btnCount.addEventListener(MouseEvent.CLICK, countUp);
function countUp(evt:MouseEvent):void { numPressed++; trace("Button was pressed " + String(numPressed) + " times.");}
Show the teacher what you have done for credit. Put on your blog "Success!!" when complete.
Subscribe to:
Posts (Atom)