action script two point 0
is a lot different than action script three point 0 which is what we're gonna
cover in this video
when we did action script two point 0
we would have to choose where we wanted to place our action script such as on the
timeline or on the button directly
and we were able to use script assist to add our actions
three point 0 is different
you can still use the actions pane but your going to have to type the script in or your
going have to use something called code snippets
which helps save you time and effort
now in addition
action script three point 0 doesn't let you add
action script to objects or buttons directly
instead
you have to reference that button in the action script panel
and tell it what to do when somebody clicks on that button
so before we can actually start this let's make sure that you have the
actions panel open so go to window choose actions and I put mine on
the left hand side
you don't have to worry about this extra column here
and this little script assist wizard you can turn it on or off it doesn't really
matter so i'll just turn off for now
and then make sure that you have an actions layer
that's locked so that you don't add any artwork accidentally
and click on the first frame
of that actions layer
again with the actions panel we can see were on a key frame of the actions layer
and were on frame one
so this is where we need to add our stop action
now I could come in here and just type the stop action
just make sure that you're getting your syntax punctuation capitalization
all of that correct otherwise it'll give you an error
there's an easier way to do this though some of the most used and basic
action script functions
are in something called code snippets
which is this panel right here
now if you can't see this again go to window
and choose code snippets
and you have different categories of action so if you want to create something
from mobile devices if you want to control the timeline
if you wanna do some kind of action script with animation
then
you can go to each one of these categories for now we're going to worry about the
timeline navigation
so we want to control the timeline and how we move around the time line
whether we stop or we jump to a different part of it we
play it we loop it
whatever we want to do we're going to be in this time line navigation
so as with
action script two point 0 we can add directly and action script directly
to
the timeline
so we'll
click on that first key frame
and were gonna double click and do stop with this frame because we want people
we want this animation to stop
to wait for someone to click on this button when they're ready to view
the animation
now when I double click that
stop at this frame action it added the stop action
plus it also gives you a note telling you what it's gonna do
and its gonna
pause at the frame where you inserted it
so when I want to stop it
on the two hundredth frame the end of my animation
I need to make sure to insert a blank key frame and this is very similar to two
point 0
because even though I'm clicked on the two hundredth frame of the actions layer
If I go to the actions panel you can see I'm on a key frame on the actions layer
but I'm on frame one
and that's because actions will only apply themselves to key frames
or blank key frames
so in order to create a stop action at frame two hundred
I need to add a blank key frame
so I'll go up to insert timeline and blank key frame
and now with that frame selected you can see I'm on the actions layer but this time
it's the two hundredth layer
so we'll go back to code snippets and double click stop at this frame
and it's gonna stop there as well
now we just need to add functionality to our buttons
again with two point 0 we would add it to the button directly
and this caused a lot of problems because
all of the sudden you would have button's and there would script scattered every where
only when you add it to the timeline can you see the a
so you would have a action script that you added to buttons and you'd have to
find that button click on the button edit it and
is was really hard to troubleshoot what was going on with the action script
so now we keep all the action script on the actions layer
so that you have one place and it's easier to troubleshoot
and from here we're gonna reference this button
and listen for a click
and when somebody clicks it were going to tell it what to do so
let's to ahead and choose the code snippets
and I'll go ahead and click off just so it doesn't erase that
and there's a couple options you can click to go to a certain frame and stop
or play
you can go to the next frame and stop or play and the previous frame
and stop or play
so we're just gonna go ahead and do the click to go to frame and stop or in
play cuz we want it to play our animation
so I'll double click it
and it says this action requires an object to be selected on the stage
okay that's a good warning for us were going to choose the button
and again it's going to tell us it can't be applied directly to the button
so it's kind of confusing that you have to select the button first
but that's okay
so with that button selected we"ll double click and do
click to go to frame and play
and it's gonna ask us what the instance of this button is
and what's happening here is that we've created one
button clip symbol or button symbol
called start
and we can use that button symbol as many times as we want
but in order to add action script to it we have to tell it which symbol
were referring to
so let's say
this was a larger animation
and it had
let's say
an animation with a dinosaur an animation with a horse an animation with
a sheep
then what we would need to do
is we would need to create
start buttons for each of those animations and we wouldn't want to create three
different symbols
we can use a symbol over and over again
we just need to give um each instance names so this can be dinosaur
dinosaur start horse start sheep start
and we're gonna be okay
so for this one we'll just call this start
btn
because we only have one version of that I can put one or two or whatever
and click okay
and now when we go into the action script let's see what's happening
it kinda tells you what it did there
and replace the number five of where you want it to go
so let's break this down as to what's happening right here
it's referencing the instance on the stage so that's telling it
we want you to add the script
to this button
with the instance name of start btn
and we're gonna to add an event listener so it's waiting for an event and its
listening for a certain type of event
so the event it's listing for is a click
and this could be a rollover it could be a double click
it can be a right click
it can listen for a bunch of different things
but for this one it's just waiting for a person to click
when it hears that click
it's gonna execute this click to go to
to and play from frame
so this is the function
this is the command what we want to have happen when it hears the click
what do we want it to do
we want it to do
go to and play
a certain frame
so again it says replace number five
and we want it to be number two so it can start at number two
so I'll go ahead and type two in there
and now it should work
lets view this
and it's going to wait
and it's gonna wait and listen for my click
and even if I click anywhere outside of the button nothing's gonna work
because we've reference that particular button
by its instance name in the script
so now when I click it
okay
so it worked
now we just need to make this replay button work
now we're gonna go about this a different way
instead of trying to add the code
and then it tells me it needs an instance name we're gonna go the other way
we'll go over to the replay button
and click the replay button
and in the properties panel
with that button selected
you can see this is where you can add your instance name
so I'll call this replay
btn
and again like I said I can drag as many of these replay buttons onto the stage
as I want to
and now with that one selected you can see it doesn't have an instance name
in this one
does have an instance name so even though they look exactly the same
there two instances of that button and they should have two different names
so think of them kinda like twins
you can create as many as you want
but their unique so they each need their own unique names because their each
gonna have a different unique command associated with them
so I'll delete that
and now that we've had the instance name
we can go to our code snippets
and we're gonna click to go to
frame in play
and again it's gonna add that event listener but as you can see it replaced the
instance name
at the beginning as replay button
and now its listening for a click and where do we want to go and actually
we want it to go to two as well
because we want to skip that first scene where they would have to click start
and that's just tedious to have to click two buttons just to have to replay it again
so now this animation should be working perfectly for us
when it comes to action script three point 0
it's really important that you remember to use the code snippets so you don't give
yourself head aches trying to figure this out
and again any symbol that you're using
it needs to have an instance name
now if you're working with graphic symbols they can't be targeted with
action script three point 0 so they won't give you an instance name
so make sure the object is a movie clip first
and always the instance name if I go back always the instance name
is gonna start here
so that's a way to double check if things aren't working make sure your object
has an instance name and that that instance name
is referenced in your actionscript