10 Replies Latest reply on May 9, 2010 12:29 PM by Zombiecook KochtVorWut

    load an Image then Fade it in

    Zombiecook KochtVorWut

      Hello,

      iam really new with flex ,I do this since 2 days.

      My problem is that i want to load an image and then fade it(the animation type is not important it could be a scale animation ,too).

      But when i test my Application,it does not fade in. What i have done wrong ?

       

      <?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" preloader="Pre" backgroundColor="#242424" currentState="Startseite">

       

          <fx:Script>
              <![CDATA[
                  import flash.events.*;
                 
                  public function LoadImg001(event:Event):void
                  {
                      Img001.load('Assets/Zugspitze.48.jpg');
                      Img001.addEventListener(Event.COMPLETE, GotoImg001State);
                  }
                 
                  public function GotoImg001State(event:Event):void {
                      currentState = 'Img001State';
                     
                  }
                  public function CadereImg001(event:MouseEvent):void {
                      currentState = 'Startseite';
                  }
                 
              ]]>
          </fx:Script>

         
          <s:states>
              <s:State name="Startseite" />
              <s:State name="Img001State"/>
          </s:states>

       

          <mx:Image autoLoad="false" id="Img001"/>
         
          <s:Button click="LoadImg001(event)" id="LoadImg001Button" horizontalCenter="0" verticalCenter="30" label="ImgIn" enabled.Img001State="false" />
          <s:Button click="CadereImg001(event)" id="CadereImg001Button" horizontalCenter="0" verticalCenter="0" label="ImgOut" enabled.Startseite="false" />
         
          <s:transitions>
              <s:Transition fromState="Startseite"  toState="Img001State" autoReverse="true" >
                  <s:Fade alphaFrom="0.0" alphaTo="1.0" target="{Img001}" duration="500" />
              </s:Transition>
              <s:Transition fromState="Img001State" toState="Startseite" autoReverse="true">
                  <s:Fade alphaFrom="1.0" alphaTo="0.0" target="{Img001}" duration="500" />
              </s:Transition>
          </s:transitions>   
      </s:Application>

       

      thank you very much for your help

       

      ps. sry for my english !