actionScript: removing references

  • loveToScript12
  • Born
  • Born
  • No Avatar
  • Joined: Feb 21, 2011
  • Posts: 1
  • Status: Offline

Post February 21st, 2011, 4:56 am

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
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post February 21st, 2011, 4:56 am

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Joined: Nov 05, 2004
  • Posts: 1254
  • Loc: Ro
  • Status: Offline

Post April 4th, 2011, 4:22 am

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;
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 31 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
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.