[flexcoders] Re: BitmapData from asset embedded in external stylesheet swf

2012-05-14 Thread flexwdw
Alex, thanks again for you help, it got me there :)  I have found the solution. 
 The problem was that this was indeed a vector graphic I was trying to import, 
so I needed to bring it in as a SpriteAsset.  I can addChild the SpriteAsset to 
component I'm working from...I can then set that component's mouseChildren to 
false and get the same thing I needed to render the bitmap directly for.  Kudos 
to you, sir. 




[flexcoders] Re: BitmapData from asset embedded in external stylesheet swf

2012-05-14 Thread flexwdw
Hey Alex,

Looks like I'm ignorant here.  First, yeah, that was the only thing the trace 
spit out.  Secondly, I have never implemented the external stylesheet with 
embeds other than stuff in our SWF -- so, it sounded right in my head when I 
said it.  (and the SWF is all artsy and stuff.  My home has white walls for 
reason...).  It looks like I am getting a sprite from the generated code, 
right? (paths changed, but you get the idea):

package 
{
import mx.core.SpriteAsset;
import flash.display.DisplayObject;

[ExcludeClass]

[Embed(_resolvedSource="/opt2/stuff/Platform/stylesheets/commonV5.1/skins.swf", 
source="/opt2/stuff/Platform/stylesheets/commonV5.1/skins.swf", 
symbol="cursor_move", original="commonV5.1/skins.swf", _line="3665", 
_file="/opt2/development/stuff/Platform/stylesheets/myskins2.css")]
public class myskins2__embed_css_commonV5_1_skins_swf_cursor_move_2116628543 
extends mx.core.SpriteAsset 
{
public function 
myskins2__embed_css_commonV5_1_skins_swf_cursor_move_2116628543() 
{ 
super(); 
}

public var hour_hand:flash.display.DisplayObject;
public var minute_hand:flash.display.DisplayObject;

}
}

I'm looking to render whatever this embed is to a UIComponent -- I wanted a 
BitmapData because I was just going to use fillBitmap and render it directly 
without having to have an additional child in the way -- like I would with a 
canvas and a background-image.  Is there a way to do this?

--- In [email protected], Alex Harui  wrote:
>
> Hey, your changing your story.  First it was embedded PNGs and now it is SWF 
> assets.  SWF assets do not have to be Bitmaps.  They could be Sprites, 
> MovieClips, etc.
> 
> I'm surprised that ObjectUtil.toString only showed one line of output.  Or 
> did the forum software cut it off?  Maybe try describeType instead, or use 
> the –keep-generated-actionscript MXMLC option and see what it used for that 
> asset in the SWF.  I'm trying to see what the base classes are for the embed.
> 
> -Alex



Re: [flexcoders] Re: BitmapData from asset embedded in external stylesheet swf

2012-05-14 Thread Alex Harui
Hey, your changing your story.  First it was embedded PNGs and now it is SWF 
assets.  SWF assets do not have to be Bitmaps.  They could be Sprites, 
MovieClips, etc.

I’m surprised that ObjectUtil.toString only showed one line of output.  Or did 
the forum software cut it off?  Maybe try describeType instead, or use the 
–keep-generated-actionscript MXMLC option and see what it used for that asset 
in the SWF.  I’m trying to see what the base classes are for the embed.

-Alex

On 5/14/12 12:41 PM, "flexwdw"  wrote:






Thanks for the help, Alex!

So, code:

trace( ObjectUtil.toString( 
StyleManager.getStyleDeclaration(".wdwTest").getStyle("icon")) );

var test:Class =
StyleManager.getStyleDeclaration(".wdwTest").getStyle("icon");
var bitmap:Bitmap = new test();

CSS (cursor_move is a resource I am using elsewhere in the app already):
.wdwTest
{
icon: Embed(source="commonV5.1/skins.swf", symbol="cursor_move");
}

output:
(myskins2__embed_css_commonV5_1_skins_swf_cursor_move_2116628543)

Exception:

TypeError: Error #1034: Type Coercion failed: cannot convert 
myskins2__embed_css_commonV5_1_skins_swf_cursor_move_2116628543@366be041 to 
flash.display.Bitmap.

thanks!

--- In [email protected]  , Alex 
Harui  wrote:
>
> 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?
>






--
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


[flexcoders] Re: BitmapData from asset embedded in external stylesheet swf

2012-05-14 Thread flexwdw
Thanks for the help, Alex!

So, code:

trace( ObjectUtil.toString( 
StyleManager.getStyleDeclaration(".wdwTest").getStyle("icon")) );

var test:Class =
StyleManager.getStyleDeclaration(".wdwTest").getStyle("icon");
var bitmap:Bitmap = new test();

CSS (cursor_move is a resource I am using elsewhere in the app already):  
.wdwTest
{
icon: Embed(source="commonV5.1/skins.swf", symbol="cursor_move");
}

output:
(myskins2__embed_css_commonV5_1_skins_swf_cursor_move_2116628543)

Exception:

TypeError: Error #1034: Type Coercion failed: cannot convert 
myskins2__embed_css_commonV5_1_skins_swf_cursor_move_2116628543@366be041 to 
flash.display.Bitmap.


thanks!

--- In [email protected], Alex Harui  wrote:
>
> 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?
> 



Re: [flexcoders] Re: BitmapData from asset embedded in external stylesheet swf

2012-05-14 Thread Alex Harui
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"  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 [email protected]  , Alex 
Harui  wrote:
>
> What code works when it is in the "code swf"?
>
>
> On 5/11/12 8:43 PM, "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 [email protected]   
>  , "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


[flexcoders] Re: BitmapData from asset embedded in external stylesheet swf

2012-05-14 Thread flexwdw
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 [email protected], Alex Harui  wrote:
>
> What code works when it is in the "code swf"?
> 
> 
> On 5/11/12 8:43 PM, "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 [email protected]  , 
> "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
>



Re: [flexcoders] Re: BitmapData from asset embedded in external stylesheet swf

2012-05-14 Thread Alex Harui
What code works when it is in the “code swf”?


On 5/11/12 8:43 PM, "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 [email protected]  , 
"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


[flexcoders] Re: BitmapData from asset embedded in external stylesheet swf

2012-05-11 Thread flexwdw
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 [email protected], "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.
>