Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


AS3.0 Creating an instance of a function, with singleton?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 JETeran   Members   -  Reputation: 275

Like
0Likes
Like

Posted 05 September 2012 - 10:29 AM

Hello every one !

I'm working on a game that has many .as files, one of the is called MainMenu.as where you select your current mission.

After finishing any mission, I want the game to take you back to that MainMenu.as so you can select another mission.

Thanks to Deft (really thanks !!) I'm working on a singleton pattern and actually works great. The thing is that I'm able to call back a function that is not the constructor of the class. So how can I do to call it? This is because I have the main code in the constructor.

If is not possible, I will change all the code so it goes to a function inside the MainMenu class instead of it's constructor.

Thanks so much guys !!

Success with courage,

José Eduardo Terán

Project Management & Game Programming. DSK International Campus

Indie Game Developer
Google + Account


Sponsor:

#2 Deft   Members   -  Reputation: 218

Like
1Likes
Like

Posted 05 September 2012 - 11:30 AM

Hey there))

Just relocate you base code into separated method. Making constructor big not so good.
If you need to get re-usable code, wrap it with public method and call it wherever you want. This is true for singletons too.

#3 JETeran   Members   -  Reputation: 275

Like
0Likes
Like

Posted 05 September 2012 - 11:36 AM

Awesome, thanks Deft and thanks for sharing it to the community.

I will start doing it right now !!

Happy day !!

Success with courage,

José Eduardo Terán

Project Management & Game Programming. DSK International Campus

Indie Game Developer
Google + Account





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS