Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-15-2007, 08:37 PM   #1
vee
Senior Member
 
Join Date: Jan 2006
Location: new york
Posts: 361
Default testing for all display objs that == MC

Im looking to try to use the new RegExp class in replacement of substring to pick up all instance names with the string "step" as part of its name
Heres what i have so far thats not working
ActionScript Code:
var searchClip:RegExp=/step/; var thingy:MovieClip; for (thingy in this) {     if (this[thingy].type ==MovieClip) {         trace(thingy);         searchClip.test(thingy.name);     } }
vee is offline   Reply With Quote
Old 08-16-2007, 12:56 AM   #2
Assertnfailure
as[org].addListener(this)
 
Assertnfailure's Avatar
 
Join Date: Dec 2005
Location: LA, California
Posts: 837
Default

You can't evaluate the the class type using ==, you have to use:
if(thingy is MovieClip)

Regardless though, thingy is typed as MovieClip, so this should always either return true or throw a TypeError.
Assertnfailure is offline   Reply With Quote
Old 08-16-2007, 01:07 AM   #3
vee
Senior Member
 
Join Date: Jan 2006
Location: new york
Posts: 361
Default

Is this not the best way to search for instance names with similar criteria in the name?

I changed thingy to an object type and made the other change you suggested. Nothing happens after the changes are made.
ActionScript Code:
var searchClip:RegExp=/step/; var thingy:Object; for (thingy in this) {     if (thingy is MovieClip) {         trace(thingy);         searchClip.test(thingy.name);     } }

Last edited by vee; 08-16-2007 at 01:36 AM.
vee is offline   Reply With Quote
Old 08-16-2007, 02:17 AM   #4
Assertnfailure
as[org].addListener(this)
 
Assertnfailure's Avatar
 
Join Date: Dec 2005
Location: LA, California
Posts: 837
Default

ActionScript Code:
var searchClip:RegExp=/step/; for each (var thingy:* in this) {     if (thingy is MovieClip) {         trace(thingy);         searchClip.test(MovieClip(thingy).name);     } }

Try that.
Assertnfailure is offline   Reply With Quote
Old 08-16-2007, 02:42 AM   #5
vee
Senior Member
 
Join Date: Jan 2006
Location: new york
Posts: 361
Default

First I got an error that told me searchClip was a name used internally, so I switch it to: searchMyClips

After that I got no errors but also no traces. I put a trace just inside the for loop but my string did not trace. Two things i did notice. The keywords each and is are still black. Is that normal?
vee is offline   Reply With Quote
Old 08-16-2007, 02:42 PM   #6
Assertnfailure
as[org].addListener(this)
 
Assertnfailure's Avatar
 
Join Date: Dec 2005
Location: LA, California
Posts: 837
Default

Well....that all depends on how the rest of your code looks.

for each in and for in loops both only iterate through dynamic properties, so if you don't have any of those in your for loop, then it probably won't show up.
Assertnfailure is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
local(desktop) testing works but not on the server lporiginalg Server-Side Scripting 0 07-01-2007 01:19 AM
Calculator Problems jaredg86 Other Flash General Questions 10 02-16-2007 08:58 PM
Display object cordinates relative to display object container Daedalus ActionScript 3.0 2 12-16-2006 10:03 AM
Newbie: Getting Display To Update from setInterval function callback. (First Post) KShapiro Simple Stuff (Newbies) 0 05-05-2006 09:56 PM
Unit Testing GUI code? confusednoise ActionScript 2.0 0 07-11-2005 09:55 PM


All times are GMT. The time now is 01:24 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.