This content has been marked as final. Show 5 replies
Here is a quick sample. This code assumes you have 2 movieclips, one names bullet, and one named weapon on the stage.
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 :)
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.
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 ;)
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.