Not signed in (Sign In)

Vanilla 1.0.3 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorArc
    • CommentTimeMay 10th 2007 edited
     
    Hey guys, I have a problem here that involves accessing the flash movie thru some javascript code.

    I have this code that works just fine using the normal OBJECT and EMBED tags, but is not working with the SWFObject solution. It just needs to find the ID of the flash movie so it can pass a variable to it, but for some reason it can't find the ID even though I am passing the ID thru the so.addParam("id", "FlashFilesUpload");

    I guess my question is, how do I access the movie thru Javascript?



    <script language="JavaScript">
    function mysubmit()
    {
    var Flash;

    Flash = document.getElementById("FlashFilesUpload");
    var FormObj = document.getElementById("myform");

    var FormValues = '';
    for (var i = 0; i FormValues += FormObj.elements[i].name + '=' + FormObj.elements[i].value + ((i!=(FormObj.elements.length-1))?'&':'');
    Flash.SetVariable("SubmitFlash", FormValues);
    return false;
    }
    </script>


    The form is supposed to upload the images and all that, then move on to the next page, but since it can't find the flash movie it just gives a JS error and doesn't work at all.
    • CommentAuthorphilip
    • CommentTimeMay 10th 2007 edited
     
    In order for Flash to communicate with Javascript (and vice versa) you need to use Flash's ExternalInterface class.

    Here's one of Adobe's explanations:
    http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_15683

    And here's a sample I made about week ago:
    http://pipwerks.com/lab/captivate-flash-communication/ext-int/sample.html

    In my example I followed Adobe's instructions exactly, except I used SWFObject to embed the SWF instead of Adobe's stock scripts.

    (I was experimenting with ExternalInterface because I wanted to make JavaScript calls from Adobe Captivate SWFs, but the example I just provided you is pure Flash, no Captivate.)

    Good luck
    - philip
    • CommentAuthorArc
    • CommentTimeMay 10th 2007 edited
     
    But the code works perfectly using the typical OBJECT and EMBED tags for the flash movie...it only doesn't work when I use SWFobject to embed the movie.... And I can't rewrite the Flash movie because I didn't make it and I don't have the source code.

    So am i forced to abadon SWFObject because it has no ID for me to grab thru javascript?
    • CommentAuthorphilip
    • CommentTimeMay 10th 2007
     
    Ahh I see.

    I believe the SWF Id is the second parameter in the new SWFObject line.

    In your case that would be changing:

    var fo = new SWFObject("ElementITMultiPowUpload1.7.swf", "EmbedFlashFilesUpload", "300", "300", "8", "#FFFFFF");

    to

    var fo = new SWFObject("ElementITMultiPowUpload1.7.swf", "FlashFilesUpload", "300", "300", "8", "#FFFFFF");

    I don't think you need to set the ID using so.addVariable or addParam.
    • CommentAuthorArc
    • CommentTimeMay 10th 2007
     
    That was the problem. Thanks a ton philip.
    • CommentAuthorphilip
    • CommentTimeMay 10th 2007
     
    Cool, glad it was an easy fix! :)