ok ich antworte mir mal selber =), hab es geschaft hier der undokumentierte/optimierte Code:
ActionScript:
import mx.utils.Delegate;
var b = cont._width / 4;
var h = cont._height / 4;
var MovArr:Array = [];
bitmapDat = new flash.display.BitmapData (400, 300, true, 0x000000);
bitmapDat.draw (cont);
btn.addEventListener ("click", Delegate.create (this, clickHandler));
function clickHandler ()
{
setNewDraw (cont);
}
btn2.addEventListener ("click", Delegate.create (this, clickHandler2));
function clickHandler2 ()
{
setNewDraw (cont2);
}
btn3.addEventListener ("click", Delegate.create (this, mische));
function mische ()
{
for (var i = 0; i < _root.MovArr.length; i++)
{
_root.MovArr[i]._y = random (200);
_root.MovArr[i]._x = random (300);
}
}
setNewDraw (cont);
function setNewDraw (e)
{
bitmapDat = new flash.display.BitmapData (400, 300, true, 0x000000);
bitmapDat.draw (e);
for (var i = 0; i < 4; i++)
{
for (var j = 0; j < 4; j++)
{
if (!_root["container" + i + j])
{
_root.createEmptyMovieClip ("container" + i + j, this.getNextHighestDepth ());
_root["container" + i + j].createEmptyMovieClip ("conB", 1);
_root["container" + i + j]._x = (Stage.width / 2) - (_root.cont._width / 2);
_root["container" + i + j]._y = (Stage.height / 2) - (_root.cont._height / 2);
_root.MovArr.push (_root["container" + i + j]);
}
_root["bitmapData" + i + j] = new flash.display.BitmapData (400, 300, true, 0xCCCCCC);
_root["container" + i + j]["conB"].attachBitmap (_root["bitmapData" + i + j], 2);
var t = j * _root.b;
var z = i * _root.h;
rect = new flash.geom.Rectangle (t, z, _root.b, _root.h);
_root["bitmapData" + i + j].copyPixels (_root.bitmapDat, rect, rect);
_root["container" + i + j].createEmptyMovieClip ("mask", 2);
with (_root["container" + i + j]["mask"])
{
lineStyle (1, 0x000000, 100);
beginFill (0x000000, 100);
lineTo (0, 0);
lineTo (_root.b, 0);
lineTo (_root.b, _root.h);
lineTo (0, _root.h);
lineTo (0, 0);
endFill ();
_x = t;
_y = z;
}
_root["container" + i + j]["conB"].setMask (_root["container" + i + j]["mask"]);
_root["container" + i + j].onPress = function ()
{
this.startDrag ();
this.swapDepths (_root.getNextHighestDepth ());
};
_root["container" + i + j].onRelease = function ()
{
this.stopDrag ();
};
}
}
}
und was man damit machen kann könnt Ihr Euch
hier anschauen.