Not signed in (Sign In)

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

    • CommentAuthorhelenearth
    • CommentTimeNov 12th 2007 edited
     
    I'm having a hard time figuring how to get something particular to work like it did when I was using the undesirable embed method. I prefer to use SWFObject so any help would be greatly appreciated.

    Previously, when I needed pass a web alias I would embed the flash in the page like this:

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="250" height="400">
    <param name="movie" value="flash/3dnavi.swf?ID={%WebAlias%}">
    <param name="quality" value="high">
    <embed src="flash/3dnavi.swf?ID={%WebAlias%}" quality="high"
    pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="250" height="400">
    </object>

    Then, in my SWF I would include a script on the first frame (this would allow me to use buttons within my flash movies to open pages like "Webpageid315")

    //Start Script
    myURL = this._url;
    trace(myURL);
    myPos = myURL.lastIndexOf("?");
    if (myPos>0) {
    //this will pass back the ID number if it
    //detects that there is a param used with the swf
    //url in the object tag. (will work with the last param
    //in the param list ...."?param1=xxx&ID=xxx
    myParams = myURL.substring(myPos+1,myURL.length);
    myPos = myParams.lastIndexOf("=");
    id = myParams.substring(myPos+1,myParams.length);
    loadURL = "Flashdata.aspx?ID="+id;
    loadVariables (loadURL, "");
    } else {
    //this will run if there is no params in
    //the swf url
    myPos = myURL.indexOf("file://")
    if (myPos==-1) {
    loadVariables ("Flashdata.aspx", "");
    }
    }
    //End Script


    Now that I am using SWFObject I cannot get this to work. I have tried:



    <script type="text/javascript">
    // <![CDATA[

    var so = new SWFObject("flash/3dnavi.swf?ID={%WebAlias%}" , "3dnavi", "250", "400", "9", "#FFFFFF");
    so.write("homepage_news");
    // ]]>
    </script>



    Any ideas? Thanks.
    • CommentAuthorAran
    • CommentTimeNov 12th 2007
     
    So if you wanted to keep it in the querystring as before, you need to seperate your static (unchanging) string values from the dynamic variable.

    You want:
    var so = new SWFObject("flash/3dnavi.swf?ID=" + {%WebAlias%} , "3dnavi", "250", "400", "9", "#FFFFFF");

    But a better way to do it is to seperate the variables from the file like below:

    var so = new SWFObject("flash/3dnavi.swf" , "3dnavi", "250", "400", "9", "#FFFFFF");
    so.addVariable("ID", {%WebAlias%});


    Cheers,
    Aran
    • CommentAuthorhelenearth
    • CommentTimeNov 13th 2007
     
    Aran,

    Thanks so much for your response. I tried both of the methods you mentioned. Here's an update:


    *1st Method (leaving it in the querystring) Flash doesnt show & browser error "Error: 'adamtest1' is undefined".

    Code:

    <script type="text/javascript">
    var so = new SWFObject("flash/imagetransition.swf?ID=" + {%WebAlias%},"imagetransition","221","288","9","#FFFFFF");
    so.write("homepage_news");
    // ]]>
    </script>

    Real working URL:

    http://www.mybiopro.com/Default_Test2.aspx?ID=adamtest1



    *2nd Method (seperated veriable from file) Flash doesnt show & browser error "Error: 'adamtest1' is undefined".

    Code:

    <script type="text/javascript">
    var so = new SWFObject("flash/imagetransition.swf","imagetransition","221","288","9","#FFFFFF");
    so.addVariable("ID", {%WebAlias%});
    so.write("homepage_news");
    // ]]>
    </script>

    Real working URL:

    http://www.mybiopro.com/Default_Test3.aspx?ID=adamtest1



    I'm not sure what's going on. Perhaps there's something I need to modify in my actionscript?
    • CommentAuthorAran
    • CommentTimeNov 14th 2007
     
    I have had a look at your test pages in both IE and Firefox (debugging with the firebug debugging add-on)

    On your test2.aspx page, I don't see any .swf definition with a ?ID= ....

    The rendered HTML shows only:
    <SCRIPT type=text/javascript>
    var so = new SWFObject("flash/imagetransition.swf","imagetransition","221","288","8","#FFFFFF");
    so.write("homepage_news");
    // ]]>
    </SCRIPT>


    Are you sure you put "?ID=" + {%WebAlias%} in your code? Even if the {%WebAlias%} variable wasn't resolving for some reason, you'd still get the code looking like:
    flash/imagetransition.swf?ID=



    On your test3.aspx page, the rendered HTML is correct in that on view source you can see:


    <SCRIPT type=text/javascript>
    var so = new SWFObject("flash/imagetransition.swf","imagetransition","221","288","9","#FFFFFF");
    so.addVariable("ID", adamtest1);
    so.write("homepage_news");
    // ]]>
    </SCRIPT>

    So the {%WebAlias%} variable has translated correctly on the test3 page.

    I have no idea what you are trying to do with the ID value within your imagetransition.swf though.


    If all you are actually doing is grabbing the querystring fronm the adress bar, then you can pass the querstring var directly into SWFObject like below:


    <script type="text/javascript">
    var so = new SWFObject("flash/imagetransition.swf","imagetransition","221","288","9","#FFFFFF");
    so.addVariable("ID", getQueryParamValue("ID"));
    so.write("homepage_news");
    // ]]>
    </script>

    BTW - do you actually need flash 9 to view your content? If not then specify the actual lowest version of the player someone needs. Unless you are using some advanced AS3 code, there should be a reason to spec v9.