Tuesday, February 17, 2009

mx.controls.Image

Blast you, Image class. The 'goods' are stored as an internal namespace'd variable named contentHolder. There are two methods to set this from the outside.
  • via source: this expects to be a url string or a IFlexDisplayObject class (generally one auto-generated by the @Embed directive)
  • via load(): see source above
Unfortunately, no one thought that maybe you would already have the data or you were generating it fresh. Of course, you'd ask, why would you need the Image class then - why not just make a custom component? Because then you'd have to rewrite any and all of Image's other features that you wanted (and making a horrible OO-fail example in the process). So basically I wanted a UIComponent that had all the features of Image but could also accept a bitmapData and some other stuff as inputs.

For what I'm doing (preloading resource chunks), I decided on a pattern of two coupled classes: GraphicResource and Graphic. They both derive from Image, but a Graphic is only really useful if it has a linked GraphicResource so it can pull bitmap clips out of it. There are probably better ways (maybe not better, but more Kosher) of doing this, but I'm sticking with this for now. Theoretically the GraphicResource can still be a Vector Sprite while the Graphic is a Bitmap in this setup, but I don't have a concept yet of having a Graphic pull out a vector asset from a swf contained in a GraphicResource. First show me wash the car.

Also ignore the fight menu stuff... none of that is functional.

Now with 100% more Dragon

No comments: