getDefinitionByName() problem

Once I spotted getDefinitionByName function in flash.utils.* namespace I was very happy with idea to solve objects instancing on elegant and easy way. I’ve created XML decription format like this:

 <ogroup typing=”ifs.ifs3D.Camera” arrayName=”camArray” >
  <ent camPos=”200,200,800″ camTar=”0,0,0″ camRot=”0,0,0″ fov=”90″ focus=”100″ name=”maincam” />
 </ogroup>

 where <ogroup> with it’s <ent /> nodes describes objects and putting it to camArray:Array.
Here usage of getDefinitionByName() sounds great, because ifs.ifs3D.Camera is real classpath.

 But :)

 Problem is that both Flash and Flex compiler AI in this way can’t see that my code will use ifd.ifs3D.Camera class and in compile time it doesn’t put it in resulting bytecode. So I was getting error at runtime:

- Camera value is undefined

Solution is to somewhere in code use classpath that you’re going to call with getDefinitionByName(); in command like:

var proto_i3D:ifs.ifs3D.Camera;

or just

var proto_i3D:Camera;

 So it’s imposable to create totally XML driven object instancing, but getDefinitionByName() is still usable to avoid big switch(xml.@objecttype) structure.

Usefull links:

http://www.as3guru.com/?p=5 - Here I found solution for this problem

Leave a Reply


tesseractstudio.org | all rights reserved 2005-2008. | tesseractstudio ltd, Serbia
omnetwork.net | tutorialautomated.info | osgamer.org | freeflashscripts.com | tesslabs.com | thefirstexodus.com | thefirstexodus.com