Hi I’m trying to create an drag, duplicate and drop program in flash and as3 but I can’t get it to work, I have this as2 code that works perfect but for as2 any one have a tip on how to convert it or can give me a hand ?
stop();
// the press action for gifts to be picked up and dragged
function copyGiftForDrag(){
// create a copy to be dragged (name same as linkage identifier)
var position = {_x: this._x, _y: this._y};
var copy = this._parent.attachMovie(this._name, this._name, 1, position);
// drag the copy
copy.startDrag();
// define an action for when the mouse releases the copy
copy.onMouseUp = dropGift;
}
// the drop action for a gift that has been dragged
// assigned in copyGiftForDrag
function dropGift(){
// stop dragging copy
stopDrag();
// if the mouse is within the area of the dropareaCheck_mc clip
// dropareaAttach_mc shouldn’t be used since its size can change
// based on what clips are attached to it (which can make it bigger)
if (dropareaCheck_mc.hitTest(_root._xmouse, _root._ymouse)){
// attach the clip to the dropareaAttach_mc, using a transformed
// position to make sure it attaches in the same visual spot
var position = transformPosition(this, this._parent, dropareaAttach_mc);
dropareaAttach_mc.attachMovie(this._name, “gift”+dropareaAttach_mc.depth, dropareaAttach_mc.depth, position);
dropareaAttach_mc.depth++; // increase depth for next drag and drop
}
this.removeMovieClip();
}
// transform a position (_x and _y) from one movie clip
// to another marking a similar location on the screen
// used in dropGift
function transformPosition(position, from_mc, to_mc){
// use localToGlobal and globalToLocal to transform the
// position/point from one timeline to another
var point = {x:position._x, y:position._y};
from_mc.localToGlobal(point);
to_mc.globalToLocal(point);
position = {_x:point.x, _y:point.y};
return position;
}
/*******************/
// set a variable to keep drack of depths for
// dropareaAttach_mc which is where gifts are attached
dropareaAttach_mc.depth = 0;
// assign onPress functions for gifts in menu_mc clip
// the instance names of these clips need to be the same
// as their linkage ID’s so that copies can be created
// for the drag and drop operations
menu_mc.giftgreen.onPress = copyGiftForDrag;
menu_mc.giftblue.onPress = copyGiftForDrag;
menu_mc.giftred.onPress = copyGiftForDrag;