Exporting AS3 animation to FLV using AS3 - actionscript-3

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();

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)

AS3 Air — Check a Zip to get Audio File

I have a problematic situation that I wish to expose you because it contains some opposites constraints. Maybe someone will have an idea on how to unlock my problem.
I'm going to make a mobile application with ActionScript 3 and Air for iOS and Android. This application has to download zip file which it uses to display text, bitmap and sound.
This last one is the problem.
After some research, one of the best way I found to check a zip file is FZip, but it allows us to get data from zip on a ByteArray form. And a Sound can't be converted from ByteArray. ( That's what a lots of results about it appear to say. )
One of the solution proposed is to put the ByteArray of a sound and put it in a SWF. Then take the SWF from the zip to get the Sound.
I can't do that because this zip will be uploaded from a admin interface used by anybody. I can't force them to use Flash.
I have few potential direction where I ask for your advices :
• Use Code or Native Extension ( iOS and Android ) to check a zip without files read in ByteArray
• Convert a ByteArray into Sound without have to pass it in a SWF
• Dynamicly create a SWF with the ByteArray of a Sound
• In the last possibility, another way to drag and download few files together which can be consulted in another format than ByteArray ( Like a iOS Bundle but with android too )
Thanks a lot to help me,
You can simply write the ByteArray on a local mp3 (or mp4) file and then play it, to write a ByteArray to file see documentation here.

ActionScript3 - Saving objects created when application is running

I made an editor that allows to create some custom space ships for game I'm making.
This editor is meant for the player and his ships are saved in SharedObject without a problem.
What i would like to do is to use the editor to create some ships for enemies and use them later when designing levels.
I was thinking about writing the Ship object to ByteArray and than tracing them so i can copy and paste them to code and read them back to object but this does not seem to work since what i get from tracing a ByteArray is only class name and few undefined symbols that i can't even paste here.
The standard trace panel in flash is text based, therefore no bytes can be output properly (ByteArray).
I'm not pretty sure what are the types of objects you need to store, but you can do two things:
Save ByteArray to UTF8 external file; then read it back to ByteArray, and you're on the road again
if you need to trace them out, Base64 encode them (simple but powerful class here: https://gist.github.com/burakkirkil/4051420)

How to join multiple mp3s into one downloadable mp3 file in Flash AS3?

I have a couple of short mp3 files that the user can reorganize on a timeline. After that, I want to save the result as one mp3 file, combining six short ones.
In other projects I have done microphone recording, compressing to mp3 using the alchemy ShineMP3Encoder, and saving that as a file.
I see at least two approaches:
Extracting all ByteArray data from the loaded Sound objects,
concatenating that in a new ByteArray and compressing that with
Shine. However the ByteArray from Sound.extract doesn't seem to be
compatible with the encoder, telling me "Error : Input not a
MS-RIFF file"
Somehow combining the raw MP3 files without the need of decoding
and encoding. But that would mean having to strip off file header info
and such.
If impossible or very inefficient in Flash, I would consider a server side solution in PHP. So if that would be easy, please let me know.
Thanks!
Do these need to be physically combined into a single file; ie does the Flash need to actually generate a single MP3? Or just played back to the user as if they were one long file?
Flash does not have any built-in capacity to encode MP3s, though various I believe Flash Media Servers have that capacity (Red5, etc.). Actually, on exploration, here is a link to a guy who claims he has technology that will allow you to record an MP3 client-side, though it appears to be more for audio recordings from a built-in mic:
http://fms.denniehoopingarner.com/
Perhaps you could work with him to alter the code to work with existing sound files and generate a new one. Otherwise, you will probably need to do it with some fancy server-side footwork.
It turns out it is in fact easy to combine multiple mp3 files. You can just concatenate their raw data and save it out as a new mp3 file. A few conditions apply:
Make sure all compression settings are identical and non-dynamic. Bitrate, frequency, stereo/mono, etc.
The end result's length indicated by your OS or an mp3 player might be wrong, and show the length of the first segment only. This is header-data. Most players, including Flash, will just play the whole file though, so in most situations this might not be a problem.
In this example I'm using Greensock's LoaderMax library. DataLoader is the specific loader type you want to use (should be binary by default). *Note that I'm using the url as the name to identify the loader later, and some *_variables* need to be declared as class members*
Of course you could use the native way or a different library to load your files too.
for each ( var mp3FileURL : String in _mp3FileURLs )
{
var loader : DataLoader = new DataLoader( mp3FileURL, mp3FileURL ) );
_preloadQueue.append( loader );
}
When loading the queue is complete, you can start processing the data from the loaders.
_audioEditMP3 = new ByteArray();
for each ( var mp3FileURL : String in _mp3FileURLs )
{
var content : * = _preloadQueue.getContent( mp3FileURL );
_audioEditMP3.writeBytes( content );
}
You are now ready to save the file!
var file : FileReference = new FileReference();
file.save( _audioEditMP3, "myAudioCompilation.mp3" );

Code-generated SWF to FLV

I need to convert a swf movie that is created entirely through code (with the help of TweenLite) to a .flv format. The issue here is that I need to 1) Do this as a batch process, and that 2) since the swf is entirely generated by code it only has 1 frame and as such normal conversions like from CS5.5 to to the .avi format give me just 1 frame in the resulting video format. Is there a free converter out there that can get past the fact that my video is technically only 1 frame long and can handle batch jobs? Thanks for all your help
Sounds like you could implement a JSFL extension if you have a copy of Adobe Flash or a trial from their site. It basically adds a command to publish multiple folders and sub folders.
http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&loc=en_us&extid=1021887