Jump to content
Search Community

Patterns of simple animations

Astraport test
Moderator Tag

Recommended Posts

Hi, everyone!

 

I want to add functionality to my photo gallery app (Air mobile) - different types of animation of the thumbs of the photos. Now I did like the code below. This is the simplest move left-right and top-bottom.

But I need more different patterns of animation y- the movement as a 3D carousel, spinning in a circle, orbiting, movement of the sun's rays and back, movement along the wave path etc.

I would be very grateful if you have a ready-made pieces of code for these and similar animations with help TweenLite lib.

 

[bindable] private var stageW:int = Capabilities.screenResolutionX;
[bindable] private var stageH:int = Capabilities.screenResolutionY;

private var itemsVector:Vector.<Image>=new Vector.<Image>();
private var xSpeedVector:Vector.<Number>=new Vector.<Number>();
private var ySpeedVector:Vector.<Number>=new Vector.<Number>();

stage.addEventListener(Event.ENTER_FRAME, update);

private function moveSetup():void {
for(var i:int = 0; i < FlexGlobals.topLevelApplication.objects.length; i++){
   if (FlexGlobals.topLevelApplication.objects[i] is Image){
       var item:Image=FlexGlobals.topLevelApplication.objects[i] as Image;
       item.x=Math.random()*stageW;
       item.y=Math.random()*stageH;
       var randomDirection:Number=Math.random()*2*Math.PI;
       this.addElement(item);
       itemsVector.push(item);
       xSpeedVector.push(2*Math.cos(randomDirection));
       ySpeedVector.push(2*Math.sin(randomDirection));
   }
}   
}

protected function update(event:Event):void {
   for(var i:uint=0;i<itemsVector.length;i++){
       itemsVector[i].x+=xSpeedVector[i];
       itemsVector[i].y+=ySpeedVector[i];
       if(itemsVector[i].x>stageW){
           itemsVector[i].x-=stageW;
       }
       if(itemsVector[i].x<0){
           itemsVector[i].x+=stageW;
       }
       if(itemsVector[i].y>stageH){
           itemsVector[i].y-=stageH;
       }
       if(itemsVector[i].y<0){
           itemsVector[i].y+=stageH;
       }
   }
}

.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...