An Import statement simply tells the compiler what long name to use for
a short name.  It does not actually import the code into the app. So:
 
import com.apps.MyClass
 
is not good enough.  But this is:
 
import com.apps.MyClass
private var myClass:MyClass;
 
 
Several folks do not like it when people post issues to both email
groups.  One is sufficient.  Adobe people are in fact trolling this list
as well.

________________________________

From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of Amol Pandhare
Sent: Thursday, December 14, 2006 8:57 AM
To: [email protected]
Subject: Re: [flexcomponents] Instantiating Class Dynamically



I have also imported the class but still the same scenario remains. 
 
Amol.


----- Original Message ----
From: slangeberg <[EMAIL PROTECTED]>
To: [email protected]
Sent: Thursday, December 14, 2006 9:11:03 PM
Subject: Re: [flexcomponents] Instantiating Class Dynamically



Sorry for my lame reply before. Here's the real deal. You've got to
check out the flexcoders group (yahoo), if you haven't already. There's
a number of adobe people who are trolling there.


        
        
          Reply          
                
Reply to all  Reply to allForward Forward  Print  Add Matt to Contacts
list  Delete this message Report phishing  Show original  Message text
garbled?
          Matt Chotin <[EMAIL PROTECTED] com <mailto:[EMAIL PROTECTED]> >
to flexcoders
show details
 Sep 18         
Images are not displayed. 

Display images below - Always display images from [EMAIL PROTECTED] com
<mailto:[EMAIL PROTECTED]> 

        

You need to make sure that the class gets linked into your SWF.  You
don't need to instantiate it but you need to declare a variable with the
type of the class that you want.  You can also use the -include-classes
directive to the compiler to force the class to be available.  Check the
docs for more details.

 

Matt

 



On 12/14/06, slangeberg <[EMAIL PROTECTED] com
<mailto:[EMAIL PROTECTED]> > wrote: 

        I'm guessing it's because your custom class hasn't been
imported.
        
        Long shot, but have you tried something like:
        
        var classRef:Class = flash.utils. getDefinitionByN
ame(dynamicClass ) as Class;
        var myClass:classRef = new classRef();
        
        -Scott 
        
        
        
        
        On 12/14/06, genius_gen2k < genius_gen2k@ yahoo.com
<mailto:[EMAIL PROTECTED]> > wrote: 

                Hello Everyone,
                
                I am trying to instantiate a class dynamically via the
data from an
                external XML file. I get the class name as a String in
Flex code and
                then I have applied the below code to instantiate that
string as a
                class. Here "MyClass" is a custom class inside the
"com.apps" package.
                
                I have a code written as below:
                
                try {
                var dynamicClass: String = "com.apps.MyClass";
                var classRef:Class = flash.utils. getDefinitionByN
ame(dynamicClass )
                as Class;
                var myClass:* = new classRef();
                } 
                catch(e:ReferenceEr ror) {
                tracer.traceMe( e.errorID + " "+e.message);
                }
                
                This code works perfectly with the standard Flex classes
like
                "flash.display. MovieClip" but gives me Reference error
(code 1065)
                when I use "com.apps.MyClass" for the dynamicClass
statement above.
                
                Anything specific needed to be done with the custom
class, to make it
                accessible, the way MovieClip class is accessed. Any
ideas of how do i
                go about this?
                
                Amol.
                
                

                




        -- 
        
        : : ) Scott 




-- 

: : ) Scott 


________________________________

Everyone is raving about the all-new Yahoo! Mail beta.
<http://us.rd.yahoo.com/evt=42297/*http://advision.webevents.yahoo.com/m
ailbeta>  

 

Reply via email to