PDA

View Full Version : ComboBox and pop-up windows


ian27
12-13-2004, 04:39 AM
Hi guys,

Okay, this is where I am at so far. I'm using the ComboBox component to add a drop down menu to a webpage I'm building. I've scripted it so that when I click to a particular label it opens up the appropriate url. This is the script I have at present:

-----------------------------------

ComboBox.addItem("Select...", "");
ComboBox.addItem("Item1", "http://www.item1.com");
ComboBox.addItem("Item2", "http://www.item2.com");
ComboBox.addItem("Item3", "http://www.item3.com");

// establish component listener
lo = new Object();
lo.change = function (evt) {
// take action
trace("Selected data is: " + evt.target.getValue() );
trace(" Label = " + evt.target.selectedItem.label);
trace(" Data = " + evt.target.selectedItem.data);
trace(newline);

my_url = evt.target.getValue();
if (my_url != "") {
getURL(my_url);
}

}
ComboBox.addEventListener("change", lo);

-----------------------------------------

The problem:

Instead of a new URL opening up in the same browser window when I click on the appropriate label, I want a pop-up window to appear instead containing the information from the chosen url.

How can I do this?

I hope this makes sense.

Thank you.

Ian

CyanBlue
12-13-2004, 08:55 AM
Howdy... If you want the separate windows for each item, try adding the frame name like this...

getURL(my_url, "_blank");

ian27
12-13-2004, 03:39 PM
Thanks for your response CyanBlue. I tried that but couldn't get it to work with this code. It does work if I put the code straight into a getURL statement and apply it to an MC though.

I'm really wanting to create a pop window that I can specify the size of as opposed to opening a new browser window, so I'd be using some code similar to this:

getURL("javascript:spawnWindow('http://www.myurl.com/page.html','myPage','toolbar=no,location=no,status =no,menubar=no,scrollbars=yes,resizable=yes,width= 780,height=600')");

I guess you know the kind of thing. However, I can't get this kind of code to work with the ComboBox component at all.

Any help or advice would be wholeheartedly appreciated as this problem is starting to drive me up the wall. :confused:

Thanks.

Ian

CyanBlue
12-13-2004, 04:29 PM
Can you post a sample??? I am too lazy to make one... :D

ian27
12-13-2004, 05:21 PM
Hi CyanBlue. Please find an example .fla attached.

CyanBlue
12-13-2004, 05:49 PM
Try this...

getURL("javascript:window.open('" + my_url + "','myPage','width=780,height=600,toolbar=no,locati on=no,status=no,menubar=no,scrollbars=yes,resizabl e=yes');void(0);");

ian27
12-14-2004, 12:18 AM
Hoorah CyanBlue - that's fixed it, thank you so much. When I looked your correct code I was almost there at one point (but as you will already know, almost is never good enough).

Another quick query (although slightly off topic), do you know if it's possible to add a submenu to the ComboBox? And is it possible to change the colour of the background on selected areas as opposed to changing the background colour of the whole menu?

Thanks again mate - I really appreciate your help.

Ian

CyanBlue
12-14-2004, 09:58 AM
Uh... What do you mean by the submenu in the comboBox??? I can't really imagine how it should be working... :(

As for changing the color, check out the Customizing Components section from the Flash manual... I know you can do that in FMX, so you should be able to do the same in FMX 2004... :)

ian27
12-14-2004, 03:47 PM
Hi Cyanblue. What I mean by a submenu is say you have a list in your drop-down menu "page1", "page2", "page3" etc, and when you rollover say "page2" it opens up a submenu to the side of it, such as "page2.1", "page2.2", "page2.3" etc. The hierarchical menu component has the ability to do just this but unfortunately it doesn't work when published in AS2.0. I hope this makes sense. If it doesn't please let me know and I'll try to find an example for you.

Thanks for the reference to the customising components section in the flash menu. I've already been through this but it appears that it only has the ability to change the background colour etc for the whole menu (or possibly alternative row colours) but I can't specify which sections I want which colour. Nevermind.

Ian

CyanBlue
12-14-2004, 09:10 PM
Hm... I am not aware of that sort of submenu with the comboBox... Maybe you should be able to do it, but it will require some programming to have it working as you want...

I thought that you could do that in FMX but it is not possible in FMX 2004??? Dang... Why did they have to change things all of sudden... :(

ian27
12-15-2004, 12:31 AM
Thanks for looking at that. I'm not sure how it can be done either, but if I come across a solution I'll let you know.