Edits to post #25311457 by CyberMonkey30
Edited at 2014-11-26 22:11:04
At 11/26/14 10:02 PM, MSGhero wrote:At 11/26/14 09:52 PM, CyberMonkey30 wrote: this is still not working i keep getting this response.Read what it says. You're missing a }. Flashdevelop is working perfectly, your code is what's incorrect.
can you help fix my code.
package
{
import flash.display.MovieClip;
public class player extends MovieClip
{
public var grav:int = 0;
public var floor:int = 450;
public function player()
{
this.graphics.beginFill(0, 1);
this.graphics.drawCircle(this.x, this.y, 25);
this.graphics.endFill();
}
public function adjust ():void
{
this.y += grav;
if(this.y+this.height/2<floor)
grav++;
else
{
grav = 0;
this.y = floor - this.height / 2;
}
if (this.x - this.width / 2 < 0)
this.x = this.width / 2;
if (this.x +this.width / 2 < 800)
this.x = 800 - this.width / 2;
}
}
}
At 11/26/14 10:02 PM, MSGhero wrote:At 11/26/14 09:52 PM, CyberMonkey30 wrote: this is still not working i keep getting this response.Read what it says. You're missing a }. Flashdevelop is working perfectly, your code is what's incorrect.
can you help fix my code.
package
{
import flash.display.MovieClip;
public class player extends MovieClip
{
public var grav:int = 0;
public var floor:int = 450;
public function player()
{
this.graphics.beginFill(0, 1);
this.graphics.drawCircle(this.x, this.y, 25);
this.graphics.endFill();
}
public function adjust ():void
{
this.y += grav;
if(this.y+this.height/2<floor)
grav++;
else
{
grav = 0;
this.y = floor - this.height / 2;
}
if (this.x - this.width / 2 < 0)
this.x = this.width / 2;
if (this.x +this.width / 2 < 800)
this.x = 800 - this.width / 2;
}
}
}
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
public class Main extends Sprite
{
private var aDown:Boolean = false;
private var dDown:Boolean = false;
private var char:player = new player();
public function Main():void
{
char.x = 500;
char.y = 300;
addChild(char);
stage.addEventListener(Event.ENTER_FRAME, checkStuff);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keysdown);
stage.addEventListener(KeyboardEvent, KEY_UP, keysUp);
}
public function checkStuff(e:Event):void
{
if (aDown)
char.x -= 5;
if (dDown)
char.x += 5;
char.adjust();
}
public function keysDown(e:KeyboardEvent):void
{
if (e.keyCode == 65)
aDown = true;
if (e.keyCode == 68)
dDown = true;
if (e.keyCode == 87&&char.y+char.width/2===char.floor)
char.grav = -15;
}
public function keysUp(e:KeyboardEvent):void
{
if (e.keyCode == 65)
aDown = false;
if (e.keyCode == 68)
dDown = false;
}
}

