00:00
00:00
Newgrounds Background Image Theme

BACKRUMS just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Coding Practices & Displays

332 Views | 2 Replies
New Topic Respond to this Topic

Coding Practices & Displays 2014-10-17 12:19:03


Hi,

So, I'm wondering how one would go about making a system for a global output that can be viewed with all classes without passing the same object over and over. To clarify, I'm trying to have 1 overall output box (say at the bottom of the screen), but I want other classes to be able to access it. The way It's being implemented, currently, is one class (let's call it the GUI script) is being used to create the window. The Main Class has a GUI object that creates the window and adds it to the stage, or whatever it's called in Flash Develop. The problem I'm having is that I'm writing a Player Class and I want to be able to output errors such as, when the player tries to equip something, but already has something in that slot.

What's the best way to do this without passing the gui object created in the main class to everything?
Or is that the only way to do this?


*nudge* *nudge* *wink* *wink*

Response to Coding Practices & Displays 2014-10-17 12:33:01


Look into static methods. Generally they're a pretty bad practice to just throw around. But for this situation I suggest them.

Ever notice how you could call things like Math.round() without making a new Math()? That's a static method.


If ya have something to say, PM me. I have a lot of time to spare.

Also never PM egg82.

BBS Signature

Response to Coding Practices & Displays 2014-10-17 13:18:56


At 10/17/14 12:33 PM, MintPaw wrote: Look into static methods. Generally they're a pretty bad practice to just throw around. But for this situation I suggest them.

Ever notice how you could call things like Math.round() without making a new Math()? That's a static method.

This worked perfectly, thanks!


*nudge* *nudge* *wink* *wink*