?
Solved

movie clip play in reverse with as3

Posted on 2008-10-30
6
Medium Priority
?
8,085 Views
Last Modified: 2013-11-11
i want to be able to make a movie clip play in reverse when a separate button is clicked.

i have the attached code but it only moves the movie clip back one frame at a time:

can someone tell me how to make the movie clip play all the way back to first frame and stop?

thanks
closeBtn.addEventListener(MouseEvent.MOUSE_UP, closemask);
 
function closemask(event:MouseEvent):void
{
    if (masktest1.currentFrame == 1)
    {
        masktest1.gotoAndStop(masktest1.totalFrames);
    }
    else
    {
        masktest1.prevFrame();
    }
}

Open in new window

0
Comment
Question by:flashdope
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 1

Expert Comment

by:trypt
ID: 22865086
you should use Event.ENTER_FRAME inside your function called by closeBtn, here's the example:
closeBtn.addEventListener(MouseEvent.MOUSE_UP, closemask);
 
function closemask(e:MouseEvent):void
{
    masktest1.addEventListener(Event.ENTER_FRAME, playMe);
    function playMe(e:Event):void
    {
        if(e.target.currentFrame == 1)
        {
            e.target.gotoAndStop(e.target.totalFrames);
            e.target.removeEventListener(Event.ENTER_FRAME, playMe);
        }
        else
        {
            e.target.prevFrame();
        }
    }
}

Open in new window

0
 

Author Comment

by:flashdope
ID: 22871387
hey trypt,

thanks for this. it works except it didnt stop when it got back to frame 1 so i changed "e.target.gotoAndStop(e.target.totalFrames);" to "e.target.gotoAndStop(1);" which seems to work.
i have a follow-up question:

my movie clip instance name is now yelltail
inside that movie clip is a button called backBtn1

if i want to target 'backBtn1' from the main timeline instead of inside the movie clip, how would i do that? i tried the attached but it didnt work.


yelltail.backBtn1.addEventListener(MouseEvent.MOUSE_UP, closemask);
 
function closemask(e:MouseEvent):void
{
    yelltail.backBtn1.addEventListener(Event.ENTER_FRAME, playMe);
    function playMe(e:Event):void
    {
        if(e.target.currentFrame == 1)
        {
            e.target.gotoAndStop(1);
            e.target.removeEventListener(Event.ENTER_FRAME, playMe);
        }
        else
        {
            e.target.prevFrame();
        }
    }
} 

Open in new window

0
 
LVL 1

Expert Comment

by:trypt
ID: 22875366
what do u mean by target backBtn1 from the main timeline?
backBtn1 is yelltail's child isn't it?
do u mean u want to remove backBtn1 from yelltail's child list and add it to the main timeline?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:flashdope
ID: 22876216
no i mean i want to put my code on the main timeline rather than on the movie clip's timeline.
0
 
LVL 1

Accepted Solution

by:
trypt earned 1500 total points
ID: 22877962
oh... ok, so when backBtn1 is clicked, which movieclip will play backwards?
yelltail? if it is then the code should be like this...

yelltail.bakBtn1.addEventListener(MouseEvent.MOUSE_UP, closemask);
 
function closemask(e:MouseEvent):void
{
    e.target.parent.addEventListener(Event.ENTER_FRAME, playMe);
    function playMe(e:Event):void
    {
        if(e.target.currentFrame == 1)
        {
            e.target.gotoAndStop(1);
            e.target.removeEventListener(Event.ENTER_FRAME, playMe);
        }
        else
        {
            e.target.prevFrame();
        }
    }
}

Open in new window

0
 

Author Comment

by:flashdope
ID: 22878607
sorry trypt but this isnt working. no error messages, the button goes to its rollover state, but it doesnt work.

i'm attaching the rest of the code on the frame in case you can see a conflict. this site wont let me attach the file.

any ideas?
stop();
 
 
 
yelltail.stop();
 
 
var topDepth = 20;
var bottomDepth = 19;
 
ytBtn.addEventListener(MouseEvent.MOUSE_UP, up);
 
function up(event:MouseEvent) {
        var thisIndex = getChildIndex(yelltail);
        setChildIndex(yelltail, topDepth);
}
 
ytBtn.addEventListener(MouseEvent.MOUSE_UP, scalemask);
 
function scalemask(event:MouseEvent) {
	yelltail.play();		
}
 
 
 
yelltail.backBtn1.addEventListener(MouseEvent.MOUSE_UP, closemask);
 
function closemask(e:MouseEvent):void
{
    e.target.parent.addEventListener(Event.ENTER_FRAME, playMe);
    function playMe(e:Event):void
    {
        if(e.target.currentFrame == 1)
        {
            e.target.gotoAndStop(1);
            e.target.removeEventListener(Event.ENTER_FRAME, playMe);
        }
        else
        {
            e.target.prevFrame();
        }
    }
}

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question