# Index xml target.name.length and double-digits issue

**URL:** <https://forum.kirupa.com/t/index-xml-target-name-length-and-double-digits-issue/246997>\
**Category:** flash\
**Created:** [December 17, 2007, 5:01pm UTC](https://forum.kirupa.com/t/index-xml-target-name-length-and-double-digits-issue/246997 "2007-12-17T17:01:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jrutter](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jrutter/32/2004_2.png) [@jrutter](https://forum.kirupa.com/u/jrutter)\
**Post date:** [December 17, 2007, 5:01pm UTC](https://forum.kirupa.com/t/index-xml-target-name-length-and-double-digits-issue/246997/1 "2007-12-17T17:01:44Z")

</div>

I have an issue, I have about 25 mc’s that are named carBtn1 through carBtn25 - the problem is when I index my array - its only taking the first number from the end of the carBtn, so carBtn1 is seen as the same as carBtn10. I tried taking the last 2 digits off which works for 2 digit numbers - but everything below 10 isnt working anymore. Im not sure what to do to get it working…

Here is my code:

```auto
// variables
var popInfo:popMc;

// 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);
        //trace(xml.city[0].@weburl.toString());
        var url:URLRequest = new URLRequest(xml.city[0].@weburl.toString()); 

    }
);

// event listeners
stage.addEventListener(MouseEvent.CLICK, onClickStageRemove);

for (var j:int = 0; j < 11; 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);
}

function onClickLoadData(event:MouseEvent):void
{
    popInfo = new popMc();
    popInfo.x = 100;
    popInfo.y = 50;
    addChild(popInfo);    
    popInfo.closeBtn.addEventListener(MouseEvent.CLICK , onClickRemove);
    popInfo.nyopBtn.addEventListener(MouseEvent.CLICK, onClickNYOP);
    //better approach would be add separate classFile to haldle some popInfo's events
    //such removing on stageClick in that file u could add those functions:
    var index:Number=event.target.name.slice(event.target.name.length-1);
    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 
{
    //navigateToURL(url, "_blank");
    // navigateToURL(urlNY, "_blank"); //trying to get this variable to work
    ExternalInterface.call("selectNY");

}

// set button mode here

```
