Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts

    Conditional Stop

    I want to be able to move the stop() around on the timeline based on a condition. The condition it the hour of the day.

    For Ex.
    Code:
    //get date info from system
    mydate =new Date();
    myhour = mydate.getHours();
    
    switch (myhour) {
     case 1:
      //play and then stop play head on frame 24;
      break;
    
     case 2:
      //play and then stop play head on frame 27;
      break; 
    
     default:
     //play and then stop play head on frame 30;
     }
    The reason I didn't think I could use gotoAndStop() is because I want it to play until the desired stop frame at which point it would stop, opposed to jumping directly to the stop frame and stopping.

    Any suggestions?
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #2
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Shouldn't this ideally work? Or am I missing something?

    Code:
    function playUntilFrame (mc:MovieClip,f:Number):Void {
            // this function plays movieclip 'mc' until it reaches frame 'f'
            mc.onEnterFrame = function () {
                    if (this._currentframe<f) {
                            // 'mc' is not yet at frame 'f' so go to next frame
                            this.nextFrame();
                    } else {
                            // reached frame 'f' so stop oEF
                            delete this.onEnterFrame;
                    }
            }
    }
    // call like so:
    playUntilFrame(instanceNameMovieClip,45);
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •