2
votes

I am currently using flex transition effects on state change. Is there a way I can use tweenmax library for that?

Update:

In the code below, I have transitions from state one to state two. I would like to replace that code tweenermax library.

<?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"
           currentState="NORMAL">
<s:states>
    <s:State name="NORMAL" />
    <s:State name="CLICKED" />
</s:states>
<fx:Script>
    <![CDATA[
        import com.greensock.TweenMax;

        public function init():void
        {
            currentState = "CLICKED";
            TweenMax.to(topbar, 10, {x:0, startAt:{x:-500}});
        }
    ]]>
</fx:Script>

<s:layout>
    <s:VerticalLayout paddingTop="5" paddingLeft="5" paddingRight="5"/>
</s:layout>

<s:BorderContainer id="topbar" height="30" width="100%" includeIn="CLICKED" >
    <s:backgroundFill> 
        <s:SolidColor 
            color="#292929" 
            alpha="1"/> 
    </s:backgroundFill> 

</s:BorderContainer>

<s:HGroup id="hg">
    <s:TextInput  />
</s:HGroup>
<s:Button click="init()" label="Click" />
</s:Application>
1
You need to be more specific. Give an example of what you are doing now. Show some code. - Scott
Did my examples help out? You can accept the answer if so. - Scott
i wasn't successful, i dont know what am i doing wrong. Updated code added! - Nish

1 Answers

0
votes

There are a few things you can do if you don't like your mxml getting too ugly. First you can just do everything in actionscript as is shown here. As you mentioned, TweenLite is another option. To accomplish a fade affect in TweenLite, you can just choose a beginning alpha and ending alpha so that the object transitions from opaque to transparent.

Check out the interactive demo here. Set the alpha to 0 and run the tween and you should see it fade away. Just remember that even when you fade something away it is still in memory and still being rendered. Make sure to remove if it takes up a reasonable amount of memory and you don't need it anymore.