cmattar
asked on
Movie Clip with Close button won't stop looping
Hi EE
I have a Flash CS5.5 file with 1 frame in the timeline. In that frame I have a button which when clicked opens a movie clip. The movie clip is a 24-frame animation (it's a motion tween), and has a Close button on the Frame 24. However, when I test the FLA, the movie clip loops and I get the error:
TypeError: Error #1010: A term is undefined and has no properties.
at scrCustomerMaint_fla::Main Timeline/f rame1()
My code is:
Debug says the problem is on the "modAnimate.btnClose" line. I guess it's because btnClose isn't available at that point, but I don't know how to fix the problem. I've tried adding a stop() function to Frame 24 of the movie clip but that just throws up more errors. Can anyone please help?
Incidentally, if I use a similar movie clip - one that has no motion tween - the above scenario works perfectly, i.e. main timeline button opens the movie clip, and the movie clip's Close button closes the movie clip.
TIA
I have a Flash CS5.5 file with 1 frame in the timeline. In that frame I have a button which when clicked opens a movie clip. The movie clip is a 24-frame animation (it's a motion tween), and has a Close button on the Frame 24. However, when I test the FLA, the movie clip loops and I get the error:
TypeError: Error #1010: A term is undefined and has no properties.
at scrCustomerMaint_fla::Main
My code is:
modAnimate.visible = false;
btnCustCode.addEventListener(MouseEvent.CLICK, showPopup);
function showPopup(event:MouseEvent):void
{
modAnimate.visible = true;
}
modAnimate.btnClose.addEventListener(MouseEvent.CLICK, hidePopup);
function hidePopup(event:MouseEvent):void
{
modAnimate.visible = false;
}
Debug says the problem is on the "modAnimate.btnClose" line. I guess it's because btnClose isn't available at that point, but I don't know how to fix the problem. I've tried adding a stop() function to Frame 24 of the movie clip but that just throws up more errors. Can anyone please help?
Incidentally, if I use a similar movie clip - one that has no motion tween - the above scenario works perfectly, i.e. main timeline button opens the movie clip, and the movie clip's Close button closes the movie clip.
TIA
ASKER
Thanks for responding Vulturous, however either I'm not understanding you or I've not explained the issue correctly.
I've got a button on the main timeline which opens the movieclip - the movieclip is the object that's looping. Using your suggestion, I can now have btnClose appearing thru the whole 24 frames (thanks for that!), so I can click that in the movieclip to stop it - but the rest of the clip loops. Putting a stop() on frame 24 doesn't help as the movieclip then just jumps to the end of its timeline, i.e. no animation.
I'd upload the FLA but EE won't allow it - says that .xlf is not an allowed extension. I'm assuming that the .xlf referred to is the ActionScript part of the FLA...?
I've got a button on the main timeline which opens the movieclip - the movieclip is the object that's looping. Using your suggestion, I can now have btnClose appearing thru the whole 24 frames (thanks for that!), so I can click that in the movieclip to stop it - but the rest of the clip loops. Putting a stop() on frame 24 doesn't help as the movieclip then just jumps to the end of its timeline, i.e. no animation.
I'd upload the FLA but EE won't allow it - says that .xlf is not an allowed extension. I'm assuming that the .xlf referred to is the ActionScript part of the FLA...?
Can you try exporting the file to Flash CS4 or Flash CS5? (should be a *.fla, not *.xlf).
And yeah, I must have not explained myself all too well.
-V
And yeah, I must have not explained myself all too well.
-V
ASKER
No problem - CS4 uploads seem to behave themselves. You'll see I've implemented your suggestion about alpha on the btnClose within the movieclip. Thanks for taking a look.
ButtonTest-CS4.fla
ButtonTest-CS4.fla
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It worked! Never would've figured this out myself. I can also understand the logic of the solution, so thanks for taking the time to explain that. Thanks heaps :-)
I'm glad I was able to help out :D
-V
-V
Sooo, the fix is rather simple, btnClose must exist in the first frame (and throughout the timeline). You can extend the frame it appears in so it's from frame 1 to 24 and set it invisible via code (btnClose.visible = false;) on frame 1 and visible again on frame 24 (btnClose.visible = true;).
You could also simply make it a new keyFrame and set its alpha to 0 in the timeline.
I'm not sure if I'm being clear over here, heh. If I'm not I can provide a sample.
Good luck,
-V