问题
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