Error in code, please help

[font=Arial]this.onPress = function(){
if(this._name == “myClip”){
counter++;
this.duplicateMovieClip(“myClip” + counter, counter);
}else{
this.startDrag();
}
}
this.onRelease = function(){
stopDrag();
}[/font]

I get two errors:

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 1: Statement must appear within on/onClipEvent handler
this.onPress = function(){
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 9: Statement must appear within on/onClipEvent handler
this.onRelease = function(){

Anyone know what I might be doing wrong? I’m placing the code on the symbol-movie that I want to duplicate and haven’t added any other script

i suppose you have this code on a movieclip, so you have to use onClipEvent, something like this

onClipEvent (enterframe){
this.onPress = function(){
if(this._name == "myClip"){
counter++;
this.duplicateMovieClip("myClip" + counter, counter);
}else{
this.startDrag();
}
}
this.onRelease = function(){
stopDrag();
}
}

Thank you so much

No problem :slight_smile:

I got it working just if you click on the square, i tried something with Key.isDown to use the del key but it won’t work, so here’s the code

onClipEvent (load){
this.onPress = function(){
if(this._name == "myClip"){
counter++;
this.duplicateMovieClip("myClip" +counter, counter);
trace("myClip"+counter)}else{
this.startDrag();
this.onPress=function(){
	this.removeMovieClip()
}
}
}
this.onRelease = function(){
stopDrag();
}
}

UBIK >> There’s no point using dynamic event handlers if you’re going to put them inside static event handlers :slight_smile:

eeh,so what would it look like? still trying to learn this d*mn language :ne:

You could either write directly on the clip on(press) {…} or put the clip.onPress = function () {…} declaration in the main timeline :slight_smile:

http://www.kirupa.com/developer/actionscript/tricks/dynamicevent.htm

haha, yeh the code posted above seems a little redundant.

You could either write directly on the clip on(press) {…} or put the clip.onPress = function () {…} declaration in the main timeline

ok, i understand ! et merde…[SIZE=1](juste pour le plaisir, i can put bad words in french, it won’t filter :P) [/SIZE] my english understanding isn’t that good :beam:
Thanks