打破它,你首先需要加載您的圖像無論是從AA自包含裝載機,或給用戶的選擇,選擇有文件:
var holder = new movieClip;
Addchild(holder)
var file:FileReference;
var fileLoader:Loader;
function start()
{
loadImageBtn.addEventListener(MouseEvent.CLICK, showDialog);
}
start();
function showDialog(event:MouseEvent):void
{
file = new FileReference();
var imageFileTypes:FileFilter = new FileFilter("Images (*.png; ","*.png;");
file.browse([imageFileTypes]);
file.addEventListener(Event.SELECT, selectFile);
}
function selectFile(e:Event):void
{
file.addEventListener(Event.COMPLETE, loadFile);
file.load();
}
function loadFile(e:Event):void
{
fileLoader = new Loader();
fileLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, displayImage);
fileLoader.loadBytes(file.data);
}
function displayImage(e:Event):void
{
holder.addChild(fileLoader);
}
這時你會:由用戶 負載圖像需要能夠對周圍的內容移動:
var maxY:Number = 0;
var minY:Number = Math.min(0,stage.stageHeight - holder.height - 300);
var _startY:Number;
var _startMouseY:Number;
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void
{
_startY = holder.y;
_startMouseY = mouseY;
stage.addEventListener(MouseEvent.MOUSE_MOVE, stage_mouseMoveHandler, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, stage_mouseUpHandler, false, 0, true);
}
function stage_mouseMoveHandler(event:MouseEvent):void
{
var offsetY:Number = mouseY - _startMouseY;
holder.y = Math.max(Math.min(maxY,_startY + offsetY),minY);
}
function stage_mouseUpHandler(event:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, stage_mouseMoveHandler);
stage.removeEventListener(MouseEvent.MOUSE_UP, stage_mouseUpHandler);
}
如果你想要幾個圖像,我想你會,你可以通過他們識字,每個圖像推到一個數組存儲,並把每一個項目像一個網格
鍵入模式或在列中按自己的身高或寬度拼圖。
var array()
for (i = 0; i <items; i++)
{
items.x = 170+ i * (item.width + 1);
//you can add child
}
一個更好的選擇可能是對每個statment,使用數組或XML抓住每個object..hope它有助於