PDA

View Full Version : Referencing a MovieClip within a Button


xwielder
02-28-2008, 03:30 PM
Here's my issue:

I have a MovieClip within a Button that's within a MovieClip.

Like this:

container_mc.myButton_btn.btnMC_mc.alpha = .2;


I receive this error:
ReferenceError: Error #1069: Property btnMC_mc not found on flash.display.SimpleButton and there is no default value.

It seems as though I'm not able to reference a MovieClip that sits within a Button. Is this correct?

GordonG
02-28-2008, 03:43 PM
I know you could not in AS2, and I don't see anything that indicates that you can in AS3 either...

xwielder
02-28-2008, 03:48 PM
I know you could not in AS2, and I don't see anything that indicates that you can in AS3 either...

Fair enough.

You say however that you don't see anything that indicates that you can do it in AS3, but do you see anything specfically stating that you can't? Just curious.

GordonG
02-28-2008, 04:16 PM
I don't know. It may make a difference if you are authoring the button or creating it dynamically at runtime, but I can't give you a definitive answer. Haven't tried it myself - I have rarely used "buttons" and have always rolled my own using movieClips ( and now Sprites ) It was just as easy given the functionality I wished to imbue...

xwielder
02-28-2008, 04:41 PM
I am in fact authoring my own button(s), and tracking them as a buttons ~vs~ MovieClips to utilize the 'button states'. I am not using the Button Component.

Referencing a MovieClip within a 'button' does not seem possible, so I'll come up with a work-around (a.k.a. hack). :)

Thank you for your insight, GordonG.

Flassari
02-28-2008, 05:13 PM
You must use getChildByName(), in actionscript 3 many basic classes (except for MovieClip) are sealed and not dynamic.

SimpleButton(container_mc.myButton_btn.getChildByN ame("btnMC_mc")).alpha = .2;

xwielder
02-28-2008, 05:38 PM
You must use getChildByName(), in actionscript 3 many basic classes (except for MovieClip) are sealed and not dynamic.

SimpleButton(container_mc.myButton_btn.getChildByN ame("btnMC_mc")).alpha = .2;

Error:

SimpleButton(container_mc.myButton_btn.getChildByN ame("btnMC_mc")).alpha = .2;

/*
ReferenceError: Error #1069: Property getChildByName not found on flash.display.SimpleButton and there is no default value.
*/


I even tried:

MovieClip(container_mc.myButton_btn.getChildByName ("btnMC_mc")).alpha = .2;

/*
ReferenceError: Error #1069: Property getChildByName not found on flash.display.SimpleButton and there is no default value.
*/



<sigh> I was so hoping your solution would work.

Flassari
02-28-2008, 05:54 PM
hmm, the simple button does not extend the DisplayObjectContainer class... so no child mc support. I would change it from simpleButton to movie clip and use buttonMode = true to get button behaviour.

stompwampa
02-28-2008, 05:57 PM
you cannot refer to objects that are inside of buttons. It just doesn't work.
Make your button into a movie clips instead.

xwielder
02-28-2008, 05:57 PM
hmm, the simple button does not extend the DisplayObjectContainer class... so no child mc support.

That sucks.


I would change it from simpleButton to movie clip and use buttonMode = true to get button behaviour.

Yeah, I won't go that route, but I have some other alternatives in mind.

Thank you for your thoughts and ideas. I appreciate your time and effort into this. :)

xwielder
02-28-2008, 07:49 PM
got it