From: zavpublic-spamblock-mac.com
Subject: Re: [DIRECT-L] Reusable UI framework code. The code. Part 2
Date: January 26, 2007 3:18:45 PM CST
To: DIRECT-L-spamblock-LISTSERV.UARK.EDU
Reply-To: DIRECT-L-spamblock-LISTSERV.UARK.EDU
Now, before we going with the code, there are a few final concepts of the structure that is about to follow:
Most importantly are the words spoken to Jason Chinn in 1998 when we were working on a site for Macromedia:
"The structure affords you the luxury to focus on the details."
And in that, understanding the structure and the "whys" behind it are also very important.
In this design, modularity and expandability is key. Therefore, in the script that determines the button has been clicked, when the click happens, it broadcasts a success message back to the button, which is caught by the scriptInstanceList of the button. Any script in that instanceList that contains a Success handler will be called.
Why is this cool?
This is great in terms of modularity. You do not have to cobble special condition code into already working code. You just create a behaviour for the task you desire the button to call. If you want a button to update a graph, then you have this type of code for your script:
-- Update Graph behaviour script
on Success
UpdateGraph
end
If the button's click would invoke more than one task, you can now organize your task execution more logically.
If the button would cause a user to Login and you have a "logged in user count" displayed somewhere, you can now do this:
-- Login and Update Display behaviour script
on Success
Login
UpdateUserDisplay
end
Or, since these are two separate tasks, you can have the tasks separated in two behaviours which reside on the mask sprite's instanceList:
-- Login behaviour script
on Success
Login
end
-- Update Display behaviour script
on Success
UpdateUserDisplay
end
The behaviour list for the mask sprite would look like so:
Cool?
Now bear in mind that the "Button specific subclass - 1" script defines which sprites are the mask and the graphic sprites for the "4 state button script" which is forthcoming. It inherits this script and you have to do NOTHING AT ALL to make it work. I do believe that I've covered mostly everything that one would expect a button to do. If it does not do what you desire, the design is modular enough that other behaviours and classes can be added to accomplish this. Once we've got this lesson covered, we'll explore in that direction.
Final sprite, behaviour and cast structure is to be used as follows:
Sprite structure:
channel n + 0: Graphic sprite ("active" graphic, 32 bit alpha channeled bmp )
channel n + 1: Mask sprite (1 bit mask of "active" region)
Sprite Ink Settings
channel n + 0: copy, 100% blend
channel n + 1: matte, 0% blend
Cast Structure:
Member names for Graphic sprite members
myButtonName Active
myButtonName Rollover
myButtonName Down
myButtonName Disabled
Member name for mask sprite member
myButtonName Mask
Cast Member Names of Scripts to be placed on the Mask sprite:
Button sprite specific subclass - sprite - 1
Behaviour code structure:
Button sprite specific subclass - sprite - 1
Your Success Script
* Note that the "Button sprite specific subclass - sprite - 1" script has two levels of ancestory:
4 state button script
Display UI enable/disable
But you don't care at all. These are all set up for you.
"Enough talk, you long winded bastard, where's the source code", you kindly ask?
Well, here:
Next email: How to set it up.
Enjoy,
- Zav
---
Macromedia Director Mailing List (Direct-L)
List Administrator: Eve M. Owens (emowens-spamblock-theserver.uark.edu)
To SUBSCRIBE or to UNSUBSCRIBE go to
and click on
"Join or leave the list (or change settings)"
For list archives