Ok, I believe this isn’t coded according to AS 3.0 “rules” but I’m just starting to learn this stuff so please have patience…
But, how can I in my moveForward function get the name/number of the current displaying image and let the user move forward without pulling down the thumbs? (Note that the Arrays are shortened in post for saving space)
Check it out: http://www.gregory.se/peter
Here’s the code;
import caurina.transitions.Tweener;
var thumbs:Array = ["thumbs/01.jpg", "thumbs/02.jpg", "thumbs/03.jpg", "thumbs/04.jpg", "thumbs/05.jpg", "thumbs/06.jpg", "thumbs/07.jpg", "thumbs/08.jpg", "thumbs/09.jpg", "thumbs/10.jpg"];
var images:Array = ["large/00.jpg", "large/01.jpg", "large/02.jpg", "large/03.jpg", "large/04.jpg", "large/05.jpg", "large/06.jpg", "large/07.jpg", "large/08.jpg", "large/09.jpg", "large/10.jpg"];
var thumbText:Array = ["text 1", "text 2", "text 3", "text 4", "text 5", "text 6", "text 7", "text 8", "text 9", "text 10""];
// PRELOADER
var preLoader:Sprite = new Sprite();
preLoader.graphics.beginFill(0xFF0000);
preLoader.graphics.drawRect(0, 0, 1, 10);
// TOOLBAR
// ButtonModes
rew_mc.buttonMode = true;
pause_mc.buttonMode = true;
play_mc.buttonMode = true;
ff_mc.buttonMode = true;
showThumbs_mc.buttonMode = true;
info_mc.buttonMode = true;
// Actions
showThumbs_mc.addEventListener(MouseEvent.CLICK, showThumbs);
var imageContainer:Loader = new Loader;
imageContainer.x = 0;
imageContainer.y = 33;
addChildAt(imageContainer, 0);
var thumbContainer:MovieClip = new MovieClip;
thumbContainer.x = 29;
thumbContainer.y = 33;
thumbContainer.buttonMode = true;
addChildAt(thumbContainer, 1);
var count:Number = 0;
function initHandler(event:Event):void {
if (count < thumbs.length-1) {
count ++;
startLoad(count);
}
}
function startLoad(itemNum:Number) {
var thumbRequest:URLRequest = new URLRequest(thumbs[itemNum]);
var imageRequest:URLRequest = new URLRequest(images[itemNum]);
var textRequest:URLRequest = new URLRequest(thumbText[itemNum]);
var thumbFormat:TextFormat = new TextFormat;
thumbFormat.font = "CstBerlinEast-Medium";
thumbFormat.size = 14;
thumbFormat.letterSpacing = 1;
thumbFormat.color = 0xFFFFFF;
var thumbInfo:TextField = new TextField;
thumbInfo.type = TextFieldType.DYNAMIC;
thumbInfo.antiAliasType = AntiAliasType.ADVANCED;
thumbInfo.embedFonts = true;
thumbInfo.mouseEnabled = false;
thumbInfo.background = true;
thumbInfo.backgroundColor = 0x000000;
thumbInfo.multiline = true;
thumbInfo.wordWrap = true;
thumbInfo.alpha = 0;
thumbInfo.width = 100;
thumbInfo.autoSize = "left";
var myLoader:Loader = new Loader;
var perRow:Number = 9;
var xspacing:Number = 105;
var yspacing:Number = 105;
var row:Number = Math.floor(count / perRow);
myLoader.alpha = 0;
myLoader.x = count * xspacing - (row * (perRow * xspacing))
myLoader.y = row * xspacing;
Tweener.addTween(myLoader, {alpha:.7, time:2});
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, initHandler);
myLoader.load(thumbRequest);
myLoader.addEventListener(MouseEvent.ROLL_OVER, onOver);
myLoader.addEventListener(MouseEvent.ROLL_OUT, onOut);
myLoader.addEventListener(MouseEvent.CLICK, onClick);
ff_mc.addEventListener(MouseEvent.CLICK, moveForward);
thumbContainer.addChild(myLoader);
function onClick (event:MouseEvent) {
preLoader.x = event.target.x;
preLoader.y = event.target.y;
imageContainer.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
imageContainer.contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);
Tweener.addTween(imageContainer, {alpha:0, time:.5, onComplete:function() { imageContainer.load(imageRequest); thumbContainer.addChild(preLoader); Tweener.addTween(thumbInfo, {y:event.target.y+10, time:.5}); }});
}
function onOver (event:MouseEvent):void {
Tweener.addTween(event.target, {alpha:1, time:.5});
thumbContainer.addChild(thumbInfo);
thumbInfo.x = event.target.x;
thumbInfo.y = event.target.y;
thumbInfo.text = (thumbText[itemNum]);
thumbInfo.setTextFormat(thumbFormat);
Tweener.addTween(thumbInfo, {alpha:1, time:.5});
var topPosition:uint = thumbContainer.numChildren - 1;
thumbContainer.setChildIndex(thumbInfo, topPosition);
}
function onOut (event:MouseEvent):void {
Tweener.addTween(event.target, {alpha:.75, time:.5});
Tweener.addTween(thumbInfo, {alpha:0, time:.5});
}
function moveForward (event:MouseEvent):void {
trace (event.target(images[itemNum]));
}
}
//FUNCTIONS
function showThumbs (event:MouseEvent):void {
Tweener.addTween(thumbContainer, {alpha:1, y:38, time:1});
startLoad(count);
}
function showImage (event:Event):void {
thumbContainer.removeChild(preLoader);
Tweener.addTween(imageContainer, { alpha:1, time:1 });
Tweener.addTween(thumbContainer, { y:-500, time:1 });
}
function loadProgress(event:ProgressEvent):void {
var progress:Number = Math.round((event.bytesLoaded / event.bytesTotal) * 100);
preLoader.scaleX = progress;
}
startLoad(count);