dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Convert Text To Binary - SWFStudio

  1. #1
    Senior Member
    Join Date
    Sep 2003
    Posts
    356

    Convert Text To Binary - SWFStudio

    Hi,
    Using SWFStudio...

    I have the text string of the SWF file saved in the scratch area of an EXE. And can read it from the scratch area already.

    The string of the SWF is in it's original form.

    I want to be able to convert it back to binary format and then display it in a movieclip.

    1) Can this be done?
    2) Do I have to save it back to a file before loading into a movieclip?
    3) What command and code do i need to use?


  2. #2
    Senior Member
    Join Date
    Sep 2003
    Posts
    356
    Okay... I answerd half my question.

    I used....
    Code:
    var r = ssCore.FileSys.writeToFileBinary({path:"binary.swf", data:txtArea.text});
    This method writes the file back to local pc and then I have a simple button event to load the binary.swf into a MC. Works fine.

    However, I would rather not have to save to a file , then load into MC.

    Can I convert the string into a binary and store it in a variable, then load the variable into the MC?


  3. #3
    Senior Member
    Join Date
    Sep 2003
    Posts
    356
    I am trying to convert the binary string to binary format IN MEMORY using LoadVars object.

    Code:
    var lv:LoadVars = new LoadVars();
    lv.txt = txtArea.text;
    //var r = ssCore.FileSys.writeToFileBinary({path:lv, data:lv.txt});
    var r = ssCore.FileSys.readFileBinary({path:lv, data:lv.txt});
    I have tried both write and read binary, but it generates "path not found". It needs a file path.

    So, I am not sure if I can use those two methods.

    How can I convert the string to binary in a LoadVars object (or memory)??


  4. #4
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    Answered you over in the Northcode forums, but since you posted here too...

    Forget about LoadVars, use the functions we provided in the AS2 and AS3 string utils library to convert between hex strings (that the FileSys functions return) and ByteArray (AS3) or Array (AS2).

    I believe you'll need to use AS3 to make this work in memory by converting the hex string to a ByteArray and then using the MovieClipLoader to load the ByteArray into a MovieClip.

    Finally, the path parameter has to be a fully qualified path to a physical file, nothing else will work. Monikers are still paths, they're just a shorthand (in case you thought there might be a way around the requirement).

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