2 Replies Latest reply on Jan 9, 2007 3:12 PM by myckelh

    Adding button

    myckelh

      from a button in my flash file I wan to basicly create another button and give it a URL and place it at cordinate specified.

      Basicly I want my script on button A to do the following.
      _root.Create a button -- Name it "download Doc for example" give it a URL link " getURL(..//lesson2) and place this button at x=100 Y =200


      I'm not sure how to write this in AS.
        • 1. Re: Adding button
          Level 7
          fairly simple:
          let's say your button A has an instance name of 'a_btn' (and its placed in
          level0), and in your library you have a MC from which you want to preapare
          your new button, and it has a linkage ID of 'newButton' (and the 'download
          doc for example' all over it...).
          In that case put on a frame in level 0 the following code:
          a_btn.onRealse = function() {
          // this line creates a new movieclip on the stage out of the MC in the
          libarary,
          // names it 'b_btn' and places it in the next available depth in your
          movie's root
          _root.attachMovie("newButton", "b_btn", _root.getNextHighestDepth());
          // placing the button at the required cordinations
          b_btn._x = 100;
          b_btn._y = 200;
          // adding functionality to the button
          b_btn.onRelease = function() {
          getURL("../lesson2")
          }
          }

          ta-da...

          you might as well create your new button's graphic also by code, but that's
          the subject of another lesson.

          eRez

          ps - pay attentin, that the URL u're using has no extentin (html, swf,
          jpg...)

          "myckelh" <webforumsuser@macromedia.com> wrote in message
          news:ekfbm9$q3n$1@forums.macromedia.com...
          > from a button in my flash file I wan to basicly create another button and
          > give
          > it a URL and place it at cordinate specified.
          >
          > Basicly I want my script on button A to do the following.
          > _root.Create a button -- Name it "download Doc for example" give it a URL
          > link " getURL(..//lesson2) and place this button at x=100 Y =200
          >
          >
          > I'm not sure how to write this in AS.
          >


          • 2. Re: Adding button
            myckelh Level 1
            Thanks for the help