Btw, this entire problem is not reproduced if the swf is loaded locally. However once it is loaded from remote location - it happens. Maybe related to flash security?
--- In flexcoders@yahoogroups.com, "yotam_shacham" <[EMAIL PROTECTED]> wrote: > > I am loading the same bitmap asset using two methods, they should > work the same but they don't. > > Method 1: Statically link to swc file that contains embedded images. > Method 2: Dynamically load swf content that contains embedded images. > > The actual embedding code for both methods is as follows: > > [Embed(source="res/test.png")] > [Bindable] > public var test:Class; > > Here is the problematic code snippet: > > ---------------------------------------------------------- > > // event handler for when external swf finishes to load > public function OnExternalSwfLoadComplete(event:Event):void > { > // InternalResource was the name of the class compiled in the swc > var internalResource:Object = new InternalResource(); > var externalResource:Object = event.target.content; > > // get the classes and instantiate > var internalClass:Class = internalResource["test"]; > var externalClass:Class = externalResource["test"]; > var internalAsset:* = new internalClass(); > var externalAsset:* = new externalClass(); > > // Here I test 2 things, what are the super class names, and > // whether the instances are of type IFlexDisplayObject > var internalIsDisp:Boolean = internalAsset is IFlexDisplayObject; > var externalIsDisp:Boolean = externalAsset is IFlexDisplayObject; > > var internalSuperClass:String = getQualifiedSuperclassName > (internalAsset); > var externalSuperClass:String = getQualifiedSuperclassName > (externalAsset ); > > ---------------------------------------------------------- > > The results are that both assets have type mx.core::BitmapAsset. > However internalIsDisp is true while externalIsDisp is false!! > > Questions: > 1) Shouldn't this be impossible according to as3 language? > 2) What can I do to change the externally loaded resource to behave > like the statically linked one. Currently if I use the externally > loaded resource I crash in the flex framework in places such as > setStyle for example where it is expecting a IFlexDisplayObject. > 3) Am I going about the wrong way externally loading resources? To > generate the external swf I am using mxmlc compiler on an .as file > that contains a bunch of embedded images. > > Any help would be greatly appreciated. >