PDA

View Full Version : Deleting Functions


piratefish
11-06-2005, 11:29 PM
So I'm trying to figure out how to use "Delete" in MX. I'm trying to delete a function called this.onEnterFrame. I believe I've seen delete used this way before, but i'm not sure. Here's my AS.

this.onEnterFrame = function() {
_root.guy2_mc._x += 5;
if (_root.guy2_mc._x>=550) {
setProperty(_root.guy2_mc, _x, 20);
}
};

_root.rock_btn.onRelease = function() {
_root.guy2_mc.gotoAndPlay("rock");
delete this.onEnterFrame;
setProperty(_root.guy2_mc, _x, 25);
};

The second code snippet is where the first bit of code is removed. I'm obviously not doing it correctly or I wouldn't be asking here. Can anyone help me out with how to delete/stop a function from continuing?

senocular
11-07-2005, 12:05 AM
where is the onEnterFrame defined? Its that you need to delete it. 'this' in _root.rock_btn.onRelease is _root.rock_btn. Is that where the onEnterFrame is defined? If not, it wont work.

piratefish
11-07-2005, 12:38 AM
The onEnterFrame is defined in the first snippet (or so I believe). So I'll try making it a variable or an object. We'll see which one works. Thanks for the tip.

piratefish
11-07-2005, 01:37 AM
I did a bit of a workaround and opted out of using "Delete". But I'd like to get to know this and because the title is such a general title for delete, perhaps someone has some sort of link or tutorial that could lead us in the right direction.