Animate a layer with Tween option

  • Hi,

    I'd like to add a little animation to a layer. The animation will be very simple, just a scale and scale.

    I'd liket o use Tween option, but is doesn't work.

    Someone can help me to add the Tween option to a layer ?

    Thanks.

  • Here is my code :

    Code
    <layer name="glaceannou" url="images/glaceannou.png" align="topleft" x="10" y="10" style="tooltip" tooltip="Intégrez votre Mascotte" keep="true" onclick="flyin(zoom-mascotte);"  onlaoded="execute(beat-spots)"  />	
    		
    <action name="beat-spots">
    tween(layer[glaceannou].scale,1.0,0.5,default);
    </action>

    I'd like to scale and unscale the layer with a delay and in loop mode ....

  • i think that you are not calling action correct:

    First you have 'onlaoded' instead 'onloaded'

    Second:
    If action name is 'beat-spots', the correct way to call that is (without 'execute'):

    Code
    onloaded="beat-spots();"

    BTW, i would avoid character like '-' in the name of action

  • ok here is my code now :

    Code
    <layer name="glaceannou" url="images/glaceannou.png" align="topleft" x="10" y="10" onclick="flyin(zoom-mascotte);" onloaded="beatspots();"  />	
    		
    <action name="beatspots">
    tween(layer[glaceannou].scale,1.0,0.5,default);
    </action>


    But nothing change .... *cry*

  • Hi Shura,

    Thanks for example but it doesn't work.

    Here is my code :

    Code
    <layer name="glaceannou2" url="images/glaceannou.png" align="middle" x="10" y="10" scale="1.0" onclick="flyin(zoom-mascotte);" onloaded="beatspots();"  onover="tween(alpha,0.5);" onout="tween(alpha,1.0);"
    />	
    
    
    		<action name="beatspots">
    		tween(layer[glaceannou2].alpha,0.5,1.0);<!-- 0.5 - target scale, 2 - time -->
    		</action>

    Here the OnOver and OnOut effect are working fine. No probleme.

    But the OnLaod action don't work ... *huh*

  • Ok I'v got it :

    Here is my code :

    The onstart was missing that's why the animation couldn't work.

    Now how can I use the Loop Mode ?

  • So here is th esolution for Loop Mode :

    Code
    <action name="beatspotsOn">
    delayedcall(5.0,tween(layer[glaceannou].scale, 1.2, 0.5, default, tween(layer[glaceannou].scale, 1, 0.5, default, beatspotsOn() ) ));
    </action>
    		
    <layer name="glaceannou" url="images/glaceannou.png" align="topleft" x="10" y="10"  tooltip="Intégrez votre Mascotte" keep="true" onclick="flyin(zoom-mascotte);" onover="tween(alpha,0.5);" onout="tween(alpha,1.0);"  />

    The layer animation will start after 5 secondes.

    The layer is scalling from 100% to 120% for 1seconde, then the layer is scalling down from 120% to 100% for 1seconde.

    The animation is looping !!! *tongue*

    Hope it could help some of you ! *wink*

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!