Search code examples
jqueryflashexternalfilereference

jquery send file to as3 fileReference


i am trying to do a simple flash file uploader. I created a flash SWF which manages to upload the file on the server and a php which saves it there. The thing i want to accomplish right now is to have this flash somewhere hidden and access it via external functions. All i want to do is to browse a file with and to give the file to the flash fileReference via jQuery and than call fileReference.upload().

I hope someone can help me with this issue. Thank you in advance, Daniel!


Solution

  • In the Flash file you would wan't to look at the ExternalInterface class where you'll add a callback method. Something like this:

    if (ExternalInterface.available)
        ExternalInterface.addCallback("jsFunc", doSomething);
    
    function doSomething():void
    {
         trace("i did something");
    }
    

    The method jsFunc should then be callable from JS on the SWF Object. Check the ExternalInterface documentation for further info.