Handling JavaScript calls to window.open()- not using Native Windows - Adobe AIR - html

I am developing an Adobe AIR application which uses both native windows and floating panels. Is is possible to enable the creation of a floating window instead of a native window when a JavaScript window.open() function is called?
It is required that all of the floating windows are contained within one native window, therefore the creation of more native windows is not suitable.
I have used a Custom HTMLHost class in order to enable the creation of a native window but I can’t work out a way of creating a MDI window instead. I am using the flexMDI framework for my floating panel interface.
Any help on this would be much appreciated.

You can try hijacking the HTML's window object via code:
htmlContent.addEventListener(Event.COMPLETE, htmlLoaded);
private function myOpenFunction(...args) {
// Do stuff with args
}
private function htmlLoaded(event:Event):void
{
htmlContent.domWindow.open = myOpenFunction;
}
I'm not sure if that (or something very similar) will work, but it's probably the only way to do it if it can be done at all.

Related

is it possible to pin AIR app over any opened windows?

I need to pin AIR application over other windows, I mean, regardless if AIR application is in focus or not, it must not hide, it always must be shown, whatever other program I activate or work with, AIR application must be over every window always. Is it possible? If it is, please show me the function (example code will be better :) ) which does it, incase if AS3 has one.
You're looking for the alwaysInFront property of the NativeWindow class:
The alwaysInFront property specifies whether this window will always be in front of other windows (including those of other applications).
The following example forces a window to be displayed in front of all
other windows (that are not similarly forced to the front):
windowObj.alwaysInFront = true;
Another example with a reference to a display object on the window stage:
displayObject.stage.nativeWindow.alwaysInFront=true;

ActiveX hosted by IE: how to render DirectShow EVR inside an IE's HTML dom object

I'm trying to display a video in Internet Explorer with my own ActiveX control.
I created the ActiveX control and a demo HTML page creating the control using the OBJECT tag (and setting a width/height on it). I can call simple methods on this control through javascript, it works.
I also created a working directshow graph to display the video. The graph contains a "Enhanced Video Renderer" (EVR) renderer filter.
But i am stuck : i can not find a way to link these 2 technologies. Some MSDN doc says the EVR should use WindowLess activation. But this activation requires a hWnd and a rectangle inside the hWnd. My ActiveX is hosted in Internet Explorer, how can i get the hWnd and make the renderer render at the correct position/size in this window ?
Note that I know how to get the object's absolute rectangle in javascript and give it to the ActiveX. But this rectangle may move with the scrollbar ? And how to get this damn hWnd ?
EDIT
It seems the ActiveX needs to implement the IOleInPlaceObjectWindowless interface which has a SetObjectRects methods called by the host, and should query the host for the IOleWindow interface which has a GetWindow method returning the hWnd.
EDIT 2
It seems all you have to do is implmenet IComponent to retreive an ISite host interface on which you can query any service you need.

Moving Native Window in AS3

How to move native window when any display object start drag in Flash action script? As we do with clock gadget in windows 7.
Actually, I am trying to make my custom clock that will work like a clock in windows 7.
If you are targeting Air, then use stage.nativeWindow.startMove(); like so:
private function dragWindow(e:MouseEvent):void
{
stage.nativeWindow.startMove();
}
clock.addEventListener(MouseEvent.MOUSE_DOWN, dragWindow);

StageWebView Lack on URLs with target="_blank"

is there any solution on StageWebView.loadURL(), how I can handle URLs in HTML Pages which have target="_blank"?
It's a mobile Android App. (TabbedViewApplication)
Hope someone can help.
Thx
One option is StageWebViewBridge.
StageWebViewBridge is an extended version of flash.media.StageWebView.
Extends loadString method with AS3 - JS communication.
-Extends Bitmap class, you can modify his x,y,alpha,rotation,visible, etc ( Version 1 Beta )
-Communicates Actionscript with Javascript.
-Communicates Javascript with Actionscript.
-Load local files and resources in a easy way.
-Extends loadString method with AS3 - JS communication.
-Extends loadString method to load local resources.
-Lets you take an SnapShot to use as the bitmapData of the bitmap.
StageWebViewBridge source: https://code.google.com/p/stagewebviewbridge/
I never worked with the StageWebView but I know it's really limited. When using an HTMLLoader, you can set a custom HTMLHost instance that specifies to use current HTMLLoader when opening to _blank. However, I don't think it's possible with StageWebView.
public class MyHTMLHost extends HTMLHost
{
public function MyHTMLHost(defaultBehaviors:Boolean=false)
{
super(defaultBehaviors);
}
override public function createWindow(windowCreateOptions:HTMLWindowCreateOptions):HTMLLoader
{
// all JS calls and HREFs to open a new window should use the existing window
return htmlLoader;
}
}
OK, so the only solution for this problem i could found is to load the page (containing the links) as String with the URLLoader and replace its specified parts. Finally loading it via StageWebView.loadString() method.
Problems occur when the Site is dynamic and contains JavaScript. I had also replace some relative links with absolute pathes.
That's it... but I really hope that adobe makes it possible to load those "_blank" links with the StageWebView.loadURL() method.
If you want to capture when a user clicks on a link inside your StageWebView add an an event listener for location changing event (LocationChangeEvent).
This LocationChangeEvent will include the URL they are going to and target. Then you can prevent the URL from loading, let it continue (by doing nothing) or handle it any other way including loading another URL.
If you want to load another URL first stop the loading with stageWebView.stop(). You should also call event.preventDefault(). You can then attempt to
Note: There is another event called locationChange that may be helpful.
As it was declared as an official bug, adobe QA Owner Sanjay C. added a comment: "Able to reproduce the issue with the attached project. Sending to IRB."
So, hope the next Build will come up with the fix wit it.
Best regards

How to control mobile softkeys from Flash application embedded in HTML

I have a flash application running Flash 9 (CS3). Application is able to control the Softkeys when this flash application is loaded in the supported mobile device. But, the application doesn't have control when the same is embedded in HTML page and browsed via supported mobile device. Any ideas how to make this work?
Thanks
Keerthi
There is no special way to receive soft key events when embedded in HTML - if the browser/OS gives the events to Flash, then you can catch them like any other key event:
var myListener = new Object();
myListener.onKeyDown = function() {
var code = Key.getCode();
if (code==ExtendedKey.SOFT1) {
trace("I got a soft key event");
}
}
Key.addListener(myListener);
However, you'll find that most phones/browsers will not give you soft key events when your SWF is embedded in HTML. This isn't part of the Flash Lite spec - strictly speaking I believe they could give you those events if they wanted to, but most phones simply use those keys for browser functions, and consume them before they get to Flash.
Note that you can check at runtime whether or not softkeys are available:
trace(System.capabilities.hasMappableSoftKeys);
trace(System.capabilities.softKeyCount);
If you use a switch statement, you can have more than one keycode associated with an action, you make a desktop version for testing too. I have done it myself.