Re: [Flashcoders] Dynamic class creation

2006-01-31 Thread Bart Wttewaall
Or just use mx.utils.ClassFinder.

var classname:String = "com.mosesSupposes.fuse.Fuse";
var FuseClass:Function = mx.utils.ClassFinder.findClass(classname);
fuse = new FuseClass();

2006/1/30, franto <[EMAIL PROTECTED]>:
> thank you all, i've already made it!
>
> var str:String = 'test1.test2.ClassC';
> var arr = str.split('.');
> var variable = _global;
>
> for (var i=0;i {
> variable = variable[arr[i]];
> trace(variable);
> }
> new variable();
>
>
>
> On 1/30/06, Serge <[EMAIL PROTECTED]> wrote:
> >
> >  import pkg1.pkg2.pkg3.*
> > or
> > import pkg1.*
> >
> >  >> new pkg1.pkg2.pkg3.className(),
> > sorry, should be:
> > new className()
> >
> >  make sure pkg1 has classes you would like to be compiled in swf or use
> >  exclude xml file
> >
> >
> >
> > On 1/30/06, franto <[EMAIL PROTECTED]> wrote:
> > >> Hi all,
> > >>
> > >> maybe it is easy, maybe not, but i cant figure it out now, and i need it
> > >> :)
> > >>
> > >> when i got class e,gpkg1.pkg2.pkg3.className
> > >>
> > >> i can make new instance in this way
> > >> new pkg1.pkg2.pkg3.className()
> > >>
> > >> but i want to make it from string
> > >>
> > >> this dont work of course
> > >> _global['pkg1.pkg2.pkg3.className']();
> > >>
> > >> but this work:
> > >> _global['pkg1']['pkg2']['pkg3']['className']();
> > >>
> > >> can this done automatcally? i want jsut read string from XML and
> > >> create new class instance,
> > >> but i cant do it now.
> > >> Any help is appreciated :)
> > >>
> > >> -
> > >> Franto
> > >>
> > >> http://blog.franto.com
> > >> http://www.flashcoders.sk
> > >> ___
> > >> Flashcoders mailing list
> > >> Flashcoders@chattyfig.figleaf.com
> > >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >>
> > > ___
> > > Flashcoders mailing list
> > > Flashcoders@chattyfig.figleaf.com
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > > ___
> > > Flashcoders mailing list
> > > Flashcoders@chattyfig.figleaf.com
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> > ___
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
>
>
> --
> -
> Franto
>
> http://blog.franto.com
> http://www.flashcoders.sk
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Dynamic class creation-thoughts?

2006-01-30 Thread Kamyar Nazeri
Nice job for creating dynamic linked library in flash, thanks to Farid and 
Scott.  Of course compiled clips and components do the same, but using dlls 
gives us the ability to load classed whenever they are needed and not just 
including them all in the first frame!
  I was wondering if it is possible to load a class with a given string using 
pure ActionScript and I guess it's not. Well that's not an issue in flash and I 
was wrong to compare Java and flash in this case because in Java classes are 
compiled in separate .java files and it takes time for an application to load 
them all at startup, hence manually loading classes (as I described in my other 
post) can improve application performance, but since in flash all classes are 
embedded in a single compiled .swf file they are available when swf is loaded

Kamy


  Scott Hyndman <[EMAIL PROTECTED]> wrote: Hey Kamyar,

Sure it is...unless I misunderstand you.

http://www.osflash.org/using_a_swf_as_a_dll

Scott


-Original Message-
From: [EMAIL PROTECTED] on behalf of Kamyar Nazeri
Sent: Mon 1/30/2006 12:48 PM
To: Flashcoders mailing list
Cc: 
Subject: Re: [Flashcoders] Dynamic class creation-thoughts?

I looked into Java Virtual Machine "Class" code, it's not possible to load a 
class dynamically in flash. at least you need to have somehow the main package 
loaded in flash!

after all it is ActionScript and it still needs lots of improvements in 
language syntax


Kamyar Nazeri  wrote: first, what you guys have done is dynamically refrencing 
a *loaded* class not dynamically creating a class! if the class is not yet 
loaded it returns null.

and of course dynamically refrencing a class gives you nothing, I was wondering 
if it is possible to load a class dynamically?

in Java there's a forName method on "Class" class that loads a class with given 
string and that's what we use with applications with dozens of classes, because 
it can take a long time for a big  application to load all classes 
automatically, frustrating the user. so we can give users of our program the  
illusion of a faster start with the this trick: the class  containing the main 
method does not explicitly refer to other classes. first display a splash 
screen. Then manually force the loading of other classes  by calling 
Class.forName

anybody? any suggestions for loading a class dynamically?

[EMAIL PROTECTED] wrote: Just a general, - what are people's thoughts on 
dynamic class
instantiation? I've always been under the impression( and hence, been
told) that one should avoid it at all costs.

Thoughts? Discussion? Benefits? Would it be better to implement a factory
type pattern to create the new instances of classes?

> thank you all, i've already made it!
>
> var str:String = 'test1.test2.ClassC';
> var arr = str.split('.');
> var variable = _global;
>
> for (var i=0;i
> {
>  variable = variable[arr[i]];
>  trace(variable);
> }
> new variable();
>
>
>
> On 1/30/06, Serge  wrote:
>>
>>  import pkg1.pkg2.pkg3.*
>> or
>> import pkg1.*
>>
>>  >> new pkg1.pkg2.pkg3.className(),
>> sorry, should be:
>> new className()
>>
>>  make sure pkg1 has classes you would like to be compiled in swf or
>> use exclude xml file
>>
>>
>>
>> On 1/30/06, franto  wrote:
>> >> Hi all,
>> >>
>> >> maybe it is easy, maybe not, but i cant figure it out now, and i
>> need it :)
>> >>
>> >> when i got class e,gpkg1.pkg2.pkg3.className
>> >>
>> >> i can make new instance in this way
>> >> new pkg1.pkg2.pkg3.className()
>> >>
>> >> but i want to make it from string
>> >>
>> >> this dont work of course
>> >> _global['pkg1.pkg2.pkg3.className']();
>> >>
>> >> but this work:
>> >> _global['pkg1']['pkg2']['pkg3']['className']();
>> >>
>> >> can this done automatcally? i want jsut read string from XML and
>> create new class instance,
>> >> but i cant do it now.
>> >> Any help is appreciated :)
>> >>
>> >> -
>> Franto
>> >>
>> >> http://blog.franto.com
>> >> http://www.flashcoders.sk
>> >> ___
>> >> Flashcoders mailing list
>> >> Flashcoders@chattyf

RE: [Flashcoders] Dynamic class creation-thoughts?

2006-01-30 Thread Scott Hyndman
Hey Kamyar,

Sure it is...unless I misunderstand you.

http://www.osflash.org/using_a_swf_as_a_dll

Scott


-Original Message-
From:   [EMAIL PROTECTED] on behalf of Kamyar Nazeri
Sent:   Mon 1/30/2006 12:48 PM
To: Flashcoders mailing list
Cc: 
Subject:Re: [Flashcoders] Dynamic class creation-thoughts?

I looked into Java Virtual Machine "Class" code, it's not possible to load a 
class dynamically in flash. at least you need to have somehow the main package 
loaded in flash!

after all it is ActionScript and it still needs lots of improvements in 
language syntax


Kamyar Nazeri <[EMAIL PROTECTED]> wrote: first, what you guys have done is 
dynamically refrencing a *loaded* class not dynamically creating a class! if 
the class is not yet loaded it returns null.

and of course dynamically refrencing a class gives you nothing, I was wondering 
if it is possible to load a class dynamically?

in Java there's a forName method on "Class" class that loads a class with given 
string and that's what we use with applications with dozens of classes, because 
it can take a long time for a big  application to load all classes 
automatically, frustrating the user. so we can give users of our program the  
illusion of a faster start with the this trick: the class  containing the main 
method does not explicitly refer to other classes. first display a splash 
screen. Then manually force the loading of other classes  by calling 
Class.forName

anybody? any suggestions for loading a class dynamically?

[EMAIL PROTECTED] wrote: Just a general, - what are people's thoughts on 
dynamic class
instantiation? I've always been under the impression( and hence, been
told) that one should avoid it at all costs.

Thoughts? Discussion? Benefits? Would it be better to implement a factory
type pattern to create the new instances of classes?

> thank you all, i've already made it!
>
> var str:String = 'test1.test2.ClassC';
> var arr = str.split('.');
> var variable = _global;
>
> for (var i=0;i
> {
>  variable = variable[arr[i]];
>  trace(variable);
> }
> new variable();
>
>
>
> On 1/30/06, Serge  wrote:
>>
>>  import pkg1.pkg2.pkg3.*
>> or
>> import pkg1.*
>>
>>  >> new pkg1.pkg2.pkg3.className(),
>> sorry, should be:
>> new className()
>>
>>  make sure pkg1 has classes you would like to be compiled in swf or
>> use exclude xml file
>>
>>
>>
>> On 1/30/06, franto  wrote:
>> >> Hi all,
>> >>
>> >> maybe it is easy, maybe not, but i cant figure it out now, and i
>> need it :)
>> >>
>> >> when i got class e,gpkg1.pkg2.pkg3.className
>> >>
>> >> i can make new instance in this way
>> >> new pkg1.pkg2.pkg3.className()
>> >>
>> >> but i want to make it from string
>> >>
>> >> this dont work of course
>> >> _global['pkg1.pkg2.pkg3.className']();
>> >>
>> >> but this work:
>> >> _global['pkg1']['pkg2']['pkg3']['className']();
>> >>
>> >> can this done automatcally? i want jsut read string from XML and
>> create new class instance,
>> >> but i cant do it now.
>> >> Any help is appreciated :)
>> >>
>> >> -
>> Franto
>> >>
>> >> http://blog.franto.com
>> >> http://www.flashcoders.sk
>> >> ___
>> >> Flashcoders mailing list
>> >> Flashcoders@chattyfig.figleaf.com
>> >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> >>
>> > ___
>> > Flashcoders mailing list
>> > Flashcoders@chattyfig.figleaf.com
>> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> > ___
>> > Flashcoders mailing list
>> > Flashcoders@chattyfig.figleaf.com
>> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
>
> --
> -
> Franto
>
> h

Re: [Flashcoders] Dynamic class creation-thoughts?

2006-01-30 Thread Farid Shahlavi
Take a look at this, basically the closest thing to what you're referring to in 
Java. http://www.osflash.org/sexie
 
 
Farid

- Original Message 
From: Kamyar Nazeri <[EMAIL PROTECTED]>
To: Flashcoders mailing list 
Sent: Monday, January 30, 2006 12:48:04 PM
Subject: Re: [Flashcoders] Dynamic class creation-thoughts?


I looked into Java Virtual Machine "Class" code, it's not possible to load a 
class dynamically in flash. at least you need to have somehow the main package 
loaded in flash!

after all it is ActionScript and it still needs lots of improvements in 
language syntax


Kamyar Nazeri <[EMAIL PROTECTED]> wrote: first, what you guys have done is 
dynamically refrencing a *loaded* class not dynamically creating a class! if 
the class is not yet loaded it returns null.

and of course dynamically refrencing a class gives you nothing, I was wondering 
if it is possible to load a class dynamically?

in Java there's a forName method on "Class" class that loads a class with given 
string and that's what we use with applications with dozens of classes, because 
it can take a long time for a big  application to load all classes 
automatically, frustrating the user. so we can give users of our program the  
illusion of a faster start with the this trick: the class  containing the main 
method does not explicitly refer to other classes. first display a splash 
screen. Then manually force the loading of other classes  by calling 
Class.forName

anybody? any suggestions for loading a class dynamically?

[EMAIL PROTECTED] wrote: Just a general, - what are people's thoughts on 
dynamic class
instantiation? I've always been under the impression( and hence, been
told) that one should avoid it at all costs.

Thoughts? Discussion? Benefits? Would it be better to implement a factory
type pattern to create the new instances of classes?

> thank you all, i've already made it!
>
> var str:String = 'test1.test2.ClassC';
> var arr = str.split('.');
> var variable = _global;
>
> for (var i=0;i
> {
>  variable = variable[arr[i]];
>  trace(variable);
> }
> new variable();
>
>
>
> On 1/30/06, Serge  wrote:
>>
>>  import pkg1.pkg2.pkg3.*
>> or
>> import pkg1.*
>>
>>  >> new pkg1.pkg2.pkg3.className(),
>> sorry, should be:
>> new className()
>>
>>  make sure pkg1 has classes you would like to be compiled in swf or
>> use exclude xml file
>>
>>
>>
>> On 1/30/06, franto  wrote:
>> >> Hi all,
>> >>
>> >> maybe it is easy, maybe not, but i cant figure it out now, and i
>> need it :)
>> >>
>> >> when i got class e,gpkg1.pkg2.pkg3.className
>> >>
>> >> i can make new instance in this way
>> >> new pkg1.pkg2.pkg3.className()
>> >>
>> >> but i want to make it from string
>> >>
>> >> this dont work of course
>> >> _global['pkg1.pkg2.pkg3.className']();
>> >>
>> >> but this work:
>> >> _global['pkg1']['pkg2']['pkg3']['className']();
>> >>
>> >> can this done automatcally? i want jsut read string from XML and
>> create new class instance,
>> >> but i cant do it now.
>> >> Any help is appreciated :)
>> >>
>> >> -
>> Franto
>> >>
>> >> http://blog.franto.com
>> >> http://www.flashcoders.sk
>> >> ___
>> >> Flashcoders mailing list
>> >> Flashcoders@chattyfig.figleaf.com
>> >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> >>
>> > ___
>> > Flashcoders mailing list
>> > Flashcoders@chattyfig.figleaf.com
>> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> > ___
>> > Flashcoders mailing list
>> > Flashcoders@chattyfig.figleaf.com
>> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
>
> --
> -
> Franto

Re: [Flashcoders] Dynamic class creation-thoughts?

2006-01-30 Thread Kamyar Nazeri
I looked into Java Virtual Machine "Class" code, it's not possible to load a 
class dynamically in flash. at least you need to have somehow the main package 
loaded in flash!

after all it is ActionScript and it still needs lots of improvements in 
language syntax


Kamyar Nazeri <[EMAIL PROTECTED]> wrote: first, what you guys have done is 
dynamically refrencing a *loaded* class not dynamically creating a class! if 
the class is not yet loaded it returns null.

and of course dynamically refrencing a class gives you nothing, I was wondering 
if it is possible to load a class dynamically?

in Java there's a forName method on "Class" class that loads a class with given 
string and that's what we use with applications with dozens of classes, because 
it can take a long time for a big  application to load all classes 
automatically, frustrating the user. so we can give users of our program the  
illusion of a faster start with the this trick: the class  containing the main 
method does not explicitly refer to other classes. first display a splash 
screen. Then manually force the loading of other classes  by calling 
Class.forName

anybody? any suggestions for loading a class dynamically?

[EMAIL PROTECTED] wrote: Just a general, - what are people's thoughts on 
dynamic class
instantiation? I've always been under the impression( and hence, been
told) that one should avoid it at all costs.

Thoughts? Discussion? Benefits? Would it be better to implement a factory
type pattern to create the new instances of classes?

> thank you all, i've already made it!
>
> var str:String = 'test1.test2.ClassC';
> var arr = str.split('.');
> var variable = _global;
>
> for (var i=0;i
> {
>  variable = variable[arr[i]];
>  trace(variable);
> }
> new variable();
>
>
>
> On 1/30/06, Serge  wrote:
>>
>>  import pkg1.pkg2.pkg3.*
>> or
>> import pkg1.*
>>
>>  >> new pkg1.pkg2.pkg3.className(),
>> sorry, should be:
>> new className()
>>
>>  make sure pkg1 has classes you would like to be compiled in swf or
>> use exclude xml file
>>
>>
>>
>> On 1/30/06, franto  wrote:
>> >> Hi all,
>> >>
>> >> maybe it is easy, maybe not, but i cant figure it out now, and i
>> need it :)
>> >>
>> >> when i got class e,gpkg1.pkg2.pkg3.className
>> >>
>> >> i can make new instance in this way
>> >> new pkg1.pkg2.pkg3.className()
>> >>
>> >> but i want to make it from string
>> >>
>> >> this dont work of course
>> >> _global['pkg1.pkg2.pkg3.className']();
>> >>
>> >> but this work:
>> >> _global['pkg1']['pkg2']['pkg3']['className']();
>> >>
>> >> can this done automatcally? i want jsut read string from XML and
>> create new class instance,
>> >> but i cant do it now.
>> >> Any help is appreciated :)
>> >>
>> >> -
>> Franto
>> >>
>> >> http://blog.franto.com
>> >> http://www.flashcoders.sk
>> >> ___
>> >> Flashcoders mailing list
>> >> Flashcoders@chattyfig.figleaf.com
>> >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> >>
>> > ___
>> > Flashcoders mailing list
>> > Flashcoders@chattyfig.figleaf.com
>> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> > ___
>> > Flashcoders mailing list
>> > Flashcoders@chattyfig.figleaf.com
>> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
>
> --
> -
> Franto
>
> http://blog.franto.com
> http://www.flashcoders.sk
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



   
-
 Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews, & more on new 
and used cars.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




-
 
 What are the most popular cars? Find out at Yahoo! Autos 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Dynamic class creation-thoughts?

2006-01-30 Thread Kamyar Nazeri
first, what you guys have done is dynamically refrencing a *loaded* class not 
dynamically creating a class! if the class is not yet loaded it returns null.

and of course dynamically refrencing a class gives you nothing, I was wondering 
if it is possible to load a class dynamically?

in Java there's a forName method on "Class" class that loads a class with given 
string and that's what we use with applications with dozens of classes, because 
it can take a long time for a big  application to load all classes 
automatically, frustrating the user. so we can give users of our program the  
illusion of a faster start with the this trick: the class  containing the main 
method does not explicitly refer to other classes. first display a splash 
screen. Then manually force the loading of other classes  by calling 
Class.forName

anybody? any suggestions for loading a class dynamically?

[EMAIL PROTECTED] wrote: Just a general, - what are people's thoughts on 
dynamic class
instantiation? I've always been under the impression( and hence, been
told) that one should avoid it at all costs.

Thoughts? Discussion? Benefits? Would it be better to implement a factory
type pattern to create the new instances of classes?

> thank you all, i've already made it!
>
> var str:String = 'test1.test2.ClassC';
> var arr = str.split('.');
> var variable = _global;
>
> for (var i=0;i
> {
>  variable = variable[arr[i]];
>  trace(variable);
> }
> new variable();
>
>
>
> On 1/30/06, Serge  wrote:
>>
>>  import pkg1.pkg2.pkg3.*
>> or
>> import pkg1.*
>>
>>  >> new pkg1.pkg2.pkg3.className(),
>> sorry, should be:
>> new className()
>>
>>  make sure pkg1 has classes you would like to be compiled in swf or
>> use exclude xml file
>>
>>
>>
>> On 1/30/06, franto  wrote:
>> >> Hi all,
>> >>
>> >> maybe it is easy, maybe not, but i cant figure it out now, and i
>> need it :)
>> >>
>> >> when i got class e,gpkg1.pkg2.pkg3.className
>> >>
>> >> i can make new instance in this way
>> >> new pkg1.pkg2.pkg3.className()
>> >>
>> >> but i want to make it from string
>> >>
>> >> this dont work of course
>> >> _global['pkg1.pkg2.pkg3.className']();
>> >>
>> >> but this work:
>> >> _global['pkg1']['pkg2']['pkg3']['className']();
>> >>
>> >> can this done automatcally? i want jsut read string from XML and
>> create new class instance,
>> >> but i cant do it now.
>> >> Any help is appreciated :)
>> >>
>> >> -
>> Franto
>> >>
>> >> http://blog.franto.com
>> >> http://www.flashcoders.sk
>> >> ___
>> >> Flashcoders mailing list
>> >> Flashcoders@chattyfig.figleaf.com
>> >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> >>
>> > ___
>> > Flashcoders mailing list
>> > Flashcoders@chattyfig.figleaf.com
>> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> > ___
>> > Flashcoders mailing list
>> > Flashcoders@chattyfig.figleaf.com
>> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
>
> --
> -
> Franto
>
> http://blog.franto.com
> http://www.flashcoders.sk
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




-
 Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews, & more on new 
and used cars.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Dynamic class creation-thoughts?

2006-01-30 Thread Cédric Muller
I may be idiot, but how would you generate a menu's items given  
dynamic data ???

I cannot but see dynamic instantation, can I ?
same for games, same for MP3 players (and video), same for whatever  
almost anything ?

cedric

I don't see the ish. If you're making a shooter game and have  
classes for enemies and classes for bullets, how would you put that  
into effect WITHOUT dynamic instantiation. I'm a hell of a lot more  
concerned with the idea of dynamic definition.


- Andreas X

[EMAIL PROTECTED] wrote:

Just a general, - what are people's thoughts on dynamic class
instantiation? I've always been under the impression( and hence, been
told) that one should avoid it at all costs.
Thoughts? Discussion? Benefits? Would it be better to implement a  
factory

type pattern to create the new instances of classes?

thank you all, i've already made it!

var str:String = 'test1.test2.ClassC';
var arr = str.split('.');
var variable = _global;

for (var i=0;i wrote:


import pkg1.pkg2.pkg3.*
or
import pkg1.*

>> new pkg1.pkg2.pkg3.className(),
sorry, should be:
new className()

make sure pkg1 has classes you would like to be compiled in swf or
use exclude xml file



On 1/30/06, franto <[EMAIL PROTECTED]> wrote:


Hi all,

maybe it is easy, maybe not, but i cant figure it out now, and i


need it :)


when i got class e,gpkg1.pkg2.pkg3.className

i can make new instance in this way
new pkg1.pkg2.pkg3.className()

but i want to make it from string

this dont work of course
_global['pkg1.pkg2.pkg3.className']();

but this work:
_global['pkg1']['pkg2']['pkg3']['className']();

can this done automatcally? i want jsut read string from XML and


create new class instance,


but i cant do it now.
Any help is appreciated :)

- 
- 
---


Franto


http://blog.franto.com
http://www.flashcoders.sk
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




--
 
 
-

Franto

http://blog.franto.com
http://www.flashcoders.sk
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


--

- Andreas Rønning

---
Flash guy
Rayon Visual Concepts, Oslo, Norway
---
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Dynamic class creation-thoughts?

2006-01-30 Thread Andreas Rønning
I don't see the ish. If you're making a shooter game and have classes 
for enemies and classes for bullets, how would you put that into effect 
WITHOUT dynamic instantiation. I'm a hell of a lot more concerned with 
the idea of dynamic definition.


- Andreas X

[EMAIL PROTECTED] wrote:

Just a general, - what are people's thoughts on dynamic class
instantiation? I've always been under the impression( and hence, been
told) that one should avoid it at all costs.

Thoughts? Discussion? Benefits? Would it be better to implement a factory
type pattern to create the new instances of classes?



thank you all, i've already made it!

var str:String = 'test1.test2.ClassC';
var arr = str.split('.');
var variable = _global;

for (var i=0;i wrote:


import pkg1.pkg2.pkg3.*
or
import pkg1.*

>> new pkg1.pkg2.pkg3.className(),
sorry, should be:
new className()

make sure pkg1 has classes you would like to be compiled in swf or
use exclude xml file



On 1/30/06, franto <[EMAIL PROTECTED]> wrote:


Hi all,

maybe it is easy, maybe not, but i cant figure it out now, and i


need it :)


when i got class e,gpkg1.pkg2.pkg3.className

i can make new instance in this way
new pkg1.pkg2.pkg3.className()

but i want to make it from string

this dont work of course
_global['pkg1.pkg2.pkg3.className']();

but this work:
_global['pkg1']['pkg2']['pkg3']['className']();

can this done automatcally? i want jsut read string from XML and


create new class instance,


but i cant do it now.
Any help is appreciated :)

-


Franto


http://blog.franto.com
http://www.flashcoders.sk
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




--
-
Franto

http://blog.franto.com
http://www.flashcoders.sk
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders





___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


--

- Andreas Rønning

---
Flash guy
Rayon Visual Concepts, Oslo, Norway
---
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Dynamic class creation-thoughts?

2006-01-30 Thread stacey
Just a general, - what are people's thoughts on dynamic class
instantiation? I've always been under the impression( and hence, been
told) that one should avoid it at all costs.

Thoughts? Discussion? Benefits? Would it be better to implement a factory
type pattern to create the new instances of classes?

> thank you all, i've already made it!
>
> var str:String = 'test1.test2.ClassC';
> var arr = str.split('.');
> var variable = _global;
>
> for (var i=0;i {
>   variable = variable[arr[i]];
>   trace(variable);
> }
> new variable();
>
>
>
> On 1/30/06, Serge <[EMAIL PROTECTED]> wrote:
>>
>>  import pkg1.pkg2.pkg3.*
>> or
>> import pkg1.*
>>
>>  >> new pkg1.pkg2.pkg3.className(),
>> sorry, should be:
>> new className()
>>
>>  make sure pkg1 has classes you would like to be compiled in swf or
>> use exclude xml file
>>
>>
>>
>> On 1/30/06, franto <[EMAIL PROTECTED]> wrote:
>> >> Hi all,
>> >>
>> >> maybe it is easy, maybe not, but i cant figure it out now, and i
>> need it :)
>> >>
>> >> when i got class e,gpkg1.pkg2.pkg3.className
>> >>
>> >> i can make new instance in this way
>> >> new pkg1.pkg2.pkg3.className()
>> >>
>> >> but i want to make it from string
>> >>
>> >> this dont work of course
>> >> _global['pkg1.pkg2.pkg3.className']();
>> >>
>> >> but this work:
>> >> _global['pkg1']['pkg2']['pkg3']['className']();
>> >>
>> >> can this done automatcally? i want jsut read string from XML and
>> create new class instance,
>> >> but i cant do it now.
>> >> Any help is appreciated :)
>> >>
>> >> -
>> Franto
>> >>
>> >> http://blog.franto.com
>> >> http://www.flashcoders.sk
>> >> ___
>> >> Flashcoders mailing list
>> >> Flashcoders@chattyfig.figleaf.com
>> >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> >>
>> > ___
>> > Flashcoders mailing list
>> > Flashcoders@chattyfig.figleaf.com
>> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> > ___
>> > Flashcoders mailing list
>> > Flashcoders@chattyfig.figleaf.com
>> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
>
> --
> -
> Franto
>
> http://blog.franto.com
> http://www.flashcoders.sk
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Dynamic class creation

2006-01-30 Thread franto
thank you all, i've already made it!

var str:String = 'test1.test2.ClassC';
var arr = str.split('.');
var variable = _global;

for (var i=0;i wrote:
>
>  import pkg1.pkg2.pkg3.*
> or
> import pkg1.*
>
>  >> new pkg1.pkg2.pkg3.className(),
> sorry, should be:
> new className()
>
>  make sure pkg1 has classes you would like to be compiled in swf or use
>  exclude xml file
>
>
>
> On 1/30/06, franto <[EMAIL PROTECTED]> wrote:
> >> Hi all,
> >>
> >> maybe it is easy, maybe not, but i cant figure it out now, and i need it
> >> :)
> >>
> >> when i got class e,gpkg1.pkg2.pkg3.className
> >>
> >> i can make new instance in this way
> >> new pkg1.pkg2.pkg3.className()
> >>
> >> but i want to make it from string
> >>
> >> this dont work of course
> >> _global['pkg1.pkg2.pkg3.className']();
> >>
> >> but this work:
> >> _global['pkg1']['pkg2']['pkg3']['className']();
> >>
> >> can this done automatcally? i want jsut read string from XML and
> >> create new class instance,
> >> but i cant do it now.
> >> Any help is appreciated :)
> >>
> >> -
> >> Franto
> >>
> >> http://blog.franto.com
> >> http://www.flashcoders.sk
> >> ___
> >> Flashcoders mailing list
> >> Flashcoders@chattyfig.figleaf.com
> >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >>
> > ___
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > ___
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>


--
-
Franto

http://blog.franto.com
http://www.flashcoders.sk
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Dynamic class creation

2006-01-30 Thread Serge


import pkg1.pkg2.pkg3.*
or
import pkg1.*

>> new pkg1.pkg2.pkg3.className(),
sorry, should be:
new className()

make sure pkg1 has classes you would like to be compiled in swf or use
exclude xml file



On 1/30/06, franto <[EMAIL PROTECTED]> wrote:

Hi all,

maybe it is easy, maybe not, but i cant figure it out now, and i need it 
:)


when i got class e,gpkg1.pkg2.pkg3.className

i can make new instance in this way
new pkg1.pkg2.pkg3.className()

but i want to make it from string

this dont work of course
_global['pkg1.pkg2.pkg3.className']();

but this work:
_global['pkg1']['pkg2']['pkg3']['className']();

can this done automatcally? i want jsut read string from XML and
create new class instance,
but i cant do it now.
Any help is appreciated :)

-
Franto

http://blog.franto.com
http://www.flashcoders.sk
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders 


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Bulk] Re: [Flashcoders] Dynamic class creation

2006-01-30 Thread Serge

import pkg1.pkg2.pkg3.*
or
import pkg1.*

new pkg1.pkg2.pkg3.className()

make sure pkg1 has classes you would like to be compiled in swf or use 
exclude xml file




On 1/30/06, franto <[EMAIL PROTECTED]> wrote:

Hi all,

maybe it is easy, maybe not, but i cant figure it out now, and i need it 
:)


when i got class e,gpkg1.pkg2.pkg3.className

i can make new instance in this way
new pkg1.pkg2.pkg3.className()

but i want to make it from string

this dont work of course
_global['pkg1.pkg2.pkg3.className']();

but this work:
_global['pkg1']['pkg2']['pkg3']['className']();

can this done automatcally? i want jsut read string from XML and
create new class instance,
but i cant do it now.
Any help is appreciated :)

-
Franto

http://blog.franto.com
http://www.flashcoders.sk
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders 


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Dynamic class creation

2006-01-30 Thread Martin Wood

This should do the job.

1. ClassFactory to create classes specified by strings.


class ClassFactory
{
public static function create(className:String):Object
{
// Split the class name into its parts
var parts:Array = className.split(".");

// a variable to build a reference to the class
var classRef:Object = _global;

// Iterate over the parts, digging deeper each time
// into the namespace heirarchy
for(var n=0;n < parts.length;n++)
{
classRef = classRef[parts[n]];
}

// Check that the class exists
if(classRef == undefined)
{
throw new ClassCreationException("Class not found : " + 
className);
}
else
{
return new classRef();
}
}
}


2. The Class Creation Exception, nothing special :)


class ClassCreationException extends Error
{
public function ClassCreationException(msg:String)
{
message = msg;
}
}


and some test code to check it works :


var className:String = "com.test.MyClass";

import com.test.MyClass;
var c:MyClass;

try
{
var c:Object = ClassFactory.create(className);
}
catch(e)
{
trace(e.message);
}


of course, you need the reference to the class you want to create somewhere or 
the compiler wont include it when it builds the swf, hence the


var c:MyClass line.

for me thats the worst part of the whole thing, but theres ways you can organise 
this, e.g. a simple include that just lists the declarations you will need


#include "forceIncludes.as"

which just contains a list of the references

im sure there are other solutions to this little problem, if anyone else has any 
bright ideas id like to know.


Of course, the other part of this is that the class factory can only return 
objects that are typed as 'Object' so you lose quite a bit of type safety like 
this, unless of course you are creating objects that all conform to a specific 
interface. You might want to modify the class factory to add methods that return 
particular types of objects with a return type set to their common interface. It 
depends on what your requirements are really on how you architect this part.


hope that all makes sense.

thanks,

Martin


franto wrote:

Hi all,

maybe it is easy, maybe not, but i cant figure it out now, and i need it :)

when i got class e,gpkg1.pkg2.pkg3.className

i can make new instance in this way
new pkg1.pkg2.pkg3.className()

but i want to make it from string

this dont work of course
_global['pkg1.pkg2.pkg3.className']();

but this work:
_global['pkg1']['pkg2']['pkg3']['className']();

can this done automatcally? i want jsut read string from XML and
create new class instance,
but i cant do it now.
Any help is appreciated :)

-
Franto

http://blog.franto.com
http://www.flashcoders.sk
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



--
Martin Wood

http://relivethefuture.com/choronzon
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Dynamic class creation

2006-01-30 Thread Mischa Williamson
I've done exactly that using eval() before. Give it a try.

Cheers,

Mischa

On 1/30/06, franto <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> maybe it is easy, maybe not, but i cant figure it out now, and i need it :)
>
> when i got class e,gpkg1.pkg2.pkg3.className
>
> i can make new instance in this way
> new pkg1.pkg2.pkg3.className()
>
> but i want to make it from string
>
> this dont work of course
> _global['pkg1.pkg2.pkg3.className']();
>
> but this work:
> _global['pkg1']['pkg2']['pkg3']['className']();
>
> can this done automatcally? i want jsut read string from XML and
> create new class instance,
> but i cant do it now.
> Any help is appreciated :)
>
> -
> Franto
>
> http://blog.franto.com
> http://www.flashcoders.sk
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] Dynamic class creation

2006-01-30 Thread franto
Hi all,

maybe it is easy, maybe not, but i cant figure it out now, and i need it :)

when i got class e,gpkg1.pkg2.pkg3.className

i can make new instance in this way
new pkg1.pkg2.pkg3.className()

but i want to make it from string

this dont work of course
_global['pkg1.pkg2.pkg3.className']();

but this work:
_global['pkg1']['pkg2']['pkg3']['className']();

can this done automatcally? i want jsut read string from XML and
create new class instance,
but i cant do it now.
Any help is appreciated :)

-
Franto

http://blog.franto.com
http://www.flashcoders.sk
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders