views:

590

answers:

2

I'm trying to pass parameters from HTML-land to Flex-3 Flash-land, and can't seem to get it to work. Here's what I've got (basically the default template, modified with FlashVars):

<noscript>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
  id="${application}" width="${width}" height="${height}"
  codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"&gt;
  <param name="movie" value="${swf}.swf" />
  <param name="quality" value="high" />
  <param name="bgcolor" value="${bgcolor}" />
  <param name="allowScriptAccess" value="sameDomain" />

    <param name="flashVars" value="userID=foo&assignmentID=1"/>


  <embed src="${swf}.swf" quality="high" bgcolor="${bgcolor}"
   width="${width}" height="${height}" name="${application}" align="middle"
   play="true"
   loop="false"
   quality="high"
   allowScriptAccess="sameDomain"
   type="application/x-shockwave-flash"
   pluginspage="http://www.adobe.com/go/getflashplayer"
        flashVars="userID=foo&assignmentID=1">
  </embed>
</object>
</noscript>

And here's the ActionScript (called after the app's creationComplete event is fired):

function initApp() : void
{
 // default params
 userID = Application.application.parameters.userID;
 assignmentID = Application.application.parameters.assignmentID;
 if (userID == null || assignmentID == null)
 {
  Alert.show("I didn't get any params!", "Error");
 }
}

Anybody know what's going wrong? I've tried several permutations of this with no luck. (Firefox 3, OS-X, Flash Player 9 FWIW)

Thanks!

A: 

Try "FlashVars" instead of "flashVars".

CookieOfFortune
+2  A: 

I think you want to be setting query params after the .swf stuff too. Try

 <embed src="${swf}.swf?userID=foo" quality="high" bgcolor="${bgcolor}"
Sean Clark Hess
Yep, that's it .. I was modifying the seldom-used "no javascript" version.http://elromdesign.com/blog/2009/02/17/passing-flashvars-using-flex-template-html/
sehugg