The import statement does not create instances.  It just makes a class
available to another class so it can use its methods and create
instances of it.  You don't need an import statement if the class you
want to import is in the same package as the class you are referencing
it from. You can import an entire package by using the wildcard
character (import mx.controls.*).

You create instances by using the new operator. When you declare an
object in MXML that tag is compiled into a block of Actionscript that
contains the new operator.

--- In [email protected], "Scott" <[EMAIL PROTECTED]> wrote:
>
> The "import <class>;" is what creates the instance?  So in other
words, if I use the import <thisfile.mxml> in each of my other files,
each one is creating another instance of the <thisfile.mxml>?
> 
> ________________________________
> 
> From: [email protected] on behalf of Michael VanDaniker
> Sent: Tue 7/29/2008 10:30 AM
> To: [email protected]
> Subject: {Disarmed} Re: {Disarmed} RE: [flexcoders] mxml components
> 
> 
> 
> > 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;
> > 
> > ...
> > 
> > ..
> 
> These are not instances. You create instances by either declaring
> them in MXML or using the new operator in script. The import
> statements make LoginClass available to MainClass and Class3 so you
> can create instances of LoginClass from within each of those
> components. You don't need an import statement if the class you
> reference is in the same package you are referencing it from.
> 
> 
> 
>  
> 
> -- 
> 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