Stupid question about AS3 Arrays

I know I’m missing something fundamental here but I’ll ask the question anyway:
Why, when I have an array prepopulated with instance names of movieclip names like this:

var navArr:Array = [navBtns.hideNavB, navBtns.nav01, navBtns.nav02, navBtns.nav03];

Flash recognises them as movieClips and you can manipluate them in a for loop.
However, when I create an empty array and then populate it dynamically with the same text form an XML file Flash does not recognise these as instance names but treats them as array values. WHAT AM I MISSING !!!@@*&%**

This is a bit of a guess (the last time I played with AS3 was several years ago), but when you populate the array from an XML file are they [not] listed as quoted strings?

var navArr:Array = ["navBtns.hideNavB", "navBtns.nav01", "navBtns.nav02", "navBtns.nav03"];

It’s been ages since I even looked at any AS as well.

But I think ParkinT has it. i.e.
Without quotation marks the “names” are in fact objects
With quotation marks the names are text strings

So if you can find a way to use those strings to get and return the objects you should be all set.

@ParkinT @Mittineague Thanks for getting back so quickly… I sat up all night wondering the same as Perkin T and have tried so many things I’m going round in circles. If I push to the Array like this:

navAry.push(navXML..navRef.text[i]);

Then I’m assuming it would be text(String)
But I’m pushing liek this:

navAry.push(navXML..navRef[i]);

It traces fine and when I use the value in the array[0] (navBtns.nav01) to see if there’s a movie clip with that name on stage with

if    (navAry[i].stage){
                            trace(navAry[i] + " is on stage");
}

it also traces fine and confirms in the positive. But, if I then try to assign an event listerner to it nothing happens…
Something in the back of my mind keeps telling me that I’ve come across this before but I can’t remember the details for the life of me (getting old). It’s really bugging me and I have a potential work around but its a real hack and not very elegant at all…

@ParkinT @Mittineague Finally cracked it with this but thanks for the steer. you guys were right… here’s the end result for anyone having similar issues/challenges

navBtns.getChildByName(navShrt[i]).addEventListener(MouseEvent.MOUSE_OVER, mOvNav);

I am very glad to hear that.

And I am even more pleased to hear this!

Thanks for returning to post the solution. As you said, this will help someone else someday in the future; pay it forward.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.