7 Replies Latest reply on Dec 1, 2011 10:19 AM by Flex harUI

    Setting bordercontainer backgroundimage from inside component


      For my flex project I am making, I'm trying to change the background of my website change to the image I have clicked on. The background in my main page I have set like this:


          <s:BorderContainer id="backgroundContainer" width="100%" height="100%" backgroundImage="@Embed('assets/background.png')" borderAlpha="0">
                      <s:VerticalLayout horizontalAlign="center"/>
              <mx:LinkBar styleName="mainnav" width="600" dataProvider="content" horizontalCenter="0" paddingLeft="20" paddingTop="125"/>
              <s:Image top="5" bottom="5" horizontalCenter="50" source="assets/nav.png"/>
              <mx:ViewStack id="content">
                  <mx:HBox id="home"
                  <mx:HBox id="bio"
                  <mx:HBox id="portfolio"
                  <mx:HBox id="contact"

      Now from inside my component, I am trying to set the the background of the image you click on.



                  import mx.core.Application;
              public function changeBackground(event:MouseEvent):void
                  Application.application.backgroundContainer.setStyle('backgroundImage', img1.source);

      I call this function when you click on an image.



      <mx:Image id="img1" source="assets/placeholder.jpg" click="changeBackground(event)"/>


      But it doesn't work.

      So I was wondering how this should be done?


      Thank you,