Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Flash Actionscript / August 2007



Tip: Looking for answers? Try searching our database.

Weird code problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob Robertson - 30 Aug 2007 18:36 GMT
I'm trying to create a hotkey of sorts. The idea is that the user should press
Crtl-Shift-T to make the movie jump to a special frame. The code attached works
correctly when put onto an empty frame in a fresh movie. However, when I use
the exact same code (literally a copy-paste) in the intended application, it
doesn't trigger. I have Control->Disable Keyboard Shortcuts enabled, and I have
observed this behavior both locally and remotely.

Could someone more experienced please advise me in what could be causing this?
I've never seen anything of the sort before.

Many Thanks,
Bob Robertson

var myListener = Object();
myListener.onKeyDown = myOnKeyDown;
Key.addListener(myListener);
myOnKeyDown = function() {
    if (Key.isDown(Key.CONTROL) && Key.isDown(Key.SHIFT) && Key.isDown(84) &&
_root._currentframe==1){
        // 49 is key code for 1
        trace("Crtl-Shift-T pressed");
        _root.gotoAndPlay(5);
    }
}
Bob Robertson - 31 Aug 2007 15:05 GMT
Okay, found something interesting. When I publish the application for players 7
and 8, things work perfectly. However, when I try to publish for 6 and under,
it doesn't work. This is not the case for other applications of the same kind
that I have worked on: publishing for 6, 7, and 8 all work correctly.

Does anybody have any idea what's going on here? I have to publish for player
6; that's unavoidable. At the same time, I need this feature to work properly,
and I don't know how to even start debugging something like this.

Many Thanks,
Bob Robertson
kglad - 31 Aug 2007 15:24 GMT
try:

var myListener = Object();
myOnKeyDown = function() {
    if (Key.isDown(Key.CONTROL) && Key.isDown(Key.SHIFT) && Key.isDown(84) &&
_root._currentframe==1){
        // 49 is key code for 1
        trace("Crtl-Shift-T pressed");
        _root.gotoAndPlay(5);
    }
}

myListener.onKeyDown = myOnKeyDown;
Key.addListener(myListener);
Bob Robertson - 31 Aug 2007 16:00 GMT
No joy, unfortunately. I did discover an additional datum, though. Somehow, my
app is killing the Key service class entirely:

When I trace typeof(Key) in both the good and the trouble apps, it outputs
'movieclip'.

When I trace typeof(Key._listeners) in a normally functioning sister app, it
outputs 'object'; when I trace typeof(Key._listeners) in the problem app, it
outputs 'undefined'.

When I trace Key._listeners.length after adding a listener in the functional
version, it returns '1'; when I trace Key._listeners.length after adding a
listener in the trouble app, it returns 'undefined'.

This is utterly bizarre, and I've never encountered anything like it before.
The only place the 'Key' keyword shows up is in the listener definition. Have
you seen this before? Have I found a compiler bug?

Thanks,
Bob Robertson
kglad - 31 Aug 2007 16:49 GMT
i've never had a problem with the key class and i don't recall seeing any posts
about others having similar difficulties.

to find the issue, i would make a copy of your problem appication and start
eliminating major chunks of code and objects until the problem is narrowed.  
you should be able to find the essential part of your code/objects that cause
you key problems.

but you should be using the code i gave:  you can't reference myOnKeyDown
before it is defined.
Bob Robertson - 31 Aug 2007 16:31 GMT
No joy, unfortunately. I did discover that my app is apparently somehow killing
the Key instance, though:

When I trace typeof(Key) in both the trouble app and a working sister app, it
outputs 'movieclip'.

When I trace typeof(Key._listeners) in the working app, it outputs 'object';
when I do it in the trouble app, it outputs 'undefined'.

When I trace typeof(Key._listeners.length) in the working app, it outputs
'number'; when I do it in the trouble app, it outputs 'undefined'.

When I trace Key._listeners.length in the working app after adding a listener,
it outputs'1';when I do it in the trouble app, it outputs 'undefined'.

The 'Key' keyword doesn't even appear in the app besides at that point, so I
don't know how it's getting corrupted. I've never encountered anything like
this before. Do you have any ideas? Have I found a compiler bug? Am I doing
something tacitly verboten that no one mentioned?

Many Thanks,
Bob Robertson
Bob Robertson - 31 Aug 2007 17:00 GMT
No joy, unfortunately. I did discover that my app is apparently somehow killing
the Key instance, though:

When I trace typeof(Key) in both the trouble app and a working sister app, it
outputs 'movieclip'.

When I trace typeof(Key._listeners) in the working app, it outputs 'object';
when I do it in the trouble app, it outputs 'undefined'.

When I trace typeof(Key._listeners.length) in the working app, it outputs
'number'; when I do it in the trouble app, it outputs 'undefined'.

When I trace Key._listeners.length in the working app after adding a listener,
it outputs'1';when I do it in the trouble app, it outputs 'undefined'.

The 'Key' keyword doesn't even appear in the app besides at that point, so I
don't know how it's getting corrupted. I've never encountered anything like
this before. Do you have any ideas? Have I found a compiler bug? Am I doing
something tacitly verboten that no one mentioned?

Many Thanks,
Bob Robertson

PS: sorry if this is a multiple repost; I think something's wonky with the
combination of the servers, my machine, and the proxy I'm going through.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.