:: Forum >>
Associate multiple images to a control
Hi,
With the following code, I am able to associate an image to a AW group contro. BUt can I add multiple images to the control with their respective events?
var obj = new AW.UI.Group;
obj.setId("group");
var img = obj.getContent("box/image");
img.setTag("IMG");
img.setClass("image", "dynamic");
img.setAttribute("src", function(){
return this.getControlProperty("image");
});
obj.setControlImage("/image/edit.gif");
obj.setStyle ("left", "15px");
obj.setStyle ("width", "500px");
obj.setStyle ("height", "230px");
obj.setControlText("Subscribe");
document.write(obj);
There is another approach, by setting the controlText (obj.setControlText("Subscribe");) with embedded with HTML <img src=/image/edit.gif> tags, but that does not cater my requirements, as I want those images to be separate controls, rather than just images.
So can I add multiple images to a control by the first method? If so, Can you please explain?
VJ
Thursday, May 7, 2009
Yes, you can. Assuming you've read the notes on how to add images, you could add simple code like this:
obj.setControlImage("original")
obj.onControlMouseDown = function(event)
{
this.setControlImage("new")
}
obj.onControlMouseUp = function(event)
{
this.setControlImage("original")
}
which obviously changes the image for a control on a mouse click event.
Anthony
Friday, May 8, 2009
Hi Anthony,
Thanks for your response.
But I dont want to change the image, but I want to another image to the Group control and trigger both the images respective events.
Please let me know, if this can be done.
VJ
Friday, May 8, 2009
I'm not sure if I understand you. Do you mean you want to have 2 images in a control?
Anthony
Friday, May 8, 2009
Yes, that is correct.
VJ
Monday, May 11, 2009
OK, short answer, no. Long answer, you would need to create several ImageText objects to do this. You can place them within a more complex control, however. There may be some restrictions on that, depending on what you actually want.
Anthony
Monday, May 11, 2009
Thanks Anthony. I currently created HTML image objects (new AW.HTML.IMG) independently, without associating to AW group control. It works, but since it is not attached to that group, it appears loose coupled to the group.
Another approach, as I said earlier to just attach images to obj.SetControlText() method by adding HTML <img> tags. But the image onclick events does not work like AW.HTML.IMG onclick events.
With AW.HTML.IMG, I can set the other AW label's value (in my form) when I create the image control, so that when onclick event occurs, it has all the values. But with img tag option, only when I click the control, I have to pass the other label's text values, which is lost at that time.
Thanks a lot for your inputs and suggestions.
VJ
Tuesday, May 12, 2009
This topic is archived.
Back to support forum
Forum search