action script is flashes programming language
it allows you to increase the functionality in the interactivity of your
project
in this video we're gonna cover action script 2.0
it's an earlier version of the language
and it's not as a robust as action script 3.0
but it does tend to be easier for people just starting out in flash
so before we start looking at our project and where we need to add
our action script let's make sure you have the actions panel open
go to the window menu and choose actions if you have a check mark that
means you have it open
which I do
and I always put mine on the left hand side it depends on your screen size or
what you're comfortable with so feel free to have a floating window or put it
at the top whatever you want to do
and you should see this little column on the left hand side that's if you want to
create more complex actions and we don't need to do that so I'll collapse it
and then I have this special area up here for script assist that means I have script
assist on
so you can click this little wand button to show or hide script assist
if you've hidden it then you can type action script directly
and if you turn it on then you can't type indirectly you need to go to these menus
and choose the actions you want
so before we can actually start adding action script
we need to do a couple of things we need to watch this movie and decide
what we want to have happen in this movie and
how that determines where were going to add our action script
so let's go ahead and watch this movie and see how it's going to play out without
any action script whatsoever okay
so as we watch that it did something that flash typically does
if you don't have any action script it's gonna play through all of the frames
that you've added content to
and automatically loop it back to the first
frame and keep playing
and it'll keep looping it indefinitely
unless you do some kind of script to control it
so when we watch that video we barely saw the start button for a split second
and it didn't stop and gives us the option to choose when we wanted to have that start
and that's kind of annoying because if I start that movie
or if I first open that movie I might not want that animation to start right
away I want to choose
so we need to add action script so that it stops at this point
and lets users click the start button when they need it
in addition at the very end of our animation
we have a replay button
and we want to do the same thing we want to stop it here
and people can have the option to replay that if they want to
so let's go back to fame one
and before we add actions
I wanted to show you that I have an actions layer
and you should always have an actions layer and lock it so that you don't have
any artwork or content it should always be this white layer with these empty
frames and then blank key frames
so make sure that you lock it and
and as with every a new layer your going to have a blank key frame on frame one
when I click that blank key frame on frame one
we can see in the actions panel a little tab in the lower left hand corner that says
were on a key frame
on the layer with the name of actions
frame one
so if I were to unlock the music layer and click on the second frame of that layer
you can see again were on a key frame
on the music layer
frame two so it's important that you get used to looking at that to make sure your
adding your action script where you want it
to go
I want my movie to stop on the first frame
and wait for somebody to click the start button and then it needs to play
so I'll click on the blank key frame of frame one
and in my actions panel
go to global functions
timeline control
and stop
and there's a script to stop the movie at that point
let's test this out
and now it's just gonna sit there and wait for the user to do something that's
exactly I wanted to have happen
in addition
even when they do play it it's gonna automatically loop
when it hits the very last frame back to frame one
and I want it to actually stop here so they can choose whether they
want to replay it or not
now when I click on the last frame of the actions layer it looks like we already
have a stop action
but if you look down here in the bottom bottom left hand corner you can see
it's still showing you even though you've clicked on the last frame the two
hundredth frame of the actions layer
it still says that were on actions
in the first frame
that's because
action script can only be added
to a key frame or a blank key frame
so because this doesn't have a blank key frame on it I can't do anything about it
it's gonna add it all the way to the beginning
so I need to add a blank key frame here so it says
a new action script at this point
so I'll go to insert
timeline and choose blank key frame
so now for that blank key frame I want to stop it here
so your kinda thinking why did I have to do that it was stopped on frame
one and it already showed it in frame two hundred in the actions layer
well again it only stopped on frame one so eventually
we're gonna
press a button to have it jump to frame two and play it all the way out here
so we need it to stop again on frame two hundred
so let's go back and now we need to add action script to the buttons themselves
so this is a hard thing sometimes for people to grasp with two point 0 is
where they should add their action script
and you have to think about what you're trying to control
so that you know where to put it
I'm trying to control the timeline and when it plays and when it doesn't so I
added action script
to the timeline itself
and as you can see it has a little a on the first frame and that's telling you
there's action script there
you should only see those little a's on your actions layer
and I have to blank key frames so that it stops on frame one hundred and it stops
on frame two hundred
I'm trying now to control the start button or I want to try to control
the start button
so I need to click on that button itself let's go ahead and unlock the buttons
I need to click on the button itself
and add the action script to that button
so when I've selected the button symbol
in the bottom left-hand corner you can see the icon for a button symbol
and the name I gave it of btn start
that's the name I gave the actual symbol itself in
the library
so it's saying I'm gonna add actions to the symbol
button start
again will go to the plus sign
global functions
timeline control
and we want it to go to a certain frame and play
now if for some reason you can't these are grade out and you can't click on them
I don't know why it happens
but when that does happen save your project
quit flash open it again and it'll
have all these options available for you again
so I'll go ahead and click go to
and I have a couple of options here I can choose it to go to and play so it can go
to frame two which is when my animation starts and play it
or I can have it to
go to and stop where I want it to go to frame two and it's just gonna sit there
and in this project we want it to go to and play
and then we can choose
how we where we want to tell it to go do I wanna tell it to go to a
certain frame number or a frame label
or we can tell it to go to the next frame or to the previous frame
so for this one instead of frame number we're just gonna say next frame
because we want it
to go to the next frame and its gonna automatically start playing
so let's see how this works
it's just gonna sit there until the user clicks a button
uhoo
and it looks like we have a problem
so let's go ahead and try
the
delete this
click on our button
global functions timeline control go to
and we'll choose
next frame
see there's something wrong with that
so we're gonna delete the whole thing
and we're just gonna go with the
go to timeline control
and go to we want it to go to and play frame number two
so let's go ahead and make sure that one works
so we'll click it
okay
so from here
our stop actions are working and now our button is working so we need to
go back to our replay button and add actions there
so for this replay button we don't necessarily want to go back to
frame one cuz then we're gonna have that start button and there gonna have to press
another button
and that's just kinda irritating so
with the replay button we're gonna also have it jump to frame two time line
control go to
frame number two
that way they don't have to worry about hitting the start button
so when they hit replay now it's gonna take um all the way back to frame two
it's gonna play it well let's make sure we did go to and play and not go to and stop
so I'll go ahead and do this
and it says go to and play frame number two and I'll test it out later and it should
work just fine