So Im stumped, Im trying to pass a var url - which grabs the URL out of the xml file. I have the code setup correctly and I can see the URL being pulled out of the XML - but I cant seem to get it into the onClickNYOP function. I get all sorts of errors, can someone please tell what Im doing wrong?
Here is my code:
stop();
// variables
var popInfo:popMc;
var star1sp:Sprite = new Sprite();
var star2sp:Sprite = new Sprite();
var star3sp:Sprite = new Sprite();
var star4sp:Sprite = new Sprite();
var star5sp:Sprite = new Sprite();
//star1Num
var star11:MovieClip = new Star1();
var star12:MovieClip = new Star2();
var star13:MovieClip = new Star3();
var star14:MovieClip = new Star4();
var star15:MovieClip = new Star5();
//star2Num
var star21:MovieClip = new Star1();
var star22:MovieClip = new Star2();
var star23:MovieClip = new Star3();
var star24:MovieClip = new Star4();
var star25:MovieClip = new Star5();
//star3Num
var star31:MovieClip = new Star1();
var star32:MovieClip = new Star2();
var star33:MovieClip = new Star3();
var star34:MovieClip = new Star4();
var star35:MovieClip = new Star5();
//star4Num
var star41:MovieClip = new Star1();
var star42:MovieClip = new Star2();
var star43:MovieClip = new Star3();
var star44:MovieClip = new Star4();
var star45:MovieClip = new Star5();
// load xml
var xml:XML = new XML();
var loader:URLLoader = new URLLoader();
loader.load(new URLRequest("data/ht_vday08.xml"));
loader.addEventListener(Event.COMPLETE,
function(evt:Event):void {
xml = XML(evt.target.data);
}
);
// event listeners
stage.addEventListener(MouseEvent.CLICK, onClickStageRemove);
for (var j:int = 0; j < 22; j++)
{
getChildByName("carBtn" + j).addEventListener(MouseEvent.CLICK, onClickLoadData);
getChildByName("carBtn" + j).addEventListener(MouseEvent.MOUSE_OVER, onCarHover);
getChildByName("carBtn" + j).addEventListener(MouseEvent.MOUSE_OUT, onCarOut);
}
// button mode
buttonMode = true;
// functions
function onCarHover(event:MouseEvent):void
{
event.target.gotoAndPlay(11);
}
function onCarOut(event:MouseEvent):void
{
event.target.gotoAndPlay(10);
}
// loads data and populates popUp movieclips
function onClickLoadData(event:MouseEvent):void
{
if (popInfo) removeChild(popInfo);
popInfo = new popMc();
popInfo.x = 130;
popInfo.y = 50;
addChild(popInfo);
popInfo.closeBtn.addEventListener(MouseEvent.CLICK , onClickRemove);
popInfo.nyopBtn.removeEventListener(MouseEvent.CLICK, onClickNYOP);
var index = String(event.target.name);
while (index != String(uint(index))){
index = index.substr(2);
}
popInfo.stateText.text = xml.city[index].@name.toString();
var url:String = xml.city[index].@weburl.toString();
trace(url);
popInfo.cityPrice1.text = xml.city[index].cityprice.citypricename[0].toString();
popInfo.cityPrice2.text = xml.city[index].cityprice.citypricename[1].toString();
popInfo.cityPrice3.text = xml.city[index].cityprice.citypricename[2].toString();
popInfo.cityPrice4.text = xml.city[index].cityprice.citypricename[3].toString();
popInfo.fromPrice1.text = xml.city[index].cityprice.fromprice[0].toString();
popInfo.fromPrice2.text = xml.city[index].cityprice.fromprice[1].toString();
popInfo.fromPrice3.text = xml.city[index].cityprice.fromprice[2].toString();
popInfo.fromPrice4.text = xml.city[index].cityprice.fromprice[3].toString();
var star1Num:Number = xml.city[index].cityprice.starcount[0].toString();
var star2Num:Number = xml.city[index].cityprice.starcount[1].toString();
var star3Num:Number = xml.city[index].cityprice.starcount[2].toString();
var star4Num:Number = xml.city[index].cityprice.starcount[3].toString();
popInfo.addChild(star1sp);
star1sp.y = 70;
star1sp.x = -10;
if (star1Num == 1) {
star1sp.addChild(star11);
}
else if (star1Num == 2) {
star1sp.addChild(star12);
}
else if (star1Num == 3) {
star1sp.addChild(star13);
}
else if (star1Num == 4) {
star1sp.addChild(star14);
}
else if (star1Num == 5) {
star1sp.addChild(star15);
}
popInfo.addChild(star2sp);
star2sp.y = 105;
star2sp.x = -10;
if (star2Num == 1) {
star2sp.addChild(star21);
}
else if (star2Num == 2) {
star2sp.addChild(star22);
}
else if (star2Num == 3) {
star2sp.addChild(star23);
}
else if (star2Num == 4) {
star2sp.addChild(star24);
}
else if (star2Num == 5) {
star2sp.addChild(star25);
}
popInfo.addChild(star3sp);
star3sp.y = 70;
star3sp.x = 142;
if (star3Num == 1) {
star3sp.addChild(star31);
}
else if (star3Num == 2) {
star3sp.addChild(star32);
}
else if (star3Num == 3) {
star3sp.addChild(star33);
}
else if (star3Num == 4) {
star3sp.addChild(star34);
}
else if (star3Num == 5) {
star3sp.addChild(star35);
}
popInfo.addChild(star4sp);
star4sp.y = 105;
star4sp.x = 142;
if (star4Num == 1) {
star4sp.addChild(star41);
}
else if (star4Num == 2) {
star4sp.addChild(star42);
}
else if (star4Num == 3) {
star4sp.addChild(star43);
}
else if (star4Num == 4) {
star4sp.addChild(star44);
}
else if (star4Num == 5) {
star4sp.addChild(star45);
}
}
function onClickNYOP(event:MouseEvent):void
{
navigateToURL(url, "_blank");
}
function onClickRemove(event:MouseEvent):void
{
popInfo.closeBtn.removeEventListener(MouseEvent.CLICK, onClickRemove);
popInfo.nyopBtn.removeEventListener(MouseEvent.CLICK, onClickNYOP);
removeChild(popInfo);
popInfo=null;
}
function onClickStageRemove(event:MouseEvent):void
{
if(event.eventPhase == EventPhase.AT_TARGET) {
removeChild(popInfo);
popInfo=null;
}
}