ActionScript 3 AS3 Clicktag - 适用于多个ClickTag变量

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 AS3 Clicktag - 适用于多个ClickTag变量相关的知识,希望对你有一定的参考价值。

// clickTag code ------------------------------------------------------------

var url : String;
var btn : Sprite;

createBanner();

function createBanner() : void
{
	btn = new Sprite();
	
	with ( btn.graphics ) 
	{
		beginFill( 0x000 );
		drawRect(0,0,stage.stageWidth,stage.stageHeight + 100);
		endFill();
	}
	
        with ( btn ) 
	{
	    alpha = 0;
	    buttonMode = true;
	    addEventListener( MouseEvent.MOUSE_UP, handleMouse );	
	}
	
        addChild( btn );	

	if ( LoaderInfo(root.loaderInfo).parameters.clickTag ) 
	{
		url = String( LoaderInfo(root.loaderInfo).parameters.clickTag );
		btn.addEventListener( MouseEvent.MOUSE_UP, handleMouse );
		
	} else if ( LoaderInfo(root.loaderInfo).parameters.clicktag )
	{
		url = String( LoaderInfo(root.loaderInfo).parameters.clicktag );
		btn.addEventListener( MouseEvent.MOUSE_UP, handleMouse );
	}
	
	// use this if you are adding other things to the displaylist dynamically,
	// so that the button is always on top.
    //stage.addEventListener( Event.ENTER_FRAME, bringBtnToTop );
}

function bringBtnToTop( evt:Event ) : void
{
	addChild( btn );
}

function handleMouse( evt : MouseEvent ) : void 
{
	if ( url != null ) 
	{
		navigateToURL( new URLRequest(url), "_blank" );
		
	} else {
		
		trace("There was an error, or you have clicked the button in the Flash IDE.");
	}
}

以上是关于ActionScript 3 AS3 Clicktag - 适用于多个ClickTag变量的主要内容,如果未能解决你的问题,请参考以下文章

[ActionScript 3.0] AS3.0 水面波纹效果

ActionScript 3 AS3:使用SWFObject2和AS3传递变量

ActionScript 3 克隆数组(AS3)

ActionScript 3 AS3序列化

ActionScript 3 As3初始上限

ActionScript 3 AS3 HTML清理