Skip to main content
Arddy
Known Participant
April 8, 2016
Question

Flash AS3 reverse play and check label exists

  • April 8, 2016
  • 1 reply
  • 1201 views

Hi all!

I've searched all over and I can't find what I need. if you can help me out I would very much appreciate it.

I have a movie clip named "ContentClip." Every 5 frames in this clip is a keyframe(classic tween) where an image or content moves from right to left (like as if you are swiping it).

Each key frame has a Stop(); on it so it can hold on that frame showing it's content.

I can play it forward no problem, but I am trying to reverse play back i.e replicate swiping right to go back 5 frames. Currently I have something similar to this -

e.target.parent.addEventListener(Event.ENTER_FRAME, playMe);

    function playMe(e:Event):void

    {

        if(currentFrame == 1)

        {

            e.target.stop();

            e.target.removeEventListener(Event.ENTER_FRAME, playMe);

        }

  else

        {

          e.target.prevFrame();

        }

    }

that is activated on one of the buttons. However, it doesn't stop when it reaches a frame with "stop();" which is an issue as I only want it to reverse for 5 frames.

How Can I -

Make it reverse only 5 frames?

Or make it reverse and stop to only when a frame has a 'label' (no specific label, just 'a' label)?

THank you!

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
April 8, 2016

currentFrame is referencing the current movieclip.  ie, the one containing that code.

if you're trying to control the timeline of e.target, you should be using e.target.currentFrame (and you probably need to cast that as a movieclip, MovieClip(e.target).currentFrame).

and you can use the currentFrameLabel property of movieclips to determine if a frame has a label.

Arddy
ArddyAuthor
Known Participant
April 8, 2016

Thanks for clearing that part up. I just copied that code from else where, and didn't(and still don't) understand what e.target means.

Anyways, the question is still there, how do I reverse.

kglad
Community Expert
Community Expert
April 8, 2016

your code is will work if the references are correct.  the stop() is superfluous but doesn't hurt anything.

to debug, trace the name of the movieclip you want to reverse and e.target.  they're probably not the same.  usually e.currentTarget is the correct reference when you're trying to reference a clicked movieclip.