Hi Coders,

      In following code, I am creating a new dynamic movie clip (in
function N1 of script object) and associating the handler for unload
event. Next I am deleting the same movie clip in function N3 of script
object. But if we are calling the function N3 through setInterval
function, movieclip unload event is not called.

Now if we are calling the same function N3 directly without setInterval,
unload event will be called.

Someone please tell me what is happening here?

 

script = new Object();

Delay = new Object();

 

// Delay Object

Delay.delay = function(obj, func)

{

      this.mObj = obj;

      this.mFunc = func;

      // Calling function after an interval of 2 seconds.

      setInterval(this.func, 2000, this);

}

 

Delay.func = function(obj)

{

      var temp = obj;

      // Calling function N3 of class script.

      temp.mObj[temp.mFunc]();

}

 

// Script Object

script.N1 = function()

{

      // Creating a new movie clip.

      _root.createEmptyMovieClip("Dhiraj", 1);

 

// Associating unload event with it.

      _root.Dhiraj.onUnload = function()

      {

            trace("Dhiraj Unload");

      }

 

      // Storing the movie clip instance in member variable.

      this.mMC = _root.Dhiraj;

 

      // Calling next function of script.

      this.N2();

}

 

script.N2 = function() 

{

// Calling N3 after some delay.

      Delay.delay(this, "N3");

}

 

script.N3 = function()

{

      this.mMC.removeMovieClip();

}

 

script.N1();      // Calling first function of script.

 

Regards:

Dhiraj

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to