DuplicateMovieClip og StartDrag
Hej EksperterJeg står med et problem: jeg har 15 MC, som jeg alle giver en onPress function gennem et for-loop. Function skal, når brugeren klikker på ét af de 15 MC kopiere dette MC og drag'e denne kopi ud på scenen. Denne function skal så igen tildeles det nye MC, så brugeren kan gentage processen. indtil videre har jeg denne kode, men den virker langt fra efter hensigten .. Kan I hjælpe?
classHeight_int = class_mc_1._height + 5;
for(var i:Number = 0; i < classAmount_int; i++){
this["class_mc_" + i]._y = (classHeight_int * (i+1)) + scrollPositionX;
this["class_mc_" + i]._x = scrollPositionY;
this["class_mc_" + i].onPress = function(){
duplicateThis = this._name.substr(9)
attachMovie("class_mc_" + duplicateThis, "new_mc" + duplicateThis , _root.getNextHighestDepth())
trace(["class_mc_" + duplicateThis])
_root["new_mc" + duplicateThis]._x = this._x
_root["new_mc" + duplicateThis]._y = this._y
trace(" X : " + _root["new_mc" + duplicateThis]._x)
["class_mc_" + duplicateThis]._x = 10
startDrag(["class_mc_" + duplicateThis]);
}
this["class_mc_" + i].onRelease = function(){
stopDrag();
}
}
