Salve a tutti.
Sto usando duplicateMovieClip per clonare n oggetti con drag and drop. Ho incontrato dei problemi e quindi ho creato un file semplificato del mio progetto i cui ho lasciato solo l'operazione di cloning, con il suo bug.
Ho, per esempio, 4 movieclip (che chiamo obj1, obj2, obj3 e obj4) che possono essere duplicati, come vorrei, all'infinito.
Provo però a descrivere il bug con un esempio: se faccio una copia di obj1 e poi una copia di obj2 quest'ultima distruggerà la copia di obj1 che ho creato.
Vi posto qui sotto l'swf dell'esempio a questo link.
http://www.nopetshop.com/test/
ed ecco il codice:
Ed ecco il fla:Codice PHP:
/*CLONER*/
function cloner(){
this.onPress = function() {
var buttonID:MovieClip;
buttonID = this.duplicateMovieClip(this._name+"-"+this.num+"_mc", this.num++);
buttonID.startDrag();
_root.selected_mc=this._name+"-"+this.num+"_mc";
buttonID.onPress = function() {
this.startDrag();
_root.selected_mc=this._name;
}
buttonID.onRelease = buttonID.onReleaseOutside=function () {
this.stopDrag();
trace("Name:"+this._name);
}
}
this.onRelease = this.onReleaseOutside = function () {
this.stopDrag();
trace("Name:"+this._name);
}
}
for (i=1; i<5; i++) {
_root["obj" + i].onEnterFrame = cloner;
_root["obj" + i].num=0;
}
http://www.nopetshop.com/test/cloner.zip
Sapete aiutarmia capire perchè succede?