7 Replies Latest reply on Feb 4, 2007 8:26 PM by depakchopra

    Button Action Script Question

    conniereh
      I would like to place a graphic in a defined area after clicking on a button. I tried this and the graphic loads but not on releas of the button.

      on (release) {
      var ourTextfield:TextField;
      ourTextField.text = "Please wait...Loading...";

      var ourLoadVar:LoadVars = new LoadVars();

      ourLoadVar.onLoad = function(successful) {
      if (successful) {
      ourTextField.text = ourLoadVar.brideGroom.mov;
      } else {
      ourTextField.text = "Error in loading data..."
      }
      }
      }
        • 1. Re: Button Action Script Question
          abeall Level 3
          I don't see any graphic being loaded in that script, unless you mean the "Please wait" text, which should appear as soon as you release(not press) the button.
          • 2. Re: Button Action Script Question
            conniereh Level 1
            I made the graphic a movie - brideGroom.mov

            thanks
            • 3. Re: Button Action Script Question
              abeall Level 3
              I still don't get it. All the script is doing is assigning the text property of ourTextField to be the loaded string ourLoadVar.brideGroom.mov, no graphic, and additionally LoadVars is not actually loading anything, it is only being declared and an onLoad event assigned.
              • 4. Re: Button Action Script Question
                conniereh Level 1
                I'm just not sure what I'm doing. I wanted add a graphic in a defined area after clicking a button. Am I even close to being on the right track? I thought the LoadVar script would be the right choice.
                • 5. Re: Button Action Script Question
                  depakchopra
                  I think this might work,

                  create your button with an instance name of but,

                  Then, create an empty movieclip by selecting insert/newsymbol, it should be in your library. drag it onto the stage where you want it. name it 'brup'.

                  then the code is
                  but.onRelease = function(){
                  brup.loadMovie("brideGroom.mov");
                  }

                  have your brideGroom.mov in the same folder,

                  I could be off here, I am pretty new to actionscript, but I think its worth a shot trying this.

                  • 6. Button Action Script Question
                    abeall Level 3
                    > I'm just not sure what I'm doing.
                    Ah, okay, no problem. :)

                    You are on the right track, but you don't use LoadVars to load media(images, movies, etc). LoadVars is used to load URL variables, which is basically just String/text data. depakchopra gave you a good start, you can use loadMovie or MovieClipLoader(Flash 7 and up) to load in JPGs or SWFs, or if you use Flash 8 GIF/PNG as well.

                    However, you can't load a .mov file. To load a movie, you have to encode it in the FLV format(Flash Pro comes with a tool to do this) and then there are several different ways to do it. You could use a component, or the FLV import video wizard(just import the FLV into a document to get the wizard), or using ActionScript with NetConnection, NetStream, and a Video instance.

                    I hope that is not intimidating, but there are a lot of different ways to load different kinds of stuff ;)
                    • 7. Re: Button Action Script Question
                      depakchopra Level 1
                      I was wondering about that. I have never used movies with actionscript, just created my own animations or loaded images. I forgot about the need to turn it into a FLV.