3 Replies - 3263 Views - Last Post: 29 August 2012 - 05:14 AM

#1 HxC_Pokecore  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 07-September 11

Problem with using 'and' and '!'

Posted 27 August 2012 - 01:49 AM

So I need to make a game in flash for school and I was using this http://www.newground...tal/view/237541 as a guide.

I got to
onClipEvent (enterFrame){
if (!Key.isDown(Key.LEFT) and !Key.isDown(Key.RIGHT) and !Key.isDown(Key.DOWN) and inair == false and this._currentframe>1) {
this.gotoAndStop(2);
down = false;}}


and it just won't work.

if (Key.isDown(Key.RIGHT) and !Key.isDown(Key.UP) and inair == false and this._currentframe>1) {
this.gotoAndStop(3);
this._x += speed;}

This won't work either. If I delete everything but (Key.isDown(Key.RIGHT) then it works (though I needed to add another bracket because it seems that the person who made this left it out)

So why isn't this working?

Is This A Good Question/Topic? 0
  • +

Replies To: Problem with using 'and' and '!'

#2 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1011
  • View blog
  • Posts: 4,215
  • Joined: 14-February 08

Re: Problem with using 'and' and '!'

Posted 28 August 2012 - 05:13 AM

and is not an operator, the operator is &&

onClipEvent(enterFrame)
{
     if (!Key.isDown(Key.LEFT) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.DOWN) && !inair && this._currentframe>1)
     {
        this.gotoAndStop(2);
        down = false;
     }
}



This will work although I think you should look at some more recent actionscript code than that tutorial. Also tutorials are only a starting point and should not be used word for word but as a way to get started on your own code.
Was This Post Helpful? 0
  • +
  • -

#3 HxC_Pokecore  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 07-September 11

Re: Problem with using 'and' and '!'

Posted 28 August 2012 - 04:54 PM

I'm using ActionScript 2 if I didn't say that.
So more recent actionscript won't work..
Was This Post Helpful? 0
  • +
  • -

#4 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1011
  • View blog
  • Posts: 4,215
  • Joined: 14-February 08

Re: Problem with using 'and' and '!'

Posted 29 August 2012 - 05:14 AM

regardless, and is not an operator. Use &&
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1