Re: [Flashcoders] Getting bitmap data after successfully loading a swf file
Hi, If your loaded asset is a swf, you cannot just access the bitmapData property - it does not have one. However, you can draw the contents of a MovieClip / Sprite / DisplayObject into a BitmapData object, which you can then pass to the constructor of a Bitmap. http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7d60.html You should also use the INIT event rather than the COMPLETE event for loaded objects because your SWF may have to initialise when it's loaded and you cannot be guaranteed that height, width and child clips are on stage. HTH Glen On 30/11/2010 19:18, ACE Flash wrote: hi there, I am pulling my hair off :), i was able to use any PNG or JPG file in my code, the SWF file just didn't work. Would you please take a look for me? Is there anything I am missing?? I am using flash 9 and all files are on the same domain. Thanks import flash.net.URLRequest;import flash.display.Loader; // I am able to use the PNG/JPG files var fileURL:String = http://www.google.com/images/logos/ps_logo2.png; // BUT!!! the SWF just doesn't work, it always return null! //var fileURL:String = x.swf var request:URLRequest = new URLRequest(fileURL); var loader:Loader = new Loader();loader.contentLoaderInfo.addEventListener(Event.COMPLETE, dataCompleteHandler);loader.load(request); function dataCompleteHandler(e:Event):void{ var image:Bitmap = new Bitmap(e.currentTarget.content.bitmapData); addChild(image);} ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Getting bitmap data after successfully loading a swf file
Hi all, Just curious and I think it may shed a little light on this issue, but isn't there a way to grab another SWFs library assets and plug them into your own swf? If so, then you could just assign ids to the loaded library assets and then call on them in your swf?? I thought I remembered something about this a while back, but I could be mistaken. Best, Karl On Dec 1, 2010, at 3:44 AM, Glen Pike wrote: Hi, If your loaded asset is a swf, you cannot just access the bitmapData property - it does not have one. However, you can draw the contents of a MovieClip / Sprite / DisplayObject into a BitmapData object, which you can then pass to the constructor of a Bitmap. http://help.adobe.com/en_US/as3/dev/ WS5b3ccc516d4fbf351e63e3d118a9b90204-7d60.html You should also use the INIT event rather than the COMPLETE event for loaded objects because your SWF may have to initialise when it's loaded and you cannot be guaranteed that height, width and child clips are on stage. HTH Glen On 30/11/2010 19:18, ACE Flash wrote: hi there, I am pulling my hair off :), i was able to use any PNG or JPG file in my code, the SWF file just didn't work. Would you please take a look for me? Is there anything I am missing?? I am using flash 9 and all files are on the same domain. Thanks import flash.net.URLRequest;import flash.display.Loader; // I am able to use the PNG/JPG files var fileURL:String = http://www.google.com/images/logos/ ps_logo2.png // BUT!!! the SWF just doesn't work, it always return null! //var fileURL:String = x.swf var request:URLRequest = new URLRequest(fileURL); var loader:Loader = new Loader();loader.contentLoaderInfo.addEventListener(Event.COMPLETE, dataCompleteHandler);loader.load(request); function dataCompleteHandler(e:Event):void{ var image:Bitmap = new Bitmap(e.currentTarget.content.bitmapData); addChild(image);} ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Getting bitmap data after successfully loading a swf file
@ACE You may want to separate your function calls for each type of file. IE: using your bitmap function for png, jpg, gif, etc. Then another function that just loads the swf files in a MC the way they come? But I think Henrik is right here, you cant load a SWF as if it was an image. Its a swf. :) HTH, Best, Karl On Dec 1, 2010, at 3:44 AM, Glen Pike wrote: Hi, If your loaded asset is a swf, you cannot just access the bitmapData property - it does not have one. However, you can draw the contents of a MovieClip / Sprite / DisplayObject into a BitmapData object, which you can then pass to the constructor of a Bitmap. http://help.adobe.com/en_US/as3/dev/ WS5b3ccc516d4fbf351e63e3d118a9b90204-7d60.html You should also use the INIT event rather than the COMPLETE event for loaded objects because your SWF may have to initialise when it's loaded and you cannot be guaranteed that height, width and child clips are on stage. HTH Glen On 30/11/2010 19:18, ACE Flash wrote: hi there, I am pulling my hair off :), i was able to use any PNG or JPG file in my code, the SWF file just didn't work. Would you please take a look for me? Is there anything I am missing?? I am using flash 9 and all files are on the same domain. Thanks import flash.net.URLRequest;import flash.display.Loader; // I am able to use the PNG/JPG files var fileURL:String = http://www.google.com/images/logos/ ps_logo2.png // BUT!!! the SWF just doesn't work, it always return null! //var fileURL:String = x.swf var request:URLRequest = new URLRequest(fileURL); var loader:Loader = new Loader();loader.contentLoaderInfo.addEventListener(Event.COMPLETE, dataCompleteHandler);loader.load(request); function dataCompleteHandler(e:Event):void{ var image:Bitmap = new Bitmap(e.currentTarget.content.bitmapData); addChild(image);} ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Getting bitmap data after successfully loading a swf file
There are several ways to get at the assets. The most obvious one is to simple ask the code in the loaded swf to give you what you want. You can use all the fancy factory patterns that you've been reading about this way. Personally I keep it simple and just store each thing in an object that I can then read from the main swf. But you don't need any code in the loaded swf at all, you can just use the getDefinitionByName function. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Getting bitmap data after successfully loading a swf file
SWF files are not bitmaps. Stop trying to treat them like bitmaps. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Getting bitmap data after successfully loading a swf file
Hi list... I want loop through to delete certain nodes, but can't figure out how to do it. I've tried a conventional loop, for...in and for...each...in, and I must be missing something. pack dog id=1/ dog/ dog id=2/ dog/ dog id=3/ /pack I'd like to delete all instances of dog that don't have an @id, or @id==2. Any thoughts? Thanks, - Michael M. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders