I need some help learning how to keep track of my movieClips and set boundries for them once I add them to the stage. In the code below I can add movieClips to my stage add senoculars freeTransform movieClip prototype. I also trace which movieClip I am clicking on but I get stuck after this. I need to control the drag boundries.
I can set the boundries if I use a simple startDrag and stopDrag in my onPress and onRelease functions, but once the prototype is added I can’t use the onRelease function. How do I set the boundries in this case?
_global.count = 0;
_global.pX = 0;
_global.pY = 0;
function newPiece() {
// create a movieclip to hold the functionality of the peice of furniture
// keep all the furniture inside 1 clip (called 'pieceContainer') for organizational purposes
// use this with this.drag
// var item_mc:MovieClip = pieceContainer.createEmptyMovieClip("item_mc"+count, count, this.getNextHighestDepth());
// use this with prototype
var item_mc:MovieClip = pieceContainer.createEmptyMovieClip("item_mc"+count, this.getNextHighestDepth());
// create a container to load the furniture swf into
var container:MovieClip = item_mc.createEmptyMovieClip("container_mc", 0);
// setup a MCL to handle the swf's loading
item_mc.mcl = new MovieClipLoader();
item_mc.mcl.addListener(mclListener_2);
item_mc.mcl.loadClip("decals/"+this.piece+".swf", container);
count++;
//add value of width and depth to text box
item_w.text = j;
item_h.text = k;
}
//
var mclListener_2:Object = new Object();
mclListener_2.onLoadInit = function(obj_mc:MovieClip) {
// set variables to remember the original dimensions
_global.axw = obj_mc._width;
_global.axh = obj_mc._height;
// center piece
obj_mc._y = -(axh/2);
obj_mc._x = -(axw/2);
//
pieceContainer._x = floor._x+(wide/2);
pieceContainer._y = floor._y+(high/2);
// set drag boundries
left = -(wide/2)+axw/2;
top = -(high/2)+axh/2;
right = (wide/2)-axw/2;
bottom = (high/2)-axh/2;
// set variable to note the starting positions
var startX = obj_mc._x;
var startY = obj_mc._y;
trace("startX "+startX);
trace("startY "+startY);
//
obj_mc._parent.onPress = function() {
this.addFreeTransform();
//this.startDrag(false, left, top, right, bottom);
trace(this);
//this.attachMovie("rotate_mc", "rotator", this.getNextHighestDepth(), {_x:25, _y:-50});
};
/*
obj_mc._parent.onRelease = function() {
stopDrag();
//delete this.onPress;
//this.removeFreeTransform();
//trace("test");
};
*/
//
};