[CS3] OOP: MCs and Buttons as Class Members
I've been working on a signage project for our new office building that will let users see floor plans and tell who is in which office and what their Gtalk status is. So far I've got a working concept (test movie) but as you can see, it doesn't load all the statuses at the start. It's working off of one LoadVars object and the script executes too fast for the variables to be loaded for the other offices. However, the problem is corrected when an individual office is rolled over.
My intention is to create an object called office that will hold a background MC (the part that changes color), a button (the part that initiates actions), an offices number string, and a LoadVars for each office. Ideally I'd like to be able to instantiate the offices once and then just have the code in the class definition handle the actions so I don't have to define actions for every single office (code for 100 buttons? I don't think so...).
Here's what I have so far (working with Action Script 2.0):
Code:
class office{
var officeNumber:String;
var backgroundMC:MovieClip;
var officeButton:Button;
var officeLoadVars:LoadVars;
function office(n,mc,button,dx,dy){
officeNumber = n;
backgroundMC = mc;
officeButton = button;
//initialize positioning
backgroundMC._x = dx;
backgroundMC._y = dy;
officeButton._x = dx;
officeButton._y = dy;
//set the displayed office number
backgroundMC.number.text = officeNumber;
setStatus();
}
offcVars.onData = function(success){
if(success){
//process the data and put it in the tooltip window
// exe- tooltip.name.text = officeLoadVars.name
// tooltip.message.text = officeLoadVars.message
}
}
function changeBGColor(code){
//change the bg color of the office bgMC
// either use setTranform or change the _currentframe
}
function setOfficeStatus(){
//php file takes an office number and returns:
// Occupant name or use (person vs storage vs training room)
// Gtalk status (already externally coded for; available, busy, idle, ect.)
// Gtalk status message (exe- Out to lunch; Working from Home)
officeLoadVars.load("getOfficeStatus.php?room="+officeNumber);
changeBGColor(officeLoadVars.statusCode);
}
officeButton.onRollOver = function(){
revealToolTip();
setOfficeStatus();
}
officeButton.onRelease = function(){
revealToolTip();
setOfficeStatus();
}
officeButton.onRollOut = function(){
hideToolTip();
}
}
The idea is to pass in a movie clip and a button already on the stage and have the actions inside the class handle everything that I was typing out manually before. The problem is I'm getting stuck at errors for the button functions I'm trying to define.
Is it even possible to do what I'm attempting? (If something doesn't make sense, PLEASE let me know).