Might be interesting to know why you need to do this at all.
I'm using an XML document to create a file. Without going into
details, each node of the XML is to be turned into an
object, based on the kind of node.
So for example:
xmlitem type='Big' size='3' /item
Might be interesting to know why you need to do this at all.
I'm using an XML document to create a file. Without going into details, each
node of the XML is to be turned into an object, based on the kind of node.
So for example:
xmlitem type='Big' size='3' /item type='Small'
- Original Message -
From: Danny Kodicek [EMAIL PROTECTED]
To: flashcoders@chattyfig.figleaf.com
Sent: Monday, March 19, 2007 10:08 AM
Subject: [Flashcoders] Create an object by name
If I have a string, how can I make an object from the class it represents?
Eg:
I have class
Hello Danny,
This short snippet should return you the constructor:
/** Returns the class constructor from a dotted path.
* e.g. [EMAIL PROTECTED] var
cons:Function=getConstructorFromPath(com.pkg.fred.Bucket); }
*/
public static function
Hello Danny,
This short snippet should return you the constructor:
/** Returns the class constructor from a dotted path.
* e.g. [EMAIL PROTECTED] var
cons:Function=getConstructorFromPath(com.pkg.fred.Bucket); }
*/
public static function
If I have a string, how can I make an object from the class
it represents?
Eg:
I have class MyBigClass
the string className contains the text Big
I want to do something like
obj:Object = new(My + className + Class)()
Paul:
Might be interesting to know why you need to do this
Hi Danny,
An import statement is just a compiler-friendly shortcut. It has no
effect whatsoever on the final code.
Saying:
import com.pkg.fred.Bucket;
// later
var bucket:Bucket=new Bucket();
is identical to saying just:
var bucket:com.pkg.fred.Bucket=new com.pkg.fred.Bucket();
That's all
- Original Message -
From: Danny Kodicek [EMAIL PROTECTED]
To: flashcoders@chattyfig.figleaf.com
I'm still not entirely sure what import actually
*does* :)
It tells flash where the class definitions can be found and distinguishes
between classes of the same name, but different
Kodicek [mailto:[EMAIL PROTECTED]
Sent: 19 March 2007 11:45
To: flashcoders@chattyfig.figleaf.com
Subject: RE: [Flashcoders] Create an object by name
Hello Danny,
This short snippet should return you the constructor:
/** Returns the class constructor from a dotted path.
* e.g
Hi,
new eval(_global.mypackage.MyClass) does the trick as well I believe.
greetz
JC
On 3/19/07, Danny Kodicek [EMAIL PROTECTED] wrote:
If I have a string, how can I make an object from the class
it represents?
Eg:
I have class MyBigClass
the string className contains the text Big
On 3/19/07, Ian Thomas [EMAIL PROTECTED] wrote:
That's all it is. A convent bit of syntactic sugar. It's exactly the
same in Java.
Um... _convenient_, obviously. Although that does conjure up some
wacky images...
Ian
___
Hi Danny,
An import statement is just a compiler-friendly shortcut.
It has no effect whatsoever on the final code.
Saying:
import com.pkg.fred.Bucket;
// later
var bucket:Bucket=new Bucket();
is identical to saying just:
var bucket:com.pkg.fred.Bucket=new
I'm still not entirely sure what import actually
*does* :)
It tells flash where the class definitions can be found and
distinguishes between classes of the same name, but different
packages.
You seem to be in a mega hurry Danny!
I've been working on my current task for about nine
I'm still not entirely sure what import actually
*does* :)
It tells flash where the class definitions can be found and
distinguishes between classes of the same name, but different
packages.
You know, it occurs to me that import is an astonishingly bad name for this
statement. Poorly
- Original Message -
From: Danny Kodicek [EMAIL PROTECTED]
To: flashcoders@chattyfig.figleaf.com
Sent: Monday, March 19, 2007 2:36 PM
Subject: RE: [Flashcoders] Create an object by name
I'm still not entirely sure what import actually
*does* :)
It tells flash where the class
Most of the time, what I've seen is setting a temporary var to either an
instance of the class, or in the case of a static class, setting it to a
reference to the class.
var myClass:MyClass = new com.client.project.package.MyClass();
or
var myClass:MyClass = com.client.project.package.MyClass;
I
16 matches
Mail list logo