1 Reply Latest reply on May 24, 2010 7:23 PM by David_F57

    How to change the backgroundImage of a borderContainer?

    storm767

      Hi,

       

      I know how to do it by embedding the image, but haven't found a way to change it dynamically. I want to be able to use an image hosted on a web server.

       

      any ideas?

       

      tks.

        • 1. Re: How to change the backgroundImage of a borderContainer?
          David_F57 Level 5

          hi,

           

          this should help you

           

          David.

           

          <?xml version="1.0" encoding="utf-8"?>

          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

             xmlns:s="library://ns.adobe.com/flex/spark"

             xmlns:mx="library://ns.adobe.com/flex/mx"

             xmlns:fl="flash.net.*" minWidth="955" minHeight="600" creationComplete="application1_creationCompleteHandler(event)">

           

          <fx:Script>

          <![CDATA[

          import mx.events.FlexEvent;

           

          private var ldr:Loader = new Loader();

           

          protected function application1_creationCompleteHandler(event:FlexEvent):void

          {

          ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);

          ldr.load(new URLRequest("assets/Koala.jpg"));

          }

           

          private function onComplete(event:Event):void

          {

          bc.setStyle("backgroundImage",ldr.content);

          }

           

          ]]>

          </fx:Script>

          <s:BorderContainer id="bc" x="379" y="188" width="337" height="355" backgroundImageFillMode="scale">

          </s:BorderContainer>

          </s:Application>