stop(); the MovieClip

We talked about “stop();” function,and how we can use it to stop the time line at a specific key-frame.Just add “stop();” for the Actions panel at the desired key-frame,and it will be stopped.

If we want to stop a specific MovieClip on the the time,we need first to give it an Instance Name

The Instance Name is the name we can use in Actionscript for acting with the MovieClip.

There are many things we can notice about the name and how we select it,we consider the MovieClip object as a variable ,and the variables in ActionScript 3 have some limitations to be considered :

Naming limitations for variables in ActionScript 3

  • Variable names cannot be a reserved word or keyword. For more information, see ActionScript 3 fundamentals: Syntax
  • Variable names must start with a letter, an underscore, or a dollar sign
  • Variable names cannot use special characters (except _ and $ in certain situations)
  • Variable names must be unique

So,we can give any name match with these criteria for the MovieClip to act with it via ActionScrip,as example :

  • myMovieClip
  • object1
  • _car

We prefer adding “_mc” at the end of the given name to be easy remembered in the

coding:

  • myMovieClip_mc
  • object1_mc
  • _car_mc
  • anyName_mc

Now we can call that MovieClip via ActionScript and apply any required code.

We will start with “stop();” function,we will see how to stop that MovieClip at any key-frame on the time-line by attaching the function to the instance name :

box_mc.stop();

 

 

Lets see our example MovieClip animation :

Then we add our MovieClip to the time line.As we know the movie clip will repeat its animation all the time,so when we need to stop it we just add the code for it : ourMovieClipName + stop();

to apply the function on the MovieClip it attached by adding dot.‘ between them.

car_mc.stop();

that mean apply stop(); function on the object called car_mc

like That :

Try it,best wishes.

About these ads
Tagged with: , , , ,
Posted in Actionscript, Flash

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow AS3.0 for Flash Designers on WordPress.com
Archives
Categories
Follow me on Twitter
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: