HELP!!! Ive been trying to figure out this issue for the past 2 hrs, I can get the text to show up on the root, but when I stick in into an MC, it wont show up. Does anyone have any ideas as to why?
Here is my code:
// variables
var popInfo:popMc;
var xmlList:XMLList;
var mcLoader:Loader;
// load xml
var xml:XML = new XML();
var loader:URLLoader = new URLLoader();
loader.load(new URLRequest("data/cities.xml"));
loader.addEventListener(Event.COMPLETE,
function(evt:Event):void {
xml = XML(evt.target.data);
var url:URLRequest = new URLRequest(xml.city[0].@weburl.toString());
xmlList = xml.children();
for(var i:int = 0; i < xmlList.length(); i++)
{
// attach carBtn from library and assign x,y coords from xml
var carBtn:carBtn_mc = new carBtn_mc();
carBtn.x = xml.city*.@mcCarX.toString();
carBtn.y = xml.city*.@mcCarY.toString();
addChild(carBtn).name = "carBtn" + i;
trace(carBtn.name);
// carBtn event listeners
getChildByName("carBtn" + i).addEventListener(MouseEvent.CLICK, onClickLoadData);
getChildByName("carBtn" + i).addEventListener(MouseEvent.MOUSE_OVER, onCarHover);
getChildByName("carBtn" + i).addEventListener(MouseEvent.MOUSE_OUT, onCarOut);
}
}
);
// stage event listeners
stage.addEventListener(MouseEvent.CLICK, onClickStageRemove);
// button mode
buttonMode = true;
// functions
function onCarHover(event:MouseEvent):void
{
event.target.gotoAndPlay(11);
removeChild(popInfo);
this.carcityName.text = "please show up";
}
// carBtn onMouseout
function onCarOut(event:MouseEvent):void
{
event.target.gotoAndPlay(10);
}
// loads data and populates popUp movieclips
function onClickLoadData(event:MouseEvent):void
{
popInfo = new popMc();
popInfo.x = 130;
popInfo.y = 50;
popInfo.closeBtn.addEventListener(MouseEvent.CLICK , onClickRemove);
popInfo.nyopBtn.addEventListener(MouseEvent.CLICK, onClickNYOP);
var index = String(event.target.name);
while (index != String(uint(index))){
index = index.substr(2);
}
popInfo.carsizeText.text = xml.city[index].bidlist.carsize.descendants().toXMLString();
popInfo.priceText.text = xml.city[index].bidlist.price.descendants().toXMLString();
popInfo.savingsText.text = xml.city[index].bidlist.savings.descendants().toXMLString();
popInfo.stateText.text = xml.city[index].@name.toString();
addChild(popInfo);
}
function onClickRemove(event:MouseEvent):void
{
popInfo.closeBtn.removeEventListener(MouseEvent.CLICK, onClickRemove);
popInfo.nyopBtn.removeEventListener(MouseEvent.CLICK, onClickNYOP);
removeChild(popInfo);
}
function onClickStageRemove(event:MouseEvent):void
{
if(event.eventPhase == EventPhase.AT_TARGET) {
removeChild(popInfo);
}
}
function onClickNYOP(event:MouseEvent):void
{
ExternalInterface.call("selectNY");
}