|
-
access button (by instance name) inside MC
how do you access a button inside a movie clip by instance name?
i want to add an event listener to the button.
i tried:
Code:
myMovieClip.myButton.addEventListener(MouseEvent.MOUSE_DOWN etc......
and got no errors but at the same time it didnt respond to my event listener
-
is there another movie clip placed on top of the clip that you are trying to assign the event listener to?
-
_______________________
|||||||||||||||||||||||||||
|||||||||||||||||||||||||||
||||| _______________||||
||||||______________ ||||
|||||____ button_____|||||
||||||______________|||||
|||||||_____________|||||
|||||||||||||||||||||||||||
||||||||movie clip||||||||||
|||||||||||||||||||||||||||
that picutre is really bad but its showing how the button is inside the moveie clip
you know when you double click on a movie clip and it opens up the movie clips timeline? the button is inside that-the movie clips timeline. do you knwo what i mean?
-
If u have a movieClip named as mc and place a button with instance name btn inside that movieClip then simply go for
mc.btn.addEventListener(MouseEvent.CLICK,clicked)
function clicked(evt:MouseEvent)
{
trace("Heelo")
}
-
ok that worked.
so i have two event listeners, one for when the button is pressed and one for when it is released.
when its pressed it traces "btnPressed" and when its released it traces "btnReleased". i need the user to be able to release the button anywhere on the stage, so i tried this:
Code:
mc.btn.addEventListener(MouseEvent.MOUSE_DOWN, btnPRESSED);
function btnPRESSED(e:MouseEvent):void{
trace("brnPressed");
}
stage.addEventListener(MouseEvent.MOUSE_UP, btnRELEASED);
function btnRELEASED(e:MouseEvent):void{
trace("btnReleased");
}
the only problem with this is that now when ever the stage is clicked and released, it traces "btnReleased". is there a way to only apply the "stage.addEventListener(MouseEvent.MOUSE_UP, btnRELEASED);" function only if the btn has first been pressed?
i tried different ways of using "if(btnpressed){" etc.. and Booleans, but neither worked..
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
|