Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UI Design Pattern

Status
Not open for further replies.

BluesmanUK

Programmer
Dec 17, 2001
55
GB
Hi all,
I posted this in some flash forums but I thought it would be just as appropriate to post my question here too...

Im creating a UI using Flash and OOP Actionscript; and my question relates to designing the menu navigation system.

What needs to happen is fairly simple i guess : when a button is rolled over, it changes state (enlarges and changes colour) AND all the other buttons change (they shrink and fade out slightly).

My question is about how to approach writing the classes from a design perspective. I havent totally got to grips with using Design patterns but im wondering if the Observer pattern would be suitable:

Have a 'Navigation manager' as the observable subject, and each menu-button would be an instance of a class that acted as the Observer and registers for updates with the Navigation Manager. When a menu button (observer) is interacted with (rolled over, clicked etc), the Subject is notified and tells all of the observers to update themselves. Not sure if its good practice to have the observer updating the observable :-S
Does it sound like i'm on the right track?

If anyone has any thoughts it'd be much appreciated!

thanks
Tim

 
Perhaps I am misunderstanding you, butI think you might need to do it the other way round, with the navigation manager as the observer and the buttons as the observables.

Assume that a button has a makeBigAndJazzy(), makeSmallAndFaded(), and a makeNormal() method.

As you add each button to the manager's collection, it (the manager) can register for the mouse in/out and click events of the button.

When a button gets a mouseIn, the manager gets notified. It iterates over the buttons in its collection calling makeSmallAndFaded(), then calls makeBigAndJazzy() on the one that initiated the event. When you get a mouseOut, just iterate over again calling makeNormal().

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Ah yes thats what i meant - i think i was getting observer and observable the wrong way round :)

thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top