1 Reply Latest reply on May 13, 2008 10:42 AM by Ned Murphy

    Newbie needs help with button script

    goshenvideo
      I need help figuring out why I am getting the an error message. I have Action Script associated with a button with its keyframe sitting in the first frame of my main timeline. There is no Action Script attached to the instance of the button. My frame label is correct, and the link to where my .FLV is sitting is correct. The action script is copied verbatim from pg 233 "Communicating With External Video" in Visual QuickPro Guide Flash 8 Advanced book. thanks.

      **Error** Scene=Scene 1, layer=photo buttons, frame=1:Line 1: Statement must appear within on handler
      ribbon_btn.onRelease = function() {

      Total ActionScript Errors: 1 Reported Errors: 1

      ribbon_btn.onRelease = function() {
      var myVideo_nc:NetConnection = new NetConnection();
      myVideo_nc.connect(null);
      var newStream_ns:NetStream = new NetStream(myVideo_nc);
      busVanVideoholder_video.attachVideo(newStream_ns);
      newStream_ns.play("bus van ax.flv");
      };

      The action script is definately a part of the keyframe associated with the button. (sitting on the first frame of my timeline). When I click on the button, the keyframe becomes highlighted, a blue bounding box outlines the square I drew for the button, and the action script appears.

        • 1. Re: Newbie needs help with button script
          Ned Murphy Adobe Community Professional & MVP
          If you click on the button and the actionscript appears when you do that, then the actionscript IS attached to the button.

          If that is the case, then try replacing that actionscript with the following:

          on(release){
          var myVideo_nc:NetConnection = new NetConnection();
          myVideo_nc.connect(null);
          var newStream_ns:NetStream = new NetStream(myVideo_nc);
          busVanVideoholder_video.attachVideo(newStream_ns);
          newStream_ns.play("bus van ax.flv");
          }

          For the code you have used, it belongs in the timeline. So what you could do instead is create a new layer above the button in the main timeline, click on the frame, and put your code in the actions panel. A small "a" should appear in the frame if you do it dorrectly.