AS3 to goto and play first frame again?

I have 3 frames on my timeline. When the playhead reaches the
last
frame, I want it to go back to the first frame and start
playing again.
What is the AS for this?
Thanks!

Mike,
> I have 3 frames on my timeline. When the playhead
reaches
> the last frame, I want it to go back to the first frame
and start
> playing again.
You'll be psyched to hear that the ActionScript 3.0 for this
is no
different from pre-AS3 approaches. :)
> What is the AS for this?
gotoAndPlay(1);
David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design."

Similar Messages

  • HT1363 after pressing Menu and Select, when the Apple sign appears, I immediately press select and play/pause, but again the red X sign appears. so it does not go to Disk Mode. Has anyone had this issue? I would be grateful if you could tell me what to do

    The red X has appeared in my Ipod Classic Screen. Apple support tells me that I need to first put it manually on disk mode. to put it on disk mode I ought to press menu and select buton togeher, when the apple sign shows up, hold select button and play together.
    After pressing Menu and Select, when the Apple sign appears, I immediately press select and play/pause, but again the red X sign appears. so it does not go to Disk Mode. Has anyone had this issue? I would be grateful if you could tell me what to do.

    Thank you everyone for the replies. It defiantly helped point me in the right direction. With any luck, I will have my replacement phone sometime tomorrow.
    I was able to call the iPhone support line this morning. The Apple rep stayed on the line with me for about an hour until he was sure the new phone would ship out. For $199 plus $29 for expedited handling I was able to get the replacement ordered with overnight shipping. Since the replacement doesn’t involve ATT&T I have no reason to suspect any further delays. Kudos to the Apple rep that helped me straighten out this mess.
    It’s a shame that AT&T cares so little for their existing customers. Not only did they try to sell me the same phone for $499, they outright refused to help me. They also lied to me on numerous occasions and strung me along for close to three weeks for something that only took an hour to complete with the Apple rep.
    I filed a formal complaint against AT&T through the Better Business Burrow as well as requested a review of our cooperate contract with AT&T. Our company currently has over 3000 phones with AT&T and there contract comes up for bid the end of our fiscal year (this October). We will be giving it heavy consideration before we consider renewing their contract.
    I doubt that any of that will matter to a company that cares so little about their customers, but you never know.
    Thanks again for all your help. I would probably still be trying to get my replacement for the next few months if it wasn’t for your suggestions.
    -Niel

  • Goto and play frame problem

    I have a basic flash application with about 500 frames in
    this scene. I want to go play this frame when the user selects a
    button. I have the following code but it seems to go back to the
    first frame each time whereas I want it to go to frame 460. The
    statement above works by continuing the movie though.
    if (finalresult <8) {
    Play();
    } else if (finalresult >= 8) {
    gotoAndPlay(460);
    Any ideas?

    add this to the statement as below, the current value of the
    variable will be shown in the output panel when the condition
    fires:
    actually try it in a few places to see what;s getting
    through:
    if (finalresult <8) {
    trace(testA:'+finalresult);
    play();
    } else if (finalresult >= 8) {
    trace(testB:'+finalresult);
    gotoAndPlay("Shopping - Level 1", 460);
    if the there is no value shown in the output panel then the
    statement is not working at all, if so place the trace() just
    before the condition and see what the result is.

  • Help using multiple if else statements & manual dynamic xml data input to trigger a goto and play.

    Below is code that has a timer countdown that reads off of the computer. Below in bold is code to read "if it reaches the date, go to and play frame (2).
    timer.removeEventListener(TimerEvent.TIMER, updateTime);
      timer.stop();
      gotoAndPlay(2);
    Below is code that is manual input-   I had set up a dynamic txt field in flash named it : raffle_tix_remain When loaded on to the host I can manulally update the xml code and the change will take effect.
    raffle_tix_remain.text = root.loaderInfo.parameters.raffle_tix_remain;
    My question:  Since the raffle_tix_remain is a manual input from a user to xml  Is there a way to tell flash once it refreshes and "raffle_ tix_ remain"  goes to (0) zero gotoAndPlay(2); and let it play like a "sold out" sign
    i guess that would be a  if else statement. 
    Code Below-----------------
    stop();
    var year:Number = 2011;
    var month:Number = 12;
    var day:Number = 30;
    var finalDate:Date = new Date(year,month-1,day);
    var timer:Timer = new Timer(100);
    timer.addEventListener(TimerEvent.TIMER, updateTime);
    timer.start();
    function updateTime(e:TimerEvent):void{
              var now:Date = new Date();
              var remainTime:Number = finalDate.getTime() - now.getTime();
              if (remainTime >0) {
                        var secs:Number = Math.floor(remainTime/1000);
                        var mins:Number = Math.floor(secs/60);
                        var hours:Number = Math.floor(mins/60);
                        var days:Number = Math.floor(hours/24);
                        var secsText:String = (secs%60).toString();
                        var minsText:String = (mins%60).toString();
                        var hoursText:String = (hours%24).toString();
                        var daysText:String = days.toString();
                        if (secsText.length < 2) {secsText = "0" + secsText;}
                        if (minsText.length < 2) {minsText = "0" + minsText;}
                        if (hoursText.length < 2) {hoursText = "0" + hoursText;}
                        if (daysText.length < 2) {daysText = "0" + daysText;}
                        day_txt.text = daysText;
                        hour_txt.text = hoursText;
                        min_txt.text = minsText;
                        sec_txt.text = secsText;
              else {
                        timer.removeEventListener(TimerEvent.TIMER, updateTime);
                        timer.stop();
                        gotoAndPlay(2);

    stop();
    var year:Number = 2011;
    var month:Number = 12;
    var day:Number = 30;
    var finalDate:Date = new Date(year,month-1,day);
      var now:Date = new Date();
    var timer:Timer = new Timer(1000);
    timer.addEventListener(TimerEvent.TIMER, updateTime);
    timer.start();
    function updateTime(e:TimerEvent):void{
             var remainTime:Number = finalDate.getTime() - now.getTime()-e.currentCount;
              if (remainTime >0 || raffle_tix_remain==0) {
                        var secs:Number = Math.floor(remainTime/1000);
                        var mins:Number = Math.floor(secs/60);
                        var hours:Number = Math.floor(mins/60);
                        var days:Number = Math.floor(hours/24);
                        var secsText:String = (secs%60).toString();
                        var minsText:String = (mins%60).toString();
                        var hoursText:String = (hours%24).toString();
                        var daysText:String = days.toString();
                        if (secsText.length < 2) {secsText = "0" + secsText;}
                        if (minsText.length < 2) {minsText = "0" + minsText;}
                        if (hoursText.length < 2) {hoursText = "0" + hoursText;}
                        if (daysText.length < 2) {daysText = "0" + daysText;}
                        day_txt.text = daysText;
                        hour_txt.text = hoursText;
                        min_txt.text = minsText;
                        sec_txt.text = secsText;
              else {
                        timer.removeEventListener(TimerEvent.TIMER, updateTime);
                        timer.stop();
                        gotoAndPlay(2);

  • If Multiple Hittests equal true, go to and play next frame

    Hi All,
    I am trying to finish up a project and run into this problem, right now I am trying to create a drag and drop game and on the last game you can drop
    parts into the others, what I want to happen is that when all are in the correct spot gotoandplay next frame. This is my current code,
    Thanks
    if(one_mc._droptarget=="/onedef_mc" && two_mc._droptarget=="/twodef_mc" && three_mc._droptarget=="/threedef_mc" &&
    four_mc._droptarget=="/fourdef_mc" && five_mc._droptarget=="/fivedef_mc" && six_mc._droptarget=="/sixdef_mc" &&
    cave_mc._droptarget=="/cavedef_mc" && eight_mc._droptarget=="/eightdef_mc" && nine_mc._droptarget=="/ninedef_mc" &&
    ten_mc._droptarget=="/tendef_mc" && eleven_mc._droptarget=="/elevendef_mc" && twelve_mc._droptarget=="/twelvedef_mc");
    this is the if statement, im just not sure how to implement the gotoandplay...
    Does this make sense?
    Thanks

    if you don't have code to check if all the movieclips have been dropped on their targets, there's no way that code can work.
    use something like:
    one_mc.onPress = function()
    one_mc.startDrag();
    one_mc.onRelease = function()
    checkF();
    if(one_mc._droptarget=="/onedef_mc")
      // align Sprite3
      one_mc._x = onedef_mc._x + (onedef_mc._width-one_mc._width)/2;
      one_mc._y = onedef_mc._y + (onedef_mc._height-one_mc._height)/2;
      one_mc.gotoAndPlay("success");
      // the code in italics doesn't look right
    } else {
      (one_mc._droptarget=="/onedef_mc")
      // align Sprite3
      one_mc._x = onewrong_mc._x + (onewrong_mc._width-one_mc._width)/2;
      one_mc._y = onewrong_mc._y + (onewrong_mc._height-one_mc._height)/2;
      onedef_mc.gotoAndStop("fail");
    one_mc.stopDrag();
    function checkF(){
    if(one_mc._droptarget=="/onedef_mc" && two_mc._droptarget=="/twodef_mc" && three_mc._droptarget=="/threedef_mc" &&
    four_mc._droptarget=="/fourdef_mc" && five_mc._droptarget=="/fivedef_mc" && six_mc._droptarget=="/sixdef_mc" &&
    cave_mc._droptarget=="/cavedef_mc" && eight_mc._droptarget=="/eightdef_mc" && nine_mc._droptarget=="/ninedef_mc" &&
    ten_mc._droptarget=="/tendef_mc" && eleven_mc._droptarget=="/elevendef_mc" && twelve_mc._droptarget=="/twelvedef_mc"){
    gotoAndPlay(_currentframe+1);

  • Rotoscoping - it only roto's the first frame

    What I have done:
    Created a video clip with my Canon GL2 featuring a person against a bright background.
    I then used Adobe Premier CS5 to create an AVI of the sequence. (called it ROTO4.avi)
    I then opened CS5 After Effects, imported the clip into the composition timeline.
    I then changed the framerate of the composition to 59.94 (cause a previous attempt told me to do so).
    I then went under LAYER and Open New Layer.
    I then clicked the TOP rotobrush icon (can't find another one anywhere) and began outlining my subject and de-outlining the background. I have a perfect pink line around my subject (on frame1).
    I then drag the timeline bar and it creates the (mask?) on the first frame only and no subsequent frames.
    I switch to composition view and sure enough the first frame is beautiful (subject complete, background now a black screen), but no other frames are generated rotoscooped.
    Arghhh, I've been at this for about an hour and only first frame is ROTO'd.
    Help?
    Montie

    Montie - this is the line that I have the most suspicion about:
    I then drag the timeline bar.
    What exactly are you dragging?
    The recommended way to engage Rotobrush at this point is to press Page Down to move forward a frame, or press the spacebar to begin preview, not to jump to the end of your footage. Rotobrush only analyzes frames under the playhead, and only frames that are inside a span of time near the base frame you drew the strokes on. So if you move the playhead beyond the span it won't have any frames to analyze.
    This is what a Rotobrush span looks like. The span is the gray area with < and > arrows, the base frame is the yellow mark, and the analyzed frames are the green marks extending from the base frame mark.
    Read here about base frames and spans.
    To me it sounds like you are expecting Rotobrush to do all the work magically when you go to the end of your footage, and that's not the case. It needs to analyze each frame, and you need to keep an eye on the analysis because Rotobrush isn't actually magic, it's just some very cool math.
    Note the part in that document about the default span length: 20 frames forward and 20 frames backward. The reason for the short length is because the farther you get from a base frame the larger the probability for inaccuracies. As you move forward through each frame, check for inaccuracies and draw new strokes as necessary. Each time you draw a stroke, a new base frame is created and the span is extended. If you happen to have a sequence of 20 frames that don't need corrections, you can extend the length of the span and continue. (You could extend the span to the entire length of your clip, but you still need to pay attention to the analysis and make corrections.)
    I hope that helps.
    -=TimK

  • Capturing only audio, no video beyond first frame

    When I log and capture it looks okay until I move clips to timeline. Then I only have audio and the first frame. I've cleared the settings and preferences each time. Still happens. What is going on? (The capture audio only is NOT on).

    Is it only a single frame of video in the viewer window ie if you double click the clip in the bin is it the same frame through the entire clip, or is it that only 1 frame displays when you drop the clip in the timeline? if it's the latter check your view>external video settings to make sure they conform to your sequence settings.

  • CS5 fails to import first frame of QT

    I'm having a problem I've encountered before CS5, which is that Photoshop is failing to import the first frame of a .mov file. I render a video from After Effects, Animation compression, Best quality. I check it in QuickTime, and all the frames are there. I open it in Photoshop, and the first frame I get is actually the second frame of the file. No way to access the first frame in Photoshop.
    Any insights?

    bump

  • I used a code i got with my moive to download the itunes version and i was watching the itunes extras, but now when i click on "play itunes extras" it plays the audio but the only thing it displays is the first frame (the movie is catching fire)

    i used a code i got with my moive to download the itunes version and i was watching the itunes extras, but now when i click on "play itunes extras" it plays the audio but the only thing it displays is the first frame (the movie is catching fire) i deleted the movie and reinstalled from my icloud backup and it still does the same thing. The actual movie works fine, its just the itunes extras

    Hi there MickeyDresaj,
    You may find the troubleshooting steps in the article below helpful.
    Troubleshooting iTunes for Windows Vista or Windows 7 video playback performance issues
    http://support.apple.com/kb/ts1718
    -Griff W. 

  • Ram preview not playing from first frame

    Anyone else having problems with Ram preview playing back from a different spot in the timeline OTHER than the first frame? I have seen this happening consistently since the latest update (2014.2). I checked my preferences, and made sure nothing is accidentally selected to play from the last keyframe or something odd. But no. I am on a Mac Pro, running Yosemite, I googled this, and haven't seen anything. I haven't trashed my preferences yet, because I'm not sure it's a preference issue, and god...if I have to rebuild my render setting one more time...
    So to give you more detail.
    - I hit "0" on my number pad to launch a ram preview
    - It LOOKS like it's rendering each frame in order
    - When I hit "0" again to playback, it starts from a random location usually about 2 - 5 seconds from the beginning of the timeline.
    - It will loop back and then play from the start of the timeline.
    It's not using the current time indicator line or anything that would make sense. It's random, but near the start. I suspect it's pulling keyframe information from a nested pre-comp and using that, but there is not a keyframe in the comp I'm previewing.
    I also do not have the "From Current Time" checked box in the Ram Preview options, and there are 0 skip frames in that setting as well.
    If anyone has any ideas what this may be...I'd appreciate it.

    Here's the page with the known Yosemite issues:
    After Effects with Mac OSX v10.10 (Yosemite)

  • Only first frame played with gotoAndPlay

    Hello,
    My issue is: I have a 120 frame movieclip with a stop(); action on the first frame.  I have AS (below) that tells the mc to 'gotoAndPlay(2); But it only goes to frame 2 and stops (no action on that frame) instead of continuing to frame 120.  Here an example of the code:
    my_mc.onEnterFrame=function(){
    if((mcText1 eq "Hit")){
    _root.other_mc.gotoAndPlay(2);
    else{
    _root.other_mc.gotoAndStop(1);
    Any ideas to make the mc play automatically when the function requirements are met???
    I should know this.
    Thank you

    Each frame (thanks to onEnterFrame ) the condition (mcText1 eq "Hit") is true or false then each frame go to the frame 1 or frame 2 EVER!!.
    When the movie is going to frame 3 again is sent to frame 2
    change onEnterFrame to onLoad or call the function only once when you need
    my_mc.onLoad=function(){
    if((mcText1 eq "Hit")){
    _root.other_mc.gotoAndPlay(2);
    else{
    _root.other_mc.gotoAndStop(1);

  • AS3 array used to load and play random swfs?

    Hi, I'm trying to use an array adapted from AS2 script to load random swfs called "koan_1.swf" or "koan_2.swf" etc into a "koan_loader_mc" on the stage.  Each "koan_#.swf" has code in its last frame to both advance the "shuffle" array in the action script in the first frame of the stage and to load the next koan swf.  The code below -- almost -- works, but....?
    Frame on main stage:
    // creates function called at the end of koan_#.swfs
    function shuffle(a:Array) {
    for (var ivar = a.length-1; ivar>=0; ivar--) {
    var p = Math.floor(Math.random())(ivar+1);
    var t = a[ivar];
    a[ivar] = a[p];
    a[p] = t;
    // loads koans into koan_loader_mc
    var index:uint = 0;
    var koan_loader:Loader = new Loader();
    var koan:Array =["swfs/koans/koan_1.swf","swfs/koans/koan_2.swf", "swfs/koans/koan_3.swf", "swfs/koans/koan_4.swf", "swfs/koans/koan_5.swf", "swfs/koans/koan_6.swf", "swfs/koans/koan_7.swf", "swfs/koans/koan_8.swf", "swfs/koans/koan_9.swf", "swfs/koans/koan_10.swf", "swfs/koans/koan_11.swf", "swfs/koans/koan_12.swf"];
    koan.shuffle();
    koan_loader.load(new URLRequest(koan[index]));
    MovieClip(this).koan_loader_mc.addChild(koan_loader);
    MovieClip(this).stop();
    Code is on the last frame of the loaded koan swfs:
    MovieClip(stage).index++
    if(MovieClip(stage).index>MovieClip(stage).koan.length-1){
    MovieClip(stage).index=0;
    MovieClip(stage).koan.shuffle();
    MovieClip(stage).koan_loader.load(new URLRequest(koan[MovieClip(stage).index]));
    MovieClip(stage).koan_loader_mc.addChild(koan_loader);
    Thanks for -- any -- guidance and suggestions...at my wit's end...

    Thank you for taking the time to help, but......unfortunately it still isn't working.  When the "koan.shuffle():" segment of code on the first frame of the stage timeline, below, is commented out, everything else in the movie (except randomizing of swfs) works fine.
    This code loads swfs (but they are not randomized/shuffled):
    // loads koans into koan_loader_mc
    var index:uint = 0;
    var koan_loader:Loader = new Loader();
    var koan:Array =["swfs/koans/koan_1.swf","swfs/koans/koan_2.swf", "swfs/koans/koan_3.swf", "swfs/koans/koan_4.swf", "swfs/koans/koan_5.swf", "swfs/koans/koan_6.swf", "swfs/koans/koan_7.swf", "swfs/koans/koan_8.swf", "swfs/koans/koan_9.swf", "swfs/koans/koan_10.swf", "swfs/koans/koan_11.swf", "swfs/koans/koan_12.swf"];
    //koan.shuffle(); 
    koan_loader.load(new URLRequest(koan[index]));
    MovieClip(this).koan_loader_mc.addChild(koan_loader);
    Thanks again for your help....

  • Problems with pausing and playing again

    Whenever I'm listening to a song by The Ramones, then i pause for a second and play it again it skips to the next song. It is only with songs by The Ramones though. If anyone can help please post.

    Ryan,
    Have you tried re-importing the songs from the Ramones? If not I wouldtry that first. Other than that I can only think of restoring the Shuffle. (Making sure that you have the latest version of the iPod shuffle software) Start the iPod updater program, (Without the iPod attatched) insert the iPod and click "Restore". This will wipe your shuffle clean of all music and put it at factory settings but is normaly one of the first thins one tries when troubleshooting.
    <hr>
    Hope this helps, let us know if either of those suggestions works
    -Sam

  • Helpppp! my flash array will only play the first frame

    my flash array will only play the first frame
    this is the code
    stop();
    var t:Timer=new Timer(100,0);
    t.addEventListener(TimerEvent.TIMER,preloadF);
    t.start();   
    var rdmFrame:Array = ["15","150","420","589","712","807","1135"];
    stage.addEventListener(MouseEvent.CLICK, fnClick)
    function fnClick(e:MouseEvent):void
    trace(rdmFrame[numberRange(0, rdmFrame.length)]);
    function preloadF(e:TimerEvent)
        if(this.framesLoaded>7)   
            t.stop();       
            t.removeEventListener(TimerEvent.TIMER,preloadF);       
            t=null;        
            this.gotoAndPlay(numberRange(0, rdmFrame.length - 1));    
    function numberRange(minNum:Number, maxNum:Number):Number
            return (Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum);

    Ned Murphy wrote:
    Your timer function is not using the array, it is just using the random number.  Adapt what you have in the fnClick function.
    Hi Ned ,
    I am a little confused , sorry .. i am not sure what you mean...i am very new at AS3 ...
    I dont even need the click function .. another developer recommended it as a way to track the random action..
    stop();
    var t:Timer=new Timer(100,0);
    t.addEventListener(TimerEvent.TIMER,preloadF);
    t.start();   
    var rdmFrame:Array = [15,150,420,589,712,807,1135];
    function preloadF(e:TimerEvent)
        if(this.framesLoaded>7)   
            t.stop();       
            t.removeEventListener(TimerEvent.TIMER,preloadF);       
            t=null;        
            this.gotoAndPlay(numberRange(0, rdmFrame.length - 1));    
    function numberRange(minNum:Number, maxNum:Number):Number
            return (Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum);

  • Video Turns Blue After First Frame Plays in iMovie HD 6 !!??? Help

    Just bought & Installed iLife'06; iMovie HD 6 turns my existing projects hasey blue immediately after the first frame plays. The clips on the real below appear to be OK but when playing the movie it looks like you're viewing through a bottle of windex! Is this a known bug? Will the DVD burn this way? Please help

    Had the same problem but I seemed to have fixed it by doing the following:
    Open iMovie preferences, click on playback, change the quality from highest (field blending), to one of the other choices.
    Go back and preview your stuff and see if the purple cast is gone.

Maybe you are looking for

  • All Apple products on my computer are not working properly

    Hello, i am having trouble with my itunes, Quicktime, and all other apple products on my computer. This all start when i tried to update my Itunes(which was working fine minus this problem) and it would not let me. It kept giving me the error "The fe

  • WCServer error

    I am using jdev 11.1.1..7 I get below stack trace when i try to run project <WebCenterConfig> <_createConfigMapSnapshot> An error occurred reading a service's configuration. oracle.adf.share.ADFShareException: java.lang.NullPointerException   at orac

  • How to test multiple Resource connection in sun Idm

    Hi, I am configuring 1000+ servers by importing one resource.xml file in IDM. The resources are added in the resource list in IDM. But i want to check the connectivity of each resource. Is there any procedure to check the connectivity of all resource

  • Safari opens my PDF files but it's blank. Why?

    I use safari and I was trying to open a PDF file on my schools website. When the page came up (still in safari) it was blank. Why? I haven't changed anything that I know of.

  • Unable to activate with serial number Version 10

    I am getting invalid serial number error message.  I would like to upload to my new Win computer, so that I can get all the updates on the new computer.  The original date of purchase was 8.0 6-10-07, then we bought another one and registered it 1-29