1 Reply Latest reply on Dec 9, 2008 2:40 PM by Zen Seven

    Can't implicitly cast from Bitmap to Class?

    Zen Seven Level 1
      Hello everyone,

      I've created a dynamic ResourceLoader class which loads all required assets into an internal dictionary, storing the Loader.content (which is a bitmap object) keyed by a string name. Everything works fine and dandy when I clone() the bitmapdata and cast it to a display object, but when i try to do the same thing and set it to setStyle, I get this weird error:

      Type Coercion failed: cannot convert flash.display::Bitmap@c479439 to Class.

      How can that be? Isn't everything derived from class?

      So instead of this: (only relevant lines below)

      private var defClick:Class;
      /// in ctor....
      setStyle('downSkin', defClick);

      I'm now trying to do this:

      mLoader.load(new URLRequest(I'../media/actionbar_def-click.png')));
      // after load...
      mImages["defClick"] = mLoader.content;
      // during button construction..
      setStyle('downSkin', DisplayObject(new Bitmap(Bitmap(mImages["defClick"]).bitmapData.clone()));

      Does anyone have any suggestions on where I'm going wrong?

      Thank you.