现在我有一个静态方式,我将网址设置为5个按钮,这是我正在做的一个示例:
Object(root).grid_slider.links.twitter.addEventListener(MouseEvent.CLICK, fl_ClickToGoToTwitter);
Object(root).grid_slider.links.facebook.addEventListener(MouseEvent.CLICK, fl_ClickToGoToFacebook);
function fl_ClickToGoToFacebook(event:MouseEvent):void
{
navigateToURL(new URLRequest("http://www.facebook.com"), "_blank");
}
function fl_ClickToGoToTwitter(event:MouseEvent):void
{
navigateToURL(new URLRequest("http://www.twitter.com"), "_blank");
}
我很喜欢闪光灯我在Flash MX之后放弃了它,但现在我被要求制作一个快速滑块(当然我推荐jquery但它们没有它)。我有一切正常,但我被问到url是从xml文件而不是静态加载的。不太清楚从哪里开始..我已经阅读了如何从xml读取但我是否需要在全局变量中设置值?
答案 0 :(得分:1)
你的XML:
<?xml version="1.0" encoding="utf-8"?>
<MYXML>
<FACEBOOK>"http://www.facebook.com"</FACEBOOK>
<TWITTER>"http://www.twitter.com"</TWITTER>
</MYXML>
您将此xml加载到myLinks变量:
var myLinks:XML;
var urlRequest:URLRequest = new URLRequest("link to your xml file");
var urlLoader:URLLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, urlLoader_completeHandler);
urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, urlLoader_securityErrorHandler);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR, urlLoader_ioErrorHandler);
function urlLoader_completeHandler(event:Event):void
{
myLinks = new XML(event.target.data);
}
function urlLoader_securityErrorHandler(event:SecurityErrorEvent):void
{
// Do you have crossdomain.xml?
}
function urlLoader_ioErrorHandler(event:IOErrorEvent):void
{
// Houston, we have a problem!
}
Object(root).grid_slider.links.twitter.addEventListener(MouseEvent.CLICK, fl_ClickToGoToTwitter);
Object(root).grid_slider.links.facebook.addEventListener(MouseEvent.CLICK, fl_ClickToGoToFacebook);
function fl_ClickToGoToFacebook(event:MouseEvent):void
{
navigateToURL(new URLRequest(myLinks.FACEBOOK.toString()), "_blank");
}
function fl_ClickToGoToTwitter(event:MouseEvent):void
{
navigateToURL(new URLRequest(myLinks.TWITTER.toSting()), "_blank");
}