PDA

View Full Version : changing images


lakor03
07-24-2009, 09:43 PM
Hi all

I'm working on a little game and would love to have a new image as background on each "new level" screen (50 total).

Right now I have the same background image on each level like this:


<mx:State name="NextLevel">
<mx:AddChild relativeTo="{myPlayArea}" position="lastChild">
<mx:Image x="0" y="0" width="242" height="484" id="levelImage" source="{imgCls}" mask="{maskCanvas}"/>
</mx:AddChild>
</mx:State>

<mx:Script>

<![CDATA[

[Embed(source="../assets/Bane1.jpg")]
[Bindable]
public var imgCls:Class;



But I would like to change the image for each level, how is that done smart? Should I create multible instances each embedding a new source? -how would that look like? or are there easier tricks?

Thanks for the help

KristopherWindsor
07-25-2009, 08:20 AM
Why not just change the image source (in a line of ActionScript) to change the image?

lakor03
07-25-2009, 11:05 AM
hmm yeah - but it seems I have done A more fundamental error:

Why doesn't this work:

<mx:State name="MainMenu">
<mx:AddChild relativeTo="{myPlayArea}" position="lastChild">
<mx:Image x="0" y="0" width="242" height="484" id="firstImage" source="../assets/Bane1.jpg"/>
</mx:AddChild>
</mx:State>

I only get an "broken link" icon where the image should be?