On April 12, 2010 at 12:41, Barry Gordon said...
[...]
Here is some snippett code
var MSG=new Array(); MSG[0]={}; // This is for the general user message
MSG[0].label="OK"; // There is one button in the descriptor array at index 0
MSG[0].action="Popup,Remove,userMsg"; // What to do when pressed
MSG[0].color=255 // color for button text
var UMpnl=""; // This is the panel object storage
var UMbtn=new Array(); // This is the button array storage for a popup object.
var userMsg={}; // this is the definition of a Popup to do user messages
userMsg.name="UserMsg"; // The name of this popup
userMsg.Rpage="Resources"; // Where the widget images are (a resource page)
userMsg.Rpanel="UMPanel"; // widget for backgropund of the popup
userMsg.Rbutton="UMButton"; // widget for the buttons (all look the same)
userMsg.Dpanel=UMpnl; // temporary storage for panel
userMsg.Dbutton=UMbtn; / temporary storage for buttons
userMsg.btnInfo=MSG; // the name of the button descriptor array
userMsg.buttons=[0]; // which buttons in the button descriptor array to use
doPopup("Show",userMsg,"A non recoverable Socket\nTimeout has Occurred.")
Barry,
Be aware that if you initialize objects like this in JavaScript, the object is de-referenced every time you set a property. Instead, do something like:
var MSG, UMpnl, UMbtn, userMsg;
MSG = [
{
label: "OK",
action: "Popup,Remove,userMsg",
color: 255
}
];
UMpnl = "";
UMbtn = [];
userMsg = {
name : "UserMsg",
Rpage: "Resources",
Rpanel: "UMPanel",
Rbutton: "UMButton",
Dpanel: UMpnl,
Dbutton: UMbtn,
btnInfo: MSG,
buttons: [0]
};
When compiled to SpiderMonkey byte code, you'll end up with:
[..]
00069: name "Object"
00072: pushobj
00073: newinit
00074: string "UserMsg"
00077: initprop "name"
00080: string "Resources"
00083: initprop "Rpage"
[..]
instead of
[..]
00077: name "Object"
00080: pushobj
00081: newinit
00082: endinit
00083: setvar 3
00086: pop
00087: getvar 3
00090: string "UserMsg"
00093: setprop "name"
00096: pop
00097: getvar 3
00100: string "Resources"
00103: setprop "Rpage"
00106: pop
[..]