LOADING
Loading
Hi , welcome back.
LogoutLOGOUT
 
  Lost password?  
Hi
 




 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-17-2002, 03:25 AM
barn barn is offline
curmudgeon
 
Join Date: Dec 2001
Location: Lake Forest Park, Washington, USA
Posts: 270
Rep Power: 12
barn is on a distinguished road
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));
}
You can pass this function either a reference to a clip or the instance name itself.

Passing the instance name:
Code:
onClipEvent(load){
    nID = _root.parseNum(this._name);
    trace(nID);
}
Passing the reference:
Code:
onClipEvent(load){
    nID = _root.parseNum(this);
    trace(nID);
}
And in either case, the function will discard everything in the instance name up to the occurence of the first numeric digit.

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.
__________________
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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




All times are GMT. The time now is 12:13 AM.