TwelvestoneFlash

Key.isDown()...at least it was.


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
faerieprince
 
2003-01-23

Here is an interesting thing. I had this code working, then made some changes to fla and now it does not work at all! I have not altered this code a bit but now it does not work. Have you ever experienced this? I even tried recoding it in 'save as' version and it did not work there either!

this.onEnterFrame = function () { moveMe.apply (this); };

moveMe = function () { if (Key.isDown(Key.LEFT)) { if (this._x < left) { this._x -= 5; } else { this._x = left; }
} if (Key.isDown(Key.RIGHT)) { if (this._x < right) { this._x += 5; } else { this._x = right; } } };

Any thoughts on why this does not work and what ought to fix it?

persist
 
2003-01-23

where are the vars left and right coming from?

The function is tracing okay, it's just not passing those if statements because I haven't set them.

What do you get for traces when you run:

this.onEnterFrame = function () { moveMe.apply (this); };

moveMe = function () { if (Key.isDown(Key.LEFT)) { trace("left!"); if (this._x < left) { this._x -= 5; trace("left fired!"); } else { this._x = left; } } if (Key.isDown(Key.RIGHT)) { trace("right!"); if (this._x < right) { this._x += 5; trace("right fired!"); } else { this._x = right; } } };

?

faerieprince
 
2003-01-24

The 'left' and 'right' are _global. I am using them to define a box on my main stage. As far as the trace goes, I had tried that and nothing was traced. Now that is really weird to me. If I put other code on the same frame, it works. I just cannot get this section to work like it did initially.

F r u s t r a t i o n.

Any other ideas? Oh, this seems to work fine on a brand new movie, just not the one I need it to work with.

persist
 
2003-01-24

wird. I can see why your getting frustrated.

try this on it and see if the function is even firing:

this.onEnterFrame = function () { moveMe.apply (this); };

moveMe = function () { trace("yes I am actually firing here."); };

faerieprince
 
2003-01-24

so i know it is reading my function. It just seems to be an issue with the Key.isDown(). More interesting twists, this works:

on (keyPress "f")

but I do not want to have everything set up on buttons.

warrg:mad:

persist
 
2003-01-24

did you lock the left and right keys? are you using them for something else as well?

this is so weird!

faerieprince
 
2003-01-24

Yeah, I did check that. I had the same thought, but there are only three keys that are 'active' in this movie, the LEFT, RIGHT and 'f' (which is the button command). So I switched them to keys that I knew were not in use, SHIFT and DELETE. Still nothing!

Man, what a pain in the brain this is becoming. I have, in the past, experienced times where my AS, for whatever reason, breaks after modifying it. I have never seen Flash just totally disregard an entire object class though. No matter where I put it in my movie it still refuses to recognize that I am pressing keys using the Key.isDown() method.

I am currently devising a workaround using buttons, but that is not what I wanted it to do. I suppose in the end it will function the same, but now it is a matter of conquering the .fla and getting this to work.

Any further thoughts would be appreciated k

masaflash
 
2003-01-25

tp={}; tp.onKeyDown=function(){ trace(Key.getCode()); } Key.addListener(tp);

this script might help you in some way? masa.

faerieprince
 
2003-01-27

Thank you for the idea!

It works just as well as the button method. For whatever reason, if I check against the getCode() it works out, but if I am just looking for isDown() Flash acts as though it has no idea what key is being pressed.

Freaky glitch.

Still wish I could get isDown to work, just so it works. Ah well, I can save that for another day.

Thanks to you both for your help.

  • Craig
Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

Key.isDown()...at least it was.