开发者

Opening page in same window using navigatetoURL function

I have a flash code, in which i am loading images and opening urls through xml file, now it is opening in a different window(pop up window) but i want it to open in the same window. Please have a look at my code and suggest me.

var xmlReq:URLRequest = new URLRequest("XML/ImagesData01.xml"); 
var xmlLoader:URLLoader = new URLLoader();

xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded); 
xmlLoader.load(xmlReq);

var myXML:XML;
var mySprite:Sprite;
var headLoader:Loader;


function i开发者_JAVA百科magepress(e:MouseEvent):void  
{
navigateToURL(new URLRequest(String(myXML.data[Number(e.currentTarget.name)].@url)),"_self");

}


function xmlLoaded(e:Event):void{
myXML = new XML(e.target.data);
for (var i:int = 0; i < myXML.children().length(); i++)
{
headLoader = new Loader();
mySprite = new Sprite();
headLoader.load(new URLRequest(String(myXML.data[i].@image)));
mySprite.addChild(headLoader);
mySprite.name = String(i);
mySprite.addEventListener(MouseEvent.CLICK, imagepress)
addChild(mySprite);
}


}


it's not:

navigateToURL(new URLRequest(String(myXML.data[Number(e.currentTarget.name)].@url,"_self"))); 

rather it's

navigateToURL(new URLRequest(String(myXML.data[Number(e.currentTarget.name)].@url)) ,"_self"); 

you've been sending 2 arguments to URLRequest class instead of navigateToURL function... my code should work.


You need to pass "_self" as a second parameter to navigateURL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜