Everyone,

Thank you for the responses. Attila's suggestion to do the
addEventListener() in an onLoad function worked perfectly, thanks Attila!

To answer someone else's question about why I was calling it
createChildren(): my class is a subclass of UIObject, the base class of all
v2 components. UIObjects run the following methods in the following order:

constructor (usually left empty)
init() (runs only once)
createChildren() (used to create sub-movieclips and components, called only
once)

** a frame passes **

draw() (called whenever the component needs to redraw, usually in response
to a invalidate() call)

In my code, onLoad appears to fire after createChildren fires, so I put my
addEventListener calls there, and they work like a champ.

Thanks very much to everyone who responded!

OK
DAH 

PS Chafic Kazoun wrote an excellent introduction to UIObject and
UIComponent. It's at Ultrashock.com and is called "Introduction to the V2
Component Architecture."
 
http://www.ultrashock.com/ff.htm?http://www.ultrashock.com/tutorials/flashmx
2004/v2a-01.php




On 12/19/06 10:22 AM, "David Ham" <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I was having trouble with some components yesterday. I am writing a
> NavigatonView class that extends UIObject. I linked it to a symbol in the
> library that had four Button components in it. The symbol had no code in it;
> the code for the class was entirely in an external .as file.
> 
> Here is the trouble: the Button components appear on stage, but only as
> Movieclips, they do not respond to component commands like move(), and they do
> not register calls to addEventListener(). However, they respond visually when
> I roll over them, and I can attach functions to their onRelease. What gives?
> 
> Here is the code from the class:
> 
>     private function createChildren():Void {
>         trace("CREATECHILDREN");
>         roomShape_btn.toggle = true;
>         //roomShape_btn.addEventListener( "click", this );
>         //resizeRoom_btn.addEventListener( "click", this );
>         //editCorners_btn.addEventListener( "click", this );
>         //placeObjects_btn.addEventListener( "click", this );
>         roomShape_btn.onRelease = click;
>         resizeRoom_btn.onRelease = click;
>         editCorners_btn.onRelease = click;
>         placeObjects_btn.onRelease = click;
>         
>     }
>     
>     function click(evt:Object) {
>         trace( this );
>     }
> 
> The commented lines do not work (and yes, I did try uncommenting them first,
> har har) but the onRelease ones do.
> 
> Incidentally, component instances that I create dynamically with
> createClassObject() work as expected.
> 
> Thanks for any help you can offer,
> 
> OK
> DAH
> 

-- 
David Ham
http://anthropomorphy.org        ::     +1 630.297.1273
http://davidham.com            ::     [EMAIL PROTECTED]




_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to