Playing certain frames in AS3.0

Posted on 2009-02-24
Last Modified: 2012-05-06
Timeline scripting

I have a movie clip that is 30 frames long. It is a clip of tab menu sliding out, and then back in again. However, I want it to stop when it is out, until some logic makes it go back in again. It's easy to do if I add a stop(); on frame 15, but I want all my actionscript to be on frame 1.

How can I tell the animation to just play to frame 15 and then stop?

Also, how can I get the information about which frame the playhead is on in a movie clip instance?
Question by:Jason210
    LVL 4

    Accepted Solution

    Hi Jason210

    Lets say you have a movie clip name Test:

    for the movie clip to play until frame 15 you can create a function to loop until it reach frame 15 and stop for example :

    GoToFrame(15) <--- will loop and play until frame 15

    function GoToFrame(Frame:int){
          function LoopToFrame(){
             if(Test.currentFrame < 15){
                   Test.gotoAndStop(Test.currentFrame + 1)
                   trace(Test.currentFrame) <--------- Will tell you which frame it stop at.
    LVL 11

    Author Comment

    Thanks. Some stuff to look at there. ENTER_FRAME is new to me. currentFrame is also handy.
    Now, just a couple of questions regarding your suggestion.
    Firstly, it seems the animation of the timeline is controlled by this statement being in a loop...
    The only thing that worries me here is that it seems this is no control over the frame rate, that it will just whizz through this as fast the processor will allow?
    Second question. Why do you remove the event listener? I have never done this before. Is it important to do?
    Thanks for your patience.
    LVL 4

    Expert Comment

    Hi Jason210

    ENTER FRAME is control by the frame rate you set, the faster the fps you set the faster the code execute (the faster the loop will run), it is not base on processor speed.

    In the end I remove the listener is to stop the code from keep on Looping because once you add listener on ENTER_FRAME the code will keep on execute base on the fps you set and as long as the movie is running so you have to remove the listener in the end.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
    The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
    The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
    The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now