Problem with SWF and arrow keyboard events

  • shadowswind
  • Born
  • Born
  • shadowswind
  • Posts: 1

Post 3+ Months Ago

HI all!!

I have a problem. I load a SWF on my flash application on frame 133 with this code:


Code: [ Select ]
this.createEmptyMovieClip("load",0);
loadMovie("teste.swf", load);
load._x = 80.0;
load._y = 300.0;
load._xscale = 80;
  1. this.createEmptyMovieClip("load",0);
  2. loadMovie("teste.swf", load);
  3. load._x = 80.0;
  4. load._y = 300.0;
  5. load._xscale = 80;



The first time it loads, i can press the RIGHT arrow key and it will continue to play the SWF, but when i press the LEFT arrow key, it won't play the SWF's LEFT arrow key event,but it plays the LEFT arrow key of the main timeline, because i have a key listener in the main timeline to go foward or back pressing the arrow key. How can i solve this problem?? help me please. thanks in advance.

here is the code for the key listener

Code: [ Select ]
// this is the object that will listen, #1
 var keyListener:Object = new Object ();
// this is what the object will do
 keyListener.onKeyDown = function ():Void {
 trace("keyGode: " + Key.getCode());
 if (Key.getCode() == 37 ) { // left arrow
     _root.gotoAndStop(2);
 }
 if(Key.getCode () == 39 ){ // right arrow
  _root.gotoAndStop(3); }
}  
 
 
// tell the object what to listen for
Key.addListener(keyListener);
  1. // this is the object that will listen, #1
  2.  var keyListener:Object = new Object ();
  3. // this is what the object will do
  4.  keyListener.onKeyDown = function ():Void {
  5.  trace("keyGode: " + Key.getCode());
  6.  if (Key.getCode() == 37 ) { // left arrow
  7.      _root.gotoAndStop(2);
  8.  }
  9.  if(Key.getCode () == 39 ){ // right arrow
  10.   _root.gotoAndStop(3); }
  11. }  
  12.  
  13.  
  14. // tell the object what to listen for
  15. Key.addListener(keyListener);
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

most listeners (but especially keyboard listeners) are global in Flash. Meaning the listener will fire no matter where it is in the timeline or nested clips. What you need to do is create ONE listener and then use an if/else to check if your sub clip is open and then it should either move the main timeline or the sub timeline.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 13 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.