actionScript: removing references

  • loveToScript12
  • Born
  • Born
  • loveToScript12
  • Posts: 1

Post 3+ Months Ago

I have a class which calls another class in which a timer runs and there are some actions to be performed based on the current count.
Now, my problem is, the player must have the option to start the level all over again, and hence I have removed the class that called the class with the timer in the first place..unfortunately i realized that the subclasses don't really get removed if the parent is.

Any suggestions on what method i should use? i am not totally clear with the concept of classes so any info related to this will help.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

it depends on how you use them.
First i'd suggest you get a better knowledge of OOP in general.
Then read about the OOP for actionscript.
In your case, you should do something like old school c++,
creating a destructor function in your classes, which will reset most of the variables, and call it from the other class, before removing it.
Something like:
Code: [ Select ]
// in ClassCaller you add
public function Destructor()
{
  timerClass.Destructor();
  timerClass = null;
  // any other code in here
}

// in TimerClass
public function Destructor()
{
  myTimer.stop();
  myTimer = null;
  // any other code
}


// before removing the class ... which i suppose you just set it to null because as far as i`m aware, there's no such thing as removing a class ... a child yes, but not a class object
classCaller.Destructor();
classCaller = null;
  1. // in ClassCaller you add
  2. public function Destructor()
  3. {
  4.   timerClass.Destructor();
  5.   timerClass = null;
  6.   // any other code in here
  7. }
  8. // in TimerClass
  9. public function Destructor()
  10. {
  11.   myTimer.stop();
  12.   myTimer = null;
  13.   // any other code
  14. }
  15. // before removing the class ... which i suppose you just set it to null because as far as i`m aware, there's no such thing as removing a class ... a child yes, but not a class object
  16. classCaller.Destructor();
  17. classCaller = null;

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 19 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.