I want to make the browser fullscreen through my flex website - apache-flex

I have a website which is built totally in flex.
I want to make a button, on the click of which the browser becomes fullscreen. I am not talking about a flex fullscreen, by which i mean "Application.application.stage.displayState = StageDisplayState.FULL_SCREEN;" I dont want to use this.
The reason, I dont want to use it is, that flash does not supports keyboard on flex-fullscreen. But if i can make the browser fullscreen, it will solve my purpose.
Also i am hoping the same method will be good for all browsers on PC and Mac both.

Use ExternalInterface to call a javascript function for it. Sorry this solution is half-baked so I'm not 100% sure it works..
//In ActionScript
public function fullScreen():void
{
if (ExternalInterface.available)
{
ExternalInterface.call("fullScreen");
}
else
{
//Error
}
}
//In JavaScript
function fullScreen()
{
if (parseInt(navigator.appVersion)>3) {
moveTo(0,0);
resizeTo(screen.availWidth,screen.availHeight);
}
//on older browsers just leave it alone
}

i did the same work using thw solution for which you r saying no, u r saying the keyboard doesn't work, but it's working in ma case
here is the button code :
<mx:Button id="fullscreen" styleName="fullscreen" click="toggleFullScreen();"/>
and here is the function which gets called :-
private function toggleFullScreen():void
{
if(Application.application.stage.displayState == StageDisplayState.NORMAL)
Application.application.stage.displayState = StageDisplayState.FULL_SCREEN;
else if(Application.application.stage.displayState == StageDisplayState.FULL_SCREEN)
Application.application.stage.displayState = StageDisplayState.NORMAL;
}
also there are some files , that u need to copy in the html-template folder:-
i'll send u those files, mail me ankursharma85#in.com, i'll reply u
and yes, when u r in full screen mode, u can press "esc" key to get to the normal mode, and if u want to use keyboard to make fullscreen, then u keyboard events, thats a different story
i hope this helps
tc hav a gr8 time

Related

Disable copying data from webpage

I was looking for any way to create web page,so that user wont be able to copy content from my web page. i.e. User wont be able to select the any text present on the webpage.
Let's assume i am working on asp.net
Any interesting ideas to accomplish the task ?
Ultimately you can't.
If you disable the ability to select text, the context menu or even just the copy option from the context menu users will still be able to see your content.
If they can see it they can copy it:
Take a screenshot.
Take a photo.
Type the text they see into Notepad.
Dictate the text into a recorder.
It's not worth the development effort and you won't stop the determined copier. All you'll end up doing is annoying your legitimate users.
Add value to your site so people want to keep coming back rather than just taking content and running. This could be:
Allow user generated content to expand on what's there.
Update content regularly so it's always fresh.
You can use user-select CSS3 propertie
HTML like this :
<span class="protected">Datas you wants protect</span>
And the correspondant CSS :
.protected {
-moz-user-select:none;
-webkit-user-select:none;
user-select:none;
}
See my example : http://jsfiddle.net/DoubleYo/RPv4q/
This solution is not cross browser but work fine with firefox and chrome/safari
EDIT : advanced user can copy your content with view the page source, make pdf or print your page, and some people mention firebug, fiddler.
If you send down any text the user will be able to see the source, so disabling copy and paste by any method will not really help stop the determined copier.
The most effective approach would be to render your text in to an image on the server and send down the image and not the raw text, but before you do that there are several downsides to consider: 1) You will require capacity on your server to generate the image. 2) The data load will be higher than just text and compresion will be less effective. 3) You may also loose some caching options.
Is there a particular reason you don't want the user to copy the text, perhaps if you can provide more details other approaches may be possible?
Try this
<html>
<head>
<script language="<strong class="highlight">javascript</strong>">
function onKeyDown() {
// current pressed key
var pressedKey = String.fromCharCode(event.keyCode).toLowerCase();
if (event.ctrlKey && (pressedKey == "c" ||
pressedKey == "v")) {
// <strong class="highlight">disable</strong> key press porcessing
event.returnValue = false;
}
} // onKeyDown
</script>
</head>
<body>
<form name="aForm">
<input type="text" name="aText" onkeydown = "onKeyDown()">
</form>
</body>
</html>
When someone visits your website they receive the html/css/images/JavaScript that makes up the bulk of your site. So they already have your Content, as most browsers cache this too, to allow quicker browsing.
Read more on HTTP here - http://www.http.header.free.fr/http.html
So it is not quite possible to totally stop anyone that know how the http protocol works. But what you can do is to maybe listen for right clicks and stop normal end users from right clicking and saving a image etc. You can get a snippet here - http://www.dynamicdrive.com/dynamicindex9/noright.htm
But if you are talking about protecting images/files that are selling please have a look at Protect html/php/image files from tracking as it then applies to your problem.
You can add to your body tag like so:
<body onselectstart="return false">
This is Internet. You can't completely protect the content of the page.
But you can difficult this task for the user.
You can too handle keyboard and mouse inputs, like Ctrl+C or right click of the mouse.
But remember that the user can always see the source code of the page, copy it and paste on a HTML editor.
You can make your site in Silverlight or Flash, but this will "disable" search engines indexing.
convert your page into a image
You can disable the selection, and with out selection you do not have copy/paste, however I suggest do that only on some parts of your page because is frustrate for the user.
This is the simple code that you can do that, eg, if you have a div with id="notme", run the disableSelOnThis("notme");
function disableSelOnThis(IdName) {
var oElem = document.getElementById(IdName);
if (oElem)
disableSelection(oElem); }
function disableSelection(element) {
element.onselectstart = function() {
return false;
};
element.unselectable = "on";
element.style.MozUserSelect = "none";
element.style.cursor = "default";
}
The code was from : http://ajaxcookbook.org/disable-text-selection/ , but its seams that this site is not longer live.
Of course without javascript enable this is not working and everything ChrisF says still stands.
Just copy and Paste the below javascript in your webpage:
<script language="javascript" type="text/javascript">
function disableselect(e) {
return false
}
function reEnable() {
return true
}
document.onselectstart = new Function("return false")
if (window.sidebar) {
document.onmousedown = disableselect // for mozilla
document.onclick = reEnable
}
function clickIE() {
if (document.all) {
(message);
return false;
}
}
document.oncontextmenu = new Function("return false")
var element = document.getElementById('tbl');
element.onmousedown = function () { return false; } // mozilla
</script>
Note:If the above code not works for Firefox then add style="-moz-user-select:none" in the body tag which needs to be restricted alongwith the above code.

Ctrl + C not working in flash player(swf file) when browser is Google Chrome

I have my project developed in Flex3,
<<Site Link Removed now>>
You can check it here, the problem I'm facing is, copying(Ctrl + c) the content from screen textarea when the swf is running in chrome browser.
suppose, I have to add some text on the stage, so the text area which is opened on the left side, I can't copy the text written in text area, although by right clicking in textarea, and selecting the copy option, thats working, but my client has asked for copying the content by using Ctrl + c, although it's working very fine with other browsers,
only chrome is not supporting copying(Ctrl + c), although selecting all(Ctrl + A ) is working
So this the thing, which I thought I should discuss, may b someone also hav same problem,
Use KeyboardEvent.KEY_DOWN to detect "C" being pressed. Then check for ctrlKey to see if it is down, and use System.setClipboard(source.text); to set the clipboard content.
textArea.addEventListener (KeyboardEvent.KEY_DOWN, onKeyDown);
private function onKeyDown ( ev : KeyboardEvent ) : void
{
if (ev.keyCode != 67 || !ev.ctrlKey) return;
var text:String = textArea.text;
System.setClipboard( text);
}
Beware, though: Sometimes odd things can happen simultaneously, like the text content disappearing and such. You might have to work around that!
It's not just chrome that does this, safari and some other browsers do it too.
Your best bet is to use a JavaScript library to catch these keyboard events and then pass them through to your Flex app.
For communicating between the two: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html
How to detect keyboard short cuts in JavaScript (have tested Ctrl+1 in Chrome on Windows XP: http://www.openjs.com/scripts/events/keyboard_shortcuts/

Flex: cannot resize player back from Full Screen

The key event is not listened by my Flex app. Since it is really simple code, I cannot understand where the problem is...
init() {
stage.addEventListener(KeyboardEvent.KEY_DOWN, escHandler);
}
private function escHandler(event:KeyboardEvent):void {
debugF.text = "ESC pressed";
}
thanks
I'm not sure I fully understand your question, but a lot of the user interaction events (including keyboard) are disabled when Flash is in fullscreen mode. Escape is automatically handled by Flash to exit out of fullscreen. I don't believe it will be passed to your listeners.

How to disable a Perl/Tk window close ('X') button on Windows

Is there a way to make a Perl/Tk window's close ('X') button disabled?
I know how to ignore clicking it using the technique described here, but I would much rather have it disabled.
I'm using Perl/Tk on Windows.
Thanks,
splintor
If you are in a Unix environment you are out of luck. The "close" button is managed by the Window Manager of the desktop which is a completely different process that you have no control on.
Even if by a hack you disable the "close" button the user can always bring it back
if the window manager permits this. The enlightenment window manager for example can
enable/disable all window buttons on demand.
The technique you give in the link is doing exactly this. It does not remove
the "close" button. It just gives a hint to the window manager (WM_DELETE_WINDOW).
It is up to the window manager if this hint will be honoured or not.
See also the icccm and NetWM pages.
What you want might be possible on Windows, but my experience with this OS
is limited so perhaps another poster will know this.
I have an app that I wrote, i was wondering about the same thing, and i don't disableit, but i have a call back to a subroutine, that simply does return;
$Mw->protocol('WM_DELETE_WINDOW',sub{return;});
According to the Perl Monks, it looks like the following works on Windows:
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
my $window = new MainWindow;
$window ->title("Close test");
$window ->geometry("400x250");
#prevents window from closing
$window->protocol('WM_DELETE_WINDOW' => sub {
print "Do stuff before exiting\n";
exit;
});
MainLoop;
In the above code, you are intercepting the signal sent when the user presses 'X' and can then write your own subroutine to execute when the button is pressed.
If you want to disable the close icon, set sub to empty (effectively telling it to "do nothing when pressed"): 'WM_DELETE_WINDOW' => sub {}
If you don't manage to really disable the close button (I mean to grey it out or even remove it from the window decoration), it might be the most intuitive thing to iconify your window instead of closing it. This is what I did.
$window->protocol('WM_DELETE_WINDOW', sub { $window->iconify(); } );

How print Flex components in FireFox3?

Thanks to FireFox's buggy implementation of ActiveX components (it really should take an image of them when printing) Flex components (in our case charts) don't print in FX.
They print fine in IE7, even IE6.
We need these charts to print, but they also have dynamic content. I don't really want to draw them again as images when the user prints - the Flex component should do it.
We've found a potential workaround, but unfortunately it doesn't work in FireFox3 (in FireFox2 it sort-of works, but not well enough).
Anyone know a workaround?
Using the ACPrintManager I was able to get firefox 3 to print perfectly!
The one thing I had to add to the example was to check if stage was null, and callLater if the stage was null.
private function initPrint():void {
//if we don't have a stage, wait until the next frame and try again
if ( stage == null ) {
callLater(initPrint);
return;
}
PrintManager.init(stage);
var data:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight);
data.draw(myDataGrid);
PrintManager.setPrintableContent(data);
}
Thanks. A load of callLater-s added to our custom chart code seems to have done it.

Resources