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
2009-04-02 17:40:16
ok and how do i make the items works as actual links like in browser??i'm on air app
Chen Kinnrot
2009-04-02 17:45:22
You want to use the itemClick event, not click.
cliff.meyers
2009-04-03 05:24:22
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.
Joel Hooks
2009-04-04 03:54:14