Actionscript Code:
// ******* Variables I have added :: ////
myTimer = null;
var counter = null;
var roll = null;
// ******* Time Delays :: /////
myTimer = setInterval( function(){ scrollIcons(1);}, 6000 );
//••••••••••••••••••••••••••••••••••••
// ******* importing other classes :: ////
import caurina.transitions.Tweener;
// Initialization methods
//-----------------------------------------------------------------------------------
this.init = function():Void {
// Initializes the movieclip
// Properties
this.icons = [this.mk302wx1, this.dytp8640, this.ot3866, this.Hammer, this.ro34788, this.apt8710,this.flkrld2, this.ot3825j, this.gwr85599, this.gwr85597, this.mc55500uv, this.lxt311hx1, this.mc98661, this.ir1207max, this.apt3018p, this.bsl130];
this.iconNames = ["MK LCT302WX1", "DY TP-8640CS", "OT 3866", "IR 2015MAX","RO 34788", "APT 8710", "FLK RLD2", "OT 3825J","GWR 85599", "GWR 85597","MC 55500UV", "MK LXT311HX1", "MC 98661-PRO", "IR 1207MAX-D3", "APT 3018P", "BSL 130221SE" ];
this.currentIcon = 3;
// Finally, redraws
this.redraw(true);
this.stop();
};
// Execution methods
//-----------------------------------------------------------------------------------
this.redraw = function(p_immediate:Boolean) {
// Redraws every item on their new position
var i:Number;
var scaleSmall:Number = 0.3; // Scale when not focused
var scaleBig:Number = 1; // Scale when focused
var baseX:Number = 340; // Base column for focused position
var baseY:Number = 160; // Base row for all icons
var iconDistance:Number = 130;
var iconDistanceFocused:Number = 220;
var animationTime:Number = p_immediate ? 0 : 0.5;
var animationType:String = "easeoutCirc";
// Redraw: icons
// Set correct scale
for (i = 0; i < this.icons.length; i++) {
var distance:Number = this.currentIcon - i;
var itemScale:Number = Math.abs(distance) > 1 ? scaleSmall : ((1-Math.abs(distance)) * (scaleBig-scaleSmall)) + scaleSmall;
var itemX:Number = baseX + (distance * -iconDistance);
if (distance != 0) {
itemX += (iconDistanceFocused - iconDistance) * (distance > 0 ? -1 : +1);
}
Tweener.addTween(this.icons[i], {_x:itemX, _xscale:100 * itemScale, _yscale:100 * itemScale, time:animationTime, transition:animationType});
this.icons[i]._y = baseY;
if (animationTime > 0) {
// Apply a motion blur depending on the ammount of pixels the object has to be moved
var ammountToBlur:Number = Math.abs(this.icons[i]._x - itemX) / 12;
Tweener.addTween(this.icons[i], {_blur_blurX:ammountToBlur, _blur_quality:2, time:animationTime/2, transition:"easeOutQuint"});
Tweener.addTween(this.icons[i], {_blur_blurX:0, time:animationTime/2, delay:animationTime/2, transition:"easeOutQuad"});
}
}
//••••••••••••••••••••••••••••••••••••••
// Redraw: text
this.caption.text = this.iconNames[this.currentIcon];}
var goLeft = true;
this.scrollIcons = function(p_offset:Number) {
if (goLeft = true) {
this.icons.push(this.icons.shift());
this.icons[this.icons.length-1]._x = Stage.width;
} else {
this.icons.unshift(this.icons.pop());
this.icons[0]._x = 0-this.icons[0]._width;
}
this.redraw(false);
};
btnLeft.onPress = function() {
goLeft = true;
};
btnRight.onPress = function() {
goLeft = false;
};
//••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
// Finally Setting the Correct Icon (SET ICON FUNCTION)
this.setIcon = function(p_icon:Number) {
// Set the currently selected icon
if (p_icon != undefined) {
if (p_icon < 0) p_icon = 0;
if (p_icon > this.icons.length - 1) p_icon = this.icons.length - 1;
if (p_icon != this.currentIcon) {
this.currentIcon = p_icon;
this.redraw(false);}}};
==============================
// End
//-----------------------------------------------------------------------------------
this.init();