Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-06-2012, 04:53 PM   #1
JZweige
Registered User
 
Join Date: Feb 2012
Posts: 17
Default OOP concepts - buttons

Hello,

I am kind of new to OOP, but I understand the basics. In AS3, what I am trying to achieve is basically an interface with numbers and buttons. In the Main class I will have a Timer running. Each of the buttons has an image, a cooldown timer and an action.

Can someone point me in the right direction on how to this? I mean, how can I have Button.as to have a specific function in the Main class? Also, how can I assign a cooldown to each instance of Button.as and make them stop each time the Main.as timer stops?

Any ideas?

Thank you all in advance!
JZweige is offline   Reply With Quote
Old 05-06-2012, 05:00 PM   #2
lordofduct
Senior Member
 
lordofduct's Avatar
 
Join Date: Feb 2008
Location: West Palm Beach, FL
Posts: 3,872
Default

you don't exactly explain what a "cool down timer" is, or what you're exactly trying to do. SO it's kind of hard to say...
__________________
www.lordofduct.com - come read my blog!

If you want to know how to program, take a math class, take a lot of math classes!
lordofduct is offline   Reply With Quote
Old 05-06-2012, 05:35 PM   #3
JZweige
Registered User
 
Join Date: Feb 2012
Posts: 17
Default

Right, silly me.

By cooldown timer, I mean a timer that limits the button usage. For example, you may only use that button once every 2 minutes. Nevertheless, that cooldown timer should pause itself each time the Timer from Main.as pauses as well.
JZweige is offline   Reply With Quote
Old 05-07-2012, 12:22 AM   #4
lordofduct
Senior Member
 
lordofduct's Avatar
 
Join Date: Feb 2008
Location: West Palm Beach, FL
Posts: 3,872
Default

I'd create a composite object to house this logic. Something like so:

Code:
class ButtonBlocker
    get Button:Button
    get set Enabled:Boolean
    func Block(dur:Number):void
This object you'd give the button it handles. It'd listen for the click event on the button. When said click would occur it'd call its own function 'Block' for some duration. If enabled is set to false this functionality doesn't happen and any running timer gets paused.
__________________
www.lordofduct.com - come read my blog!

If you want to know how to program, take a math class, take a lot of math classes!
lordofduct is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:03 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.