actionscript-3clicktag

Transferring Variables in Query String


enter image description here

Im pulling my hair and Im still unable resolve this. Please tell me what did I do wrong with these codes?

Errors (NEW):

No Error, but display undefined;cppar=1&EmailURLVariable=aa@aa.com

CODE (UPDATED x3)-

import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.net.navigateToURL;

var EmailFlashVariable = 'aa@aa.com'
var url:String = root.loaderInfo.parameters.clickTAG + ';cppar=1&EmailURLVariable=' + EmailFlashVariable
var url_request:URLRequest = new URLRequest(url)

mcButton.addEventListener(MouseEvent.CLICK, ADFclicked)
function ADFclicked(event:MouseEvent) { 
navigateToURL(url_request, '_blank')  

I added

<param name="flashvars" value="clickTAG=http://www.freescoreonline.com">

In the generated HTML


Solution

  • To show your swf in a html page, we use usually a code like this ( you can modify it of course, It's generated by Flash ) :

    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400">
        <param name="movie" value="banner.swf">
        <param name="allowScriptAccess" value="sameDomain">             
        <param name="flashvars" value="clickTAG=http://www.example.com">
        <!--[if !IE]>-->
        <object type="application/x-shockwave-flash" data="banner.swf" width="550" height="400">
            <param name="movie" value="banner.swf">
            <param name="allowScriptAccess" value="sameDomain">
            <param name="flashvars" value="clickTAG=http://www.example.com">
        <!--<![endif]-->
            <a href="http://www.adobe.com/go/getflash">
                <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player">
            </a>
        <!--[if !IE]>-->
        </object>
        <!--<![endif]-->
    </object>
    

    You can see here that I used flashvars to pass params to our swf file (banner.swf), It's recommended to do that instead of banner.swf?clickTAG=http://www.example.com if you have the ability to use flashvarsof course.

    In AS3, to get a param that was passed by flashvars or using ?param=value, we do like this : root.loaderInfo.parameters.param. In your case, here is what you can do :

    import flash.events.MouseEvent
    import flash.net.URLRequest
    
    var EmailFlashVariable:String = 'aa@aa.com'
    var url:String = root.loaderInfo.parameters.clickTAG + ';cppar=1&EmailURLVariable=' + EmailFlashVariable
    var url_request:URLRequest = new URLRequest(url)
    
    button.addEventListener(MouseEvent.CLICK, ADFclicked)
    function ADFclicked(event:MouseEvent) { 
        navigateToURL(url_request, '_blank')    
    }
    

    I hope it's clear now, and please try always to explain your problem and to give all details for others to help you.

    For flashVars, take a look here swfs flashVars (by Adobe) and here for very good tutorial to better understand AS3 flashVars.