I have embedded my SWF file to an HTML. I am using a TLF text in my AS3 application for the chatbox, but the problem is that the application loses its focus on TLF text while I switch to other pages, and switch back on my application. Please note that I do not face this problem while I run the SWF file using flash player on my desktop.
I have tried to use following code to re-focus on the TLF text but it does not work on my case.
addEventListener(Event.ACTIVATE, infocus);
function infocus(e:Event):void {
myTLF.textFlow.interactionManager = new EditManager();
myTLF.textFlow.interactionManager.selectRange(myTLF.text.length, myTLF.text.length);
myTLF.textFlow.interactionManager.setFocus();
}
My question is how we can resolve this? because it really bothers people since they have to click on the chatbox every times that they switch to other pages.
There are few ways to do so. You can manually put focus on your desired objects either by:
listening to MouseEvent.ROLL_OVER on your stage make a handler that will return the focus to your text field
if you want to make it to return focus on switch back to the page, you'll need to write a JS script that will tell SWF via ExternalInterface to put focus on your text field.
Related
I've got a flashbuilder air/flex app that used SWC's for all of it's graphic/window content that I've inherited and have run into a problem that i do not know how to solve.
The SWC has multiple text inputs which the user can tab through. However, when that SWC is loaded in flash builder pressing tab only causes the focused text field to lose focus and nothing appears to gain the focus next.
I've manually captured the tab keypress via a keyDown event listener inseide the SWC's AS3, however even setting stage.focus or setSelection() has no effect when running inside the flashbuilder app.
Is there something i can do to tell air/flex/flashbuilder to allow the focus events of the SWC?
I've closed this question as i ended up having to write my own input tab/focus manager from the ground up as a workaround.
After I set up my new project with libGDX v1.3.1 i am stuck with something that should be easy. In my main class which extends game I have:
Gdx.input.setCatchBackKey(true);
but I cannot get any response from this (in render method):
if(Gdx.input.isButtonPressed(Keys.BACK)){
this.dispose();
}
It like nothing was pressed, although I can see that the button was pressed in logCat console.
I need to mention that I was using the exact same code until libGDX version 1.0.0 (or the first one with gradle).
Note: i have also tried implementing InputProcessor and then setting the input processor. Result was the same.
And for the home button: using Gdx.input.setCatchMenuKey(true); is not working.
Use isKeyPressed instead of isButtonPressed. Buttons only refers to the three mouse buttons on a desktop game. Everything on Android is a Key (or Peripheral).
You mentioned "home button" but the code you posted is for the menu button. There is no way to catch the home button unless you make your manifest declare your app as a launcher replacement, in which case, the home button will always open your app, even when it's closed, and the user will have no easy way to get to the home screen. And libgdx doesn't have that functionality built in, since that would be weird. You would have to implement it yourself in your manifest and main Activity.
Also, disposing of this, whatever this is, sounds dangerous to do from the input handler. You could be about to render stuff and cause a crash. But I'm not sure where you're trying to use it from. Maybe it's OK.
Long story short, I seem to always be running into unpredictable StageText functionality in Adobe AIR applications. I want to avoid triggering the OS native input fields and emulate that functionality in a Feathers/Actionscript component directly.
I've incorporated an on-screen keyboard purely in Feathers and implemented a Button subclass that acts like a basic text input. When the user clicks the button, the on-screen keyboard is displayed and hardware keyboard KEYUP's are intercepted and used to dynamically update the button label attribute.
That all works well enough, but of course I have no flashing cursor or text selectability in my current rudimentary widget. I can continue along my current path and manually implement the rest of what I need, but wanted to ask if anyone has seen or implemented a 'native acting' non-native text input widget in the Feathers/Starling/Actionscript tech stack? (Google seems to say no, but I'm hoping that's wrong. Surely I'm not the only one that thinks AIR's StageText is... troublesome... at best)
I changed my rudimentary widget from a Button subclass to a TextInput with editor factory returning a custom flash.text.TextField that has it's SoftKeyboardEvent.SOFT_KEYBOARD_ACTIVATING being nixed via preventDefault().
I now have most of what I wanted from my basic text input functionality in that I now have a text widget I can click in and select text and have all the simple cursor functionality I was missing. This still prevents the flaky native-softkeyboard interaction so I think this might suffice.
I am looking for some help with Flash (CS5 version). I have a situation where if try to put a button on the stage with visible differences in the up/over/down/hit states, when I compile the document into a .swf, the button will continuously flicker through each state in order very quickly. Also, if I break the AS3 code in the Main class file, hidden parts of a slider bar component will flicker between visible and not. I'm talking Japanese-style, seizure-inducing flicker here. I've searched my code for recursive function calls and tried deleting and re-adding components and buttons, but to no avail. Any ideas on what could be up?
Well, it seems to me you aren't using stop() to stop the button at the frame you want.
If it isn't this, then there is some error with your ActionScript, which will show up in the output panel, so check that.
When you say 'button' is it an instance of the Button Class and have you set the instance type to Button?
i.e.
Select the button in your library panel, right click and choose 'Properties'. Then set the Type to Button.
Next, select the instance of the button on the stage, open the Properties panel and just underneath where you type the instance name you should see a drop down menu containing MovieClip, Button and Graphic. Set it to Button.
I have a web page which has a SWF file embeded. I have an issue with the focus.
Steps to reproduce:
1)Click on a HTML Text Field which is inside a Iframe
2)Click on a Flex Field.
3)Begin to type some text.
Expected Result is the entered text should go in the Flex TextInput field but the actual Result is it goes into HTML text field.
This is the bug which was filed but closed without any resolution. The workaround suggested there doesnt work. ( bugs.adobe.com/jira/browse/SDK-12377 )
This is happening only in IE 6.0 and IE 7.0. Below is the live example.
http://drumbeatinsight.com/examples/htmlcomponent/iframe/HTMLFrameInApplication.html
Any Suggestions or workaround to solve this problem are requested.
Your browser is maintaining focus instead of giving it back to the flash player. I ran into this issue when trying to 'embed' html content inside my flex app ... accomplished by floating html iframe above the flash player.
I have to hide and restore the iframe if I want to interact with flex because the iframe needs to be on top of the flash player, but all that is easy. I would find, even if I hid the iframe, flash player was never getting keyboard focus back. You need to tell the browser to give keyboard focus back to the flash player.
Now there is no really good way to determine if you need to instruct the browser to give keyboard focus back, I end up executing this javascript on every mouse down, rather inefficient, but it was the only way to gaurentee whenever my user clicked on flash player content, that the browser gave keyboard focus back.
Execute a javascript method that looks up the embeded content by name and call focus().
Basically - document.getElementById('flexEmbedID').focus();
Use the external interface to call that on stage.mouseDown(). Lots of overhead as it executes a lot, but it will fix your problem.