3 Replies Latest reply on Jun 19, 2007 1:16 PM by Newsgroup_User

    Should this Simple ActionScript work?

    bilbo--baggins
      I know nothing about ActionScript. I need to make my banner ad work so if you click anywhere it takes you to the web site it's advertising.

      I've spent about 3 days looking for tutorials, reading the help section etc etc and nothing seems to work. The 'action' part of this did work, as soon as I tested the movie it would load the web page, but when I try to make it dependent on a mouse click it never responds.

      If anyone could tell me whether the ActionScript should work or not I'd be very grateful. I don't know whether it's just that I havent set up the button correctly, or whether there is some other problem.

      This is using ActionScript 3. I've tried using the getURL too, but when I change the movie to ActionScript 2 I get lots of errors for commands I know nothing about - presumably related to Flash's commands it creates for the animation?

      It would be really helpful if there was just a 'here's the code, paste it in and change your button name and URL".

      I feel I've wasted far too much time on this already, and I'm sure that for someone who knows about flash this should be a 2 second job.


      import flash.events.MouseEvent;
      import flash.events.IEventDispatcher;
      var imURL:URLRequest = new URLRequest(" http://www.imaginemontenegro.com/");

      function sendtoIM(MouseEvent):void {
      navigateToURL(imURL, "_self");
      }

      mybutton.addEventListener("MouseEvent.CLICK",sendtoIM);
        • 1. Re: Should this ActionScript work?
          kglad Adobe Community Professional & MVP
          no, that sure wouldn't work. remove the quotes around your mouse event.
          • 2. Re: Should this ActionScript work?
            Level 7
            bilbo--baggins,

            > I know nothing about ActionScript. I need to make my banner
            > ad work so if you click anywhere it takes you to the web site
            > it's advertising.

            Okay. The answer to that is going to depend entirely on the version of
            ActionScript you want to use. If you're publishing to ActionScript 3.0,
            you'll have to publish for Flash Player 9. If you want to publish to
            earlier versions -- arguably a good idea, for a banner ad -- you'll have to
            configure your publish settings for ActionScript 2.0 or lower.

            > If anyone could tell me whether the ActionScript should work
            > or not I'd be very grateful. I don't know whether it's just that I
            > havent set up the button correctly, or whether there is some
            > other problem.

            Is you code available somewhere? (I'm reading this with a newsreader,
            so it's possible you posted code to the web version of these forums, and the
            code hasn't made it through.)

            > This is using ActionScript 3. I've tried using the getURL too, but
            > when I change the movie to ActionScript 2 I get lots of errors for
            > commands I know nothing about - presumably related to Flash's
            > commands it creates for the animation?

            The getURL() function has become navigateToURL() in AS3, but I'm unclear
            now what language you're using.

            > It would be really helpful if there was just a 'here's the code, paste
            > it in and change your button name and URL".

            If you're publishing to AS2, give your button an instance name in the
            Property inspector and make sure that button is a) size as large as the
            whole movie, and b) set on a layers higher than your other layers. Then, in
            a scripts layer (just a layer with nothing in it but code), type the
            following:

            buttonInstanceName.onRelease = function():Void {
            getURL(" http://www.domain.com/");
            }

            ... making sure to swap buttonInstanceName with the actual button's instance
            name, and domain.com with the URL of your choosing.


            David Stiller
            Adobe Community Expert
            Dev blog, http://www.quip.net/blog/
            "Luck is the residue of good design."


            • 3. Re: Should this Simple ActionScript work?
              kglad Adobe Community Professional & MVP
              p.s. you don't need to import those events and your mouseevent in sendtoIM isn't quite right.