I am having issues with flashvars and swfobject (as3). Mac seems to be fine but on a pc it has been flaky, firefox I had two tabs open at one stage with it all working and one not working at all. In IE7 it is not working. I need to get some admin rights on the pc so I can put debug player on etc.. but wondered if anyone had similar problems and has a solution, I had a javascript guy look over the code etc.. and I spent quite a bit of time on this at end of last week. (Cut down the flashvars hugely and hidden client info.)
// passed in from main class _level0 = this.root
// in a helper class _allFlashVars = LoaderInfo( _level0.loaderInfo ).parameters;
Then the embed code
swfObjectTest
<!--url's used in the movie-->
<!--text used in the movie-->
In order to view this page you need JavaScript and Flash Player 9+ support!
// <![CDATA[
var so = new SWFObject("amovie.swf", "amovie", "714", "300", "9", "#FFFFFF");
so.useExpressInstall('expressinstall.swf');
so.addParam('menu', 'false');
so.addParam('wmode','opaque');
so.addParam('allowScriptAccess','always');
so.addVariable( "name_0", "aname0" );
so.addVariable( "img_0", "aswf0.swf" );
so.addVariable( "name_1", "aname1" so.addVariable( "img_1","aswf1.swf"
so.write("flashcontent");
// ]]>
For a start I'd use the newer version of SWFobject -http://code.google.com/p/swfobject/ - but beyond that, I am afraid I dont have any suggestions.
I am using the newer one, I think you can use either notation. But I have tried most things.. In firefox it gets stuck when using the _1 var which is most odd.
so.addVariable( "name_1", "aname1" so.addVariable( "img_1","aswf1.swf"
right before the so.write... looks fuxored. ( no closing ")" on the last two addVariable functions )
i have also never mixed the two notations, i usually use "addVariable"
cheers
pyrogen
(Cut down the flashvars hugely and hidden client info.)
Na it's not such a simple typo, that is just when I was chopping down the var, no I got an htmler to check for simple sytax issues. Seems to be related in part to the number of vars. In IE7 on a pc I fixed it by putting a timer in, but it does not work consistantly in firefox can get it to work by changing swf object to use & amp; to separate var and by reducing number of var down and then slowly back up to the 22*6 ish I actually have.
IE7 fix
private function processLoadVars(): { _timer = new Timer(40,0); _timer.addEventListener( TimerEvent.Timer, isReady ); _timer.start(); }
private function isReady() { _allFlashVars = Loader( _level0.loaderInfo ).parameters; if( _allFlashVars != null ) { _timer.stop(); loadvarReady(); } } }
I am not sure i would use:
_level0 = this.root
maybe a dif variable name?
i check for all possibilities in addition to null;
private function checkLoadVars():void
{
if (LoaderInfo(this.root.loaderInfo).parameters.userId!=null && LoaderInfo(this.root.loaderInfo).parameters.userId!=""&& LoaderInfo(this.root.loaderInfo).parameters.userId!=undefined&& LoaderInfo(this.root.loaderInfo).parameters.userId!="undefined"){
_userId = LoaderInfo(this.root.loaderInfo).parameters.userId;
}else{
trace("________normalStart")
}
}
using this code in a project now, works great no problems across various browsers and platforms.
using SWFObject v2.0
I tried the code last night, but it did not seem to solve the issue with firefox, I am using a lot of flashvars and not yet currently preloading the movie.
pyrogen
I think this code might be more reliable than the code you suggest, not sure it has yet fixed my problem but it seems to more correctly detect the presence of flash var contents, since _allFlashVars from flash appears to resolve to an empty object rather than null.
var notEmpty:Boolean = false; for( var all in _allFlashVars ) { notEmpty = true; break; }
if( notEmpty ) { _timer.stop(); loadflashvarReady(); }
Originally posted by: JLM pyrogen
I think this code might be more reliable than the code you suggest, not sure it has yet fixed my problem but it seems to more correctly detect the presence of flash var contents, since _allFlashVars from flash appears to resolve to an empty object rather than null.
var notEmpty:Boolean = false; for( var all in _allFlashVars ) { notEmpty = true; break; }
if( notEmpty ) { _timer.stop(); loadflashvarReady(); }
Nice JLM 
I am now using the more modern formating and the javascript in the head and it seems to be more reliable, I am unsure if player 9.0.124 has extra security or firefox in windows has a bug, but 'mySwf.swf' is not loading in although the flash var 'mySwf.swf is getting in??