A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Check if an object is a Bitmap... how?

  1. #1
    Game Developer
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    292

    Check if an object is a Bitmap... how?

    I have some code that loops through all the objects in the displaylist. Is there a way to tell is the object it found is a Bitmap?

    I've tried things like :

    1.) typeof(obj)
    2.) if(obj is Bitmap)

    But they don't seem to work.

    Ideas?

  2. #2
    Senior Member Steven FN's Avatar
    Join Date
    Mar 2010
    Location
    CA, USA
    Posts
    276
    I use the following and it seems to work well, but there might be a better solution.

    if(String(obj) == "[object Bitmap]")

    Trace out the object type using trace(obj) and then replace Bitmap with it. I use custom classes so one of my objects was a Note and i would use the following:

    if(String(obj) == "[object Note]")

    Basically just a string comparison, i didn't really want to research any solutions so i came up with this for myself.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center