Web Analytics Made Easy -
StatCounter Conditional Stop - CodingForum

Announcement

Collapse
No announcement yet.

Conditional Stop

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    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.

    Comment

    Working...
    X