PDA

Volledige versie bekijken : pass parameters to AS3/SWF via HTML query string


Borizz
%Europe/Berlin %317 %2008, 08:36
Hi All,

Please help, I'm stuck and don t have a clou what to try further.
I suppose the error is in my AS3/MXML, not in the HTML.

A simple demo AS3/MXML would be VERY VERY welcome :-)

I am tryin to read HTMl query script (or FlashVars) in my AS3 code, using loaderInfo.parameters . I have read the examples here and on various other sites, but I cannot get it to work, keep getting Error #1009: Cannot access a property or method of a null object reference. So apparently the Object does not get set, but I do not know why.

*********************************
First, here's the AS3 (I use Flexbuilder3)
*********************************
<mx:Application xmlns:mx=http://www.adobe.com/2006/mxml
creationComplete="initVars()" >
<mx:Script><![CDATA[
import flash.display.LoaderInfo ;
import flash.display.Loader ;
public function initVars():void
{var testval:String = this.loaderInfo.parameters.var_1;
labeltje.text = testval ;}
]]>
</mx:Script>
<mx:HBox>
<mx:Label text="Name: "/>
<mx:Label id="labeltje" fontWeight="bold"/>
</mx:HBox>
</mx:Application>


******************************
Second, here's the HTML I use
******************************
Note: There's some standard built JS ahead of it, whcih I left out.
Note: I also tried FlashVars in both HTML and Javascript. Same error. Found full HTML-examples on the net, so I guess this is not the problem.

<html lang="en">
<head>
... [some JS]
</head>
<body scroll="no">
... [some JS]
<noscript>
<object classid="clsid:XXX"
id="URL_oef_3" width="100%" height="100%"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="URL_oef_3.swf?var_1=hello" />
<param name="quality" value="high" />
<param name="bgcolor" value="#869ca7" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="key" value="XXX" />
<embed src="URL_oef_3.swf?var_1=hello" quality="high" bgcolor="#869ca7"
width="100%" height="100%" name="URL_oef_3" align="middle"
play="true"
loop="false"
quality="high"
flashVars="key=XXX"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object>
</noscript>
</body>
</html>

TheDutch
%Europe/Berlin %335 %2008, 09:03
Drie redenen (je PB gedrag niet meegenomen) waarom ik dit onderwerp sluit en je wil vragen nog eens goed na te denken alvorens je een onderwerp plaatst op deze site:

1. We accepteren hier enkel Nederlandse (ABN) onderwerpen.
2. Dit onderwerp staat in het verkeer forum, moet Flex zijn.
3. Je code is niet geformat via het forum BB code systeem.

Mocht het Engels zijn door copy/paste, dan wijs ik je er ook graag op dat mensen het hier waarderen wanneer iemand aandacht besteed aan zijn of haar onderwerp. Vergeet niet dat jij degene bent die hulp zoekt bij mensen die dit vrijwillig aanbieden.