Thank you very much to all the people who take time to reply for this post

I was heavily stucked with the same problem and can not access main mxml
variable from the class
I was missing heavily _root and _global facilities in as-2

But the kind advice of using *mx.core.Application.application * ==
*_root*helped me to solve my problem

I want to say thank you for that



regards,

Jignesh Dodiya

+91 99 7 99 56565
www.jigneshdodiya.com


On 11/14/06, Gordon Smith <[EMAIL PROTECTED]> wrote:

   >> You can use mx.core.Application.application.myVar = "hooray!";

> It would not appear that you can actually instantiate a variable with
Karl's "mx.core.etc..." convention. Am I wrong?



It sounds like you're trying to set myVar without declaring it in the
<mx:Script> of the <mx:Application>. In AS3, most classes (such as
Application and your application subclass) are declared as non-dynamic,
which means that you can only access variables on them if they have been
declared at compile time.



> I'm truly baffled as to why this completely fundamental aspect of
actionscript has been so utterly scrapped in AS3.



If you're referring to having non-dynamic classes and using them
extensively in the Flash and Flex frameworks, this was done for performance
reasons. It's one of the biggest reasons why AS3 is often 10x faster than
AS2. If a variable is defined at compile time, then it can be accessed
quickly by its offset (say, 12 bytes) within the instance, rather than
slowly by name lookup.



- Gordon


 ------------------------------

*From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
Behalf Of *Paul Carpenter
*Sent:* Saturday, November 11, 2006 8:27 AM
*To:* flexcoders@yahoogroups.com
*Subject:* [flexcoders] Re: OK, seriously. Why can't I make a global var?



It would not appear that you can actually instantiate a variable with
Karl's "mx.core.etc..." convention. Am I wrong?



Also, my variable is not actually coming from the Application.applicationlevel, 
as it's being gathered by a custom component at a child level. I've
tried all the variations on how to reference directly into that component to
grab the variable (i.e. Application.application.smtpWindow.email) but
nothing works. Going from inside a component to the Application level is
fine, but going the other way doesn't seem to work for me.



I'm truly baffled as to why this completely fundamental aspect of
actionscript has been so utterly scrapped in AS3. It's also kind of scary
that no one has popped in with the "Duh, it's obvious! Do this...."



Hmm.







 <pedantry>This is not technically a global variable. It is simply an

instance var of the Application object.</pedantry>.



- Gordon



________________________________



Subject: RE: [flexcoders] OK, seriously. Why can't I make a global var?



You can use mx.core.Application.application.myVar = "hooray!"; if you

really want to access a global variable like that.



|<



Karl Johnson



Cynergy Systems



________________________________



After years (and years and years) of programming Flash, I'm used to

being able to simply say:



_root.myVar = "hooray!"



and being able to see that variable anywhere.



Why in God's green earth can't I do the same in Flex? I have a custom

login component which

is currently a child of the base app, sitting in a view state. All I

want to do is grab one of the

returned values that the login gets (emailaddress) and let other

sections of my program see

that.



I cannot for the life of me figure this out. I see stuff about making

static members of classes,

referencing "parentApplication" etc.



I am in no way a newbie to interactive development, and this is just

insane. Within my first

two days of using Flex I figured out how to create a complete

login/registration system that

talks to a DB, and figured out how to use the socket class to directly

talk to my mail server

and format a proper SMTP message, but I can't do this.



Clear guidance would be appreciated before i pitch my G5 out the window.






--
Regards,

Jignesh Dodiya....

Reply via email to