___________________________________
Well, nothing but another crappy AS thread by me. I dont see any other thread that would explain this, and im not very good at explaining. But ive gotten the hang of this stuff; so here goes:
___________________________________
What you will learn:
Very basic stuff, using the _name property (yay, finally got it right) and indexOf.
___________________________________
Ok, here goes
What can this be useful for?
Well, ive used it for hitTesting duplicated MCs. There is another way, explained in a tutorial by another NG Member, or you can always use Arrays. But in my own opinion, arrays are hard to understand - sure, they can be very bloody useful once you get the hang of them though.
Okay, into the tutorial.
The _name property, basically checks the name of an object. Say, it could be used combining IF statements.
if(this._name=="name"){
//do stuff
}
Thats a very basic form of it. I dont think theres much i can explain about this topic though.
Moving on.
the indexOf is often used with the _name property. It checks if the name of something starts with what you set. Ive used it quite a lot of times, again, for hitTesting duped MCs. Like this:
First off, i take it you know how to Duplicate MovieClips. Say, that your movieclip is duplicated like this:
this.duplicateMovieClip("name"+i,1337+i);
//im not going to go into further detail on for loops,for more check: Here
Then, you want to hitTest the duped MC. Id go for this:
put this code on a bullet or something to hit.
onClipEvent(enterFrame){
for(i in _root){
if([i]._name.indexOf("thing")!=-1){
if(_root[i].hitTest(this)){
//do stuff
}
}
}
thats pretty much about it.
Hehe, my second tutorial. Not very well explained, maybe even has been made before. But i just wanted to do this.
Hope it helped.
.:Blaze:.