-
skip frame 1 after mc's timeline loops
Hello, I have an mc with 72 frames and a stop action on frame 1 so that it doesn't animate until another mc is clicked. The problem I'm having is that once the animation is initiated, it gets stuck when it returns to frame 1 because of the stop action that is there. I tried to put an action to skip frame 1 after frame 72 is reached, however I'm striking out. Here's what I've got:
Code:
trashInside_mc.addEventListener(Event.ENTER_FRAME, skipFrame1);
function skipFrame1(e:Event):void{
trace("trash can wiggle");
trashInside_mc.gotoAndPlay(2);
My trace works, however trashInside_mc doesn't move beyond frame 1 after the first time through.
Any help would be much appreciated!
Thanks in advance
-
as an update, if instead of using:
trashInside_mc.goToAndPlay(2);
I use
this.nextFrame();
the animation repeats a second time, but then it stops.
I tried using a frame label instead of going to frame 2 and it responds just like the goToAndPlay(2);
-
Client Software Programmer
Hey. That sounds interesting so the trash can wiggles? Well i have the most efficient solution for you but if you send me 1$ paypal to crystalskate@gmail.com I just had so many developer fees these few years like apple, android, etc im trying to recooperate some of that slowly. Dont worry, not the end of the world. You can sell me your programs later.
-
.
Hi
You probably need to declare some sort of variable for the movieclip to compare against
try doing something like this in the main timeline
PHP Code:
import flash.events.MouseEvent;
var clicked:Boolean = false;
startClipButton.addEventListener(MouseEvent.CLICK, startClip);// this is other clip to be clicked
function startClip(e:MouseEvent):void
{
clicked = !clicked;
trace(clicked);
trashInside_mc.play();
}
and inside the trashInside_mc movieclip
PHP Code:
//if (parent["clicked"] === false)
if (MovieClip(parent).clicked === false)
{
stop();
}
else
{
nextFrame();
}
you can put all code on the main timeline really, but best get your thing working first, just mess around with it x
-
solved!
Thanks Fruitbeard, though I wasn't able to successfully use a variable to compare against. I got it working but it wouldn't loop endlessly, rather it still got stuck on frame 1. For anyone looking for a simple solution, what I ended up doing is far less elegant though it works:
I created two frames inside of "trash_mc" so that instead of having the animation on "trash_mc"'s timeline, I could have it only on frame 2 inside of an mc called "trashInside_mc". This way with a stop action on top, the 1st keyframe is just the bitmap of the trash and the 2nd keyframe plays the animation. Now I can code the "trash_mc" timeline to toggle back and forth between the static and animated trash.
The code on the main timeline to trigger it is simply:
Code:
trashTrigger_mc.addEventListener(MouseEvent.MOUSE_OVER, wastebasketMover);
function wastebasketMover(e:MouseEvent):void
{
trash_mc.nextFrame();
}
And then inside of "trash_mc" is a simple event listener on frame 2 to stop the animation:
Code:
trashInside_mc.addEventListener(MouseEvent.CLICK, backToStart);
function backToStart(event:Event):void
{
gotoAndPlay(1);
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|