1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
package{
import flash.display.*;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.*;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.net.URLRequest;
public class Viewer extends MovieClip{
public var yPos = 40;
public function Viewer(){
loadImages();
addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
}
public function addImage(event:Event):void {
event.target.loader.y = yPos;
trace(event.target.loader.width,_vc.width);
_vc.addChild(event.target.loader);
yPos += event.target.loader.height + 40;
}
public function loadImages():void{
var i = 0;
var loader:Loader;
var request:URLRequest;
while(i< 24){
request = new URLRequest("content/warm/im"+i+".jpg");
loader = new Loader();
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, addImage);
loader.load(request);
i++;
}
}
public function ioErrorHandler(event:IOErrorEvent):void {
trace("Unable to load image");
}
public function mouseMoveHandler(event:MouseEvent):void{
if(_scrollBar.DRAG){
_vc.y = -_scrollBar._bar.y*_vc.height/(_scrollBar.height - _scrollBar._bar.height);
}
}
}
} |
Partager