I wonder if the flash.utils.getDefinitionByName(name:String):Class works with custom classes? Is there a problem if the class has a constructor that takes arguments? I tell this because i have a class in a package of the form packageA.packageB and when i input the name of the class into the above function as packageA.packageB.ClassName does not work. Also i have tried (with the same result) the output from getQualifiedClass which gives packageA.packageB::ClassName. Any ideas??
Here is part of the code that belongs to a file that imports like import factory.scratchers.*; all the scratch elements which have the names AlphaScratcher, DissolveScratcheer, ExplodeScratcher ,etc. Does the above import satisfies the requirement?
import factory.scratchers.*;
...
for ( var iArea:uint = 0; iArea < _totalScratchAreas; iArea++ ) {
var sourceArray:Array = new Array();
var currentNameArray:Array = _globalAssetNameArray[iArea];
var theScratcher:Scratcher;
for ( var index:uint = 0; index < _globalMsgArray[iArea].length; index++ ) {
// here i would like to have something like:>
var ScratchClass:Class = getDefinitionByName( "factory.scratchers::ExplodeScratcher") as Class;
theScratcher = new ScratchClass( _assetGenerator, _mainSprite );
// instead of: - but it does not work not sprite shown on screen
theScratcher = new ExplodeScratcher( _assetGenerator, _mainSprite );
theScratcher.setBack( currentNameArray[index] );
sourceArray.push( theScratcher );
if ( _globalArray[iArea][4] == OPENEDAREA ) {
theScratcher.auto();
}
}