I assume you mis-typed the first one? There are too many )'s. The params to
addEventListener take a method reference, not a call to a method, so
addEventListener("bLoggedInChagned", init)
is correct.
Do you have a function init()? Is it in the same file as this code?
Otherwise, you'll need to make it public and get access to it. BTW, the init()
must now take an event as its parameter
public function init(event:Event):void
{
// call webservice or something like that
}
Alex Harui
Flex SDK Developer
Adobe Systems Inc.<http://www.adobe.com/>
Blog: http://blogs.adobe.com/aharui
From: [email protected] [mailto:[email protected]] On Behalf
Of Scott
Sent: Tuesday, September 01, 2009 1:50 PM
To: [email protected]
Subject: RE: [flexcoders] RE: creationcomplete firing when a component is
disabled
I've been playing around with this...
I added in the line
GlobalVars.instance.addEventListener("bLoggedInChanged"), init);
And I got the error:
"Access of undefined property init"
I then tried:
init()
and got:
"Call to a possibly undefined method init"
I even selected it from the "." auto selection which gave it the () after init.
________________________________
From: [email protected] [mailto:[email protected]] On Behalf
Of Alex Harui
Sent: Tuesday, September 01, 2009 2:23 PM
To: [email protected]
Subject: RE: [flexcoders] RE: creationcomplete firing when a component is
disabled
If I were writing the code, GlobalVars would look like:
Class GlobalVars
[Bindable("bLoggedInChanged")]
Public function get bLoggedIn():Boolean
{
Return _bLoggedIn;
}
Public function set bLoggedIn(value:Boolean):void
{
If (_bLoggedIn != value)
{
_bLoggedIn = value;
dispatchEvent(new Event("bLoggedInChanged");
}
}
And somewhere in the app I would do:
GlobalVars.instance.addEventListener("bLoggedInChanged", init);
Alex Harui
Flex SDK Developer
Adobe Systems Inc.<http://www.adobe.com/>
Blog: http://blogs.adobe.com/aharui
From: [email protected] [mailto:[email protected]] On Behalf
Of Scott
Sent: Tuesday, September 01, 2009 11:22 AM
To: [email protected]
Subject: RE: [flexcoders] RE: creationcomplete firing when a component is
disabled
Unfortunately, it's not a manual process...
<mx:TabNavigator x="66" y="128" width="899" height="566"
enabled="{GlobalVars.instance.bLoggedIn}" >
I just have it watch the variable that tells the application the user is logged
in...
________________________________
From: [email protected] [mailto:[email protected]] On Behalf
Of Fotis Chatzinikos
Sent: Tuesday, September 01, 2009 2:06 PM
To: [email protected]
Subject: Re: [flexcoders] RE: creationcomplete firing when a component is
disabled
No, you misunderstood. Alex meant that you need to call init when you
'manually' enable the canvas.
Ie:
you have a button where you do:
buttonClick(..)
{
myCanvas.enabled = true ;
//Here is the place to put init()
}
On Tue, Sep 1, 2009 at 9:01 PM, Scott <[email protected]<mailto:[email protected]>>
wrote:
Makes sense, but I tried that already...
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%"
enabled="false" creationComplete="init()" >
!
Still causes the init() to fire... Is this a bug?
sj
________________________________
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]<mailto:[email protected]>] On
Behalf Of Alex Harui
Sent: Tuesday, September 01, 2009 1:49 PM
To: [email protected]<mailto:[email protected]>
Subject: [flexcoders] RE: creationcomplete firing when a component is disabled
Disabling is about interactivity, not creation, which is why creationComplete
fires.
Somewhere you probably have code that sets enabled=true, and that code can call
init().
Alex Harui
Flex SDK Developer
Adobe Systems Inc.<http://www.adobe.com/>
Blog: http://blogs.adobe.com/aharui
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]<mailto:[email protected]>] On
Behalf Of Scott
Sent: Tuesday, September 01, 2009 11:01 AM
To: [email protected]<mailto:[email protected]>
Subject: [flexcoders] creationcomplete firing when a component is disabled
I've got a troubling issue...
On my main page I have a tabNavigator that has several different pages for my
app. This navigator is disabled until the user logs in. However, even though
the navigator is disabled; it still fires off the creationcomplete which is
giving me grief because the data connection hasn't been built yet.
Falling short of creating a custom event, is there a way to fire off the init()
function when the component is enabled instead of when it's creationComplete?
Thanks
Scott
--
This message has been scanned for viruses and
dangerous content by MailScanner<http://www.mailscanner.info/>, and is
believed to be clean.
--
Fotis Chatzinikos, Ph.D.
Founder,
Phinnovation
[email protected]<mailto:[email protected]>,
--
This message has been scanned for viruses and
dangerous content by MailScanner<http://www.mailscanner.info/>, and is
believed to be clean.
--
This message has been scanned for viruses and
dangerous content by MailScanner<http://www.mailscanner.info/>, and is
believed to be clean.