AS3 load bitmapData from JPG/PNG bytearray synchronously - actionscript-3

Given a ByteArray containing JPG or PNG data, is there a way to retrieve synchronically a corresponding BitmapData in Adobe AIR?

JPEGDecoder
PNGDecoder
Otherwise, use loadBytes. I'd say use loadBytes, since it won't halt your thread.

Related

Extract all png file and bitmap data from swf using as3

Is there any way to get a list of bitmap resource (eg png file) using as3? I know that I can go through the all child of the swf and check if each child is a shape or not, if yes, then I can get back the bitmap data by
var bmd:BitmapData = new BitmapData(obj.width, obj.height, true, 0);
bmd.draw(obj);
and then write out the bmd as a png file. However, by doing this I cannot know which png resource this object associate with, also if the object instance is inside an animation, this approach may not successfully capture the bitmap data correctly. Any better idea?
I believe you can play with these libraries as3swf (as3swf is a low level Actionscript 3 library to parse, create, modify and publish SWF files.) and Velocity 9 SWF Inspector (A handy little tool to peek inside SWF files)

Exporting AS3 animation to FLV using AS3

Is it possible to export an animation consisting of AS3 etc etc into a FLV file type using AS3 Code to do it rather than using manual progression
File > Export etc etc
Thanks
Aiden
It is a long shot, but depending on the conditions (CPU power, resolution, memory) it could work.
You should be able to make a BitmapData for every frame in your movie using bitmapData.draw(displayObject);. Then store all those bitmaps in an array, and then encode to flv using some external library such as this one.
Here's a tutorial on how to convert a displayObject into a BitmapData.
If instead of using Flash Player you compile to Adobe Air for desktop, you could save the frames as files in the hard drive, and then encode the sequence using a multitude of programs (such as After Effects) to any video format you want.
You can look into this codebase, it may save you some time:
http://www.zeropointnine.com/blog/simpleflvwriteras-as3-class-to-create-flvs/
var myWriter:SimpleFlvWriter = SimpleFlvWriter.getInstance();
myWriter.createFile(myFile, 320,240, 30, 120);
myWriter.saveFrame( myBitmapData1 );
myWriter.saveFrame( myBitmapData2 );
myWriter.saveFrame( myBitmapData3 ); // ... etc.
myWriter.closeFile();

Is there any method in as3 that flash can write file's last modified date

Is there any method in as3 that flash can write file's last modified date.
Its stand alone flash application which had external swf loading. I want to check the last modified date of the swf during the loading.
please suggest any possible methods.
Thanks.
In AIR, there is File class with modificationDate property. But in plain AS3, there's no file concept at all. If you loading swf with Loader, you only get data, but not the attributes of file (and file might not exist at all if loading something by URL.)

Converting SWF into GIF file

I have a flash file where I load a remote SWF file into my own. Now what I want to do is convert that remote SWF file into a GIF that I can save onto my server.
The remote file is a SWF that has a variable amount of frames, and I somehow need to be able to figure out the amount of frames (I presume), and take a snapshot (picture) of every frame, to turn the taken pictures into a GIF file. That's what I THINK has to be done, however I have no idea if it's even possible to take pictures/snapshots of remote SWF files.
I need some serious suggestions on how I could get this working. I'm a serious Flash newbie, and anything would help.
Trying to capture stage area using BitmapData
var bmd:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight);
bmd.draw(stage);
And this should help you creating the animated GIF:
http://www.bytearray.org/?p=93
You can use the totalFrames property to see how many frames there are and loop through them. You can draw the frames into a BitmapData object.

AS3 - AIR - From a swf path file to a ByteArray

I am coding an AIR application.
I've got directly a path of a swf file (because it was stored in a xml file).
Do yo know if it is possible to get the ByteArray from this file ?
I know that FileReference do that very well, but this class need a select event. But it isn't my case because I've allready got my path.
Thanks a lot for your answers !
In AIR, you can read/write files directly using flash.filesystem.File and flash.filesystem.FileStream.
See, for example, this article.
however you can load it with URLStream and get a ByteArray with URLStream.readBytes()