• Home
tudwaythecore.com
blog
  • Recent Posts

    • Detecting focus in flash player
    • BitmapData PerlinNoise
    • Creating bridges in APE part 2
    • Creating bridges in APE
    • SteerWheels 2
    • Creating a simple APE example
    • Design me some levels!
    • Finished Migrating
  • Recent Comments

    • tudway on Creating a simple APE example
    • tudway on creating a platform game in as3 part 4
    • venu on Making a Shooting Game in AS3
    • chris on creating a platform game in as3 part 4
    • Kronoshifter on Creating a simple APE example
  • Categories

    • APE
    • flash
    • game
    • platform
    • sound
    • tutorial
    • Uncategorized
  • Archives

    • May 2009
    • October 2008
    • September 2008
    • August 2008
    • May 2008
    • April 2008
    • March 2008
  •  

    March 2008
    M T W T F S S
        Apr »
     12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31  
  • games

    • Game Showcase
Mar 25

Controlling timeline events

flash, tutorial 1 Comment »

In Flash, if you want to stop, play or move to a certain frame in the movie you have to use actionscript.

First – stop. To stop a flash movie you simply have to write stop() in the actions panel of the frame you want the movie to stop at.

Play. This is just as easy as the stop function, just write play(). flash plays movies automatically so you won’t need to use this command as much as stop.
To move forward and backward one frame use nextFrame(), to go forward, and prevFrame(), to go backwards.
The most useful of the timeline controls are the gotoAndStop(num) and the gotoAndPlay(num) functions. To use them just replace “num” with the frame number that you want to play or stop, or even you can replace it with a frame label in “”.
Lets put this in to action with a demo.
Click on the buttons to effect the movie.
The code is as follows : -
import flash.events.MouseEvent;
playbut.addEventListener(MouseEvent.MOUSE_DOWN, playFunction);
stopbut.addEventListener(MouseEvent.MOUSE_DOWN, stopFunction);
nextframebut.addEventListener(MouseEvent.MOUSE_DOWN, nextframeFunction);
prevframebut.addEventListener(MouseEvent.MOUSE_DOWN, prevframeFunction);
function playFunction(Event:MouseEvent):void {
play()
}
function stopFunction(Event:MouseEvent):void {
stop()
}
function nextframeFunction(Event:MouseEvent):void {
nextFrame()
}
function prevframeFunction(Event:MouseEvent):void {
prevFrame()
}
I’m using the same button code from my last tutorial, but replacing the trace(“”) function with the functions i have talked about in this tutorial.
explaining the code:-
line 1 – importing the Mouse Events
line 2 I’m adding event listeners to the buttons instance names that i have. When the mouse is touching playbut and it is pressed, do the playFunction.
line 3-5 same as line 2 but for different functions.
line 6-8 This is the playfunction, which is called every time the playbut is pressed. it makes the flash movie play, as i have explained earlier in the post.
9-17 These are the other functions, called by the event listeners. 
Well, that’s it for timeline events.
If your unsure about buttons, check out my earlier tutorial here 
Mar 25

Buttons in as3

flash, tutorial 1 Comment »

The first thing i did when i opened CS3 for the first time was tried to create a button. 

I obviously tried to do it the as2 way, forgetting that most of the actionscript language had changed so i drew a object, then converted it to a button. But when i tried to add actions to it, flash said “Current selection cannot have actions applied to it.”. 
What you have to do is to write the actions in the frame.
i will do a step by step tutorial, to show you how its done.
  • Open up a new Flash Actionscript 3 file in the way that i explained before.
  • Draw a button shape.
  • Highlight the button shape and press F8. A box should pop up that looks like this.                                                                                                                                                                                
  • Click on “Button” in the type section and name the button appropriately.
  • Press “OK” to continue, which should take you back to the stage where you’re button is.                
  • Click on your button and look to the bottom of the screen, where the properties bar should be.                                                                                                                                                                                                                                                                                                              
  • Write an instance name in the box provided. I have called mine “buttonTest”. This is important for when we do the script.
  • Now we are ready to write the Actionscript for this button. All the button is going to do is trace a message in the output panel. Make a new layer and call in “actions”. To do this click on the “insert layer” button, where my cursor is and then double click on the new layer title, “Layer 2″ to edit it’s name.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  • Click on the frame head of layer 2 frame one, which should be a white rectangle with a white circle in the middle, like the one in this image, and press alt+F9 to open the action panel.
  • This is where we have to start coding the button. In the actions panel that you just opened write…import flash.events.MouseEvent;
    buttonTest.addEventListener(MouseEvent.MOUSE_DOWN, traceFunction);
    function tracefunction(Event:MouseEvent):void{
    trace(“Button Clicked”)
    }
Explaining the code:-
line 1 – importing the Mouse Events
line 2 I’m adding event listeners to the buttons instance names that i have. When the mouse is touching buttonTest and it is pressed, do the traceFunction.
line 3-5 This is the traceFunction. It is a MouseEvent function that is executed when the buttonTest is pressed. When it is pressed the trace function is called which traces the message “Button Clicked” in the output panel. 
  • Test your movie by pressing Command+Enter, (control+Enter on windows)
  • You should see that when you click the button a message comes up in the output panel that says “Button Clicked”.
  • Thats all for the button tutorial, i will explain how to make functions in a later post.
Mar 25

Getting started with as3

flash, tutorial No Comments »

i will start from the very basics of learning as3. 

Most of my tutorials will start this way, i know it’s extremely basic stuff, but some people might have bought flash and then haven’t a clue how to use it!

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
Open up flash a menu should appear which looks like this, without the recent items column. 
To create a new flash file just click on “Flash File (Actionscript 3.0), where the arrow is pointing.
This will create exactly what it says, a new as3 flash file.
When you have clicked it, the stage will appear. this is where you will create your flash projects, using the tools on the left hand side. 
i am more interested in the actions panel, which you can bring up by pressing alt+F9.
This is where you can write actionscript, the programming language of flash. 
Powered by WordPress .::. Designed by SiteGround Web Hosting

cssandhtml