Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Flash AS3 reverse play and check label exists

Participant ,
Apr 07, 2016 Apr 07, 2016

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!

TOPICS
ActionScript
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 07, 2016 Apr 07, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 07, 2016 Apr 07, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 08, 2016 Apr 08, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 09, 2016 Apr 09, 2016

Thanks for the replies, but I don't think you are understanding my question and problem.

How can I make it reverse playback (a movieclip) -

1. Only 5 frames?

or

2. Whenever it goes to a frame with a stop(); action on it?

or

3. Whenever it hits a frame with a label on it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 09, 2016 Apr 09, 2016

1. use a variable to track how many frame have been reversed

2. no way that i know

3. mentioned in message 1, use currentFrameLabel

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 09, 2016 Apr 09, 2016

1. How would you use a variable to track it?

2. --

3. so will it be -

  function playMe(e:Event):void

    {

        if(currentFrameLabel)

        {

            e.target.stop();

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

        }

  else

        {

          e.target.prevFrame();

        }

    }

?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 09, 2016 Apr 09, 2016
LATEST

e.target is probably wrong, as explained before.

var framesReversed:int=0;

  function playMe(e:Event):void

    {

        if(e.currnetTarget.currentFrameLabel)

        {

         

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

        }

  else

        {

          e.currentTarget.prevFrame();

framesReversed++;

if(framesReversed==5){

e.currentTarget.removeEventListener(...

}

        }

    }

?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines