
Welcome Guest
|
#1
|
|||
|
|||
|
Getting the identity of a clip
So many times, when duplicating movie clips, enumerating them via a for loop, I find myself counting the characters in the duplicate's instance name so I can perform a <b>substr()</b> operation to dynamically extract the number from the instance name.
I'm got tired of counting characters, so I wrote a function to extract the identifying number for me: Code:
function parseNum (uValue) {
var sValue = (typeof (uValue) == "movieclip") ? uValue._name : uValue;
for (var cI = 0; cI<sValue.length; cI++) {
if (sValue.charCodeAt(cI)>46 && sValue.charCodeAt(cI)<58) {
break;
} else {
continue;
}
}
return parseInt(sValue.substr(cI));
}Passing the instance name: Code:
onClipEvent(load){
nID = _root.parseNum(this._name);
trace(nID);
} Code:
onClipEvent(load){
nID = _root.parseNum(this);
trace(nID);
}It will then to a <b>parseInt()</b> on the remainder of the string, returning an integer value representing the identify of the clip instance.
__________________
|
«
Previous Thread
|
Next Thread
»
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Goto + movie clip in a movie clip | mongolian | Newbies |
2 | 11-20-2007 07:07 AM |
| MovieClip unloading and re-create | DenkouNova | General Flash | 2 | 03-27-2006 11:27 PM |
| Movie Clip within a Movie Clip: Text Linkage Problem | Inquirer | Newbies |
5 | 12-27-2005 08:22 AM |
| What is the best way to do this? | rolento | Newbies |
29 | 12-09-2005 10:12 PM |
| Scrollpane with a dynamically growing movie clip | skchun23 | Flash MX |
3 | 09-09-2004 11:05 PM |






