PDA

View Full Version : Problem with "is operator" for loaded SWF's


hermosachuck
11-29-2008, 08:54 PM
I have an application that loads an SWF file residing in my project. I then iterate over all of the children to find objects of a certain type. The "is operator" seems to return false for all children even though trace of object.toString shows some of them should match. Is there something special I have to do in order for the "is operator" to operate propery for dynamically loaded assets?


//Called in my main SWF document constructor
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.IN IT,appWindowAdded);
appWindow.addChild(loader);
...

//This function is called to load SWF files into my application.
public function loadMc( url:String ) {
var urlReq:URLRequest=new URLRequest(url);
loader.unload(); //unload previous SWF file
loader.load(urlReq); //Load new file assets
}


Here is the problem I am having. The "is operator" is not returning true for objects that indeed are of type LocSelectPb.
Trace output even shows it...
Here is a sample from the trace outut...
"Child:MGL_LAK type:[object LocSelectPb] isaLocSelectPb:false"

protected function appWindowAdded(event:Event): void {

var clip:MovieClip = MovieClip(event.target.content);
var child:Object;
var i:int;

trace("Movie clip added:" + clip.loaderInfo.url);

//Search assets for LocSelectPb classes
for ( i=0; i<clip.numChildren; i++ ) {
child = clip.getChildAt(i);

trace(" Child:" + child.name + " type:" +
child.toString() + " isaLocSelectPb:" +
(child is LocSelectPb ) );
}
}

rawmantick
11-30-2008, 04:59 AM
Make a getter method in your loaded swf for that object, don't do useless things.