在AS3中加载外包SWF文件并设定其尺寸

AS3代码:

var paramList:Object = this.root.loaderInfo.parameters;
var bkg = new Loader();var urlReq = new URLRequest(paramList['loadtarget']);
bkg.load(urlReq);var banner = this.addChildAt(bkg, 0);
bkg.contentLoaderInfo.addEventListener(Event.COMPLETE, this.onLoadComplete);
Mouse.cursor = "button";
this.root.addEventListener(MouseEvent.MOUSE_UP, function(event:MouseEvent){
  navigateToURL(newURLRequest(paramList['clickUrl']));																		  });function onLoadComplete(event:Event){	var cWidth = int(paramList['width']);	var cHeight = int(paramList['height']);	var sy = 1000 / cHeight;	var sx = 1000 / cWidth;	var sWith = sx >= sy ? sx : sy;	var ty, tx;		if(cHeight > cWidth){		tx = 0;		ty = ((cHeight - cWidth) / 2) * sWith;	}else if(cWidth > cHeight){		ty = 0;		tx = ((cWidth - cHeight) / 2) * sWith;	}else{		ty = 0;		tx = 0;	} 	with(event.target.loader){		scaleX = sWith; 		scaleY = sWith; 		x  = -tx; 		y  = -ty;	}}

 

HTML中传参代码:

<object width="250" height="625">
    <param name="movie" value="loader.swf"></param>
    <param name="allowFullScreen" value="false"></param>
    <param name="scale" value="default"></param>
    <param name="wmode" value="window"></param>
    <param name="FlashVars" value="clickUrl=http://www.google.com&amp;loadtarget=tower.swf&amp;width=250&amp;height=625"></param>
    <embed src="loader.swf" FlashVars="clickUrl=http://www.google.com&amp;loadtarget=tower.swf&amp;width=250&amp;height=625" type="application/x-shockwave-flash" width="250" height="625">
    </embed>
<object>

你可能感兴趣的:(as3)