Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want to avoid using the timeline at all, you can either check <em>currentFrame</em> on each frame using an ENTER_FRAME handler, or you can use the addFrameScript() method:</p> <pre><code>var isIdle : Boolean = true; var loopIfIdle: Function = function() : void { if (isIdle) mc.gotoAndPlay(1); }; mc.addFrameScript(24, loopIfIdle); mc.addEventListener(MouseEvent.MOUSE_OVER, handleMouseOver); // The mouse handler: function handleMouseOver(ev : MouseEvent) : void { isIdle = false; } </code></pre> <p>Essentially, what happens here is that a boolean variable is declared, which will be used to indicate whether the Flash stage has been interacted with (hovered) yet. Using a closure (a method that inherits variables in it's surrounding scope) we create the <em>loopIfIdle</em> function which will have access to this flag.</p> <p>The addFrameScript() does more or less exactly the same thing as adding code on a frame in the Flash CS3/CS4 timeline. As such, the <em>loopIfIdle</em> function will be executed each time the playhead passes frame 25. But now, because we are using a closure, we can check the state of the <em>isIdle</em> flag from within the frame script.</p> <p>The MOUSE_OVER event handler will set <em>isIdle</em> to false, to indicate that the stage has been hovered. This means that the next time that <em>loopIfIdle</em> is invoked, it will not loop (i.e. move back to frame 1) hence achieving the effect that you're after.</p> <p>An even simpler solution would be to simply gotoAndPlay(26) in the MOUSE_OVER handler, and ignore the entire frame script and isIdle flag approach. This will not, however, guarantee a smooth transition from loop to frame 26 (imagine if the mouse enters the stage on frame 1, which will then jump straight to 26.) Depending on your requirements, this might still be a good alternative.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload