HOME | DD

guzu — Utility:Attach Any File to AS3 by-sa

Published: 2009-09-03 11:04:25 +0000 UTC; Views: 992; Favourites: 1; Downloads: 27
Redirect to original
Description This utility allows flash AS3 programmers to attach any file to their AS3. Such problem has already been solved in Flex using [Embed].

Yet, the good thing about this utility is that it converts the whole file to pure text allowing it to be pasted anywhere without needing to attach.

I mainly made it so I could attach md2 files and mod files since I don't have CS4 or Flex.

Info is in the text area.
Be warned that your clipboard will be overwritten by clicking on the convert button.

Hope people find it useful

Download it to be able to use it.

Edit:
I think I'll mention the example here again with more clearance

Code will appear here unless it is huge
A copy will always go to clipboard

Type the file name and press convert to make AS3 code of it.
Process per frame allows doing more processes per frame.
Class Name will be used for naming your class.

To use it later, use the command 'load(a:Number)'. Keep calling it until it returns falls.
Then, use bytes variable to get your ByteArray. Note that it is compressed using .compress. You need to call uncompress();

example:
//Load it from the file
import aClass;
var A= new aClass();

while(!A.load(100)); // 100 means load 100 bytes each time it is called
A.bytes.uncompress(); //It comes compressed, so decompress it

//Assuming it is an image or a movieClip, we will attach it
var c:Loader=new Loader();
c.loadBytes(A.bytes); //bytes is the ByteArray with our data
addChild(c); //Attach it


Edit 23Sep2009
-Corrected the example
-Removed the dot(.) from being produced to make verifying text from file names possible
Related content
Comments: 0