RE: [Flashcoders] Where to add eventListners in UIComponent classes?
I might be getting it wrong but the following might help: In working with components and using "placed onscreen in editor" components, I always find myself needing to wait 1 frame before adding the component event listeners. It seems the v2 components need 1 enterframe to fully initialize themselves. The way I do it (very crude code, in no sense useable in a copy paste sense) Private function onEnterFrame() { // Create this handler, which if all goes well // will be called only once, but we know 100% sure // we had at least 1 frame interval. addHandlers(); } Private function addHandlers() { // Clean up the onEnterFrame delete this.onEnterFrame; // Add all listeners here myComponent.addEventListener("click", this); } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Wade Arnold Sent: dinsdag 7 november 2006 3:31 To: 'Flashcoders mailing list' Subject: [Flashcoders] Where to add eventListners in UIComponent classes? I have a component that has a couple Macromedia UI components used inside of it. I have found that if I add my event listeners inside of createChildren after I have added the UI components the events are not added. I have also tried to add the events inside of the draw method. In order to get the events to work properly I have to add them into my onLoad() method. However this makes it so when I load the component I do not get an accurate onLoad event from the component as the event handlers have yet to be registered. Is there someplace that I am missing that I should be placing all of my event registration in anything that extends UIComponent? Thanks; Wade Arnold ___ 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 ___ 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
Re: [Flashcoders] Where to add eventListners in UIComponent classes?
This seems to work reliably for simple decoration and composition into homemade widgets. Don't know if it will help you with building Adobe style 'components'... function makeBtn():Void { btnV2 = Button(btn_mc.attachMovie("Button", "btnV2", 0)); if (btnV2.initializing == true){ btnV2.watch("initializing", handleWatch, this); } else { onInt(); } } private static function handleWatch(prop, oldVal, newVal, instance):Boolean { if (newVal == false) instance.onInt(); return newVal; } private function onInt():Void { btnV2.addEventListener('click', doStuff); btnV2.setSize(WIDTH, HEIGHT); btnV2.enabled = true; ... btnV2.unwatch("initializing"); } Tony ___ 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