Re: [Flashcoders] Testing display object if its MovieClip or BitMap?

2010-12-06 Thread Ktu
I know a solution may already be found but this was my first thought and I am curious how any of you feel about switch (true) for this problem switch (true) { case loadedDisplayObject is MovieClip: case loadedDisplayObject is Bitmap: } Is switch (true) just bad practice? and does 'is' not

Re: [Flashcoders] Testing display object if its MovieClip or BitMap?

2010-12-04 Thread Micky Hulse
On Thu, Dec 2, 2010 at 3:17 AM, Karim Beyrouti ka...@kurst.co.uk wrote: Hopefully the line breaks here wont be too bad, pasting the code: Very nice!!! Many thanks Karim I will test it out and let you know how it goes. :) Have an excellent day/night! Cheers, Micky

Re: [Flashcoders] Testing display object if its MovieClip or BitMap?

2010-12-02 Thread Karim Beyrouti
Hopefully the line breaks here wont be too bad, pasting the code: CODE package { import flash.utils.describeType; import flash.utils.getQualifiedClassName; /** * @author karim @ kurst.co.uk */ public class ClassUtils {

[Flashcoders] Testing display object if its MovieClip or BitMap?

2010-12-01 Thread Micky Hulse
Hello, I am using this class: http://code.google.com/p/as3-multiple-file-preloader/ And I need to determine the display object type (i.e. is it MovieClip or Bitmap). trace(getQualifiedClassName(loadedDisplayObject)); Gives me this output (in a loop of 3 images and 1 swf loaded):

Re: [Flashcoders] Testing display object if its MovieClip or BitMap?

2010-12-01 Thread Henrik Andersson
Micky Hulse skriver: trace(getQualifiedClassName(loadedDisplayObject)); Would that be the best way to test for MovieClip or Bitmap? It fails the empty base class test. It is an extremely bad way. ___ Flashcoders mailing list

Re: [Flashcoders] Testing display object if its MovieClip or BitMap?

2010-12-01 Thread Glen Pike
How about up-casting: var mc:MovieClip = loadedDisplayObject as MovieClip; if(mc) { mc.play(); } else { //could be a bitmap, but if it's not guaranteed, then you might need to do more tests. var bmp:Bitmap = loadedDisplayObject as Bitmap; } On 01/12/2010 22:39, Micky Hulse

Re: [Flashcoders] Testing display object if its MovieClip or BitMap?

2010-12-01 Thread Glen Pike
Sorry, I meant downcast On 01/12/2010 22:56, Glen Pike wrote: How about up-casting: var mc:MovieClip = loadedDisplayObject as MovieClip; if(mc) { mc.play(); } else { //could be a bitmap, but if it's not guaranteed, then you might need to do more tests. var bmp:Bitmap =

Re: [Flashcoders] Testing display object if its MovieClip or BitMap?

2010-12-01 Thread Micky Hulse
Hi Henrik! Thanks for the quick reply, I really appreciate it. :) On Wed, Dec 1, 2010 at 2:49 PM, Henrik Andersson he...@henke37.cjb.net wrote: It fails the empty base class test. It is an extremely bad way. Ah, I am glad I asked! :D Any tips on a better way to test display object if it is

Re: [Flashcoders] Testing display object if its MovieClip or BitMap?

2010-12-01 Thread Micky Hulse
Hi Glen! Many thanks for the quick reply and example code. I really appreciate it! :) On Wed, Dec 1, 2010 at 2:56 PM, Glen Pike postmas...@glenpike.co.uk wrote: How about up-casting: var mc:MovieClip = loadedDisplayObject as MovieClip; if(mc) {    mc.play(); } else {    //could be a bitmap,

Re: [Flashcoders] Testing display object if its MovieClip or BitMap?

2010-12-01 Thread Micky Hulse
On Wed, Dec 1, 2010 at 3:02 PM, Glen Pike postmas...@glenpike.co.uk wrote: Sorry, I meant downcast No worries! I appreciate the code sample and help. That did the trick. :) Cheers, Micky ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com

Re: [Flashcoders] Testing display object if its MovieClip or BitMap?

2010-12-01 Thread Glen Pike
Hi, If your downcast does not work - the as bit - your variable will be null -it does not throw exceptions. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/operators.html#as Glen On 01/12/2010 23:07, Micky Hulse wrote: Hi Glen! Many thanks for the quick

Re: [Flashcoders] Testing display object if its MovieClip or BitMap?

2010-12-01 Thread Micky Hulse
On Wed, Dec 1, 2010 at 3:25 PM, Glen Pike postmas...@glenpike.co.uk wrote: If your downcast does not work - the as bit - your variable will be null -it does not throw exceptions. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/operators.html#as Excellent! Thanks for

Re: [Flashcoders] Testing display object if its MovieClip or BitMap?

2010-12-01 Thread Karim Beyrouti
attached a class that does that, hope it helps... example : trace( ClassUtils.getFullClassPath( canvas ) ); // flash.display.Bitmap trace( ClassUtils.getSuperClass( canvas ) ); // flash.display.DisplayObject On 1 Dec 2010, at 23:40, Micky Hulse wrote: On Wed, Dec 1, 2010 at 3:25 PM,

Re: [Flashcoders] Testing display object if its MovieClip or BitMap?

2010-12-01 Thread Henrik Andersson
Karim Beyrouti skriver: attached a class that does that, hope it helps... The mailer ate it. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Re: [Flashcoders] Testing display object if its MovieClip or BitMap?

2010-12-01 Thread Micky Hulse
Hi Karim! Many thanks for the reply and code sample! I really appreciate the help. :) On Wed, Dec 1, 2010 at 5:19 PM, Karim Beyrouti ka...@kurst.co.uk wrote: attached a class that does that, hope it helps... Doh! Looks like the Flash Coders List does not allow attachments! :( Do you have a