PDA

View Full Version : same instance names?



bigbstanley
May 21st, 2007, 01:11 PM
I'm loading a movie clip onto my stage through xml (a dot). When it does this, it also creates a small list on the side. The user can rollover the different items in the list and the corresponding dot lights up. Here's my problem. Some list items need several dots. I have it working as far as putting the multiple dots on the stage, however, on the list rollover part I'm having issues.

When the list item should have multiple dots, I am making those dots have the same instance name. I then have a function tell that instance name to run (hoping to have all mc's with that instance name run) but only one dot works.

Here's my as.



function thumbnails_fn(k){
if (duplicate[k] == "yes") {
d=d+1;
// making p equal to original k
p = k-d;
flashmap.dots.attachMovie("dot", "dot"+p+"dup", d+99);
flashmap.dots["dot"+p+"dup"]._x = xpos[k];
flashmap.dots["dot"+p+"dup"]._y = ypos[k];
addbutton = false;
}

new_k = k-d;

if(addbutton) {
locations_mc.attachMovie("location_bttn", "thumb"+k, k);
locations_mc["thumb"+k]._y = new_k*18;
locations_mc["thumb"+k].location_txt.text = locations[k];
}

addbutton = true;


flashmap.dots.attachMovie("dot", "dot"+k, k);
flashmap.dots["dot"+k]._x = xpos[k];
flashmap.dots["dot"+k]._y = ypos[k];



locations_mc["thumb"+k].onRollOver = function(){
flashmap.dots["dot"+k].dot.play();
// here's where I'm trying to get all mc's with the same name to play
flashmap.dots["dot"+k+"dup"].dot.play();

}

locations_mc["thumb"+k].onRollOut = function(){
flashmap.dots["dot"+k].dot.gotoAndPlay("out");
// here's where I'm trying to get all mc's with the same name to play
flashmap.dots["dot"+k+"dup"].dot.gotoAndPlay("out");
}


}

graylensman
May 21st, 2007, 01:22 PM
Looking at your code, you're not calling the dots properly. You've got refrences to ["dot"+p+"dup"] and you've got ["dot"+k], but nowhere to you instantiate ["dot"+k+"dup"]. The only time you reference this, is when you're trying to get your gotoAndPlay work. Try working on that angle.

bigbstanley
May 21st, 2007, 01:29 PM
Thanx for the quick response, but it under the onRollOver and onRollout.

it's right underneath the comment where it says "here's where I'm trying to get all mc's..."

graylensman
May 21st, 2007, 05:15 PM
yes, I see that, but that's not the same as instantiating those instances.
ActionScript Code:

flashmap.dots.attachMovie("dot", "dot"+k+"dup", k)




you need to do that first. That tells Flash that you've created instances named
flashmap.dots["dot"+k+"dup"]. Then you can tell Flash to gotoAndPlay on the rollOvers.

bigbstanley
May 21st, 2007, 06:30 PM
d's initial value is zero, therefore, p and k are equal. I have to use two different variables for instance naming. It's confusing. I really don't think it has anything to do with what that tho, because it will always show the last child of my xml - just not all of them. That's why I think you can't have several mc's with the same instance name and have all of them do something when a button is rolled over. I did a different naming convention in which each extra dot gets it's own unique name and it works - the code is just horrendous tho - so I was trying to simplify.