4 Replies Latest reply on Dec 14, 2008 1:10 PM by lfcfan

    Help with Action script 2.0 please

    lfcfan
      Hi,
      I am new to actionscript and i could really do with some help please. I am trying to load external movie clips into two different containers depending on which button is clicked. Sometimes there may be two conatiners attached to a buuton click, whilst other buttons may only need to load one movie clip. Here is the action script i have been using:

      button1.onPress = function () {
      _root.createEmptyMovieClip("container", 1);
      _root.createEmptyMovieClip("container1", 2);
      unloadMovie("container1");
      loadMovie("scene2.swf", "container");
      loadMovie("scene5.swf", "container1");

      container._x = 50 ;
      container._y = 110 ;
      container1._x = 170 ;
      container1._y = 5 ;
      }
      button2.onPress = function () {
      loadMovie("scene6.swf", "container");
      unloadMovie("container1");
      container._x = 50 ;
      container._y = 110 ;
      }

      This does load the movies, however i have to press button one first before button two will work. Ideally i need to be able to call any movieclip at any time. Can anyone tell me where i am going wrong?
        • 1. Help with Action script 2.0 please
          Ned Murphy Adobe Community Professional & MVP
          Try moving these lines outside of the button function:

          _root.createEmptyMovieClip("container", 1);
          _root.createEmptyMovieClip("container1", 2);

          You can use "this" instead of "_root"... that'll save any problem if you ever move this within some other movie. Also, move the x/y assignments just under those lines since they relate to them directly.
          • 2. Re: Help with Action script 2.0 please
            lfcfan Level 1
            quote:

            Originally posted by: NedWebs
            Try moving these lines outside of the button function:

            _root.createEmptyMovieClip("container", 1);
            _root.createEmptyMovieClip("container1", 2);

            You can use "this" instead of "_root"... that'll save any problem if you ever move this within some other movie. Also, move the x/y assignments just under those lines since they relate to them directly.


            Hey thankyou for your help, that works now. although if i move the x and y assignments i would have to create another container right? Thanks again for your help.
            • 3. Re: Help with Action script 2.0 please
              Ned Murphy Adobe Community Professional & MVP
              No, I don't think so at least. I'm just saying put all this code in one location since it's all related (makes for easier reviewing)...

              this.createEmptyMovieClip("container", 1);
              this.createEmptyMovieClip("container1", 2);
              container._x = 50 ;
              container._y = 110 ;
              container1._x = 170 ;
              container1._y = 5 ;

              You shouldn't need it in the button2 function since it's location is already defined above.
              • 4. Re: Help with Action script 2.0 please
                lfcfan Level 1
                Lol! oh yes i've moved that now, thanks again!!