Vaan,

 

Shouldn't the design of the object be such that it does that initialization
you require when it gets instantiated?

 

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Vaan S Lanko
Sent: Wednesday, March 26, 2008 10:11 AM
To: [email protected]
Subject: [flexcoders] Event fired when Object is created ?

 

Does anyone know whether there is an event fired when an object is 
instantiated ? I have objects that are created from an sqlite SQLEvent 
result. Presently I'm iterating over the results and calling the 
populateBar function manually, but it would be nice for the object to 
detect its been created and dispatch an event automagically.

The Event.ACTIVATE event sorta works but only if u move focus out of the 
AIR app and then back to it again. This is the code i have been working 
with sofar....

package
{
import flash.events.Event;
import flash.events.EventDispatcher;
[Bindable]
public class Foo extends EventDispatcher
{
public function Foo()
{
super();
this.addEventListener(Event.ACTIVATE,fooLoadedHandler);
}
public function fooLoadedHandler(event:Event):void
{
if(this.bar==null) this.populateBar();
this.removeEventListener(Event.ACTIVATE,fooLoadedHandler);
}
public var bar:Bar;
private function populateBar():void{
//.. this.bar = stuff
}
}
}

any comments would be greatly appreciated, maybe even an alternative 
strategy..

Cheers
Vaan

 

Reply via email to