Search code examples
actionscript-3apache-flexurlitemrenderer

Adobe Flex: Cannot Navigate to Dynamic URL


Currently in my app I can access my database of users, but now I need to open the user's facebook page when I click on either their avatar or username. I can access the user's facebook id by data.facebook id. I did have working code earlier, but it required my to enter a static URL, but I need the URL to be generated based on the user's id. This is my code so far

private function newBrowserWindow():void
{
    //Creating a URL for a facebook profile
    trace(data.facebookid);
    var facebookUrl:* = "http://www.facebook.com/" + data.facebookid;
    navigateToURL(facebookUrl);
}

I access this function with the following code:

<s:Image id="fbImg" source="http://graph.facebook.com/{data.facebookid}/picture?type=normal" x="0" y="0" click="newBrowserWindow()"/>          
<s:Label id="usernameLbl" x="120" y="0" fontFamily="Calibri" fontSize="25" fontWeight="bold" text="{data.firstname} {data.lastname}" click="newBrowserWindow()"/>

My code is showing no errors so I don't know what's wrong. My previous working code required me to access the click handler via click="newBrowserWindow('http://www.mysite.com') and thus the function required an object to process, but I removed that because I couldn't seem to get around typing in a static URL.

Any ideas?


Solution

  • Use URLRequest in navigateToURL:

     navigateToURL(new URLRequest(facebookUrl));