I am trying to simulate button click with event change. It works well but when i type a character in textbox, it calculates. I cant type the word. How can i fix this.
stage.addEventListener(Event.CHANGE, autohesap);
function autohesap(event:Event) {
hesapla_btn.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
TextField dispatches the Event.CHANGE every time it's contents are changed (e.g. a new character is entered). As you're adding the Event.CHANGE listener to the stage, the stage is going to pick up all the events of type CHANGE, including the one dispatched by your TextField. I'm not sure if this is the behaviour you're looking for?
If it is, and you "cant type the word", then it looks like it's because your autohesap is changing the stage.focus - when you click on a TextField to write in it, stage.focus is set to the TextField in question - if you manually set stage.focus = null, then the TextField will be deselected and you won't be able to type into any more, until you click it again.
Create a container object to hold all of the 'changeable' objects as children. But leave the textfield out of the container's 'family.' You can still position the textfield anywhere but its events will bypass the container, which will 'hear' events only in itself or its children.
Related
Can I remove this blinking cursor from a textfield?
Thanks,
Not in a INPUT Textfield.
You can still use some ticks with a Dynamic textfield which listens to KEY_UP events, but you'll have to do all the things by yourself (delete, home key, end key...), and you can forget about things like copy/paste, undo, mouse selection...
It's a tricky way. What can also work, is hide the textfield by setting its textcolor to the background color (so you won't see the cursor), or set its alpha to 0, then copy the text into another dynamic text field on KEY_UP events. Still, it's quite a hack.
Good luck.
`I have a movie clip that I wanted to behave as a button on mouse over and mouse out, so I added a listener to change the cursor to button and arrow in roll over and roll out:
Object(this).my_mc.addEventListener(MouseEvent.ROLL_OVER,overButton);
Object(this).my_mc.addEventListener(MouseEvent.ROLL_OUT,outButton);
function overButton(e:MouseEvent):void {
Mouse.cursor="button";
}
function outButton(e:MouseEvent):void {
Mouse.cursor="arrow";
}
The problem is that after moving the mouse over and out the my_mc and executing this code, the mouse cursor will always be arrow even when rolling over other button symbols. Is like it will only behave according to the last instruction which is the outButton function.
How can I reset the mouse cursor behavior so that it will work normally with selectable text areas and buttons?
Thanks.
You should probably be restoring the Mouse.cursor property to "auto".
Mouse.cursor="auto"
Setting it to MouseCursor="arrow" on roll out means it will always show the arrow.
However, I would recommend removing these event listeners, and setting the buttonMode property of the MovieClip to true.
It's a bit cleaner, and I'm assuming performs better b/c Flash Player manages this without any extra code.
My scene has a TextField object.
I set up my TextField as DynamicText because I need to change it programmatically.
How do I prevent mouse cursor change to I-Beam form when it's above TextField?
Also, user of my flash application is able to select text of this TextField using mouse cursor. I would like to disable this behavoiur too.
In the TextField properties panel, there is an icon that reads "Selectable", you need to uncheck it, and you will disable both.
EDIT: The icon is right below the "Anti-Alias" drop down, first in row. There is a Ab (the b is selected/highlighted) inside.
If you want to do this by ActionScript, the code is:
myTextField.selectable = false;
Hope this helps!
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextField.html?filter_flash=cs5&filter_flashplayer=10.2&filter_air=2.6
You are looking for the property selectable
I have a button with a tabIndex. The button contains a textfield.
When I click on the edge of the button and hit tab, the next item is correctly focussed.
But when I click on the textfield (non-editable,not tab-enabled, no tabindex), and then hit tab, it focusses on the first object on the page, even though the parents focusIn function is triggered, in which I'm setting the focus to the parent object:
parentObject:
addEventListener(FocusEvent.FOCUS_IN, focusIn);
private function focusIn(e:FocusEvent):void
{
//shows the child object (a textfield) has the focus
FlashConnect.trace(Main.instance.stage.focus);
//causes this focusIn function to be called again, but only once again, since then the focus does not change anymore
Main.instance.stage.focus = this;
//shows THIS parent object now has the focus
FlashConnect.trace(Main.instance.stage.focus);
//shows the correct tabIndex, which makes me expect the next item should be selected when I hit tab right?
FlashConnect.trace(Main.instance.stage.focus.tabIndex);
}
Any ideas how to solve this?
Have you tried setting mouseEnabled, mouseChildren, and tabChildren? Also, I have to point out that a Singleton View is even more bad practice than other Singletons. You're likely to really regret this architectural choice long term.
Hopefully a quick question here. I have setup a "LayoutPage" custom class (based on MovieClip) and I am attemptimg to create a "selected" behaviour.
When I assign my "addEventListener(MouseEvent.CLICK,toggleSelection)" from within my custom class, everything works as expected, clicking any object of that class does display the correct behaviour.
Now, I would like to extend the functionality by adding keyboard modifyer to either extend the selection or replace it.
For this, I thought of moving the "addEventListener" out of the class and put it inside the parent instead (my "PageLayout" class where all the "LayoutPage" live). But by doing so, the click event no longer register on the "LayoutPage" class but rather on its individual children (Page icon, Page number text field, Page Highlight shape, etc.)
Can anybody explain why this is happening and how I can circumvent it?
TIA
This should be happening no matter where you put your addEventListener. It is because mouseChildren is switched on by default. It is probably best to turn it off inside your LayoutPage class like so:
myLayoutPage.mouseChildren = false;
The actual issue is that use are probably using currentTarget to reference the item that was clicked on in your event handler method. Take a look at the descriptions for currentTarget and target to get a good idea of how they differ.
A good option would be to add your listener at the PageLayout level, but add it specifically to each LayoutPage child like so:
myLayoutPage.addEventListener(MouseEvent.CLICK, toggleSelection);
This way you can just use target in your handlers. But it would probably be best to still switch mouseChildren to false on each of your LayoutPage instances.