PDA

View Full Version : Can anyone help me


Delatory
02-05-2006, 06:39 PM
I've got this script :
this.drawobj.onPress = function() {
_root.createEmptyMovieClip("My_mc", 0);
My_mc.beginFill(0x3399FF, 100);
My_mc.lineTo(100, 0);
My_mc.lineTo(100, 100);
My_mc.lineTo(0, 100);
My_mc.lineTo(0, 0);
My_mc.endFill();
_root.My_mc.onPress = function() {
this.startDrag();
};
_root.My_mc.onRelease = function() {
this.stopDrag();
};
_root.drawobj.onPress = function() {
removeMovieClip("My_mc");
};
};

but when i press drawobj for the second time it removes the movieclip BUT when i press drawobj for the third time it wont make My_mc again. Any Help?
Thanks.

JDowzell
02-05-2006, 07:17 PM
Now i'm not very good with code, but could it be because you have used
this.drawobj.onPress = function() { as well as
_root.drawobj.onPress = function() {?

Now, if it were me, I would define a variable (only because I adore variables) and have it equal, i dunno, 1 on the first on press (and make all the code inside an if() statement), and on the on release make it equal to zero, and on the second press make it equal to one again, so were back to where we started.
If I explained that badly (as i sometimes do), heres what I mean:



QWERTY = 1;
this.drawobj.onPress = function() {
if(_root.QWERTY == 1){
_root.createEmptyMovieClip("My_mc", 0);
My_mc.beginFill(0x3399FF, 100);
My_mc.lineTo(100, 0);
My_mc.lineTo(100, 100);
My_mc.lineTo(0, 100);
My_mc.lineTo(0, 0);
My_mc.endFill();
}
_root.My_mc.onPress = function() {
this.startDrag();
};
_root.My_mc.onRelease = function() {
this.stopDrag();
_root.QWERTY = 0;
};
_root.drawobj.onPress = function() {
removeMovieClip("My_mc");
_root.QWERTY = 1;
};
};
Now, seeing as i am no good at AS it might not work, but i havent tried that so I dunno.
Hope that helped at all

Delatory
02-05-2006, 07:26 PM
Nope, that didnt work. is there anything you could add to if(drawobj=draw){
so once thats been clicked it'll go to the top of the scripting Frame?