Sorry, that's what I meant when I said...
such as the declaration of a variable or the creation of an
object
I should have provided a concrete example. :-)
As Scott says, working with .swfs is more like working with .jars than
you might think - particularly when you are working with
Hey Julian,
With your example, this should work (I've just tested a similar class
instantiation in one of my classes):
var anObject = new eval(org).eval(foo).eval(Bar)();
You can pass parameters in the final set of braces as usual.
HTH
Adrian P.
On 4/12/06, Julian 'Julik' Tarkhanov [EMAIL
Hi Julian,
A simple question perhaps but couldn't figure it out by myself.
How can I instantiate a class having it's qname? Say I know that I
need an instance of org.foo.Bar, how can I summon it?
I tried doing:
var anObject = new (eval(org.foo.Bar));
but I get undefined in return. Maybe
var qname:String = org.foo.Bar;
var x = new qname ();
Chris
--
Chris Velevitch
Manager - Sydney Flash Platform Developers Group
www.flashdev.org.au
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
Hi Chris,
var qname:String = org.foo.Bar;
var x = new qname ();
That won't work. Did you mean:
var qname:String = org.foo.Bar;
var x = new eval(qname)();
--
Steve Webster
Head of Development
Featurecreep Ltd.
http://www.featurecreep.com
14 Orchard Street, Bristol, BS1 5EH
0117 905 5047
Are you sure?
If it doesn't, then
var theCommand = new commands [ commandNameToCheck ] ();
definite does. It's used in ARP.
On 4/12/06, Steve Webster [EMAIL PROTECTED] wrote:
Hi Chris,
var qname:String = org.foo.Bar;
var x = new qname ();
That won't work. Did you mean:
var
the following would work too(though very ugly):
code1
import org.foo.Bar;
var qname:String = org.foo.Bar;
var x = new _global[qname]();
/code1
anyway, if you don't do the import, you cannot instanciate the Bar
class ...
OR
*just* reference the class ;) (no
Hi Chris,
Are you sure?
Yup :o)
If it doesn't, then
var theCommand = new commands [ commandNameToCheck ] ();
definite does. It's used in ARP.
I'd wager that 'commands' is an array of constructor function object
references, stored by name, as opposed to an array of strings which
Kind of yes and no...
(Hello to the group by the way, new here)
Please excuse my lack of correct terminology, and number of
assumptions, I think...
Once you understand the underlying structure of Flash, you realise
that referencing properties, variables, and commands is very similar
to
Of course, I was wrong (where's my head at?!).
I can get several of the eval() and [] options to work but, out of
curiosity, how would you pass parameters with the constructor? I can't seem
to do this with my tests. Apologies if this is a dumb q'.
Adrian P.
On 4/12/06, Cedric Muller [EMAIL
you could have a 'paramsObj' Object that stores parameters ?
var myStr:String = org.foo.Bar;
var paramsObj:Object = new Object();
paramsObj.name = robert;
paramsObj.age = 12;
var myInstance:Object = new _global[myStr](paramsObj);
var theCommand = new commands [ commandNameToCheck ] ();
Julian,
The problem is - I got to have new someClass somewhere in my code
for the other layouts to appear under _globals, after which I can
properly instantiate them.
You just need to reference the class, so variables like this...
var hLayoutRef:Function = Horizontal;
var
11:57
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Instantiate a class by string
you could have a 'paramsObj' Object that stores parameters ?
var myStr:String = org.foo.Bar;
var paramsObj:Object = new Object();
paramsObj.name = robert;
paramsObj.age = 12;
var myInstance:Object = new
On 12-apr-2006, at 17:05, Ian Thomas wrote:
Import doesn't actually use the class per se - a solid reference of
some sort (such as the declaration of a variable or the creation of an
object) of that class suddenly means that it's actually been used, and
so the compiler notes that it needs to
On 12-apr-2006, at 19:10, Scott Hyndman wrote:
SWF is more flexible than you give it credit for. A swf can
reference external resources just as a jar can. You can, in effect,
write your own class loader that satisfies dependencies at runtime
just by splitting all your classes into
12, 2006 12:59 PM
Subject: Re: [Flashcoders] Instantiate a class by string - SOLVED
On 12-apr-2006, at 17:05, Ian Thomas wrote:
Import doesn't actually use the class per se - a solid reference of
some sort (such as the declaration of a variable or the creation of an
object) of that class
To force a class to be imported even if no one uses it:
import com.company.project.YourClass;
static private var depend:YourClass;
warden to the rescue!
___
This e-mail is intended only for the named person or entity to which
it is
On 12-apr-2006, at 19:59, JesterXL wrote:
To force a class to be imported even if no one uses it:
import com.company.project.YourClass;
static private var depend:YourClass;
Ok, now this looks classy! Forces the class to be burned in and yet
shows why it's there.
Thanks a bunch!
--
Hello flashcoders.
A simple question perhaps but couldn't figure it out by myself.
How can I instantiate a class having it's qname? Say I know that I
need an instance of org.foo.Bar, how can I summon it?
I tried doing:
var anObject = new (eval(org.foo.Bar));
but I get undefined in return.
19 matches
Mail list logo