Search Flex Components Free

Custom Search

January 1, 2008

Create a dynamic link

Create a dynamic link

The web service doesn't provide the full text of the posts, but you still want users to be able to read the posts if they're interested. While the web service doesn't provide the information, it does provide the URLs to individual posts. According to the API documentation for the getMostPopularPosts method (see Review the API documentation ), the information is contained in a field called postLink .

You decide to create a dynamic link that opens a browser and displays the full content of the post selected in the DataGrid control.

  1. In Source mode, enter the following click property in the <mx:LinkButton> tag (in bold): <mx:LinkButton x="30" y="250" label="Select an item and click here for full post" click="navigateToURL(new URLRequest(dgTopPosts.selectedItem.postLink));" />

    The value of the link field of the selected item in the DataGrid control, dgTopPosts.selectedItem.postLink , is specified in the argument to the navigateToURL() method, which is called when the user clicks the LinkButton control. The navigateToURL() method loads a document from the specified URL in a new browser window.


    The navigateToURL() method takes a URLRequest object as an argument, which in turn takes a URL string as an argument.

  2. Save the file, wait until Flex Builder finishes compiling the application, and click the Run button.

    A browser opens and runs the application. Click an item in the DataGrid control and then click the LinkButton control. A new browser window should open and display the blog page with the full post.

Related Flex Tutorials