A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Importing binary files in a Flash CS3 project ?

  1. #1
    Senior Member Sietjp's Avatar
    Join Date
    Jan 2005
    Location
    Paris, France
    Posts
    711

    Importing binary files in a Flash CS3 project ?

    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 :

    Code:
    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 ?

  2. #2
    Code:
    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)

  3. #3
    Senior Member Sietjp's Avatar
    Join Date
    Jan 2005
    Location
    Paris, France
    Posts
    711
    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”)]

  4. #4
    Sorry yes, Embed is flex2 only, not CS3 - should have read your first post more carefully

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center