0 Replies Latest reply on May 21, 2016 4:08 PM by camip45373509

    Open to URL code snippet not working in browser?

    camip45373509 Level 1



      I have two buttons (actionscript3) that are meant to open URL's when clicked on. I used the code snippets to create this action (one opens URL in new browser, one plays music from URL). The buttons work fine when I test the project in Animate cc but once I test it in a browser the two buttons no longer open any URL. What could be going wrong?


      Here's the code I used (from code snippets):


      /* Click to Play/Stop Sound

      Clicking on the symbol instance plays the specified sound.

      Clicking on the symbol instance a second time stops the sound.




      1. Replace "http://www.helpexamples.com/flash/sound/song1.mp3" below with the desired URL address of your sound file. Keep the quotation marks ("").




      music_btn.addEventListener(MouseEvent.CLICK, fl_ClickToPlayStopSound);



      var fl_SC:SoundChannel;



      //This variable keeps track of whether you want to play or stop the sound

      var fl_ToPlay:Boolean = true;



      function fl_ClickToPlayStopSound(evt:MouseEvent):void




        var s:Sound = new Sound(new URLRequest("http://www.helpexamples.com/flash/sound/song1.mp3"));

        fl_SC = s.play();






        fl_ToPlay = !fl_ToPlay;




      /* Click to Go to Web Page

      Clicking on the specified symbol instance loads the URL in a new browser window.




      1. Replace http://www.adobe.com with the desired URL address.

         Keep the quotation marks ("").




      url_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage);



      function fl_ClickToGoToWebPage(event:MouseEvent):void


        navigateToURL(new URLRequest("http://www.gardeningchannel.com/25-fun-facts-about-flowers/"), "_blank");