# Listbox Tutorial - help with a variation

**URL:** <https://forum.kirupa.com/t/listbox-tutorial-help-with-a-variation/11399>\
**Category:** flash\
**Created:** [January 16, 2003, 5:41pm UTC](https://forum.kirupa.com/t/listbox-tutorial-help-with-a-variation/11399 "2003-01-16T17:41:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DJ\_Lex](https://avatars.discourse-cdn.com/v4/letter/d/f17d59/32.png) [@DJ\_Lex](https://forum.kirupa.com/u/DJ_Lex)\
**Post date:** [January 16, 2003, 5:41pm UTC](https://forum.kirupa.com/t/listbox-tutorial-help-with-a-variation/11399/1 "2003-01-16T17:41:25Z")

</div>

[http://www.kirupa.com/developer/mx/listbox.asp](http://www.kirupa.com/developer/mx/listbox.asp)

I downloaded this excellent tutorial and I’m trying to modify it to my needs. Problem is, the second I start getting into the code, it no longer works.

Here’s is what I’m trying to accomplish…

When an item is clicked in the list box, I’d like it to open a URL.

And a second variation to that would be to have multiple URLs assigned to each listbox item. A radio box would determine which URL to use.

Any help would be much appreciated.

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 16, 2003, 8:46pm UTC](https://forum.kirupa.com/t/listbox-tutorial-help-with-a-variation/11399/2 "2003-01-16T20:46:19Z")

</div>

Can you show me the code you tried?

pom 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 16, 2003, 10:10pm UTC](https://forum.kirupa.com/t/listbox-tutorial-help-with-a-variation/11399/3 "2003-01-16T22:10:28Z")

</div>

Yes I’ll post the code - if you promise not to laugh. 🙂

BTW, I’m just learning MX - jumping in from Flash4. I’m having a lot of errors just with formating and syntax.

Step 1 - Add items to listbox (I don’t think I have the syntax correct for the data)

list.addItem(“ABC”, artisturl(“[http://www.abcmartinfry.com](http://www.abcmartinfry.com)”));  
list.addItem(“A-Ha”, artisturl(“[http://www.a-ha.com](http://www.a-ha.com)”));

Step 2 - (I know this is completely wrong)  
function launchsite() {  
list.getSelectedItem(artisturl);  
[getURL(artisturl, “\_blank”)];  
}

Step 3 -  
list.setChangeHandler(launchsite);

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 16, 2003, 11:28pm UTC](https://forum.kirupa.com/t/listbox-tutorial-help-with-a-variation/11399/4 "2003-01-16T23:28:20Z")

</div>

Hey, I’m not laughing at all, as a matter of fact you’re almost there 🙂

Let’s have a look at your mistakes:[list][_]list.addItem(“ABC”, artisturl(“[http://www.abcmartinfry.com](http://www.abcmartinfry.com)”));  
I’m guessing you’re putting artisturl because I put Date in the tute. The thing is, you have to declare a Date object that way. But this is very specific. In your case, all you need is the string containing the URL.  
[_]The launchSite function has to take as a parameter the current component (let’s call it “c”). Then you need to get the “data” part from the selected item, which is here the second argument you put in the addItem command. And then you getURL that URL.[/list]So if you have a listbox called _list_ on the scene, you’ll have to put that kind of code:

```auto
list.addItem("ABC", "http://www.abcmartinfry.com");
list.addItem("A-Ha", "http://www.a-ha.com");
function launchSite(c){
	var j = c.getSelectedItem().data;
	getURL(j,"_blank");
}
list.setChangeHandler("launchSite");

```

Cheers.

pom :cowboy:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 16, 2003, 11:54pm UTC](https://forum.kirupa.com/t/listbox-tutorial-help-with-a-variation/11399/5 "2003-01-16T23:54:14Z")

</div>

Woohoo!!!

I have been trying to accomplish this task forever.

I’m going to work on the next variation and see if I can get it. I’m going to have multiple URLs per item and see if I can get the different data based on a radio button or popup (URL, CDs, Vinyl, DVD).

I really need to learn MX actionscripting. \<sigh\>

Thank you so much!

- Lex

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 16, 2003, 11:57pm UTC](https://forum.kirupa.com/t/listbox-tutorial-help-with-a-variation/11399/6 "2003-01-16T23:57:57Z")

</div>

Good luck. Post back if you need help. And remember that the “data” parameter can be an array…

pom :beam:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 17, 2003, 12:17am UTC](https://forum.kirupa.com/t/listbox-tutorial-help-with-a-variation/11399/7 "2003-01-17T00:17:14Z")

</div>

Thanks for the tip. I’ll have to conquer the understanding of arrays next. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 20, 2003, 8:09pm UTC](https://forum.kirupa.com/t/listbox-tutorial-help-with-a-variation/11399/8 "2003-01-20T20:09:21Z")

</div>

Here is the first version so far. This is nothing fancy - it just matches my website: [http://www.djlex.com/club80s\_artists.html](http://www.djlex.com/club80s_artists.html)

I’ll make a standalone version that my listeners can download. That will have a little more ‘flare’.

Quick question about XML. There is link that I can use to retreive the currently playing song for my webcast in XML format. I read something about Flash not being able to retrieve data across domains.

Does this mean I wouldn’t be able to use Flash to display my currently playing song?
