;

PDA

Click to See Complete Forum and Search --> : Importing binary files in a Flash CS3 project ?


Sietjp
04-02-2008, 03:23 AM
Hi,
I know that Flex can import binary files, but it seems a pure Flash project can't do this.

I thought that we could write a little utiliy in whatever scripting language that would turn a binary file into a .as class in this kind :

var binary:ByteArray=new ByteArray();
var myData:Array=[0x34,0x56,0xF1 etc....... ];
for (var i:int=0;i<myData.length;i++) {
binary.writeByte(myData[i]);
}

What do you think ?

robotz
04-02-2008, 07:25 AM
public class test extends Sprite {
[Embed(source=”anybinaryfile.bin”, mimeType=”application/octet-stream”)]
private const binaryFile:Class;

public function test() {
var ba:ByteArray = new binaryFile() as ByteArray;
}
}


Or did you mean import from an external location? (i.e. while the SWF is running)

Sietjp
04-02-2008, 07:40 AM
Thx, I mean import before compilation, not at runtime.

Can you confirm this code is Flex only and not CS3 ?
[Embed(source=”anybinaryfile.bin”, mimeType=”application/octet-stream”)]

robotz
04-02-2008, 07:47 AM
Sorry yes, Embed is flex2 only, not CS3 - should have read your first post more carefully :)