AS3 AIR RequestSoftKeyboard not working on Windows - actionscript-3

I tried to launch a virtual keyboard on Windows using this:
_txtInputName = new TextField();
_txtInputName.type = TextFieldType.INPUT;
_txtInputName.needsSoftKeyboard = true;
_txtInputName.addEventListener(FocusEvent.FOCUS_IN, onFocus );
private function onFocus(e:FocusEvent):void
{
_txtInputName.requestSoftKeyboard();
}
Unfortunaly, the softkeyboard doesn't show up. Am I missing something? Does I have to add something on the application.xml?
Thank you so much!

TextField is not an object type compatible with native keyboard handling. As a coder using a TextField does mean not using native keyboard at all. SO simple answer to your question is this:
Of course it's not working since it's not mean to.
Next: To provide native keyboard support on the AIR platform the StageText built-in class was implemented and is the one any coder wanting to handle native keyboard should use.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/StageText.html

Related

How to capture RIGHT_CLICK in FlashDevelop?

I wish to add an event listener for the MouseEvent.RIGHT_CLICK event in FlashDevelop.
In Flash CS6's editor, I can simply do:
stage.addEventListener(MouseEvent.RIGHT_CLICK, onMouse);
But MouseEvent.RIGHT_CLICK does not seem to exist in FlashDevelop.
I tried 'disabling' the context menu:
stage.showDefaultContextMenu = false;
But still to no avail. How can I get this to work?
Make sure your FlashDevelop project settings target a Flash Player version high enough to support the RIGHT_CLICK event; that being at least Flash Player 11.2.

StageText multiline problems

So I am pretty new to this whole AIR for iOS development thing and am just dipping my toe into the StageText object for a project I am working on. I am having trouble getting my StageText to be restricted to a single line. (such as for username input)
The documentation is terrible from Adobe but blog posts I have found have said to pass "false" to the StageTextInitOptions which seems to sorta work, but not really. When I do this the read-only multiline property on the stageText option traces as "false" which is good but when I actually type in the field it still breaks and goes to the next line when it is full.
here is my code:
var stageTextInitOptions = new StageTextInitOptions(false);
stageText = new StageText(stageTextInitOptions);
stageText.stage = stage;
stageText.viewPort = new Rectangle(0, 0, w, h);
trace(stageText.multiline); //traces out as false
EDIT: The problem seems to be in desktop only, when the app is placed on an ipad the multiline limitation functions as expected. (The problem is it NEEDS to work on both desktop and ios)
Any ideas? thanks so much!
StageText uses native mobile keyboards only on iOs and Android. You will need to work with the TextField and wordwrapping on the Desktop.
Why would you not use a regular hardware keyboard on a Desktop though? It's as native for Desktops as it gets.
use :
var stageTextInitOptions = new StageTextInitOptions(true);

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

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.

Flash & external form fields

Does anybody know if this is possible?
I am trying to create a flash movie that will show / preview what I am typing into a field in a normal HTML form. The call to update the flash movie would most likely be attached to an onKeyUp event.
Any advice or tutorials would be great
cheers!
Decbrad
Assuming you're using actionscript 3....
Check this out
You can also check this link out (its for Flex 3 though... AS3 should be similar for flash I believe)... I've used ExternalInterface in my Flex projects before.
As far as I'm aware, Flashplayer only listens to key events when it has focus (which it wouldn't have if you're typing into an HTML form. I'm not aware of any way to inject events into Flash with javascript.
Is there a particular reason why you can't use a text area in the actual flash movie itself?
My advise would be to grab your favorite event utility for JavaScript and then pair it with ExternalInterface. That way, you can add a callback to the EI in Flash which would mean that you could do something like this:
ExternalInterface.addCallback( "keyboardClicked", dispatcherFunc );
function dispatcherFunc():void
{
dispatchEvent( new Event( "javaScriptKeyClick" ) );
}
document.getElementById( "mySwf" ).keyboadClicked();
Hey guys, thanks for pointing me in the right direction! I haven't touched flash since version 4 so to say that i'm rusty... is an understatement!
The reason I haven't built the text area in the actual flash movie is because the system is 95% complete now and there's a lot of smarts on the server side. The flash preview is more or less the icing, as they say! Bit surprised there's not more of a hook into Flash.
Thanks again!
Dec

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.