PDA

View Full Version : Blocking Ctrl-Q and Esc on CD-rom


Tabu
07-27-2009, 10:12 PM
Hello,

Im producing a cd-rom and for a finishing touch I'd like to stop users from hitting esc or ctrl-q to quit. I'd prefer it to go through an exit button.
I know that the exit button needs a "on (release) {gotoAndPlay("quit");}"
with a timer or something to display the end credits, but how would I block the other routes?

Thanks

Tabu
07-27-2009, 10:28 PM
I have tried to put this timer at the end of the exit swf. But it simply quits the whole thing. It just ignores the fade functions and timer. Have I place the fscommand in the wrong place?



library._alpha = 5;
fadeIn();

function fadeIn(){
this.onEnterFrame = function(){
if(library._alpha <= 99){
library._alpha += 5;
}else{
delete onEnterFrame;
}
}
}
timer = setInterval(this, "fadeOut", 10000);
function fadeOut(){
this.onEnterFrame = function(){
if(library._alpha >= 1){
library._alpha -= 5;
}else{
delete onEnterFrame;
clearInterval(timer);
}
}
}
fscommand("quit");
stop();

northcode
07-28-2009, 04:17 PM
The call to fscommand("quit") is defineitely in the wrong place. You need to move it to just after your call to clearInterval in your fadeOut function.

Adding fscommand("trapallkeys", "true") to the beginning of your application will prevent the Ctrl+Q key from exiting your projector. The ESC key won't exit your projector (unless you have code in there to do that) it will only kick you out of fullscreen mode.

Tabu
07-28-2009, 08:12 PM
Thanks for your help.
Yes it was in the wrong place, that functions now, thanks for that.
The "trapallkeys" however isn't working. I've been searching on the web and it appears that in AS3 it simply crashes the animation, but in AS2 it ignores it.
I'm using CS3 but the animation is set up for AS2 so Im not sure if this is what Im experiencing? I've checked the code and even placed it in different areas but it doesn't function. From what Ive discovered there does not seem to be an equivalent for this function in CS3. Not sure if this is the problem?
Thanks again for your help.

its together with a bunch of fscommands

fscommand("trapallkeys", "true");
fscommand("fullscreen", "true");
fscommand("allowscale","false");
fscommand("showmenu","false");

can i put these under one fscommand, simply adding the , between each?

Thanks again

northcode
07-28-2009, 10:00 PM
I wrote a blog post about this quite a while ago.. FSCommand is broken in Flash CS3 (http://www.northcode.com/blog.php/2007/08/14/FSCommand-EXEC-is-Broken-in-Flash-CS3). Broken may be a strong stance, "badly bruised" might be more appropriate.

You can call all those commands but if you call two in the same frame (or compilation scipe) with the same argument, only the last one gets executed. So the only ones to be called in your example above are the fullscreen and showmenu commands.

Try it this way instead...

fscommand("trapallkeys", "true");
fscommand("fullscreen", "TRUE");
fscommand("allowscale","false");
fscommand("showmenu","FALSE");

And then all 4 fscommands will get called. I know, it's lame, but it works. Read my blog post if you REALLY care why :)

Tabu
07-29-2009, 09:01 AM
Thanks for this, the capitalisation didn't work for me, although funny enough it did block the esc button, but cmd-q still worked. I realised while i was doing this that it may be that i work on a mac so I use cmd-Q not ctrl-Q. Not tried it on a pc yet, could it be this?

northcode
07-29-2009, 02:49 PM
Cmd+Q on the Mac is like Ctrl+W on Windows, it's a message from the OS to close the application. The application can block that if it's been designed to do that, the Flash projector hasn't.

Tabu
07-29-2009, 11:09 PM
ok, is there is any way of overriding this?
I'll have to give your article a thorough read through I think, as I see it the "exec" would be what I should use? Ill give it a go.

northcode
07-30-2009, 12:04 AM
The only way to get around the operating system (i.e "user") being able to close your application normally is to use a different application to generate your projectors instead of Flash (which allows the OS to have it's way with them). There are a few commercial swf2exe applications which can do this, but only a couple that will do it for the Mac and the ones with Mac support are pretty sketchy in terms of quality - I can't, in good conscience, recommend using them if you want to retain your sanity.