flash/actionscript tutorials
i'm looking for a quick and dirty tutorial on actionscipt, i have a physics presentation due friday and i'm using flash instead of power point.
every tutorial i read wants to give me the foundation, but frankly i odn't have the time right now, so i just need to knwo how to switch scenes with a button press, i was trying
stop(); //to stop at the end of the first scene
on(keyPress"<Enter>")
{
nextScene();
}
but its throwing an error:
1084: Syntax error: expecting rightparen before <Enter>.
you can probably try with
onkeypress(key)
{
//goto to the particular frame
}
I am not sure if onkeypress is the correct keyword or not because it is sometime since i did actionscripting. U can look for similar keywords in intellisense.
onkeypress(key)
{
//goto to the particular frame
}
I am not sure if onkeypress is the correct keyword or not because it is sometime since i did actionscripting. U can look for similar keywords in intellisense.
The actionscript dictionary (it's part of the flash help) is pretty sweet. It has A to Z listings of pretty much everything you could need. You could find out all the button press, mouse input, etc. code you could ever want to use with examples (even though they're pretty trivial). There's not that much to it either so looking through all 26 subfolders to find something isn't too much of a pain.
I don't know how you want to do things, but some options for going from scene to scene would be to use the timeline (i.e. scene 1's timeline is from frame 1 to frame 30, or whatever). This scene can loop if you want. Then when you want to switch you can call gotoAndPlay(frameNo); on the main timeline movieclip.
Another option (which I would prefer) is to just have an update function that is called every frame and you can do all your event handling in there (i.e. pressing a button will go to the next scene, where you'll make whatever is needed visible, and initialize it, while making things that are not needed invisible).
I don't know how you want to do things, but some options for going from scene to scene would be to use the timeline (i.e. scene 1's timeline is from frame 1 to frame 30, or whatever). This scene can loop if you want. Then when you want to switch you can call gotoAndPlay(frameNo); on the main timeline movieclip.
Another option (which I would prefer) is to just have an update function that is called every frame and you can do all your event handling in there (i.e. pressing a button will go to the next scene, where you'll make whatever is needed visible, and initialize it, while making things that are not needed invisible).
oh ok, thanks alot, i've been lookin through and for some reason i can't figure out how to get this workin, is there any way someone can post a small sample code, it'd probobly only 4 or 5 lines long. just a simple play frame 1 and stop, and on(press enter) it goes to the next frame? just to give me an idea of how it goes.
thanks alot
thanks alot
Giving all your keyframes and object instances good names is the key:
For example this is the code for the first keyframe:
stop();
btnStart.onRelease = function()
{
_root.gotoAndStop("start");
} // end onRelease
and this would be the actionscript code for the start frame
btnPutOutFire.onRelease = function()
{
_root.gotoAndStop("sink");
} // end release
btnJump.onRelease = function()
{
_root.gotoAndStop("jump");
} // end release
etc...
For example this is the code for the first keyframe:
stop();
btnStart.onRelease = function()
{
_root.gotoAndStop("start");
} // end onRelease
and this would be the actionscript code for the start frame
btnPutOutFire.onRelease = function()
{
_root.gotoAndStop("sink");
} // end release
btnJump.onRelease = function()
{
_root.gotoAndStop("jump");
} // end release
etc...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement