5 Replies Latest reply on May 7, 2008 11:21 AM by NecroSaint

    Amatuer programming :S

    NecroSaint
      Ok this is just to play around atm. im a beginner with actionscript have done some java coding in the past but ont on great scale. I am trying to make a program so that when i press a button (Space bar in this case) a ball is formed, grows to a certain size, then is fired all by holding down this button, but if i let go of the button i want the ball to return to its orginal position at a 0,0 size so it is not visible.

      So far i can code the different effects i want, like making the ball grow and making it move, but not one button press. And i can't work out how to make it go back to it orginal state when i let go of space.

      Also can someone please tell me how to make a game so that when i choose choices that come up on a screen an animation is played.

      For me the most helpful way would be if someone posted the script explaining what each line did and maybe posted this in use in flash so i can see if it is what i want. Thanks in advance.

      James.
        • 1. Re: Amatuer programming :S
          FlashTastic Level 1
          Hi James,

          Here is a quick sample. This code assumes you have 2 movieclips, one names bullet, and one named weapon on the stage.

          Cheers,
          Flashtastic
          • 2. Re: Amatuer programming :S
            NecroSaint Level 1
            Ok thankyou so much! (but is that really a quick sample). I understand nearly all of this code but i dont like using codes without understanding them, what does the key listener do, and also why do i have to insert a movie clip named weapon. Once again thanks in advance :)

            James.
            • 3. Re: Amatuer programming :S
              NecroSaint Level 1
              also i copied this code into flash, puttin all of the code into the frame, and it didnt work, i tried changing bits around and still nothing. I checked for erros and nothing. Just to check i created a small ball and named it bullet then i made a gun (:S kind of) and called it weapon i made sure both were movie clips. Is there something else im meant to do, i read through code a few times, i think i need this object kl bit explained to me.

              Sorry if im just being stupid, but maybe someone could post a flash document with this code in correct use just to show me its me not code. Thanks in advance.

              James.
              • 4. Re: Amatuer programming :S
                FlashTastic Level 1
                Make sure this code is on the _root timeline.

                Make sure that the movieclips are on the stage and their instance names (different than their symbol names) are bullet and weapon.

                if you type trace(bullet) you should get _level0.bullet
                if you type trace(weapon) you should get _level0.weapon

                kl is just a name I gave to an object, I could have called it keylistener or whatever I wanted. Basically, I created an object, gave it onKeyDown and onKeyUp methods, and then registered that object with the key class so it would receive key events (Key.addListener)

                I can't post a FLA for you because that would be doing the work for you and you wouldn't end up learning what you need to know.

                And - you're not being stupid - it would be stupider NOT to ask for help ;)

                Cheers,
                FlashTastic
                • 5. Re: Amatuer programming :S
                  NecroSaint Level 1
                  Thanks working fine now, im pretty sure i understand how the object works, if i could work out how to upload the .fla id show you the finished product XD.

                  Thanks again,

                  James,