Hi there…
okay I just make a simple class for my drag and drop stuff thingy…actually it just more into for my learning process…I just able attach the target drop mc and the dragger mc using the class but the problem it is trace my array undefined …so where is my problem exactly…
here’s are my currently code…sorry for the messy code…
class AttachMc{
var __holder:MovieClip;
var __holder2:MovieClip;
var __total:Number;
var targetArray:Array;
function AttachMc(holdermc:MovieClip,holdermc2:MovieClip,Total:Number){
this.__holder = holdermc;
this.__holder2 = holdermc2;
this.__total = Total;
targetArray = new Array();
attachTarget.apply(this);
attachDragger.apply(this);
}
public function attachTarget():Void{
for(var i:Number=0;i<__total;i++){
var mctarget:MovieClip = this.__holder.attachMovie("box","box"+i,3+i);
mctarget._x = 50+mctarget._width*i;
mctarget._y = 100;
mctarget.labeltarget.text = "target"+i;
targetArray.push(mctarget);
}
}
public function attachDragger():Void{
for(var j:Number=0;j<__total;j++){
var mcdragger:MovieClip = this.__holder2.attachMovie("dragger","dragger"+j,6+j);
mcdragger._x = 50+mcdragger._width*j;
mcdragger._y = 250;
mcdragger.labeldragger.text = "dragger"+j;
mcdragger.jvar = j;
mcdragger.onPress = function(){
this.startDrag();
}
mcdragger.onRelease = mcdragger.onReleaseOutside = function(){
this.stopDrag();
//trace targetArray return undefined
trace(targetArray);//output undefined
//the ideas is try to browse the array for detecting droping area..
for(var k:Number=0;k<targetArray.length;k++){
if(this.hitTest(targetArray[k])){
trace("u just hit");
}
}
}
}
}
}
Hope someone will point me or give me some shed on light on it…
any help are appreciate…
Thanks