6 Replies Latest reply on Sep 10, 2009 2:57 AM by Madhav Subedi

    use variable in URLRequest

    The Converted

      Hi,

       

      I'm trying to find a way of creating a button with a link to an external site, which also passes a variable ID with it.  Using the method below just sends the id as {songsList.selectedItem.songid} how do I get a variable in there.  I'd appreciate your help, thanks

       

       

      ########################################################

       

      function navToURL(event:MouseEvent):void {
          var request:URLRequest = new URLRequest('http://www.website.comc/page.asp?id="{songsList.selectedItem.songid}"');
          navigateToURL(request, "_self");

      }

       

      ####################################################################

        • 1. Re: use variable in URLRequest
          Madhav Subedi Level 4

          try it:

           

          function navToURL(event:MouseEvent):void {
              var request:URLRequest = new URLRequest("http://www.website.comc/page.asp?id="+songsList.selectedItem.songid);
              navigateToURL(request, "_self");
          }
          
          • 2. Re: use variable in URLRequest
            jake_flex Level 2

            And if you want to use POST method, see URLVariables class.

            • 3. Re: use variable in URLRequest
              The Converted Level 1

              Hi,

               

              Thanks, that works, however on the first left click on the mouse nothing happens.  Subsequent clicks work ok which is strange, is there a way of solving this?

              Also is there method of showing a message or moving icon saying "transferring you to site" so the people know something is happening.  Thanks for your help.

               

              this is my button

               

              <mx:Button disabledSkin="@Embed(source='bin/assets/logoforplayer1.gif')" downSkin="@Embed(source='bin/assets/logoforplayer2.gif')" overSkin="@Embed(source='bin/assets/logoforplayer2.gif')" upSkin="@Embed(source='bin/assets/logoforplayer1.gif')" id="urlbutton" click="urlbutton.addEventListener(MouseEvent.CLICK, navToURL);"/>

              • 4. Re: use variable in URLRequest
                Matt Le Fevre Level 4

                showBusyCursor="true"

                 

                 

                or you could simply have a label become visible on button press with a 'Please wait' message

                • 5. Re: use variable in URLRequest
                  The Converted Level 1

                  Hi,

                   

                  I put showBusyCursor="true" in my button and it brings up error "can't resolve attribute"

                   

                  I need to find a way of solving the main problem of it not directing to the new page on the 1st click of the mouse?

                  • 6. Re: use variable in URLRequest
                    Madhav Subedi Level 4

                    something funny is happening in your code:

                     

                    <mx:Button disabledSkin="@Embed(source='bin/assets/logoforplayer1.gif')" downSkin="@Embed(source='bin/assets/logoforplayer2.gif')" overSkin="@Embed(source='bin/assets/logoforplayer2.gif')" upSkin="@Embed(source='bin/assets/logoforplayer1.gif')" id="urlbutton" click="urlbutton.addEventListener(MouseEvent.CLICK, navToURL);"/> 

                     

                    in the button click you are adding the EVENTLISTENER, not actually calling navToURL

                     

                    instead, do :

                     

                    <mx:Button disabledSkin="@Embed(source='bin/assets/logoforplayer1.gif')" downSkin="@Embed(source='bin/assets/logoforplayer2.gif')" overSkin="@Embed(source='bin/assets/logoforplayer2.gif')" upSkin="@Embed(source='bin/assets/logoforplayer1.gif')" id="urlbutton" click="navToURL(event);"/> 

                     

                    in the function you can show busy cursor by:

                     

                    cursorManager.setBusyCursor();