how to enable blink cursor in TLFTextFeild in as3 - actionscript-3

mc.textFlow.interactionManager.setFocus();//mc is a TLFTextField
It successfully gives focus to mc, however the familiar blinking text cursor/beam does not appear in the TLFTextField. This makes you think it does not have focus, so how to set cursor.
[How to set focus on TLFTextField - Here i refered about focus set

Related

Why do I have to click the movie for my character to respond?

My movie has 3 frames, first one is the welcome screen with the play button, and after I press it and jumped to frame2 I have to click the movie for my character/player to respond and move by arrows. Same happens if I go back to frame2 from my game-over screen placed on frame3.
I use gotoAndPlay(); to navigate frames, naturally.
if it's something having to do with my code from frame2 i will post what it is required. I'd like to know why is that happening and how to fix it. THANKS!
Clicking your character gives it focus.
Only* what has focus receives keyboard events.
If you register the listener for the keyboard event on your character object, you have to click it first, before it receives those events.
However, the KeyboardEvents bubble up the display list and eventually reach the top most container which is the stage. This gives you two options:
Handle the focus yourself by assigning the object that should have focus to the stage.focus property. This is basically doing what the clicking does in your current situation.http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html#focus
register your listeners at the stage
The user simply needs to click anywhere on the flash stage to add keyboard focus. Normally, a good way of achieving this is by using a start button, or something similar, for that first bit of mouse/keyboard focus.

Action Script 3 keyboard event set focus

I set focus to a text field in the init method, however keyboard enter event only works when I click the text field first.
What is the problem?
It's because, in AS3, by default, stage got the focus. So if you are adding a keyboard event listener to anything other than stage you have to set focus to that object.
Example,
If txt is your text field, you are adding a keyboard event listener to txt then you must do get focus for that like
stage.focus = txt;
That line brought focus to the text field but remember if you click on anything other than that, that object got focus. Needless to say, txt lost focus.
Tip: Try using adding keyboard event listener to stage, if you do so then it dispatches the event when a key is clicked or released regardless of the what object has focus.
stage.addEventListener(KeyBoardEvent.KEY_DOWN, onKeyDown);

Actionscript UIScrollbar and Click Event on containing Element

I'm creating a game in Flash CS5.5, basically a version of "Who wants to be a millionaire?".
I have an answerDisplay Class which contains an answer text. Answer texts can become rather long, and since I have limited screen space I check for very long texts and if a text is too big I add a UIScrollbar besides the text field.
Which works nicely, except for one thing - when the user drags the scroll tab, the text scrolls fine. When the user clicks one of the scrollbar arrows the text field also scrolls fine, as long as the button is clicked, but as soon as the mouse button is released the click event of the containing answerDisplay class is fired, which leads to my program wrongly thinking the user had selected the answer while he just tried to scroll.
I tried catching this via e.target and/or e.currenttarget, but it's no use, I never get a reference to the scrollbar, so I'm never sure if the user clicked one of the arrows or if he genuinely clicked the answer to select it.
How can I make certain that the click event of my answerDisplay Class is not fired when the UIScrollbar is used?
Checking e.target and e.currentTarget is a good start.
You might also want to check the event phase:
For more details on event phase, check grapefrukt's answer
A click from the answerDisplay Class dispatched event should have AT_TARGET phase, while the UIScrollbar event should have the BUBBLING_PHASE. This should help you differentiate between the two.
Also, you could add event listener to the UIScrollbar in your answerDisplay Class to capture the event and then suppress it via stopPropagation().
Depending on how UIScrollbar uses event bubbles internally, you can try either stopPropagation(), either stopImmediatePropagation(). The goal is to stop the event bubbling up from answerDisplay, but not breaking the UIScrollbar functionality.

Flash buttons flicker continuously when compiled

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.

Does mouseEnabled property cause Flash player to redraw the object?

So I made few text fields on the stage and launched the movie.
It appears that when I turn on the "Show redraw regions" and try to click on the text field it shows it's redrawed.
When is set the mouseEnabled property for this text field to false and try to click on the text field it doesn't show it's being redrawed.
By redrawing they mean what?
Probably because nothing happens upon a click if you set mouseEnabled to false, there's no way the textfield could have changed, so it doesn't need to be redrawn. If it is enabled, a click can have any number of effects (default or added yourself) so it needs to redraw the field to be sure.