I was afraid of that...

 

Ok, let's see if I can do it better.

 

I understand that I'm not "calling" a class, but functions within the
instance.

 

So if I understand the other message from Gordon correctly then all
classes are created when the application is started.  However, it
doesn't look like that in the debugger when I'm running the application.

 

Let's take and expand my question example below...

 

MainClass.mxml

|

|-----Class2.mxml  - ShowStat():Boolean

|

|-----Class3.mxml  -  LoggedIn():Boolean

|        |--Class4.mxml - LogMeIn(strName:String,strPassword:String)

                               |-- private var bIsLoggedOn:Boolean

 

(This is fictitious for point of discussion)

 

If I control the display and how things are laid out in MainClass.mxml,
I used the Class2 and Class3.mxml files as subclasses to control the
widgets on the screen being placed by the MainClass.mxml.

 

In C++ I would initialize the classes I wanted to use by using calling
the class initializer(). (I have been using the
creationComplete="init()" to start code in the class instance.) Then if
I needed to access a private variable from MainClass.mxml I included the
header file (in this case the class4.mxml file) and called the function,
in the above example LoggedIn():Boolean.  Also in C++ when I'm done with
the instance I needed to call the destructor to shut the class down and
free the memory.  I haven't seen a reference yet to destroy a class
instances in Flex/AS3.

 

While using the individual "class".mxml files I've been created, I've
gotten confused on how long those class instances live and when exactly
they are initialized.  And how do I "destroy" the class instances and
the variables they contain to free memory (is this necessary in
Flex/AS3)?  When I use the debugger it doesn't look like in the above
example that class4.mxml stays active if I leave the Class3.mxml code.

 

Finally, if I had a reason to log the user in from another area in the
code; say from MainClass.mxml, if I wanted to call LogMeIn( myusername,
mypassword) from Class4.mxml I can't tell if I'm creating a new instance
of that class or am I using the existing instance?  In other words...:

 

 

Are these the same instance or unique instances with in each of the
class instances themselves (mainclass/class3)?

 

MainClass.mxml:

 

<mx:script>

 <![CDATA{

            Import com.myapp.models.LoginClass;

...

..

 

And

 

Class3.mxml

<mx:script>

 <![CDATA{

            Import com.myapp.models.LoginClass;

...

..

 

 

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Tracy Spratt
Sent: Friday, July 25, 2008 5:07 PM
To: [email protected]
Subject: {Disarmed} RE: [flexcoders] mxml components

 

First, there are "classes" and "instances".  When it matters, use these
terms correctly.

 

Second, "call" does not apply to a "class", or even really an
"instance". 

 

An instantiated class stays instantiated untill all references to it are
removed, and "Garbage Collection" has run and removed it.

 

If this is not the answer, perhaps you can rephrase your question,
without using the word "call"? 

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Scott
Sent: Friday, July 25, 2008 5:59 PM
To: [email protected]
Subject: [flexcoders] mxml components

 

Ok, I'm trying to get a firm grasp on AS3 components/classes.  I'm
trying to figure out how to structure code so I can optimize code
re-use.

 

What is the life of a component/class in a flex application?

 

In other words...

 

If I have a main.mxml that calls another class like logins.mxml, is that
class in existence only while it's called?  Once the event hits to call
it back is the class still alive?  It looks like it kills it from memory
but I'm not 100% sure.

 

Take the following examples...

 

MainClass.mxml

|

|--------subclass1.mxml

|

|--------subclass2.mxml

|     |----subclass2a.mxml

 

 

If MailClass.mxml calls subclass1.mxml, completes and then calls
subclass2.mxml which calls subclass2a.mxml, what are the lives of these
classes?

 

Also, do I need to be worrying about cleanup or is that handled
automatically?

 

I hope I'm explaining this well....

 


-- 
This message has been scanned for viruses and 
dangerous content by MailScanner <http://www.mailscanner.info/> , and is

believed to be clean. 

Reply via email to