How to pass parameters to flash in ActionScript 3 (1)
Today, when I tested a flash ad program for Audi, I found that the clicktag provided by Audi is the code of ActionScript 2, which is not supported in ActionScript 3, so I went through Adobe docs.
The clicktag code in 2.0 is as follows:
On (release) = {<br/> geturl (_ root. clicktag, "_ blank"); <br/>}
In 3.0, _ root is not supported, and the event function is not written in this way. I did a test SWF myself. The simple code is as follows:
// <Br/> // test. as <br/> // written by leezhm, 26th February, 2009 <br/> // contact: leezhm@126.com <br/> // last modified by leezhm on 26th Feb, 2009 <br/> // <br/> package <br/> {<br/> Import flash. display. sprite; <br/> Import flash. display. simplebutton; <br/> Import flash. events. event; <br/> Import flash. events. mouseevent; <br/> Import flash. text. textfield; <br/> Import flash.net. URLRequest; <br/> Import flash.net. navigatetoURL; </P> <p> public class test extends sprite <br/>{< br/> Public Function Test (): void <br/>{< br/> This. addeventlistener (event. enter_frame, onenterframe); <br/> This. btnlink. addeventlistener (mouseevent. click, onbtnclick); <br/>}</P> <p> private function onenterframe (EVT: Event ): void <br/> {<br/> If (""! = Root. loaderinfo. parameters. clicktag) <br/>{< br/> this.txt. TEXT = root. loaderinfo. parameters. clicktag; <br/>}</P> <p> private function onbtnclick (EVT: mouseevent ): void <br/> {<br/> VaR _ Request: URLRequest = new URLRequest (root. loaderinfo. parameters. clicktag); <br/> navigatetoURL (_ Request, "_ blank"); <br/>}< br/>}
Obviously, _ root. clicktag is replaced by root. loaderinfo. Parameters. clicktag in ActionScript 3. For details about loaderinfo. parameters, refer to the parameters attribute of the Flash. display. loaderinfo class. In addition, geturl is replaced by the top-level function navigatetoURL in the Flash .net package, but a URL request parameter is required. Note: pop-up windows may be blocked due to Flash Player security issues. Specifically, Adobe docs is as follows:
Finally, upload the test results (test on the company's website. Due to security issues, the URLs and company logos displayed in the images are processed)
After SWF, we entered? Clicktag = http://www.google.com. Where? It is the identifier for passing parameters to flash. It must not be lost. Clicktag is the parameter name, and the Google website is the passed parameter. Click the red button below to link to the Google main site.
Well, there are actually many ways to pass Parameters on the webpage. You can go to Baidu by yourself, or you can look at Google's clicktag.
BTW.
Http://www.bannerflow.com/clicktest/