object serialization not working
Alex,
If you create 2 obects that are of the same type, but don't explicitly set the ID they will end up with the same auto-assigned ID. As you might think, this causes problems. Normally this would not be an issue to me as when I create objects I assign then unique ID's. But now that I am creating custome controls, the sub components are getting assigned the same ID so when I try and change one of the sub components they all change. How do we assign a unique ID to the sub components? Here is a quick example, how would I set the name to something unique?
I have to assign ButtonImage an unique ID otherwise when I call setImageLeft all images of this type get the same left value.
If you create 2 obects that are of the same type, but don't explicitly set the ID they will end up with the same auto-assigned ID. As you might think, this causes problems. Normally this would not be an issue to me as when I create objects I assign then unique ID's. But now that I am creating custome controls, the sub components are getting assigned the same ID so when I try and change one of the sub components they all change. How do we assign a unique ID to the sub components? Here is a quick example, how would I set the name to something unique?
AW.HTML.NavButton = AW.System.Template.subclass();
AW.HTML.NavButton.create = function()
{
var obj = this.prototype;
obj.setTag("SPAN");
with (obj)
{
setStyle("overflow", "hidden");
setStyle("top", 0);
setStyle("width", 23);
setStyle("height", 22);
setStyle("background", "white");
}
obj.defineTemplate("ButtonImage", new AW.HTML.IMG);
with (obj.getTemplate("ButtonImage"))
{
setAttribute("src", "shell.gif");
setStyle("position", "absolute");
setStyle("top", 0);
setAttribute("enabled", true);
setEvent('onmouseover', function(src){if (this.getAttribute("enabled") != false) this.setStyle("top", "-22px");});
setEvent('onmouseout', function(src){if (this.getAttribute("enabled") != false) this.setStyle("top", "0px");});
setEvent('onmousedown', function(src){if (this.getAttribute("enabled") != false) this.setStyle("top", "-44px");});
setEvent('onmouseup', function(src){if (this.getAttribute("enabled") != false) this.setStyle("top", "0px");});
}
obj.setImageLeft = function(newLeft)
{
this.getTemplate("ButtonImage").setStyle("left", newLeft);
}
obj.setContent("html", function()
{
return this.getButtonImageTemplate();
})
}
I have to assign ButtonImage an unique ID otherwise when I call setImageLeft all images of this type get the same left value.
Jim Hunter
November 3,