-
Targeting MC on main frame with a button from a MC within a MC !!HELP!!
Hello all i am new to the coding world so please be patient with me
So i have a looping animation of some thumbnails, the hierarchy goes like this
Scene1(main timeline) -> imgBar(MC)->imgBarB(MC within the imgBar MC)
My buttons symbols are in the last MC "imgBarB" where i have this code:
Code:
stop();
ss1.addEventListener(MouseEvent.CLICK, mouseDownHandler1);
function mouseDownHandler1(e:Event):void{
dispatchEvent(new Event("Play1", true));
}
I want to control the Btns in my "imgBarB" MC to play a labeled frame(named "ssbox1") on another MC on the main timeline,this other MC goes like this:
Scene1(main timeline)->ssbox_mc(MC where my labeled frame is)
So on the maine timeline(Scene1) i have this code:
Code:
addEventListener("Play1", play1);
function play1(e:Event):void{
ssbox_mc.gotoAndStop("ssbox1");
}
Problem is , the code wont work, if someone could please tell me what i'm doing wrong or point me to another solution i'll really apreciate it
-
Designer, Programmer, Musician
Dynamic referencing.
stop();
imgBarB.ss1.addEventListener(MouseEvent.CLICK, mouseDownHandler1);
function mouseDownHandler1(e:MouseEvent):void
{
this.parent["ssbox_mc"].gotoAndStop("ssbox1");
}
Instead of referencing to the movieclip directly, we reference its instance name, and as its name is a String, we won't have any
display undefined errors. And to scope to the main timeline we use "this.parent", that means "this" (is the actual movieclip) "parent" (its parent, in this case the main timeline).
And just an advise, why putting script inside movieclips? Is better to have all your script in the main timeline, unless you want to make a kind of component.
Note: If that doesn't work for you, then your ss1 button is not inside the imgBarB movieclip as I thought, then replace this:
ss1.addEventListener(MouseEvent.CLICK, mouseDownHandler1);
Last edited by angelhdz; 03-25-2014 at 03:03 AM.
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
.
Hi,
Perhaps,
PHP Code:
addEventListener("Play1", play1);
function play1(e:Event):void
{
ssbox_mc.gotoAndStop("ssbox1");
}
function mouseDownHandler1(e:Event):void
{
dispatchEvent(new Event("Play1", true));
}
with (imgBar)
{
imgBarB.ss1.addEventListener(MouseEvent.CLICK, mouseDownHandler1);
}
it may be easier for you to attach your *.fla file for us to inspect and see the layout properly.
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
|