views:

87

answers:

2

I changed my html template to include flashvars like so:

if (hasRequestedVersion) {
    // if we've detected an acceptable version
    // embed the Flash Content SWF when all tests are passed
    AC_FL_RunContent(
      "src", "${swf}",
      "FlashVars", "product_id=4958",
      "width", "${width}",
      "height", "${height}",
      "align", "middle",
      "id", "${application}",
      "quality", "high",
      "bgcolor", "${bgcolor}",
      "name", "${application}",
      "allowScriptAccess","sameDomain",
      "type", "application/x-shockwave-flash",
      "pluginspage", "http://www.adobe.com/go/getflashplayer"
    );
  }

And I am trying to access them in my app like so:

private static var _PID:uint = Application.application.parameters.product_id;

But I am getting this error:

Error #1009: Cannot access a property or method of a null object reference.

I do not know why? Any ideas? Is this just happening because I am in the flex debugger?

Thanks!!

A: 

Never done this but it looks to me like the parameter is FlashVars not product_id

Hogan
+2  A: 

I'll bet it's because this is a static variable - the assignment is probably happening before the app is initialized.

Try assigning the value to _PID inside of a creationComplete handler instead; then the application is guaranteed to be initialized.

Matt Dillard
Thank you so much, I was about ready to punch my monitor.
John Isaacks
+1 for the nice catch
Amarghosh