00:00
00:00
Newgrounds Background Image Theme

mariobros22 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Arrows movement work but not on NG

300 Views | 3 Replies
New Topic Respond to this Topic

Hi all,
our latest flash (swf) game release features a character that moves when using keyboard arrows. It works just fine when published on our website or when run directly from our machine but it doesn't work at all on Newgrounds.
Does anyone know what could be causing this?
Cheers

Response to Arrows movement work but not on NG 2017-04-01 08:06:27


At 3/31/17 10:12 AM, PGSPOTSTUDIOS wrote: Hi all,
our latest flash (swf) game release features a character that moves when using keyboard arrows. It works just fine when published on our website or when run directly from our machine but it doesn't work at all on Newgrounds.
Does anyone know what could be causing this?
Cheers

I think more details are required, what are the functions you are using that take the keyboard inputs etc. being in the iframe may be the cause of the issue. What happens if you load the swf from an iframe on your local machine?

Response to Arrows movement work but not on NG 2017-04-01 09:47:55


Hi Funkmachine,
thank you for your reply and suggestion.
Just tried that and it works fine even if loaded within an iframe both local and online.

Below is the main code we use for the movement:

public function checkKeypresses():void
{

if(key.isDown(37) || key.isDown(65))
{ // left arrow or A
leftPressed = true;
} else {
leftPressed = false;
}

if(key.isDown(38) || key.isDown(87))
{ //up arrow or W
upPressed = true;
} else {
upPressed = false;
}

if(key.isDown(39) || key.isDown(68))
{ //right arrow or D
rightPressed = true;
} else {
rightPressed = false;
}

if(key.isDown(40) || key.isDown(83))
{ //down arrow or S
downPressed = true;
} else {
downPressed = false;
}

if(!leftPressed && !rightPressed && !upPressed && !downPressed)
{
/*
if(key.isUp(37))
{
this.player.gotoAndStop('move_left');
this.player.lust_left.gotoAndStop(1);
}
else if(key.isUp(38))
{
this.player.gotoAndStop('move_back');
this.player.lust_back.gotoAndStop(1);
}
else if(key.isUp(39))
{
this.player.gotoAndStop('move_right');
this.player.lust_right.gotoAndStop(1);
}
else if(key.isUp(40))
{
this.player.gotoAndStop('move_front');
this.player.lust_front.gotoAndStop(1);
}
*/

try { this.player.lust_left.gotoAndStop(1); } catch (e:Error) {}
try { this.player.lust_back.gotoAndStop(1); } catch (e:Error) {}
try { this.player.lust_right.gotoAndStop(1); } catch (e:Error) {}
try { this.player.lust_front.gotoAndStop(1); } catch (e:Error) {}

this.previousKey = "";
this.randomBattleTimer.reset();
randomBattleTimer.delay = timerValue[Math.round(Math.random() * (timerValue.length - 1))];

}

}

public function loop(e:Event):void
{
//trace('start');
this.focusRect = false;
stage.focus = this;
checkKeypresses();
trace(leftPressed, rightPressed, upPressed, downPressed)
this.previousCharX = player.x;
this.previousCharY = player.y;
this.previousMapX = this.maps.map.x;
this.previousMapY = this.maps.map.y;

if(leftPressed && !downPressed && !upPressed)
{
if(player.x > this.visibleArea.x )
{
player.x -= speed;
}
else if(this.maps.map.x < 0) //1125
{
this.maps.map.x += speed;
}
else if(player.x >= this.screenArea.x)
{
player.x -= speed;
}
if(previousKey != "l")
{
this.player.gotoAndStop('move_left');
this.currentCharacter = this.player.lust_left;
this.currentCharacter.gotoAndPlay(2);
}
previousKey = "l";
}
if(rightPressed && !downPressed && !upPressed)
{
if(player.x < (this.visibleArea.x + this.visibleArea.width - this.player.width))
{
player.x += speed;
}
else if(this.maps.map.x > (stage.stageWidth - this.backgroundWidth)) //-1125 1920 1280
{
this.maps.map.x -= speed;
}
else if(player.x <= (this.screenArea.x + this.screenArea.width - this.player.width))
{

player.x += speed;
}
if(previousKey != "r" && !downPressed)
{
this.player.gotoAndStop('move_right');
this.currentCharacter = this.player.lust_right;
this.currentCharacter.gotoAndPlay(2);
}
previousKey = "r";
}
if(downPressed && !rightPressed && !leftPressed)
{
if(player.y < (this.visibleArea.y + this.visibleArea.height - this.player.height))
{
player.y += speed;
}
else if(this.maps.map.y >= (stage.stageHeight - this.maps.map.background.height)) //-1125
{
this.maps.map.y -= speed;
}
else if(player.y <= this.screenArea.x + this.screenArea.height - this.player.height)
{
player.y += speed;
}

if(previousKey != "f")
{
this.player.gotoAndStop('move_front');
this.currentCharacter = this.player.lust_front;
this.currentCharacter.gotoAndPlay(2);
}
previousKey = "f";
}
if(upPressed && !rightPressed && !leftPressed)
{
if(player.y > this.visibleArea.y)
{
player.y -= speed;
}
else if(this.maps.map.y <= 0) //-1125
{
this.maps.map.y += speed;
}
else if(player.y >= this.screenArea.y)
{
player.y -= speed;
}

if(previousKey != "b")
{
this.player.gotoAndStop('move_back');
this.currentCharacter = this.player.lust_back;
this.currentCharacter.gotoAndPlay(2);
}
previousKey = "b";
}

if(upPressed && leftPressed)
{

if(player.x > this.visibleArea.x )
{
player.x -= speed;
}
else if(this.maps.map.x < 0) //1125
{
this.maps.map.x += speed;
}
else if(player.x >= this.screenArea.x)
{
player.x -= speed;
}

if(player.y > this.visibleArea.y)
{
player.y -= speed;
}
else if(this.maps.map.y <= 0) //-1125
{
this.maps.map.y += speed;
}
else if(player.y >= this.screenArea.y)
{
player.y -= speed;
}

if(previousKey != "b")
{
this.player.gotoAndStop('move_back');
this.currentCharacter = this.player.lust_back;
this.currentCharacter.gotoAndPlay(2);
}
previousKey = "b";
}

if(upPressed && rightPressed)
{

if(player.x < (this.visibleArea.x + this.visibleArea.width - this.player.width))
{
player.x += speed;
}
else if(this.maps.map.x > (stage.stageWidth - this.backgroundWidth)) //-1125 1920 1280
{
this.maps.map.x -= speed;
}
else if(player.x <= (this.screenArea.x + this.screenArea.width - this.player.width))
{

player.x += speed;
}

if(player.y > this.visibleArea.y)
{
player.y -= speed;
}
else if(this.maps.map.y <= 0) //-1125
{
this.maps.map.y += speed;
}
else if(player.y >= this.screenArea.y)
{
player.y -= speed;
}

if(previousKey != "b")
{
this.player.gotoAndStop('move_back');
this.currentCharacter = this.player.lust_back;
this.currentCharacter.gotoAndPlay(2);
}
previousKey = "b";
}

if(downPressed && leftPressed)
{

if(player.x > this.visibleArea.x )
{
player.x -= speed;
}
else if(this.maps.map.x < 0) //1125
{
this.maps.map.x += speed;
}
else if(player.x >= this.screenArea.x)
{
player.x -= speed;
}

if(player.y < (this.visibleArea.y + this.visibleArea.height - this.player.height))
{
player.y += speed;
}
else if(this.maps.map.y >= (stage.stageHeight - this.maps.map.background.height)) //-1125
{
this.maps.map.y -= speed;
}
else if(player.y <= this.screenArea.x + this.screenArea.height - this.player.height)
{
player.y += speed;
}

if(previousKey != "f")
{
this.player.gotoAndStop('move_front');
this.currentCharacter = this.player.lust_front;
this.currentCharacter.gotoAndPlay(2);
}
previousKey = "f";
}
if(downPressed && rightPressed)
{

if(player.x < (this.visibleArea.x + this.visibleArea.width - this.player.width))
{
player.x += speed;
}
else if(this.maps.map.x > (stage.stageWidth - this.backgroundWidth)) //-1125 1920 1280
{
this.maps.map.x -= speed;
}
else if(player.x <= (this.screenArea.x + this.screenArea.width - this.player.width))
{

player.x += speed;
}

if(player.y < (this.visibleArea.y + this.visibleArea.height - this.player.height))
{
player.y += speed;
}
else if(this.maps.map.y >= (stage.stageHeight - this.maps.map.background.height)) //-1125
{
this.maps.map.y -= speed;
}
else if(player.y <= this.screenArea.x + this.screenArea.height - this.player.height)
{
player.y += speed;
}

if(previousKey != "f")
{
this.player.gotoAndStop('move_front');
this.currentCharacter = this.player.lust_front;
this.currentCharacter.gotoAndPlay(2);
}
previousKey = "f";
}

Again thank you for looking into this, much appreciated.

Response to Arrows movement work but not on NG 2017-04-01 09:48:45


At 4/1/17 08:06 AM, Funkmachine wrote:
At 3/31/17 10:12 AM, PGSPOTSTUDIOS wrote: Hi all,
our latest flash (swf) game release features a character that moves when using keyboard arrows. It works just fine when published on our website or when run directly from our machine but it doesn't work at all on Newgrounds.
Does anyone know what could be causing this?
Cheers
I think more details are required, what are the functions you are using that take the keyboard inputs etc. being in the iframe may be the cause of the issue. What happens if you load the swf from an iframe on your local machine?

Hi Funkmachine,
thank you for your reply and suggestion.
Just tried that and it works fine even if loaded within an iframe both local and online.
Below is the main code we use for the movement:
public function checkKeypresses():void
{
if(key.isDown(37) || key.isDown(65))
{ // left arrow or A
leftPressed = true;
} else {
leftPressed = false;
}
if(key.isDown(38) || key.isDown(87))
{ //up arrow or W
upPressed = true;
} else {
upPressed = false;
}
if(key.isDown(39) || key.isDown(68))
{ //right arrow or D
rightPressed = true;
} else {
rightPressed = false;
}
if(key.isDown(40) || key.isDown(83))
{ //down arrow or S
downPressed = true;
} else {
downPressed = false;
}
if(!leftPressed && !rightPressed && !upPressed && !downPressed)
{
/*
if(key.isUp(37))
{
this.player.gotoAndStop('move_left');
this.player.lust_left.gotoAndStop(1);
}
else if(key.isUp(38))
{
this.player.gotoAndStop('move_back');
this.player.lust_back.gotoAndStop(1);
}
else if(key.isUp(39))
{
this.player.gotoAndStop('move_right');
this.player.lust_right.gotoAndStop(1);
}
else if(key.isUp(40))
{
this.player.gotoAndStop('move_front');
this.player.lust_front.gotoAndStop(1);
}
*/
try { this.player.lust_left.gotoAndStop(1); } catch (e:Error) {}
try { this.player.lust_back.gotoAndStop(1); } catch (e:Error) {}
try { this.player.lust_right.gotoAndStop(1); } catch (e:Error) {}
try { this.player.lust_front.gotoAndStop(1); } catch (e:Error) {}
this.previousKey = "";
this.randomBattleTimer.reset();
randomBattleTimer.delay = timerValue[Math.round(Math.random() * (timerValue.length - 1))];
}
}
public function loop(e:Event):void
{
//trace('start');
this.focusRect = false;
stage.focus = this;
checkKeypresses();
trace(leftPressed, rightPressed, upPressed, downPressed)
this.previousCharX = player.x;
this.previousCharY = player.y;
this.previousMapX = this.maps.map.x;
this.previousMapY = this.maps.map.y;
if(leftPressed && !downPressed && !upPressed)
{
if(player.x > this.visibleArea.x )
{
player.x -= speed;
}
else if(this.maps.map.x < 0) //1125
{
this.maps.map.x += speed;
}
else if(player.x >= this.screenArea.x)
{
player.x -= speed;
}
if(previousKey != "l")
{
this.player.gotoAndStop('move_left');
this.currentCharacter = this.player.lust_left;
this.currentCharacter.gotoAndPlay(2);
}
previousKey = "l";
}
if(rightPressed && !downPressed && !upPressed)
{
if(player.x < (this.visibleArea.x + this.visibleArea.width - this.player.width))
{
player.x += speed;
}
else if(this.maps.map.x > (stage.stageWidth - this.backgroundWidth)) //-1125 1920 1280
{
this.maps.map.x -= speed;
}
else if(player.x <= (this.screenArea.x + this.screenArea.width - this.player.width))
{
player.x += speed;
}
if(previousKey != "r" && !downPressed)
{
this.player.gotoAndStop('move_right');
this.currentCharacter = this.player.lust_right;
this.currentCharacter.gotoAndPlay(2);
}
previousKey = "r";
}
if(downPressed && !rightPressed && !leftPressed)
{
if(player.y < (this.visibleArea.y + this.visibleArea.height - this.player.height))
{
player.y += speed;
}
else if(this.maps.map.y >= (stage.stageHeight - this.maps.map.background.height)) //-1125
{
this.maps.map.y -= speed;
}
else if(player.y <= this.screenArea.x + this.screenArea.height - this.player.height)
{
player.y += speed;
}
if(previousKey != "f")
{
this.player.gotoAndStop('move_front');
this.currentCharacter = this.player.lust_front;
this.currentCharacter.gotoAndPlay(2);
}
previousKey = "f";
}
if(upPressed && !rightPressed && !leftPressed)
{
if(player.y > this.visibleArea.y)
{
player.y -= speed;
}
else if(this.maps.map.y <= 0) //-1125
{
this.maps.map.y += speed;
}
else if(player.y >= this.screenArea.y)
{
player.y -= speed;
}
if(previousKey != "b")
{
this.player.gotoAndStop('move_back');
this.currentCharacter = this.player.lust_back;
this.currentCharacter.gotoAndPlay(2);
}
previousKey = "b";
}
if(upPressed && leftPressed)
{
if(player.x > this.visibleArea.x )
{
player.x -= speed;
}
else if(this.maps.map.x < 0) //1125
{
this.maps.map.x += speed;
}
else if(player.x >= this.screenArea.x)
{
player.x -= speed;
}
if(player.y > this.visibleArea.y)
{
player.y -= speed;
}
else if(this.maps.map.y <= 0) //-1125
{
this.maps.map.y += speed;
}
else if(player.y >= this.screenArea.y)
{
player.y -= speed;
}
if(previousKey != "b")
{
this.player.gotoAndStop('move_back');
this.currentCharacter = this.player.lust_back;
this.currentCharacter.gotoAndPlay(2);
}
previousKey = "b";
}
if(upPressed && rightPressed)
{
if(player.x < (this.visibleArea.x + this.visibleArea.width - this.player.width))
{
player.x += speed;
}
else if(this.maps.map.x > (stage.stageWidth - this.backgroundWidth)) //-1125 1920 1280
{
this.maps.map.x -= speed;
}
else if(player.x <= (this.screenArea.x + this.screenArea.width - this.player.width))
{
player.x += speed;
}
if(player.y > this.visibleArea.y)
{
player.y -= speed;
}
else if(this.maps.map.y <= 0) //-1125
{
this.maps.map.y += speed;
}
else if(player.y >= this.screenArea.y)
{
player.y -= speed;
}
if(previousKey != "b")
{
this.player.gotoAndStop('move_back');
this.currentCharacter = this.player.lust_back;
this.currentCharacter.gotoAndPlay(2);
}
previousKey = "b";
}
if(downPressed && leftPressed)
{
if(player.x > this.visibleArea.x )
{
player.x -= speed;
}
else if(this.maps.map.x < 0) //1125
{
this.maps.map.x += speed;
}
else if(player.x >= this.screenArea.x)
{
player.x -= speed;
}
if(player.y < (this.visibleArea.y + this.visibleArea.height - this.player.height))
{
player.y += speed;
}
else if(this.maps.map.y >= (stage.stageHeight - this.maps.map.background.height)) //-1125
{
this.maps.map.y -= speed;
}
else if(player.y <= this.screenArea.x + this.screenArea.height - this.player.height)
{
player.y += speed;
}
if(previousKey != "f")
{
this.player.gotoAndStop('move_front');
this.currentCharacter = this.player.lust_front;
this.currentCharacter.gotoAndPlay(2);
}
previousKey = "f";
}
if(downPressed && rightPressed)
{
if(player.x < (this.visibleArea.x + this.visibleArea.width - this.player.width))
{
player.x += speed;
}
else if(this.maps.map.x > (stage.stageWidth - this.backgroundWidth)) //-1125 1920 1280
{
this.maps.map.x -= speed;
}
else if(player.x <= (this.screenArea.x + this.screenArea.width - this.player.width))
{
player.x += speed;
}
if(player.y < (this.visibleArea.y + this.visibleArea.height - this.player.height))
{
player.y += speed;
}
else if(this.maps.map.y >= (stage.stageHeight - this.maps.map.background.height)) //-1125
{
this.maps.map.y -= speed;
}
else if(player.y <= this.screenArea.x + this.screenArea.height - this.player.height)
{
player.y += speed;
}
if(previousKey != "f")
{
this.player.gotoAndStop('move_front');
this.currentCharacter = this.player.lust_front;
this.currentCharacter.gotoAndPlay(2);
}
previousKey = "f";
}
Again thank you for looking into this, much appreciated.