Results 1 to 6 of 6
-
March 29th, 2012, 05:22 PM #185Registered User
postsloop through a list of similar names?
I have this:
but i want to do something like this:Code:function onAdd(e:Event){ switch (getQualifiedClassName(e.target)) { case "Symbol0": e.target.filters = [AdjustColorMatrix]; break; case "Symbol1": e.target.filters = [AdjustColorMatrix]; break; case "Symbol2": e.target.filters = [AdjustColorMatrix]; break; case "Symbol3": e.target.filters = [AdjustColorMatrix]; break; case "Symbol4": e.target.filters = [AdjustColorMatrix]; break; default: } }
Is there a way?Code:for (var i:Number=1; i<=5;i++){ switch (getQualifiedClassName(e.target)) { case "Symbol" + i: e.target.filters = [AdjustColorMatrix]; break; } }
Thanks!
-
March 29th, 2012, 05:39 PM #21,391Registered User
postshmmm - it seems as though all of your cases perform the same operation - it looks like you shouldn't have to differentiate between them - so you should be able to just do:
Code:function onAdd( e:Event ):void { e.currentTarget.filters = [AdjustColorMatrix]; }
-
March 29th, 2012, 10:47 PM #3
Unless there's more options other than Symbol0 - Symbol4.
You could do this:
Or this:Code:function onAdd(e:Event){ switch (getQualifiedClassName(e.target)) { case "Symbol0": case "Symbol1": case "Symbol2": case "Symbol3": case "Symbol4": e.target.filters = [AdjustColorMatrix]; break; default: } }
Or, if all Symbol classes have a common super class or interface:Code:if((/Symbol[0-4]/).test(getQualifiedClassName(e.target))) e.target.filters = [AdjustColorMatrix]
Code:if(e.target is SymbolSuperClass) e.target.filters = [AdjustColorMatrix]
Proud Montanadian
We tolerate living and breathing. And niches.
Name Brand Watches
Maybe getTimer() or TweenMax is the answer to your problem . . .
-
March 29th, 2012, 11:33 PM #41,391Registered User
postsis that a regex condition there? nice - agreed, there could certainly be other cases, but given the info presented, the referencing and test appears unnecessary *shrug*
another method (among many) would be similar to your last but within a switch - something like:
curious? your reason for using target over currentTarget?Code:switch( true ) { case (e.currentTarget is SymbolClass): e.target.filters = [AdjustColorMatrix]; break; case (e.currentTarget is SpriteClass): e.target.filters = [SpriteColorMatrix]; break; ... }
-
March 29th, 2012, 11:42 PM #5
Given the info presented, it's impossible to tell what's necessary

Yeah that's regex. I used target because it's shorter to write, but I'll use whichever one is appropriate. He used target as well...Proud Montanadian
We tolerate living and breathing. And niches.
Name Brand Watches
Maybe getTimer() or TweenMax is the answer to your problem . . .
-
March 30th, 2012, 12:25 AM #61,391Registered User
postslmao! excellent point - i spend way to much time guessin

Reply With Quote


Bookmarks