[AS3] Simple Focus Example
A simple AS3 textField focus example which adds a custom selection glow around the textfeild when it is selected....
Paste into frame 1
ActionScript Code: var glowOn = new GlowFilter(0x0099ff,1,4,4,2,1,false);var glowOff = new GlowFilter(0x0099ff,0,4,4,2,1,false);function init() { for (var i = 0; i<4; i++) { var mc = createTextField(); mc.name = "tf_"+i; addChild(mc); mc.x = 30; mc.y = 30*(i+1); mc.addEventListener(Event.CHANGE,traceValue); mc.addEventListener(FocusEvent.FOCUS_IN,showSelected); mc.addEventListener(FocusEvent.FOCUS_OUT,hideSelected); }}function createTextField() { var tf = new TextField(); var format = new TextFormat(); tf.defaultTextFormat = format; tf.width =200; tf.height =20; tf.background = true; tf.border = true; tf.type = TextFieldType.INPUT; return tf;}function traceValue(e:Event) { trace(e.target.name + ": " + e.target.text);}function showSelected(e:FocusEvent) { e.target.filters = [glowOn];}function hideSelected(e:FocusEvent) { e.target.filters = [glowOff];}init();
KirupaForum > Talk > Source/Experiments
Posted on: 10-21-2008, 08:46 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Simple Question - How To Get Focus?
I've checked the help files and searched on this board. There's plenty about focus problems but nothing gave me the single, easiest line I'm looking for:
How do I set focus on an object like an input textfield?
I'm making a form and when the user tabs into a field, the cursor is hard (or impossible) to see so you don't know where you are. I want to be able to code something like:
my_textField.onGetFocus(){
this.glowTo(0xFF0000);
}
Thanks!
Focus Problems On Return Focus To Html Window
Hi all
Im wondering if anybody has come across this problem before while developing with flash and javascript/HTML. Basically I have created a flash interface which accepts user input in the form of keystrokes - left arrow, up arrow etc....
This works fine in the standalone flash player - but when the movie is published into a html page and it loads up the keystrokes don't have any effect unless I a) click first on the flash movie within the html page or b) use JavaScript to catch the onLoad event in the html body tag and manually set focue to the movie using document.keyFocusCheck.focus();.
Ok, I've got this far and its working fine - im loading my html windo and setting focus to my flash movie(nad my keystrokes work straight off)- however here is my problem. If I alt+tab away from my html window and then alt+tab back to my window - my keystrokes don't work again unless I click first in the flash window - I've tried lots of different ways to reset focus to my flash file (eg. Putting an onFocus event handler in my html pages' body tag) but to no avail - I am wondering if it is actually possible to catch the focus event once the html window has lost its focus and then had it returned as everything I have tried doesn't work!
I have included a sample 'dumbed down' version for you guys to check out - if anybosy could point me in the right dirrection of offer any help that would be massively appreciated.
Thanks in advance
DotsC
Browser Focus Vs Flash Focus
If your swf extends the height of the browser, the standard browser scrollbar appears.
If you just opened your site, and have NOT clicked inside the browser, on your swf area, the browser will scroll vertically with the up/down keys.
If you click your swf in the browser, the up/down keys no longer register with the Browser, and you cannot scroll vertically.
Is anyone aware of a way to remedy this problem? My first thoughts are maybe sending external interface commands to a javascript function to simulate the up/down scroll, but I'm not positive if javascript can control a browsers scrollbar, and whether there are problems cross-browsers with that.
Multiple Movieclips Focus / Out Of Focus
Hi!
I'm currently creating a website for a school project, and have some questions regarding this:
I have a website with 6 different links, and a background (7 mc's).
*When the website loads I want the whole page to be in focus
*when I rollover one of the links I want the rest of the movieclips/links incl. background to go out of focus (blur out)
*when the mouse is over the background I want the whole page to be in focus again (no blurring)
When the site loads everything is in focus, this is correct.
problem is; I have to rollover all of the movieclips before the function 'starts'..
example: the website loads, everything is in focus. I rollover one of the links, nothing happens. Then when I go back to the background, the link blurs, which would be fine if I pointed my mouse at another link, but when I point it at the background, I want everything to be in focus again.
For now I have an actionscript inside every movieclip (including the background mc) similar to this:
stop ();
//importere filter
import flash.filters.BlurFilter;
import mx.transitions.Tween;
import mx.transitions.easing.*;
var filter:BlurFilter = new BlurFilter(0, 0, 3);
var filterArray:Array = new Array();
filterArray.push(filter);
//funksjon
skjermbilder.filters = filterArray;
skjermbilder.blurred = 0;
this.onRollOver = function(){
var tw1:Tween = new Tween(skjermbilder, "blurred", Strong.easeOut, skjermbilder.blurred, 0, 1, false);
tw1["onMotionChanged"] = function() {
filter.blurX = skjermbilder.blurred*5;
filter.blurY = filter.blurX;
skjermbilder.filters = filterArray;
}
};
this.onRollOut = function(){
var tw1:Tween = new Tween(skjermbilder, "blurred", Strong.easeOut, skjermbilder.blurred, 1, 1, false);
tw1["onMotionChanged"] = function() {
filter.blurX = skjermbilder.blurred*5;
filter.blurY = filter.blurX;
skjermbilder.filters = filterArray;
}
};
PLEASE HELP!!
Lage.
Multiple Movieclips Focus / Out Of Focus
Hi!
I'm currently creating a website for a school project, and have some questions regarding this:
I have a website with 6 different links, and a background (7 mc's).
*When the website loads I want the whole page to be in focus
*when I rollover one of the links I want the rest of the movieclips/links incl. background to go out of focus (blur out)
*when the mouse is over the background I want the whole page to be in focus again (no blurring)
When the site loads everything is in focus, this is correct.
problem is; I have to rollover all of the movieclips before the function 'starts'..
example: the website loads, everything is in focus. I rollover one of the links, nothing happens. Then when I go back to the background, the link blurs, which would be fine if I pointed my mouse at another link, but when I point it at the background, I want everything to be in focus again.
For now I have an actionscript inside every movieclip (including the background mc) similar to this:
stop ();
//importere filter
import flash.filters.BlurFilter;
import mx.transitions.Tween;
import mx.transitions.easing.*;
var filter:BlurFilter = new BlurFilter(0, 0, 3);
var filterArray:Array = new Array();
filterArray.push(filter);
//funksjon
skjermbilder.filters = filterArray;
skjermbilder.blurred = 0;
this.onRollOver = function(){
var tw1:Tween = new Tween(skjermbilder, "blurred", Strong.easeOut, skjermbilder.blurred, 0, 1, false);
tw1["onMotionChanged"] = function() {
filter.blurX = skjermbilder.blurred*5;
filter.blurY = filter.blurX;
skjermbilder.filters = filterArray;
}
};
this.onRollOut = function(){
var tw1:Tween = new Tween(skjermbilder, "blurred", Strong.easeOut, skjermbilder.blurred, 1, 1, false);
tw1["onMotionChanged"] = function() {
filter.blurX = skjermbilder.blurred*5;
filter.blurY = filter.blurX;
skjermbilder.filters = filterArray;
}
};
PLEASE HELP!!
Lage.
Focus In And Focus Out Problem
Hi all, first time i enter this forum and have my first question about flash mx.
I cut my image into few parts, and within each part, I want to do some focus in, focus out action. So when user pointing on the part, it will shining or some other things and when focus out, it will return to original style.
I try to convert the image into symbol, and using rollover and rollout function, but the outcome is very poor and Im hardly to point to correct spot.
Anybody can help me please ?
Focus Color/Focus MC
I looked for answers on Help and on forums, but i still couldnt make it work. Ok. First. i tried and change focusrect color and it is not working. This is the script i used:
_focusRect = true;
globalStyleFormat.focusRectInner = 0xFF0000;
globalStyleFormat.focusRectOuter = 0xFF0000;
globalStyleFormat.applyChanges();
Im using Flash MX Professional 2004 and I publish it on Flash 6 with Actionscript Ver1. Im guessing its somehow related to this scripting and flash versions. Second, Im having a hard time trying to focus on a button inside an MC. I put this script on a maintimeline frame:
_root.mc1.text1.selection.setFocus();
This are the links to the FLA and SWF:
http://www.freewebs.com/kieserr/add.fla
http://www.freewebs.com/kieserr/add.swf
Please help. Thanks
Focus Color/Focus MC
I looked for answers on Help and on forums, but i still couldnt make it work. Ok. First. i tried and change focusrect color and it is not working. This is the script i used:
_focusRect = true;
globalStyleFormat.focusRectInner = 0xFF0000;
globalStyleFormat.focusRectOuter = 0xFF0000;
globalStyleFormat.applyChanges();
Im using Flash MX Professional 2004 and I publish it on Flash 6 with Actionscript Ver1. Im guessing its somehow related to this scripting and flash versions. Second, Im having a hard time trying to focus on a button inside an MC. I put this script on a maintimeline frame:
_root.mc1.text1.selection.setFocus();
This are the links to the FLA and SWF:
http://www.freewebs.com/kieserr/add.fla
http://www.freewebs.com/kieserr/add.swf
Please help. Thanks
Focus Color/Focus MC
I looked for answers on Help and on forums, but i still couldnt make it work. Ok. First. i tried and change focusrect color and it is not working. This is the script i used:
_focusRect = true;
globalStyleFormat.focusRectInner = 0xFF0000;
globalStyleFormat.focusRectOuter = 0xFF0000;
globalStyleFormat.applyChanges();
Im using Flash MX Professional 2004 and I publish it on Flash 6 with Actionscript Ver1. Im guessing its somehow related to this scripting and flash versions. Second, Im having a hard time trying to focus on a button inside an MC. I put this script on a maintimeline frame:
_root.mc1.text1.selection.setFocus();
This are the links to the FLA and SWF:
http://www.freewebs.com/kieserr/add.fla
http://www.freewebs.com/kieserr/add.swf
Please help. Thanks
On Focus?
Is there an equivalent to onFocus in Flash's action script?
I am designing a cdrom in Flash and it has a background music loop. When clicking on one of the buttons in the flash movie, it opens up a new browser window in the foreground, putting the flash in the background, and stopping the background music. I am looking for a varible check that will start the music again once the browser window is closed and the flash window is once again in the foreground...
thanks in advance
Focus ?
hi can any one tell me weather we can have
onfocus or onblur option like javascript
i have a problem
what i want is that i have 2 text boxes
when i enter some text into first text box and come out of it or press TAB the value which is entered in the first text box should get assigned to the second text box.
thanks a lot
Set Focus
hi
in a frame i have three input text box say t1,t2,t3
,as soon as i load the frame how do i make the cursor to go and wait or blink in the t2 text box.
bye
geethanandh
Set Focus
hi
in a frame i have three input text box say t1,t2,t3
,as soon as i load the frame how do i make the cursor to go and wait or blink in the t2 text box.
bye
geethanandh
FOCUS Help..
Seems today is not my day....
i can't find the way to make that:
How can I make a simple thing like assigning
focus to single line of input text.
I have input text called user_id
I want the cursor blinking on the input
text line when loaded the frame where input is.
Thankx in advance for ur help
Focus
how can I make an image get out of focus and come back to focus without just inseting the focused image, then suddenly the one out of focus and finally again the first one?
thanks
How Do You Focus A .swf?
I got the text.focusrect to focus an input box, but the user has to click the flash movie in order to focus the .swf.
Is there an actionscript, or javascript, that will bring the .swf to the front... enabling the user to type in the textfield once the page is loaded?
Thanks....
Set Focus
Someone please help...
I have some text fields on a registration form, and I am trying to set the focus, so when one uses the tab key, the focus shifts from last name to first name, to address, to telephone... How do I do this. I have tried the following code, and it does not work: Is there a central place to put the code, or does each text field have to have a portion of the code? What is the best way to accomplish this?
Thanks
on (keyPress "<TAB>") {
if (selection.getFocus == "SSN") {
selection.setFocus = "Password";
} else if (selection.getFocus == "Password") {
selection.setFocus = "CPassword";
}
else if (selection.getFocus == "CPassword") {
selection.setFocus = "FirstName";
}
else if (selection.getFocus == "FirstName") {
selection.setFocus = "LastName";
}
else if (selection.getFocus == "LastName") {
selection.setFocus = "MiddleInitial";
}
else if (selection.getFocus == "MiddleInitial") {
selection.setFocus = "Street";
}
else if (selection.getFocus == "Street") {
selection.setFocus = "AptNumber";
}
else if (selection.getFocus == "AptNumber") {
selection.setFocus = "City";
}
}
How To Focus From .exe To .avi And .pdf
I understand how to use javascript to the focus for html pages, but how do I get it to work with other files types such as .avi and .pdf?
I need to make an interactive CDROM for our college and I'm trying to get the .avi and .pdf to appear in front of my .exe movie, but it's not working.
Any help would be greatly appreciated!
Focus
how do i make background frames out of focus? i've seen it done in multiple internet cartoons but i can't think of how to duplicate the effect- i'm also running on flash 5 so any mx tricks won't help- thanks in advance.
Jester45
MC Focus - Help
I'm setting up a simple menu. The problem is that the animation of one menu selection overlaps another, and I don't know how to fix it. My guess is to make an on RollOver focus set command...
the .fla is attached.
I've perused the site for tips, and will continue to do so while I wait for a reply!
thank you so much!
-dom
Focus
Hi,
I have a problem. I have a movie that works with keypress navigation. The problem is when you lose focus on the browser window in which my movie plays, and you come back, the keys won't work anymore, unless you click on the movie and make it focussed again.
How can I solve this problem???
thanx
Focus
Hi,
I'm working on a game which had a character which is controlled by the arrow keys on the keyboard, and on one side theres also a list box, problem is when I control the character, the selection in the list box goes up and down too!, how do I stop this?
thanks
boombanguk.
Set Focus To The Top
I have a long text document in a flash web page. When scrolling down to read this document I have a continue button at the bottom of the screen thats set to move to the next frame where I have the remainder of the document. The problem is when you click the continue button and upon moving to the next frame the focus is still at the bottom of the movie. I am trying to get the focus to go back up to the top of the screen but it staying right where the scroll bar was from the last frame??? I have spent hours trying to come up with a solution and I'm going to lose it.
To see the problem click on Hinduism link on the right handside side and scroll down to the bottom of the document. Click the continue button and you will see how it goes the next frame but not to the damn top.
View Page
Set Focus?
i have two input boxes on screen, when one has a number entered into it i want the curser (focus) to move to the second input box so that the user dosen't have to do it themselves!
any ideas?
Get Focus?
I'm having trouble figuring this one out and I've couldn't find the answer by searching.
I have a text input components and button components. When the user types something in the text input component, how can I get the button component to "get focus" (when the user hits the enter button) my button function will run?
Thanks.
Focus
I am making a fullscreeen board game. When a piece is moving I am trying to make the game automatically zoom in, and set it's center point on the piece's _x and _y position. How can this be done? (If it can be done)
Got Focus
Hi,
I've noticed that by default each button seems to have a yellow square when the focus is on that button.
Is there any way to desactivate it ?
thanks
Set Focus
I have been having a problem with Flash in the html page. It seems as though none of the buttons work until the user clicks twice on the swf file in the html.
The first click sets the focus and then after the browser has the focus set then you must click again to have the ActionScript or button get the URL during this time when the user rolls over the swf files i get a border around them .... is there a way to stop that? This all happens in IE
How can this be corrected....
thanks!
Focus
How do i set the focus on a flash text field field
[CS3] Focus
First off, Hello. I'm new here
Second, I'm kinda new to flash but am able to find my way around.
Now, to the question.
Is it possible to do an "out of focus blur" in flash with a graphic object? I don't really want to make my objects movie clips.
I guess I'll make them movie clips if I have to... But not all of them can be. For instance, I have a light bulb. It has 2 frames. One is off and the 2nd frame is the light turned on. I have that object set to Single Frame. You can't do that with a movie clip, that I'm aware of (without action scripts anyway)
Well, thanks. Also, If you're willing to explain why you would use Movie Clips over Graphic objects, I'm willing to listen.
[edit]I called them objects, but I guess they call them symbols[/edit]
Is It In Focus?
I'm trying to find out how we can figure out if a movieclip is infocus, meaning it was the last movieclip that ran the onSetFocus command.
is there any special command that will tell me what is the current in focus movieclip?
Set Focus
Hi, I'm having trouble using the set focus in my class file. What I want to accomplish is when the message is displayed I want the cursor to automatically proceed to the next box?? Can this be done? I have attached my example.
Code:
import mx.controls.Alert;
class Product {
var id:Number;
/*function Product (id:Number) {
getID(id);
}*/
public function getId () :Number
{ var userid=_root.id;
trace("your input is:"+ userid.toString());
mx.accessibility.AlertAccImpl.enableAccessibility();
_global.styles.Alert.setStyle("color", 0x4B8DEF);
_global.styles.Alert.setStyle("themeColor", "haloBlue");
Alert.show("Thanks for you input!");
userid.backgroundColor = 0xFFCC33;
userid.textColor = 0x696AC9;
//Sets the focus on the next txt box
Selection.setFocus(_root.Name_txt);
return userid;
}
}
Focus?
I have coded a game which starts with pushing the arrow keys on the keyboard.
when I implant this swf file in an html file and call this html file from another html file, it needs to be clicked with mouse first then pushing the keys(arrows) will work.
I might lost you, let me tell you this way.
a link in an html> makes > an html file which contains a flash swf file.
now this new window has been loaded, needs to be clicked then would be able to respond to the keyboard keys.
There got to be a way without clicking, I could gather the focus to the new window and flash file in the middle.
Any help please.
Help With Focus
This will be kinda hard to explain:
I have this problem with my thing I am working on.
I have two things that use the letter s.
I have an input box that processes things also known as "_root.input.text".
I have a movieclip that also uses the letter s, if you press it it goes to another frame. Well the problem is, I don't want to goto the frame if I pressed s in the input box.
So I set up the code:
if (Key.isDown(83))
{
_root.bg.gotoAndStop("sp");
}
I changed it to this:
if (Key.isDown(83) && _root.input.onSetFocus() == false)
{
_root.bg.gotoAndStop("sp");
}
and now it doesn't work.
I need it to check if input.text is selected, and if it is do not work when s is pressed. any ideas?
Post the correct code please, I don't have time to try to interpret your answers, anything that works.
Set Focus
Hi all !
This is my first post. I have switched to flash just 2 days before.
I have a button on click of which a textfields populates.
As soon as user clicks button focus should be on that textfields.
I am trying to make my small example accessible : i have written this code which sets focus to textfield:
Selection.setFocus(feedback);
But screen reader dosn't read text from textfield unless it is selected.
Any solution?
Thanks.....
Set Focus
I am developing a simple example in flash.
on click of a button i am setting focus to a dynamic text field.
its working fine. But the screen reader dosn't read text in it.
Setting focus is not the only thing, i think somthing more gas to be done. So that the complete control will go to the dynamic text field, and the screen reader will read it.
because after the focus goes to the dynamic textfield i have to do tab to go to the dynamic text field and then the screen reader reads it.
Always Get Focus
HI,
I have a little application with a dynamic text field and some buttons. I want that users dont have to click on the text field to start writting
How can I hold focus on the text field?
Thanks in advance.
Help With Focus
Help I'm stuck!!
I'm building an app that uses just the keybord (no mouse). First is the Log In: The usr enters the app & focus is on the list componenet (displays users) to find the user. The usr arrow keys down and finds his username. If a password is required for this user a log in box MC appears and the focus shifts to the input field of the log in MC to enter password. Once inside the log in box mc I have a key listener that listens for up and down arrow movement to get out of the log in box. If usr hits up or down arrow the box disappears and focus goes back to the list component. So far I can get all that to work. However once focus goes back to the list component I can't get the input field inside the log in box MC to regain focus. It only gives it focus the first time the log in box appears.
I don't get it. I have tryed to switch it with
if(_root.focusManager.getFocus() == _level0.list){
_root.focusManager.setFocus(_level0.logInBox.enteredPASS);
focusManager.setFocus(enteredPASS);
}
and other methods but no luck.
I would appreciate assistance or suggestions please.
thanks- Frank
Edited: 02/15/2007 at 01:08:38 PM by fperez55
Set Focus
Hi all,
I have a small problem with setting the focus of text fields in a form. I have the following code on the _root timeline:
stop();
Selection.setFocus(_root.form.first_name);
myListener = new Object();
myListener.onKeyDown = function() {
if (Key.isDown(Key.TAB)) {
Selection.setFocus(_root.form.last_name);
}
};
The text fields are held in a movie clip called 'form'. It sets the focus to 'first_name' but will not then focus on 'last_name' when I hit TAB.
I have about 5 text fields to go through.
Any ideas why it won't focus?
Cheers guys,
Pat
Set Focus. How.
Yea, i've never tried this before.
Whats the code to set focus to an object, and how do you use it. The method i was trying wasnt working and i dont think it was the right thing anyway.
Out Of Focus...
Hey all,
If your flash program (swf or exe) is not in focus, ie, you have another window covering it, or it hasn't been clicked on, is there a way for it to still pick up keystrokes?
I've tried Key.getCode() and if(Key.isDown(##)){ and neither seems to pick up any keystrokes unless the file is in focus.
Thanks much,
Darkfuzz
Focus In IE
When entering www.roofengarden.nl you will notice there is a dottedline around it and have to click once before you can do anything on the page.
I wanted this focus off, a class mate gave me a good javascript file to fix this. as you can see it is fixed at www.desiredesign.org/reng/index2.html you can see my problem now, the page doesn't load at the right place anymore. I am hoping someone over here will be able to help me out.
This is the javascript I have used; http://www.desiredesign.org/reng/ufo.js
You can have a look at the source code of www.desiredesign.org/reng/index2.html to see how I displayed the flash file.
Greets,
Sumpson
IE Key Focus
Heres the situation. I'm developing a Street Fighter style game using AS2. Its pretty simple keystrokes, Up is jump, Down is crouch. Well the problem is that in Internet Explorer, when you press DOWN to crouch, the browser scrolls down. Same when you press UP, it scrolls up. This does Not happen in beloved Firefox. And this is an issue that Must be fixed. Any ideas on how this is possible to fix?
Chris
Set Focus
Hi all,
I have a small problem with setting the focus of text fields in a form. I have the following code on the _root timeline:
stop();
Selection.setFocus(_root.form.first_name);
myListener = new Object();
myListener.onKeyDown = function() {
if (Key.isDown(Key.TAB)) {
Selection.setFocus(_root.form.last_name);
}
};
The text fields are held in a movie clip called 'form'. It sets the focus to 'first_name' but will not then focus on 'last_name' when I hit TAB.
I have about 5 text fields to go through.
Any ideas why it won't focus?
Cheers guys,
Pat
Set Focus
Hi all !
This is my first post. I have switched to flash just 2 days before.
I have a button on click of which a textfields populates.
As soon as user clicks button focus should be on that textfields.
I am trying to make my small example accessible : i have written this code which sets focus to textfield:
Selection.setFocus(feedback);
But screen reader dosn't read text from textfield unless it is selected.
Any solution?
Thanks.....
Focus
I cannot get the setfocus to work. How do I do to set focus in a certain textfield.
[AS] Focus Help
Hey guys,
I am trying to figure out how to make a button object not be able to recieve focus. For instance a forum with a button at the bottom, hitting tab cycles through each input field and then cycles to the button, and then back to the top. I am wondering if there is anyway to stop this from happening, since the yellow box that surrounds the button is highly unattractive. Any help would be appreciated.
Regards,
Jonathan
Focus Another App
I working on interactive CD. Im playing .AVI movie with getURL but player (windows media player) is launch under projector. can i set focus for player. Thx.
Fox Out Of Focus();
Hello friends,
Im working on a bit of functionality and there's a wee issue..
I have a scrollbar components which respond to Mouse scroll, and up and down arrow key input. Im using listeners
In FF, the features wont work unless u click somewhere on the screen first.
However in IE it works right off the bat when the page is loaded ( with flash fix )
I'd like to know if this is a firefox thing, and if it can be worked around by assigning a MouseMove function of sorts to feed flash thesame info as the 1st Mouse click....
the thing is my onRollOver MC functions do work from the start in ff with no click needed, though they have no listeners involved....
maybe I should try something functional with onEnterframe or on mouseMove and assigning focus somewhere... or maybe I'm way off..:P
trying to wrack my brain here
any thoughts outside the box??
thanks
|