A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [AS3 question] Class from String?

  1. #1
    Senior Member chriserrorplain's Avatar
    Join Date
    Aug 2002
    Location
    london village
    Posts
    623

    [AS3 question] Class from String?

    ok...so I don't know if this is possible...but...


    let's say I have

    stringName = "bigFootball";

    is it possible to some how do somehting like this :

    var ball:class[stringName] = new class[stringname]

    so initialise an instance of a Class from a string of the class type?


    danke


    Chris x

  2. #2
    Senior Member chriserrorplain's Avatar
    Join Date
    Aug 2002
    Location
    london village
    Posts
    623
    [RESOLVED]

    you do ti like this:
    PHP Code:
          var ClassReference:Class = getDefinitionByName(gameData.level[game.level].background.backgroundLayer) as Class;
          var 
    bg = new ClassReference(); 

  3. #3
    FK founder & general loiterer Flashkit's Avatar
    Join Date
    Feb 2000
    Location
    Sydney
    Posts
    1,149
    and if it was like a bitmapData you would put in the parameters eg bg = new Classreference(0,0)... or for any class that takes parameters.

    This is very very handy!

    You can also create classes from loaded swf files which is even cooler, and manipulate, add to the main stage etc etc. You'll need to look for applicationDOmain in the help for that though
    Regards Mark Fennell - Flash Kit Founder, general loiterer
    -------------------------------
    I Hate Zombies - iPhone Game | markfennell.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center