Advertise|About us|Site map|Syndicate|Search site|Mailing list|View Authors|Become an Author Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates
home » actionscript library » Search Results
Search Results
Your search returned 0 categories and 8 Scripts Actionscripts:
Tab control for flash email form
Selection.setFocus("_level0.name");
stop();
// sets tab order down the page of text fields
on (keyPress "<Tab>") {
if (Selection.getFocus() == "_level0.name") {
Selection.setFocus("_level0.email");
} else if (Selection.getFocus() == "_level0.email") {
Selection.setFocus("_level0.comments");
} else if (Selection.getFocus() == "_level0.comments") {
Selection.setFocus("_level0.name");
}
}
Posted by: Flash Harry | website http://www.webdesignlab.co.uk
Setting TextFields to listen for
//Function by missing-link
//create the function with the TextField object, and give it a single parameter
TextField.prototype.setEnterDetection=function(enterFunction){
//when the text field is selected, it will get the current focus to compare later
this.onSetFocus=function(){
tempFocus=Selection.getFocus();
}
//then, if a key is pressed, this function is run
this.onKeyDown=function(){
//if the current focus is on the this textfield
if(Selection.getFocus()==tempFocus){
//if the key pressed was the "enter" key
if(Key.isDown(Key.ENTER)){
//run the function to be called
eval(enterFunction)()
}
}
}
//!!!Must add the listener to this object
Key.addListener(this);
}
Posted by: missing-link | website http://www.evolutionar-e.com
Table maker
/////////////////////////////////////////
/////////// CREATE TABLE ////////////////
/////////////////////////////////////////
var tableFormat:TextFormat = new TextFormat();
var tableFormat2:TextFormat = new TextFormat();
tableFormat.font = "_sans";
tableFormat.size = 11;
tableFormat.align = "center";
tableFormat2.bold = true;
tableFormat2.font = "_sans";
tableFormat2.align = "center";
//
this.createTextField("columns_txt", 1, 5, 10, 50, 20);
columns_txt.type = "input";
columns_txt.border = true;
columns_txt.background = true;
columns_txt.text = "3";
//
columns_txt.setTextFormat(tableFormat);
//
columns_txt.onSetFocus = function() {
columns_txt.text = "";
};
columns_txt.onChanged = function() {
columns_txt.setTextFormat(tableFormat);
};
//
space = 5;
this.createEmptyMovieClip("tbaleMakerHolder_mc", _root.getNextHighestDepth());
makeHeaders = function () {
columns_txt.setTextFormat(tableFormat);
_root.createTextField("rowNum_txt", _root.getNextHighestDepth(), space, 40, 50, 20);
_root.rowNum_txt.type = "input";
_root.rowNum_txt.background = true;
_root.rowNum_txt.border = true;
_root.rowNum_txt.text = "5";
rowNum_txt.setTextFormat(tableFormat);
c = Number(columns_txt.text);
function doThis() {
setColumnFunction(c, _root.rowNum_txt);
}
if (c != NaN) {
for (i = 0; i < c; i++) {
_root.createTextField("columnHeader" + i, _root.getNextHighestDepth(), (100 * i) + space, space, 90, 20);
_Hdr = _root["columnHeader" + i];
_Hdr.type = "input";
_Hdr.border = true;
_Hdr.background = true;
_Hdr.html = true;
_Hdr.htmlText = "true";
_Hdr.text = "Clmn " + Number(i + 1) + " Hdr";
_Hdr.setTextFormat(tableFormat2);
setHandlers(_Hdr, tableFormat2);
_root.header_array.push(_Hdr.text);
}
//after column titles have displayed:
_root.columns_txt.removeTextField();
}
makeButton("Add Number of Rows", doThis, 5, 65);
};
//
function setColumnFunction(_c, _txt) {
_txt.onSetFocus = function() {
_txt.text = "";
};
//_txt.onChanged = function() {
r = Number(_txt.text);
_r = 0;
__c = 0;
totalRC = r * _c;
for (z = 0; z < totalRC; z++) {
_root.createTextField("field_" + __c + "_" + _r, _root.getNextHighestDepth(), (100 * _r) + space, (30 * __c) + (space * 7), 90, 20);
_T = _root["field_" + __c + "_" + _r];
_T.type = "input";
_T.border = true;
_T.background = true;
_T.html = true;
_T.htmlText = "true";
_T.text = "R " + Number(__c + 1) + " : C " + Number(_r + 1);
_T.setTextFormat(tableFormat);
setHandlers(_T, tableFormat);
__c++;
if (__c > r - 1) {
__c = 0;
_r++;
}
currentX = _T._x;
currentY = _T._y;
}
//after all is done:
_txt.removeTextField();
makeButton("Make A Nice Table", makeTable, 5, currentY + 30);
//};
}
//
function setHandlers(t, f) {
t.onSetFocus = function() {
t.text = "";
//trace(this);
};
t.onChanged = function() {
t.setTextFormat(f);
};
t.onKillFocus = function() {
};
}
//
var header_array:Array = new Array();
//
//
//
//
//
//
//
//
/////////////////////////////////////////
/////////// POST TABLE //////////////////
/////////////////////////////////////////
//Output
columnSpace = 100;
function makeTable() {
//make hearders
traceOutput();
//function makeOutPut() {
var tableFormat:TextFormat = new TextFormat();
_root.createTextField("table_txt", 1, 20, 350, 1100, 600);
table_txt.wordWrap = true;
table_txt.multiline = true;
table_txt.html = true;
tableFormat.font = "_sans";
//
rowHeaders = "";
for (ttl = 0; ttl < c; ttl++) {
thisHeader = _root["columnHeader" + ttl];
rowHeaders += "<b>" + thisHeader.text + "\t</b>";
}
rowHeaders += "";
var _rowHeaders = rowHeaders;
//make rows
for (rowNum = 0; rowNum < r; rowNum++) {
var thisRow = "";
for (col = 0; col < c; col++) {
thisField = _root["field_" + rowNum + "_" + col];
//trace(thisField.text);
thisRow += thisField.text + "\t";
}
if (rows_init != true) {
rows_init = true;
rows = thisRow + "" + newline;
} else {
rows += thisRow + "" + newline;
}
}
var _rows = rows;
//make column spacing
cSpace = "<textformat tabstops='[";
for (cS = 0; cS < c; cS++) {
if (cS < c - 1) {
cSpace += (Number((cS + 1) * columnSpace)) + ",";
} else {
cSpace += (Number((cS + 1) * columnSpace));
}
}
cSpace += "]'>";
_cSpace = cSpace;
//
table_txt.htmlText += _cSpace;
table_txt.htmlText += _rowHeaders;
table_txt.htmlText += _rows;
table_txt.htmlText += "</textformat>";
table_txt.setTextFormat(tableFormat);
}
//
function traceOutput() {
//c comes from set tables as
rowHeaders = "\"";
for (ttl = 0; ttl < c; ttl++) {
thisHeader = _root["columnHeader" + ttl];
rowHeaders += "<b>" + thisHeader.text + "\t</b>";
}
rowHeaders += "\"";
ttl_init = false;
for (rowNum = 0; rowNum < r; rowNum++) {
var thisRow = "";
for (col = 0; col < c; col++) {
thisField = _root["field_" + rowNum + "_" + col];
//trace(thisField.text);
thisRow += thisField.text + "\\" + "t";
}
if (rows_init != true) {
rows_init = true;
rows = "table_txt.htmlText +=\"" + thisRow + "\";" + newline;
} else {
rows += "table_txt.htmlText +=\"" + thisRow + "\";" + newline;
}
}
rows_init = false;
cSpace = "table_txt.htmlText = \"<textformat tabstops='[";
for (cS = 0; cS < c; cS++) {
if (cS < c - 1) {
cSpace += (Number((cS + 1) * columnSpace)) + ",";
} else {
cSpace += (Number((cS + 1) * columnSpace));
}
}
cSpace += "]'>\";";
outPut = "var tableFormat:TextFormat = new TextFormat();" + newline;
outPut += "this.createTextField(\"table_txt\", 1, 0, 0, 800, 600);" + newline;
outPut += "table_txt.wordWrap = true;" + newline;
outPut += "table_txt.multiline = true;" + newline;
outPut += "table_txt.html = true;" + newline;
outPut += "tableFormat.font = \"_sans\";" + newline;
outPut += cSpace + newline;
outPut += "table_txt.htmlText +=" + rowHeaders + ";" + newline;
outPut += rows;
outPut += "table_txt.htmlText += \"</textformat>\";" + newline;
outPut += "table_txt.setTextFormat(tableFormat);";
trace(outPut);
}
//
function makeButton(_nm, _fncn, X, Y) {
removeMovieClip(_root.button);
_root.createEmptyMovieClip("button", _root.getNextHighestDepth());
var btnTxt_frmt:TextFormat = new TextFormat();
btnTxt_frmt.font = "_sans";
btnTxt_frmt.size = 11;
btnTxt_frmt.bold = true;
btnTxt_frmt.align = "left";
button.createTextField("button_txt", 1, 5, 5, 1000, 25);
button.button_txt.text = _nm;
tX = button.button_txt.textWidth + 30;
button.button_txt.setTextFormat(btnTxt_frmt);
button.beginFill(0x0000ff, 30);
button.lineStyle(.5, 0xff0000, 100);
button.moveTo(0, 0);
button.lineTo(tX, 0);
button.lineTo(tX, 25);
button.lineTo(0, 25);
button.lineTo(0, 0);
button.endFill();
button._x = X;
button._y = Y;
button.onPress = function() {
_fncn();
};
}
makeButton("Add Number of Columns", makeHeaders, 5, 35);
Posted by: John Glynn | website http://www.leadminepond.com
TextField.prototype.numberOnly
TextField.prototype.numberOnly = function() {
this.onChanged = function() {
lastInput = this.text.length-1
cValue = this.text.charCodeAt(lastInput)
if(cValue < 48 || cValue > 57) {
trace("illegal character: "+cValue);
trace("removed: "+this.text.charAt(lastInput));
this.text = this.text.substring(0,this.text.length-1);
} else {
trace("allowed character: "+cValue);
trace("substring: "+this.text.charAt(lastInput)+","+lastInput)
}
}
}
// FLASHMX - SHiZNiT@ef/#FLASH
//
// create textfield
createTextField("myInput", depth++,0,0,100,21);
myInput.border = true;
myInput.type = "input";
myInput.numberOnly();
// set focus
Selection.setFocus(field)
Posted by: SHiZNiT | website http://www.developemental.com
Copy the contents of one textfield and paste them into another
onClipEvent (enterFrame) {
if (Key.isDown(17) && Key.isDown(67)) {
Selection.setFocus("_root.text") && Selection.setFocus("_root.text2");
} else if (Key.isDown(17) && Key.isDown(86)) {
Selection.setFocus("_root.text2");
_root.text2 = _root.text;
}
}
First the user presses control C to copy, then control V to paste to a textfield.
The above example works in HTML and gets around the focus problem by setting the focus at the begining.
Unfortuanately it's not very practical as it doesn't set the focus on the first textfield properly. Maybe when I've a little more time I'll try and work it out.
Posted by: No name | website http://
Make the TAB button setFocus of the next text box in (LEVEL5)- for example
In the following example I load my movie with the text boxes into level5. All the actions focusing the text boxes are in the level 5 movie:
Level 5 Movie:
1) First set the focus of your text box in frame 1: Selection.setFocus("box1");
This means the end user will be presented with a blinking cursor when the movie first loads. 2) Place the following action on an 'invisible button': on (keyPress "<Tab>") {
if (Selection.getFocus() == "_level5.box1") {
Selection.setFocus("box2");
} else if (Selection.getFocus() == "_level5.box2") {
Selection.setFocus("box3");
} else if (Selection.getFocus() == "_level5.box3") {
Selection.setFocus("box4");
} else if (Selection.getFocus() == "_level5.box4") {
Selection.setFocus("box1");
}
}
Change the variable names to the ones of your choice. You could have box1 leading onto box4 etc.
Posted by: No name | website http://
SelectionManager
/**
* @author: Eric Feminella
* @url: http://www.ericfeminella.com
* @copyright: (c)2004 - 2006 code.ericfeminella.com
*/
import mx.controls.TextArea;
class com.displays.SelectionManager
{
public static var caretIndex:Number;
public static var mouseEvent:Boolean;
public static var lastIndex:Number = 0;
public function SelectionManager()
{
this.initUserEvent();
}
private function initUserEvent():Void
{
var mouseListenerObject:Object = {};
mouseListenerObject.onMouseUp = SelectionManager.onSetFocus;
Mouse.addListener(mouseListenerObject);
}
public static function onSetFocus():Void
{
if (Selection.getCaretIndex() != -1)
{
SelectionManager.caretIndex = Selection.getCaretIndex();
SelectionManager.mouseEvent = true;
SelectionManager.lastIndex = 0;
}
}
public function insertAtSelectedIndex(stringToInsert:String, selectedTextArea:TextArea):String
{
var index:Number = this.getIndex(stringToInsert.length);
var originalString:String = selectedTextArea.text;
var originalStringLength:Number = originalString.length;
var selectionStart:String = originalString.substring(0, index);
var selectionEnd:String = originalString.substring(index, originalStringLength);
var newString:String = selectionStart + " " + stringToInsert + " " + selectionEnd;
return newString;
}
private function getIndex(stringToInsertLength:Number):Number
{
if (SelectionManager.mouseEvent)
{
var index:Number = SelectionManager.caretIndex;
SelectionManager.lastIndex = index + stringToInsertLength + 2;
}
else
{
var index:Number = SelectionManager.lastIndex + stringToInsertLength;
SelectionManager.lastIndex = index + 2;
}
SelectionManager.mouseEvent = false;
return index;
}
}
Posted by: Eric Feminella | website http://www.ericfeminella.com
Setting the tab key
onClipEvent (keyDown) {
if (Selection.getFocus() == "_level0.movieClip.textboxVariable1"&&Key.isDown(Key.TAB)) {
Selection.setFocus( "_level0.movieClip.textboxVariable2");
} else if (Selection.getFocus() == "_level0.movieClip.textboxVariable2"&&Key.isDown(Key.TAB)) {
Selection.setFocus( "_level0.movieClip.textboxVariable3");
} else if (Selection.getFocus() == "_level0.movieClip.textboxVariable3"&&Key.isDown(Key.TAB)) {
Selection.setFocus( "_level0.movieClip.textboxVariable1");
}
}
//Or if you'd rather place the actions on a button, try this:
on (keyPress "") {
if (Selection.getFocus() == "_level0.movieClip.textboxVariable1") {
Selection.setFocus( "_level0.movieClip.textboxVariable2");
} else if (Selection.getFocus() == "_level0.movieClip.textboxVariable2") {
Selection.setFocus( "_level0.movieClip.textboxVariable3");
} else if (Selection.getFocus() == "_level0.movieClip.textboxVariable3") {
Selection.setFocus( "_level0.movieClip.textboxVariable1");
}
}