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.