how to set an adobe Air application initial window to full screen - air

I have an air app created from one of Adobe's Examples using javascript / HTML. Is it possible to change the descriptor file so the application launches full screen or maximized?

Or you could call the maximize(); function in the application creation Complete function.

Maybe this helps (from here: http://www.kerkness.ca/how-to-launch-an-adobe-air-windowedapplication-in-full-screen-mode/)
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()">
<mx:Script>
<![CDATA[
private function init():void
{
systemManager.stage.displayState=flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE
}
]]>
</mx:Script>
</mx:WindowedApplication>

try this one.
onCreationComplete - call this method of the main application creation complete
private function onCreationComplete():void{
var current:Screen;
var scrArray:Array = Screen.screens;
var screens:Array = Screen.getScreensForRectangle(stage.nativeWindow.bounds);
(screens.length > 0) ? current = screens[0] : current = Screen.mainScreen;
this.width = current .bounds.width ;
this.height = current .bounds.height;
this.nativeWindow.x = 0;
this.nativeWindow.y = 0;
}

Related

AIR App can't capture mouse event & can't show context menu

I'm building a AIR application and I need a custom context menu.
My Problem is: There is no context menu in my application!
I searched for long while. Most people want to disable context menu, but I want to enable it. I know how to generate a context menu, but I can't even see the build in context menu.
The reason might be: My swf application cann't capture mouse event.
Anyone know the reason? Thanks very much!
You can implement like this:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="initApp()">
<mx:Script>
<![CDATA[
private function initApp():void {
var ctxMenu:ContextMenu = new ContextMenu();
var clsitem:ContextMenuItem = new ContextMenuItem("Close");
var edititem:ContextMenuItem = new ContextMenuItem("Edit");
var otheritem:ContextMenuItem = new ContextMenuItem("Etc.");
clsitem.addEventListener(Event.SELECT,closeApp);
ctxMenu.customItems.push(clsitem,edititem,otheritem);
this.contextMenu = ctxMenu;
}
private function closeApp(event:Event):void {
this.close();
}
]]>
</mx:Script>
<mx:Panel width="200" height="300">
</mx:Panel>
</mx:WindowedApplication>

How to open pdf files in windows 8 application using c#?

How to read the pdf files in windows 8 app .In my windows 8 application how to open the pdf files .
In manifest file i wrote the below code.
<Extensions>
<Extension Category="windows.fileTypeAssociation">
<FileTypeAssociation Name="pdf">
<SupportedFileTypes>
<FileType>.pdf</FileType>
</SupportedFileTypes>
</FileTypeAssociation>
</Extension>
</Extensions>
and code behind.
string imageFile = #"Images\DX730_EN.pdf";
var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);
if (file != null)
{
// Set the option to show the picker
var options = new Windows.System.LauncherOptions();
options.DisplayApplicationPicker = true;
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
if (success)
{
// File launched
}
else
{
// File launch failed
}
}
else
{
// Could not find file
}
i could not able to open the pdf file.please tell me where is error?
you can use the LaunchFileAsync method of the Windows.System.Launcher class.
Take a look at this:
http://msdn.microsoft.com/en-us/library/windows/apps/hh701465.aspx
Windows 8 comes with windows Reader to read pdf files .
This link might help you
http://www.howto-connect.com/how-to-view-pdf-file-in-windows-8-what-is-windows-reader/
If that doesn't help, this might
http://social.technet.microsoft.com/Forums/en-US/W8ITProPreRel/thread/b19fc6d8-531f-4cf2-8d6d-f1dc9e93a93d/
The solution is, you can open pdf files on Windows.ApplicationModel.Package.Current.InstalledLocation...
So, put the pdf on local folder and open from it.
StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
StorageFile file= await localFolder.GetFileAsync("myFile.pdf");
if (file != null)
{
// Set the option to show the picker
var options = new Windows.System.LauncherOptions();
options.DisplayApplicationPicker = true;
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
}

Firefox Xul Clipboad

I'm new to the programming world & i'm trying to develop an extension for Firefox. I have a Xul window with a textbox and i would like to copy the entire textbox and put in to the clipboard of firefox and paste it anywhere on the firefox browser.
Help me out with some JS code or using xul coding.
Please help me out or give me some suggestion.
Thanking you guys in advance.
For copying text to the clipboard the easiest way is to use the clipboard helper service.
My Problem is Fixed :
Here is the script: This script copy the entire text from the textbox and you can paste it anywhere in the browser Firefox.
<!-- Following script is for copy & paste function -->
<script>
<![CDATA[
function copyToClipboard() {
//Select all the text/strings from the textbox.
var copytext=document.getElementById('tb').value;
//alert(document.getElementById('tb').value + 'This is XUL');
//An XPCOM wrapper for the data which you want to put on the clipboard.
var str = Components.classes["#mozilla.org/supports-string;1"].
createInstance(Components.interfaces.nsISupportsString);
if (!str) return false;
str.data = copytext;
//This object is the component #mozilla.org/widget/transferable;1 which implements the interface nsITransferable.
var trans = Components.classes["#mozilla.org/widget/transferable;1"].
createInstance(Components.interfaces.nsITransferable);
if (!trans) return false;
trans.addDataFlavor("text/unicode");
trans.setTransferData("text/unicode", str, copytext.length * 2);
var clipid = Components.interfaces.nsIClipboard;
var clip = Components.classes["#mozilla.org/widget/clipboard;1"].getService(clipid);
if (!clip) return false;
clip.setData(trans, null, clipid.kGlobalClipboard);
//alert(document.getElementById('tb').value + 'This is fuckin XUL');
pasteFromClip();
window.close();
}
function pasteFromClip() {
var clip = Components.classes["#mozilla.org/widget/clipboard;1"].getService(Components.interfaces.nsIClipboard);
if (!clip) return false;
var trans = Components.classes["#mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
if (!trans) return false;
trans.addDataFlavor("text/unicode");
clip.getData(trans, clip.kGlobalClipboard);
var str = new Object();
var len = new Object();
trans.getTransferData("text/unicode",str,len);
str = str.value.QueryInterface(Components.interfaces.nsISupportsString);
str = str.data.substring(0, len.value / 2);
return document.createTextNode(str);
}
]]>
</script>

controlling X and Y of spark.components.Window

I am building an air app in Flex 4. I am creating windows as I need them in a chromeless application.
Here is what I have in my main app creation complete
protected function creationCompleteHandler(event:FlexEvent):void
{
facade.sendNotification(AppFacade.APP_INIT, this);
var buttons:NavigatorWindow = new NavigatorWindow();
var workingSets:WorkingSets = new WorkingSets();
buttons.addElement( workingSets );
buttons.width = 115;
buttons.height =200;
buttons.maximizable = false;
buttons.resizable = false;
buttons.addEventListener(AIREvent.WINDOW_COMPLETE, onWindowComplete);
buttons.open();
}
private function onWindowComplete(event:AIREvent):void
{
event.currentTarget.x = 100;
event.currentTarget.y = 100;
}
for some reason the application adds the window in the middle of the screen and if I set the x and y of the Window it does not put it where I expect in the upper left of my screen. How do I position the window where I would like when it is opened?
thanks,
The spark.components.Window exists inside a NativeWindow you'll need to position the NativeWindow if you want to move it around on the screen. It is a bit confusing because you can position the Window inside the native window as well. You'll have to do the positioning after creation complete, otherwise you'll get null reference errors.
You could invoke the window like this if you created a component based on spark.components.Window:
var win:MyWindow = new MyWindow(); //MXML component
win.height = 150;
win.width = 300;
win.systemChrome = NativeWindowSystemChrome.NONE;
win.type = NativeWindowType.LIGHTWEIGHT;
win.showStatusBar = false;
win.transparent = true;
win.alwaysInFront = true;
win.open(true);
Then in that mxml component, you set an creationComplete event handler to do this:
var padding:int = 25;
this.nativeWindow.x = Screen.mainScreen.visibleBounds.right - this.width - padding;
this.nativeWindow.y = Screen.mainScreen.visibleBounds.top + padding;
This should put your new window in the top right hand corner with 25px of padding on the top and right.

Launching a browser window from an AIR Application

I recently built an AIR app using HTML, CSS and JavaScript. In the web version there is a button on the Capacity tab that opens a new window with the calculated results. After packaging this into an AIR application the app attempts to open the new window but fails.
I read about doing such here, but I am not exactly sure how to implement the code (which follows below).
I would appreciate some guidance to know where this code would go. If there is an "easier" way to accomplish the same results, I am all ears.
Thanks!
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:HTML id="htmlComp" width="100%" height="100%" location="http://www.rediff.com"complete="addEventListenersToLinks(event)" />
<mx:Script>
<![CDATA[
private function addEventListenersToLinks(e:Event):void
{
var dom:Object = e.currentTarget.domWindow.document;
var links:Object = dom.getElementsByTagName("a");
for(var i:Number = 0; i < links.length; i++)
{
if(links[i].target.toLowerCase() == "_blank" || links[i].target.toLowerCase() == "_new")
links[i].onclick = linkClickHandler;
}
}
private function linkClickHandler(o:Object):void
{
navigateToURL(new URLRequest(o.currentTarget.href),"blank");
}
]]>
</mx:Script>
</mx:WindowedApplication>
This was a lot easier than I thought. Basic JavaScript:
CapacityWindow = window.open(document.location, 'CapacityWindow', 'toolbar=1,scrollbars=1,menubar=1,width=800,height=950');