3 Replies Latest reply on Oct 3, 2007 4:44 AM by Michael_Rabone

    Upgraded to CS3 - Script not woriking now

    Michael_Rabone
      Hello. Small ActionScript issue here. I've got a flash animation embeded in a html file. If at any point you want to skip the animation and proceed to the next page in the html course you can by clicking a button. This button contains the following ActionScript:

      on (release) {
      getURL("javascript:cDone()");
      stop();
      }

      And when the animation comes to the end:

      getURL("javascript:cDone()");
      stop();

      It's been working fine until I recently upgraded to Flash CS3. This script seems to work only upto Flash Player 6. What changes to I need to do to this script to make it work?

      Thanks. Help appreciated.
        • 1. Re: Upgraded to CS3 - Script not woriking now
          AScracker Level 1
          Hi
          In As 3.0 on(press) function won't work we need to change the script like this

          my_Btn.addEventListener(MouseEvent.CLICK,onPress_but);
          function onPress_but(event:MouseEvent) {
          var target_URL:URLRequest = new URLRequest(" http://google.com/");
          navigateToURL(target_URL);

          }

          ~~Sk


          • 2. Re: Upgraded to CS3 - Script not woriking now
            pmobile
            Hi. You didn't mention whether or not you're using the AS2 or AS3 compiler. I'll assume you're
            using AS3.

            if you are trying to call javascript functions that are embedded in the html page,
            read the built-in documentation on ExternalInterface.call()
            AS3 seems like alot of extra typing alot of the time, but it's neat methods for the built in Classes like this that make it worth the effort.

            Adding scripts directly on buttons isn't allowed in AS3. You'll need to attach a listener with an event handler that
            calls your script.

            import flash.events.*;
            package{
            var myButton:Button=new Button();
            myButton..addEventListener(MouseEvent.MOUSE_DOWN,loadMyScript);

            //function called when myButton is pressed
            function loadMyScript(event:EVENT):void{
            ExternalInterface.call("jsFunctionName";"parametersToPass");
            }
            }

            hope this helps. :)
            • 3. Re: Upgraded to CS3 - Script not woriking now
              Michael_Rabone Level 1
              Thanks for your help and applogies for not mentioning what ActionScript I'm using.

              I'm actually using ActionScript 2.0. Any ideas to why I've got this issue?