Swapping out stuff at runtime involves getting a handle on a compatible
asset... like:
[Embed("another_image.png")]
private var foo:Class;
The exchange would be something like:
this.setStyle( "backgroundImage", foo ); // where this¹ is your Application
context
The key is getting familiar with the BitmapAsset class. Copy and paste this
code and swap the image names as needed.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
minWidth="1024" minHeight="768">
<mx:Style>
Application {
background-image: Embed("original_image.png");
}
</mx:Style>
<mx:Script>
<![CDATA[
[Embed("another_image.png")]
private var foo:Class;
private function doExchange():void
{
this.setStyle( "backgroundImage", foo );
}
]]>
</mx:Script>
<mx:Button x="10" y="10" label="exchange asset" width="140" height="43"
click="doExchange()"/>
</mx:Application>
Cheers,
Rick Winscot
www.quilix.com
On 10/14/09 7:27 PM, "[p e r c e p t i c o n]" <[email protected]>
wrote:
>
>
>
>
> Hi all,
>
> in my css i set the background image like this..
>
> background-image: Embed('somedirectory/someimagefile.png');
>
> however...there's no way to scale it or change it's width so i'm wondering how
> i can swap it with another image while the app is running..
>
> thanks
>
> percy