-
Esquire
duplicate instance names
I have a number of layers with a button in each that have instance names set. I'm using a string to keep track of the button clicked so I can disable it once it's clicked and re-enable it later if another button is clicked. This means it's important for multiple instances of the same symobol to have the same name.
What are the implications of taking the same symbol, in the same layer, but on different (identical) keyframes, and giving them the same instance name?
Thanks,
Frank
-
Young Senior Member
sometimes i wonder whether people who post here really wants to be understood. different (identical) keyframes?!
anyway as long as they are on different frames, it doesnt matter.
-
Avoid using the same instance name twice on the same timeline
anyway as long as they are on different frames, it doesnt matter
What about if the frames overlap?
Using the same instancename in multiple places on the same timeline is not good practice. Even if for no other reason than if you need to reorganise your file at any time then you have to manually check and alter every single instancename on the stage. It almost guarantees that you will cause Flash to misbehave at some point.
This means it's important for multiple instances of the same symobol to have the same name.
Why do you need that? You just need to have an array of instancenames, for eg:
PHP Code:
instanceArray = ["button1", "button2", "button3"];
function hideclicked(setup) {
var i;
var mcname;
// "this" will contain the reference to the calling MC or button
mcname = this._name;
for (i=0; i<instancearray.length; i++) {
// The setup value allows me to turn all buttons on
// To do the activation, I check for any MC where the instancename
// is different to the one calling the function OR all of them
// if setup is set to true.
if (instancearray[i] !== mcname || setup) {
// Activate all the buttons that are not clicked
trace("ACTIVATING _root["+instancearray[i]+"]");
_root[instancearray[i]].onRelease = hideclicked;
_root[instancearray[i]]._alpha = 100;
} else {
// Deactivate the button that called the function
// You would also put any code you want the button
// to execute in here.
trace("DEACTIVATING "+targetpath(this));
delete this.onRelease;
this._alpha = 50;
}
}
}
// Finally, I call the function to set up all the buttons
hideclicked(true);
When any button in the array is clicked, it deletes its onRelease function (deactivating the button) and cycles through the list of instances to activate them by assigning the onRelease function.
Last edited by AlsoGaiusCoffey; 12-16-2002 at 06:12 AM.
-
Esquire
Hmmm.... now that I think about it, to get things to behave properly, I've made changes that may render my use of duplicate instance names unnecessary.
By the way, the instances were always in the same layer but never the same frame.
Thanks for the code, by the way... good stuff.
Frank
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|