Actionscript:
-
var thumbNum:Number = 20;
-
var spacing:Number = 10;
-
var thumbs:MovieClip = new MovieClip();
-
addChild(thumbs);
-
for (var i:int = 0; i<thumbNum; i++){
-
var t:MovieClip = new MovieClip();
-
with(t.graphics) beginFill(0x666666), drawRect(0,0,100,50);
-
t.x = i * (t.width + spacing);
-
t.y = 5;
-
t.buttonMode = true;
-
thumbs.addChild(t);
-
}
-
var minX:Number = stage.stageWidth - thumbs.width - spacing;
-
var destX:Number = thumbs.x = spacing;
-
var velX:Number = 10;
-
var stageThird:Number = stage.stageWidth / 3;
-
var right:Number = stageThird * 2;
-
var left:Number = stageThird;
-
addEventListener(Event.ENTER_FRAME, onLoop);
-
function onLoop(evt:Event):void {
-
if (mouseX> right){
-
destX -= velX;
-
}
-
if (mouseX <left){
-
destX += velX;
-
}
-
if (destX <minX){
-
destX = minX;
-
}
-
if (destX> spacing){
-
destX = spacing;
-
}
-
thumbs.x += (destX - thumbs.x) /4;
-
}
This snippet shows a technique for a common type of navigation.