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:
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>
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>
*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>
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.