6 Replies Latest reply on Jul 20, 2006 12:19 PM by brananc1

    Loading Variables

    brananc1 Level 1
      Hello all,
      I am new to flash (been playing with actionscript 2.0 for about 2 months). I am creating a game for my daughter and I need to load to variables (movieclips) on the stage. It will only let me load one or the other. Is there a way to do this? again I am still learning actionscript.

      Thanks for the help.
        • 1. Re: Loading Variables
          Wolf_van_Ween Level 1
          What are you trying? How does your actionscript look like?
          • 2. Re: Loading Variables
            brananc1 Level 1
            I am trying to place a shapes pn the screen and then have her pick the correct shape and color in sentence form. IE there is a red circle on the screen and then she has to choose which answer is correct A, B, or C. Here is the code:
            var circle1MC:MovieClip = this.attachMovie("circle1"+"_mc", "circle1"+_global.cDepth+"_mc", _global.cDepth);
            circle1MC._y =600
            circle1MC._x =250
            var rc1MC:MovieClip = this.attachMovie("Red Circle"+"_mc", "Red Circle"+_global.cDepth+"_mc", _global.cDepth);
            rc1MC._y =400
            rc1MC._x =500
            rc1MC.onPress = function() {
            if (rc1MC.hitTest(_xmouse, _ymouse, false)){
            • 3. Re: Loading Variables
              Wolf_van_Ween Level 1
              Very complicated code for something quite simple.
              First the mistake: you're using _global.cDepth as the depth in both cases, so that the second movieClip overwrites the first.
              Either you store the depth in a variable as you do, but then increase that variable: _global.cDepth++ or you go the normal way and choose the next available free depth in both cases: this.getNextHighestDepth()

              Other remarks:
              - You don't need to construct the symbol name "Red Circle"+"_mc", you can simply write "Red Circle_mc".
              - What good is a "hardcoded" var (I refer to the "1" in "rc1MC" when you give the attached movie a new instance name of "Red Circle"+depth+"_mc" (which I guess later will be put into a loop)?
              - What is the hitTest inside the onPress function for? If the mouse wouldn't be hitting rc1MC at that moment, the onPress would not be called.

              Good luck!
              • 4. Re: Loading Variables
                brananc1 Level 1
                Thank You!! Is this code really that complicated? I am just trying to figure it out as I go. This programming stuff is my new hobby. I hope I can figure it out as well as it sounds like you have. Thanks again!!!
                • 5. Re: Loading Variables
                  Wolf_van_Ween Level 1
                  Well, it takes a couple of years, but it's a very rewarding hobby. Good luck!

                  One last comment: avoid creating any names with spaces inside. Make it RedCircle instead of Red Circle. That's true for any programming language, whether names of variables or instances. You will thank me for that one day :-)

                  • 6. Re: Loading Variables
                    brananc1 Level 1
                    Thanks again. I am sure that I am going to run into many questions. Do you know of any good books that will help me with my journey? Are you available for more questions? Please let me know. Thanks again for your help.