Run ObjectUtil.toString() on the results of getStyle(“testPng”). That might shed some light on what it is. It might already be the instance of a Bitmap instead of the class itself. Also, what CSS did you use to embed?
On 5/14/12 9:16 AM, "flexwdw" <flex...@yahoo.com> wrote: Hey Alex, Two things work: 1) Using the resource embedded in the external stylesheet SWF using a Canvas and the embedded image as a background-image style. In the case I need, it is very preferable to me to render the image in a Graphics content using fillBitmap, thus I'd rather have a bitmap data. 2) Using a resource embedded directly in the SWF that has the Application, like so: [Embed("test.png")] public var testPng:Class; var bitmap:Bitmap = new testPng(); graphics.beginBitmapFill( bitmap.bitmapData ); graphics.drawRect(0,0,50,50); graphics.endFill(); If I try to do this same thing with: var myClass:Class = StyleManager.getStyleDeclaration(".test").getStyle("testPng"); var bitmap:Bitmap = new myClass(); I get a runtime error that myClass cannot be instantiated. I thought those two operations were the same, clearly I'm wrong. Is there a way to do this? thanks! --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , Alex Harui <aharui@...> wrote: > > What code works when it is in the "code swf"? > > > On 5/11/12 8:43 PM, "flexwdw" <flexwdw@...> wrote: > > > > > > > I should add -- this all works with an image embedded in the code swf...it's > just when I try to do the same thing from the external swf it doesn't work. > I can use the asset as a cursor just fine, so I know there is nothing wrong > the asset too. > > --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > <mailto:flexcoders%40yahoogroups.com> , "flexwdw" <flexwdw@> wrote: > > > > I can't seem to figure out how to get the BitmapData for a resource > > embedded in an external stylesheet swf. I'd really like to have a piece of > > artwork in the swf that I can pull in via code and render into a > > UIComponent as a bitmap. Does anyone know how to do this? If I use the > > StyleManager to get a style declaration and then pull the embedded asset of > > it and cast it to a Class, I don't seem to be able to use that class to > > create a BitmapAsset like I'd expect. Any ideas would be greatly > > appreciated. (I'm still a sad camper stuck on 3.6 btw). Thanks. > > > > > > > > > -- > Alex Harui > Flex SDK Team > Adobe Systems, Inc. > http://blogs.adobe.com/aharui > -- Alex Harui Flex SDK Team Adobe Systems, Inc. http://blogs.adobe.com/aharui