6 Replies Latest reply on Jun 22, 2007 5:29 AM by Greg Dove

    Please Help with Two bits of Action Script


      I have almost completed a virtual tour and i need two last bits of code. I'm new to flash so i still don't fully understand it and would like the exact codes please. I have 6 buttons. Each one plays a video...the videos are invisible (alpha (0)) and then become visible when the button is hit. Each button also makes all other videos that might be playing stop and go invisible. Each video also has a mute button. Here's the code i have so far that works:

      searchvideo.muteButton = muter5

      searchvideo.alpha = 0;
      muter5.alpha = 0;
      import flash.events.MouseEvent;
      import flash.events.IEventDispatcher;
      import flash.display.MovieClip;
      function startsearch(e:MouseEvent):void {
      searchvideo.alpha = 100;
      muter5.alpha = 100;
      uploadvideo.alpha = 0;
      muter1.alpha = 0;
      myspectrumvideo.alpha = 0;
      muter2.alpha = 0;
      reviewingvideo.alpha = 0;
      muter3.alpha = 0;
      toptenvideo.alpha = 0;
      muter4.alpha = 0;
      srsvideo.alpha = 0;
      muter6.alpha = 0;

      When you hit the button, the video plays. However, i need it to always play from the beginning, even if you go back to it once it has been stopped by another button. I tried replacing the line searchvideo.play(); with searchvideo.gotoAndPlay (1); but an error message came up: "1061: Call to a possibly undefined method gotoAndPlay through a reference with static type fl.video:FLVPlayback.". Please could someone tell me the EXACT code i need to make it work.

      The second thing is that when a video comes to its natural end i would like it to go invisible again, alpha (0). Again please could someone tell me the exact code for this?

      Thank you so much - i've been working on it for 10 days and i'm so close now!
        • 1. Re: Please Help with Two bits of Action Script
          Greg Dove Level 4
          For the first part try:

          • 2. Re: Please Help with Two bits of Action Script
            Greg Dove Level 4
            for the second part... I know how to do it in as2... but you're using as3...and I haven't tried it yet.. the event handling is slightly different.

            But what you need to do is set up a listener for the "complete" event from the FLVPlayback instance ..

            Someone else might be able to give you an example in as3

            • 3. Re: Please Help with Two bits of Action Script
              Tom_Kere Level 1
              Thank you so much..the first bit worked! Brilliant.

              Not sure what you mean by the second bit but i'll give it a go!

              Thanks again
              • 4. Re: Please Help with Two bits of Action Script
                Greg Dove Level 4
                Sorry.... I'd show you an example if I was comfortable with doing it in as3, but I haven't done any work in as3 yet.

                The reference for the as3 complete event for FLVPlayback is here:
                http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlayback.html#event: complete

                The basics probably haven't changed in as3
                you need to set up an object that acts as a 'listener' for the COMPLETE event
                e.g. var myVideoListener:Object = new Object()
                myVideoListener.complete = function(eventObj) {
                //do things here (this is as2 style setup for listener... I don't know if its different for as3)
                you need to use addEventListener to add the listener to your FLVPlayback instance.
                this would be something like
                searchvideo.addEventListener(VideoEvent.COMPLETE, myVideoListener)

                (please don't take this code literally... its just a quick guide.. like I said I haven't used as3 yet)
                • 5. Re: Please Help with Two bits of Action Script
                  Tom_Kere Level 1
                  That really helped actually...using script assist i managed to create this code:

                  function endsearch(e:Event):void {

                  I think its right but the wierdest thing is now happening. An error message comes up: "1084: Syntax error: expecting rightbrace before end of program." But the location is not the 'Search Actions' layer, but another actions layer relating to a different video and button - 'Upload Actions'. When i take away the code above from the 'Search Actions' layer it plays fine.

                  What is going on? I'm confused
                  • 6. Re: Please Help with Two bits of Action Script
                    Greg Dove Level 4
                    Well it seems from the code above that you are missing a right brace from the end of the endsearch function, so just try putting that in. e.g.

                    function endsearch(e:Event):void {
                    //or searchvideo.visible=false; // this is probably really what you want I think

                    In terms of whether your code is correct for what you want to do... if its not then I'm sure that others will be online soon who have more experience with the as3 way of doing things.