A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Frustrated newbie - help pls!

  1. #1
    Junior Member
    Join Date
    Jun 2001
    Posts
    4

    Smile

    Hi,

    I'm new to Flash, but not to programming. I've had experience in C/C++ but I'm stuck on my first flash project.

    Eventually I want to recreate the old game spectrum classic Juggernaught.....but first things first.

    At the moment I have a simple movie clip, of a square that rotates when you click the left and right arrow keys. What i want it to do is to travel in the same direction it's pointing.

    I don't really know where to start in Flash (version 5)

    Heres the code i got so far:

    onClipEvent ( load ) {
    rotspeed=5
    }

    onClipEvent (enterFrame) {
    if (Key.isDown(Key.RIGHT)) {
    this._rotation+=rotSpeed;
    } else if (Key.isDown(Key.LEFT)) {
    this._rotation-=rotSpeed;
    }

    }

    Any help will be much appreciated.


  2. #2
    curmudgeon swampy's Avatar
    Join Date
    Jan 2001
    Location
    [wakey]
    Posts
    2,775
    Code:
    onClipEvent (keyDown) {
    	if (Key.isDown(Key.LEFT)) {
    //change the value of rotspeed to speed up the rate of turn
    		rotspeed -= 5;
    	} else if (Key.isDown(Key.RIGHT)) {
    		rotspeed += 5;
    	}
    }
    onClipEvent (enterFrame) {
    //change the number at the end of this i.e 5 to speed up or decrease speed of forward trajectory 
    	ychange = (math.cos((math.PI/180)*rotspeed))*5;
    	xchange = (math.sin((math.PI/180)*rotspeed))*5;
    	setProperty (this, _y, this._y - ychange);
    	setProperty (this, _x, this._x + xchange);
    	setProperty (this, _rotation, rotspeed);
    }



  3. #3
    Junior Member
    Join Date
    Jun 2001
    Posts
    4

    Thanks!

    Cheers!

    Much obliged.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center