While I really don't understand why you would want to do things this way, but...

I tested this code below, with several clips on the stage:
sq_1, sq_12, sq_122, sq_1222a, sq_1212_1212, sq_6dad_12, sq_6d_6d

it worked fine and outputed the obvious results:
sq_1
sq_12
sq_122
sq_1212_1212
sq_6dad_12

var childnum:int=this.numChildren-1;
var pat:RegExp=/_[0-9]+$/;
var instance:DisplayObject;
while (childnum!=-1) {
    instance = this.getChildAt(childnum);
    if (pat.test(instance.name)) {
        trace(instance.name);
    }
    --childnum;
}


On 3/18/2010 2:08 PM, Jiri wrote:
Hello,

i would like some help, because I am confused.

If have a Movieclip that holds several sprites some of them have instance names like so
frame_<n> where n is a number.

I then loop through every child of the MovieClip and test the instance name using regExp.

var childs:int = clip.numChildren-1;
var pat:RegExp = /_[0-9]+$/ig;

while(childs >= 0){
    var instance:DisplayObject = clip.getChildAt( childs );

    if( pat.test(instance.name) ){
        Logger.debug( "info box frame" , instance.name );
    }
    childs--
}

I have three movieclips called 'frame_0' , 'frame_1' and 'frame_2' for sure, but it when I run the above code, it only show 1 and 0??

Anybody has an idea?

Jiri

On 11/03/2010 22:16, Guest Services, City Concierge wrote:
We're looking for a coder to some small contract work
We're in Los Angeles
Should know action script very well, and be able to get the flash scripts to
work in .asp and .php and use XML
Ask for Jefferson
323-874-6610


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to