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;
}
}
}
.