I used style.getStyle("icon") to look at the object, and it was just
the string representation from the stylesheet (@Embed(...)). Obviously
when the button style was set with this value from the module, it's
not going to find the image.

I've ditched the idea of using a stylesheet file and have defined all
the styles manually in actionscript. That way it works when embedding
images.

Thanks,

Mark

--- In flexcoders@yahoogroups.com, Alex Harui <[EMAIL PROTECTED]> wrote:
>
> It might just be that the module doesn't get loaded until after the
button sets up its styles.  I don't know if it will pick up the fact
that the styles showed up later.
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]
On Behalf Of skuteboarding
> Sent: Sunday, November 23, 2008 6:07 AM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Can an embedded image in a module be used by
the main application?
> 
> 
> I'm trying to load an image from a stylesheet in a module, then use
> that style declaration in the main application. It doesn't seem to
> work, but wondered if there is something special I need to do to get
> it to work?
> 
> I have the following in my stylesheet in my module:
> 
> .sun
> {
> icon: "@Embed(source='../assets/Background/Sun.png')";
> }
> 
> Then in my module I have a function like:
> 
> public function getSunStyle():CSSStyleDeclaration
> {
> return StyleManager.getStyleDeclaration(".sun");
> }
> 
> I've checked the return value here and it does exist (I've also
> checked it with simple things like background colours etc).
> 
> Now, in my main application, I take that return value and do this:
> 
> var sun:CSSStyleDeclaration = module.getSunStyle;
> if (gui.controlPanelBackgroundStyle != null)
> {
> StyleManager.setStyleDeclaration(".sun", sun, true);
> }
> 
> And I have a button (in the main app) defined as:
> 
> <mx:Button x="10" y="10" label="Button" styleName=".sun"/>
> 
> Is it possible to achieve what I'm trying to do?
>


Reply via email to