Change Banner ClickTag Code to AS3?

自闭症网瘾萝莉.ら 提交于 2020-01-14 05:24:06

问题


I have been handed a number of Flash (AS3) banners to add ClickTag codes to them and as the documents have been setup as AS3 it does not allow code added to items!

I need help changing the following code to AS3 asap if anyone can help?

on (release) {
   getURL (_level0.clickTag, "_blank");
}

I cannot change the document back to AS2 as they have been created through InDesign and the filters don't work if I change them back!

Thanks,

Thomas.


回答1:


In AS3, the on(event) workflow has been replaced with the event system; and getURL() as been renamed navigateToURL() witch is more clear about what the function does.

// 'import' the necessary resources : If you don't do this, you'll have error while compiling.
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.net.navigateToURL;

// theBanner is the name of your clickable MovieClip. If you add the code in the MovieClip, use 'this' instead
// this line indicate to call "onClick" if MOUSE_UP occurs on theBanner (ie : the user release the mouse hover the MovieClip
theBanner.addEventListener(MouseEvent.MOUSE_UP, onClick);

// The onClick function, how open the new clickTag URL when called
function onClick(e:MouseEvent):void {
  // get the clickTag URL (root.loaderInfo.parameters.clickTag), and send it to navigateToURL.
  navigateToURL(new URLRequest(root.loaderInfo.parameters.clickTag), '_blank');
}


来源:https://stackoverflow.com/questions/16691115/change-banner-clicktag-code-to-as3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!