Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 769
  • Last Modified:

In Flash 5. How to disable the Escape key ?

When playing in full screen F5 movie (Win Projector.exe)

I want to disable the Escape key.

I found; Object>Key>Escape :
Key.Escape ...........................

what expression I should place here ?

Thanks
0
4591
Asked:
4591
  • 7
  • 7
  • 5
  • +1
1 Solution
 
henrywwCommented:
... hmmm ... never tried ..

but i suppose u can keep doing
fscommand ("fullscreen", "true");
in a loop or onEnterFrame, it will be back on full screen

not sure ... let see if there is another way to do that!
0
 
rascalpantsCommented:
you could use a listener for that:  

from Macromedia.com:

----------------
Using a listener:
A listener is exactly what it sounds like: an object in memory that listens for events broadcast by other objects. In Flash MX, many objects have an addListener method which can be used to inform the object that a specific event has occurred.

The Key object contains an addListener method. When a key is pressed or released, regardless of the input focus, all listening objects registered with addListener have either their onKeyDown method or onKeyUp method invoked. Multiple objects can listen for keyboard notifications.

To create a generic Key listener object:
1  A generic listener catches all Key events and acts on them, no matter what has focus on the stage. Unlike the previous methods, it is not required that a MovieClip Object exists on stage and specific instance names are not targeted. For example, this entire script can be a frame script:

//Create a new variable and assign a new object to that variable
myListener = new Object

//Tell the object to perform a function when the onKeyDown event fires
myListener.onKeyDown = function(){


//What the function does goes here. In this case it sets a dynamic text field with the variable name resultField to a string value.
resultField = "please press another key"
}

//Registers the listener object to receive events from the Key object so that it knows when onKeyDown and onKeyUp occur
Key.addListener(myListener)
 
2  The final frame script looks like this:
myListener = new Object
myListener.onKeyDown = function(){
resultField = "please press another key"
}
Key.addListener(myListener)
 

--------------------------
0
 
henrywwCommented:
well here u go if u have mx ... thanks rp
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ZefferCommented:
put a movieclip off the stage somewhere in frame 1..and attach the following code to it..

onClipEvent (load) {
fscommand("trapallkeys", true);
}

If you are using key-press' elsewhere in the movie though..
this is total over-kill:)

Z
0
 
rascalpantsCommented:
H, you caught me NOT reading the question headline this time :)

sounds like Z has the right solution...  but as he says "may be overkill"


rp
0
 
henrywwCommented:
LOL ... ;)

this is fun ....
0
 
ZefferCommented:
this is another way..partly using henry's approach..but
it only activates when the escape button is pressed.
it's not actually disabling the button..but is effective if
you want other key press' in your movie to work.
on the movieclip off the stage..

onClipEvent (enterFrame) {
     if(Key.isDown(Key.ESCAPE)) {
          fscommand("fullScreen", true);
     }
}
Z
0
 
4591Author Commented:
I'm going to check it out all of it & get back to you
Thanx
0
 
4591Author Commented:
Hi henryww,
Did not guite get your idea , so could not tested  :)
 
hello Zeffer,
I made the 1fr movie clip place on the stage(for tasting) & attached the  code:
onClipEvent (load) {
fscommand("trapallkeys", true);
}

Esc key is still functional & I got :

Scene=Scene 1, Layer=EscapeKeyMC, Frame=1: Line 1: Clip events are permitted only for movie clip instances
     onClipEvent (load) {
---------------------------
I tried this code with the same results as above

onClipEvent (enterFrame) {
    if(Key.isDown(Key.ESCAPE)) {
         fscommand("fullScreen", true);
    }
}

wonder, why doesn't it work ??
===========
In F5 I found in the Object Action (Normal Mode) Basic Actions
fscommand("trapallkeys", true);

& is working , it's disabling all keys, right (total overkill),
however; I provide the all needed buttons for my frame-by-frame animation.
Also, the disappearing Full screen button would not work
with >>onClipEvent (enterFrame)<< nor >>onClipEvent (load)<<
because the all anim. movie would go to the full screen just from the start , right?

That was not my intention here, I wanted to disable the escape button so
viewer can't stop watching on the full screen my anim.......hahahaha..
by switching it of :)
0
 
ZefferCommented:
I think you are putting the code on the frame ..not selecting the movieclip and putting it on the clip.
as long as the frames are extended out the length of the
timeline..(on the layer where you put the movieclip with the actions)..the second one will work.
if a user presses esc..the code forces it to fullscreen again.
a slight delay..with a slow processor..but it will carry
out your evil plan..:)
Z
0
 
rascalpantsCommented:
evil plan is right :)

45, you need to put the code Z provided on the clip as mentioned above.

I think you can combine the fullscreen solutions from the last question with this one...

you would just make the movieclip with the button in it have two frames with stop(); actions in both of them.  then in the second frame put a movieclip in it and put the code mentioned above on that movieclip.

in the code that is attached to the button, just put this code in it to go to the next frame:

gotoAndPlay(2);


I have not tested whether or not this works, but I should in theory...

here is an example using Z's fullscreen solution that combines the solution that I am talking about...

http://www.rascalpants.com/flash5_fullscreen_button.fla
 

I guess it is okay to call THIS one the best solution, because I am using everyone elses and combining them all together :) ha ha ha ...this is part of my evil plan :)


rp
0
 
rascalpantsCommented:
this method is a little rough around the edges, because the screen will still go small, but them back up to fullscreen again...  that is the price you pay for not using Flash MX and a listener...


rp
0
 
4591Author Commented:
Zeffer,
yes, you're right ..haha.., now action is on movie clip (extended out the length of the
time line) & is working,
but there's one problem with:

onClipEvent (enterFrame) {
    if(Key.isDown(Key.ESCAPE)) {
         fscommand("fullScreen", true);
    }
}
after I hit Esc key animation comes back to full screen
BUT
movie stops on the frame where the Esc was pressed,
so I need  another play button , that's no good.
Can this be fixed ?
The main anim. movie should play even after Esc is pressed.
--------------------
This one, plays all right & no need to extend movie clip with action,
similar with Object Action (Normal Mode) Basic Actions
fscommand("trapallkeys", true); that I discover after looking at yours  :

onClipEvent (load) {
fscommand("trapallkeys", true);
}
Here, no need for a helping movie clip, fscommand kills all key as it ought to.

rascalpants,
Hahaha...It isn't so evil, if ones knows a couple things or two (haha..) :
Esc + Shift + Ctrl  > Win NT4 task manager - still works to end chosen task
Alt + Ctrl + Del - knocks all  wind. & apps. down
& there's always the Main switch or
just puling the plug ( the worst nightmare of any machine!)...hah aha...
rascal pants,
Today, I will not have time to look in to your idea. (perhaps tomorrow)

Your:  flash_fullscreen_button. Did you read in my previous question :
>>I've just noticed , your solution is not a button at all, wherever someone clicks on the
>>screen the swf goes full screen , we don't need the designated area "go full screen".
>>So, a viewer can click unintentionally anywhere & movie goes to full screen that's no good
>>& PRECISE for the flash ....hmmmm...Try your test to see what I mean.<<
& I stress: CLICK UNINTENTIONALLY (if  it is still there I'm not buying ...haha....)

As I said to Zeffer
>>>>>>>ya get this new software (MX) and it's so clever<<
            well...Did you know that for  frame-by-frame animation I use actually
            Flash 4 selection style ( is more efficient); a couple people who
            animate they prefer it too.
            So tell me why I need (MX) ; for a few buttons ,....neeee...<<<<<<<

Personally , I do not mind to combine the solution. I do that all the time, as long as
goal is reached. Actually that's very good approach to everything.
------------------------
Ps. Even if I kill all the keys that's all right this is just an anim. movie
NOT anything  INTERACTIVE.

go to go
0
 
ZefferCommented:
to keep the main timeline playing just add
play();

onClipEvent (enterFrame) {
   if(Key.isDown(Key.ESCAPE)) {
        fscommand("fullScreen", true);
        play();
   }
}

the playhead steps through the lines of code from the
top down..so it'll do the fscomand and then play
Z
0
 
rascalpantsCommented:
as I said in my last post, I used Z's solution to the fullscreen problem(flash 5) and I combined it with the code that was supplied in this thread...

take a look at it when you get a chance...


also...

">>>>>>>ya get this new software (MX) and it's so clever<<
           well...Did you know that for  frame-by-frame animation I use actually
           Flash 4 selection style ( is more efficient); a couple people who
           animate they prefer it too.
           So tell me why I need (MX) ; for a few buttons ,....neeee...<<<<<<<"

There is absolutely no reason to use Flash 4 to do frame by frame animation.  they all work the exact same way for that...  I bet the same people who are still using Flash 4 are the same people who code everything by hand in a txt file, because they think Dreamweaver(or any other WYSIWYG) is the devil.


I never said you should go BUY mx, I just said you should use MX... :)  

And unless you will never again use flash, then you should upgrade to MX, because it simplies everything, and is much more dynamically compatible.


or just keep spending countless hours asking questions about "previous version solutions" on boards like these, so us experts have something to do :)



rp





0
 
4591Author Commented:
Hello Zeffer,
I tried this  :

onClipEvent (enterFrame) {
  if(Key.isDown(Key.ESCAPE)) {
       fscommand("fullScreen", true);
       play();
  }
}
result :  Esc key pressed, my animation STOPS

I tried to place a 1 frame & extended out the length of the time line with the action
play(); attached >>> result :  Esc eye pressed, my animation STOPS...hahaha...

Ps.I hope you do not mind spending countless hours answering
my questions about "previous version solutions" :) :)
Can send you my tests if it can help.
0
 
ZefferCommented:
no don't mind..
I tried that code above with an animation on the main timeline..and it works.. don't know why it won't work for you..is the movieclip with the code on it..on the main timeline?

if it isn't..

_root.play();

otherwise..zip your tests and i'll have a look.
z@redpearl.co.nz
Z
0
 
4591Author Commented:
Hello Zeffer,

*esckTestZ2.fla & esckTestZ2.swf

onClipEvent (enterFrame) {
  if(Key.isDown(Key.ESCAPE)) {
       fscommand("fullScreen", true);
       play();
  }
}
result :  Esc key pressed, my animation stops.
-----------------------------------------------
*esckTestZ4.fla & esckTestZ4.swf

onClipEvent (enterFrame) {
  if(Key.isDown(Key.ESCAPE)) {
       fscommand("fullScreen", true);
       _root.play();
  }
}
result :  Esc key pressed, my animation continues.

Zeffer, you did not write >> _root. <<
Perhaps, that's obvious for you but not me & any computer
(computers are not so smart , after all ; despite that some people like to think so)
...hahaha....
Have a look , now I'm sure, esckTestZ4.fla is the one & I'll lock the question.
Thanks :)
0
 
ZefferCommented:
here's the thing..in your question you said it was for
flash projector .exe

both of those samples you sent work if you test by clicking
the exported swf or exe..testing in Flash authoring ..
both of them stop the animation.

#4 is a little smoother (works quicker)..as there is the reference to _root..
the player will reference root by default..if you just use
play();..but obvoiusly it takes a fraction longer to think
about it.

but BOTH of them work..in standalone player.
but #4 is best..for the reason described above.
Z


0
 
4591Author Commented:
Zeffer,
yes you're right about  flash projector .exe
well... hate to argue Zeffer, I sent swf, because they are smaller but there you have
both exe (esckTestZ2.exe & esckTestZ4.exe), try mine....hahaha...
Z2.exe stops when Esc key pressed; on my Macromedia Flash Player 5.0 . I was curious
This is strictly an academic discussion...haha... esckTestZ4.exe works !

I got my answer when you killed all keys, I kept going so I can use
your last solution for something  interactive , but by then we will have
a Flash 7 or whatever its name will be & I'd like to upgrade.
Flash5 speeds things up a bit , but frame-by-frame anim. is still long process.
(too long for me :) :) :)
0
 
ZefferCommented:
the .swf's work fine..I can't see that there would be a
difference to an exe..they both use the standalone player..
and i'll take your word on it for the exe's.
I looked at 4..but 2 is not showing the projector icon..so
I am not going to open it..you understand of course:)

Z
0
 
4591Author Commented:
ok Zeffer,
yes, I looked at them both when zipped & they do not have projector icons.
I've never done (zipped) exe file just sent it in its original state,
didn't hear about any problems so far.
ok. thanks for your trouble.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 7
  • 7
  • 5
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now