Skip to main content
Inspiring
April 10, 2013
Answered

delete myCountDown.onEnterFrame

  • April 10, 2013
  • 1 reply
  • 847 views

How do I delete the onEnterframe. This is my code:

function myCountDown(){

//do something

}

RecLoad.onData = function(src) {

if (condition == true) {

_root.onEnterFrame = myCountDown; // works fine

}

}

Clear_btn.onRelease = function () {

delete myCountDown.onEnterFrame;  //does not respond

}

This topic has been closed for replies.
Correct answer kglad

use:

function myCountDown(){

//do something

}

RecLoad.onData = function(src) {

if (condition == true) {

_root.onEnterFrame = myCountDown; // works fine

}

}

Clear_btn.onRelease = function () {

delete _root.onEnterFrame;

}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
April 10, 2013

use:

function myCountDown(){

//do something

}

RecLoad.onData = function(src) {

if (condition == true) {

_root.onEnterFrame = myCountDown; // works fine

}

}

Clear_btn.onRelease = function () {

delete _root.onEnterFrame;

}

Inspiring
April 10, 2013

Thanks Kglad.

Will that affect if there are more onEnterFrame functions running?

kglad
Community Expert
Community Expert
April 10, 2013

you can only have, at most, one onEnterFrame per movieclip in as2.  so, if you used:

_root.onEnterFrame=f1;

_root.onEnterFrame=f2;

only the last executed one (calling f2 repeatedly) will exist.  the first (calling f1 repeatedly) is overwritten and replaced.