XML程式碼如下:
<links>AS3的程式碼如下:
<title link="http://www.homepage.com/promotion.htm">
The Promotion</title>
</links>
import flash.net.URLRequest;
import flash.events.MouseEvent;
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("my-xml-file.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
var promotionLinkAttribute:XMLList;
function processXML(e:Event):void {
myXML = new XML(e.target.data);
promotionLinkAttribute = myXML.title[0].attribute("link");
}
senser.buttonMode=true;
senser.addEventListener(MouseEvent.MOUSE_OVER, hoverPromotionBanner);
senser.addEventListener(MouseEvent.MOUSE_OUT, visitedPromotionBanner);
senser.addEventListener(MouseEvent.CLICK, openPromotionPage);
function hoverPromotionBanner(e:MouseEvent):void{
MovieClip(getChildByName("senser")).gotoAndPlay("active");
this.gotoAndStop(currentFrame);
}
function visitedPromotionBanner(e:MouseEvent):void{
MovieClip(getChildByName("senser")).gotoAndPlay("visited");
this.play();
}
function openPromotionPage(e:MouseEvent):void {
var promotionLink:URLRequest = new
URLRequest(promotionLinkAttribute);
navigateToURL(promotionLink, "_self");
//trace(promotionLinkAttribute);
}