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
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
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 {
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):
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
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
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 =
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
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,
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
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
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
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,
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
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
15 matches
Mail list logo