It appears that I'm losing scope when I enter the anonymous function:

> >     keyListener.onKeyDown = function() {
[...]
> >     }

Because of this, I can't make function calls to this .mxml file's
ViewHelper, because it is undefined upon entering the anonymous
function. Does anyone have any advice on how to maintain scope (and
thus visibility of a ViewHelper) inside of an anonymous function?

Thanks.

--- In [email protected], "fowleryj" <[EMAIL PROTECTED]> wrote:
>
> I've also noticed that replacing the "getURL" line with a function
> call results in the function not being called:
> 
> Instead of
> >         if(currentKeyPressed == 99 && lastKeyPressedControl) {
> >             mx.controls.Alert.show('CTRL + c');
> >             getURL("javascript:self.close();");
> >         }
> 
> I now have
> >         if(currentKeyPressed == 99 && lastKeyPressedControl) {
> >             mx.controls.Alert.show('CTRL + c');
> >             closeWin();
> >         }
> 
> And closeWin() looks like this:
> public function closeWin() {
>       mx.controls.Alert.show("closeWin");
>       getURL("javascript:self.close();");
> }
> 
> The "closeWin" popup is never fired. Any ideas? Is anyone else
> successfully closing a window via a shortcut key combination?
> 
> --- In [email protected], "fowleryj" <[EMAIL PROTECTED]> wrote:
> >
> > Hello all,
> > 
> > I'm able to close a popup window in my application via the
> menuChangeHandler, like so:
> > 
> > private function menuChangeHandler(event) {
> >     if(event.menuItem.attributes.data == "Close") {
> >         getURL("javascript:self.close();");
> >     }
> > }
> > 
> > However, when I try to close the window via a shortcut key, I get
> the message box I'm invoking, but the window itself doesn't close
> (note that even before I put the message box code in, the window
> didn't close, so that's not preventing the window from closing):
> > 
> > var lastKeyPressedControl:Boolean = false;
> > var currentKeyPressed;
> > public function initKeyListener() {
> >     var keyListener = new Object();
> >     keyListener.onKeyDown = function() { 
> >         currentKeyPressed = Key.getAscii();
> >         if(currentKeyPressed == 99 && lastKeyPressedControl) {
> >             mx.controls.Alert.show('CTRL + c');
> >             getURL("javascript:self.close();");
> >         }
> >         lastKeyPressedControl = Key.isDown(Key.CONTROL);
> >     }
> >     Key.addListener(keyListener);    
> > }
> > 
> > Other shortcut keys I've checked for are recognized and their
> actions carried out... why does this one not work properly?
> > 
> > Thanks in advance.







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to