From: "Zimmen" <[EMAIL PROTECTED]>
> To: "Flashcoders mailing list"
> Sent: Thursday, June 01, 2006 5:33 PM
> Subject: Re: [Flashcoders] create an object of type defined with a
string
>
>
> > This actually works:
> >
> > function makeOb
If you were using Flex, I think there is a way to do it: let us know if you use
Flex.
Regards.
-Mensaje original-
De: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] nombre de Danny
Kodicek
Enviado el: jueves, 01 de junio de 2006 18:02
Para: Flashcoders mailing list
Asunto: [Flashcoders] crea
Subject: Re: [Flashcoders] create an object of type defined with a string
> Danny,
>
> Out of curiosity, why do you need a function that returns an object of a
> type passed as a string? It's a neat idea, but I'm scratching my head as
to
> where one might apply it.
I
> Danny,
>
> Out of curiosity, why do you need a function that returns an object of a
> type passed as a string? It's a neat idea, but I'm scratching my head as
to
> where one might apply it.
I've been hitting some memory problems when using Director's newObject()
function, which creates a new o
ny
Kodicek
Sent: Thursday, June 01, 2006 12:51 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] create an object of type defined with a string
Thanks, Zimmen and Ian, that's helpful. I'll probably go with Ian's
solution, which seems a bit more robust (I've been caugh
ay, June 01, 2006 5:33 PM
Subject: Re: [Flashcoders] create an object of type defined with a string
> This actually works:
>
> function makeObject(tType){
> var tVar = eval(tType)
> return (new tVar())
> }
> test = makeObject("Array")
> test.push("foo")
> t
just for the record you don't need to use eval:
trace(new ["Array"]() instanceof Array)
Cheers
Nick
Danny Kodicek wrote:
Thanks, Zimmen and Ian, that's helpful. I'll probably go with Ian's
solution, which seems a bit more robust (I've been caught out before
by clever tricks using eval()..
Flashcoders mailing list"
Sent: Thursday, June 01, 2006 5:33 PM
Subject: Re: [Flashcoders] create an object of type defined with a string
This actually works:
function makeObject(tType){
var tVar = eval(tType)
return (new tVar())
}
test = makeObject("Array")
test.push("foo"
This actually works:
function makeObject(tType){
var tVar = eval(tType)
return (new tVar())
}
test = makeObject("Array")
test.push("foo")
test.push("bar")
trace(test[0])
trace(test[1])
trace(test.length)
Output:
foo
bar
2
On 6/1/06, Danny Kodicek <[EMAIL PROTECTED]> wrote:
I w
Hi Danny,
mx.utils.ClassFinder.findClass("SomeClass") returns the constructor
function for a class.
e.g.
var className:String = 'String';
var cls:Function = mx.utils.ClassFinder.findClass(className);
var object:Object = new cls();
Hope that helps,
Ian
On 6/1/06, Danny Kodicek <[EMAIL PROTECTED
10 matches
Mail list logo