Log in

View Full Version : Needing help with movieclips



saltysally
11-01-2008, 09:29 PM
Using actionscript 2.0 in flash
Is their a way to be able to drag and drop one after another on top of each other(MC). I am wanting my script to have the user build an avatar. If their is another way please let me know I really could use some help.

stop();
var iconDepth:Number = 0;
var down:Boolean = false;
_root.onMouseDown =function(){
if (_root.canvas_mc.hitTest(_root._xmouse,_root._ymouse)){
var x:Number = _root._xmouse;
var y:Number = _root._ymouse;
_root.holder_mc.moveTo(x,y);
down = true;
}
};
_root.onMouseUp = function(){
down = false;
};
var currentColor:String = "F7E7D9";
_root.createEmptyMovieClip("holder_mc",100);
function draw() {
_root.holder_mc.lineStyle(0, parseInt(currentColor, 16), 100);
var x:Number = _root._xmouse;
var y:Number = _root._ymouse;
_root.holder_mc.lineTo(x, y);
}
_root.onMouseMove = function() {
updateAfterEvent();
if (down && _root.canvas_mc.hitTest(_root._xmouse, _root._ymouse)) {
draw();
}
};
window1_mc.gotoAndStop("color");
window2_mc.gotoAndStop("admin");
var topClip:MovieClip = window1_mc;
function swap(clip:MovieClip){
clip.swapDepths(topClip);
topClip = clip;
};

function buildIconList(){
var spacing:Number = 123;
var iconY:Number = 365;
var iconX:Number = 67;
for (var i = 0; i < _root.icon_mc._totalframes; ++i) {
var newName:String = "icon_mc" + i;
var clip:MovieClip = _root.icon_mc.duplicateMovieClip(newName, 10000 + i);
clip.gotoAndStop(i + 1);
clip._x = iconX + i * spacing;
clip._y = iconY;
clip.homeX = clip._x;
clip.homeY = clip._y;
clip.icon_btn.onPress = function(){
if (this._droptarget != "canvas_mc") {
startDrag(this._parent);
}
};
clip.icon_btn.onRelease = function(){
stopDrag();
_root.iconReleased(this._parent);
if(this._droptarget == "canvas_mc"){
setProperty(this,_x,60.1);
setProperty(this,_y,93.9);
} else {
setProperty(this,_x,50.5);
setProperty(this,_y,85.4);
};
}


}
on(release) {
stopDrag();
if (this._droptarget == "canvas_mc"){
setProperty(this,_x);
setProperty(this,_y);
} else {
setProperty(this,_x);
setProperty(this,_y);
}
}on(press) {
if (this._droptarget != "canvas_mc"){
startDrag(this);
}
}

buildIconList();
function iconReleased(icon:MovieClip){
if(_root.canvas_mc.hitTest(_root._xmouse, _root._ymouse)){
++iconDepth;
var newName:String = "object" + iconDepth + "_mc";
var clip:MovieClip = icon.duplicateMovieClip(newName,iconDepth);
clip.gotoAndStop(icon._currentFrame);
clip.icon_btn.enabled = false;
clip._xscale = 250;
clip._yscale = 250;
}
icon._x = icon.homeX;
icon._y = icon.homeY;
}

function clearContent() {
_root.holder_mc.clear();
for (var i = 0; i <= iconDepth; ++i) {
var name:String = "object" + i + "_mc";
_root[name].removeMovieClip();
}
iconDepth = 0;
}
next_mc.onRelease = function(){
gotoAndStop("head");

}

Medyman
11-02-2008, 05:32 PM
Perhaps this (http://www.actionscript.org/resources/articles/26/1/Drag-n-Drop-and-Drop-Targets/Page1.html).

saltysally
11-02-2008, 09:51 PM
Thank you for the help.