2 Replies Latest reply on Aug 10, 2011 10:22 AM by aligned2009

    Image doesn't render when original replaced

    aligned2009 Level 1

      I know that if I create an image and add it, it renders, but why when I replace an image that exists, why does it not render?

       

      <?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" minWidth="955" minHeight="600" creationComplete="init()">

      <fx:Declarations>

      <!-- Place non-visual elements (e.g., services, value objects) here -->

      </fx:Declarations>

      <fx:Script>

      <![CDATA[

      private function init():void{

      works.source="images/logo.gif";

      }

       

      private function renderImage(event:Event):void{

      var i:Image=new Image;

      i.source="images/logo.gif";

      doesnt=i;

      //doesnt.validateNow(); //this uncommented does not work either

      }

      ]]>

      </fx:Script>

      <s:VGroup id="images">

      <s:Button click="{renderImage(event)}" label="Image"/>

      <s:Image id="works"/>

      <s:Image id="doesnt"/>

      </s:VGroup>

      </s:Application>