views:

328

answers:

3

I have an Array of string which represents links. I want to display them in a list and make them work like links. How do I do that?

+1  A: 

You could create a list with LinkButton as the itemRenderer. You would also need to add event listeners to the list to actually do navigation. Use navigateToURL to run the link. MXML for the list:

<mx:List id="myList" 
    itemRenderer="mx.controls.LinkButton"
    click="navigateToURL(new URLRequest(myList.selectedItem.text))"> 
</mx:List>

Then in the actionscript part (Or you could set this in the MXML too if you'd like).

myList.dataProvider = arrayOfLinkStrings;
CookieOfFortune
ok and how do i make the items works as actual links like in browser??i'm on air app
Chen Kinnrot
You want to use the itemClick event, not click.
cliff.meyers
A: 

navigateToURL works in AIR. It will open the default system browser and open the page that is clicked. With a list, you will want to use itemClick instead of regular click. Personally I would add the click event handler to the ItemRender, extending either a Label (with buttonMode=true and maybe a rollOver) and placing the call to navigateToURL in the custom itemRenderer.

Peter Ent's 5 part itemRender series is fantastic.

Joel Hooks
A: 

Use LinkBar with ViewStack.

Yakov Fain