all groups > flash (macromedia) > january 2005 >
You're in the

flash (macromedia)

group:

Flash Blink Cursor Layouts


Flash Blink Cursor Layouts PopUpBob
1/23/2005 9:56:02 PM
flash (macromedia):
Hi Everyone! I've seen in many other places that its posible to change the
blinking cursor in a textbox! (Im not talking about any Mouse Cursors - But
the one that shows up when you activate a Input textbox) Instead of just
haveing a blinking Vertical Line, I wanted to know if its possible to change it
to something else? (It has to be for Flash) ex. name: James | <<< thats
the one I want to change ex, into a jumping ball or dot or so. PS! I dont even
know what that cursor is called in english - :o)
Re: Flash Blink Cursor Layouts NSurveyor
1/24/2005 12:11:45 AM
Flash has no built in way. However, after reading your post, it got me
wondering, is it possible? So, I sat down opened flash and played around a bit.
This is what I was able to come up with:

Add this to frame 1 of your movie:

TextField.prototype.addCursor = function(linkageID,xOff,yOff) {
Key.addListener(this);
var bc = this._parent.attachMovie(linkageID, this._name+'_bc',
this._parent.getNextHighestDepth());
bc._visible = false;
this.onSetFocus = function() {
this.onKeyDown = function(){
this.type = 'input';
}
var ctf = this;
this.fttID = setInterval(fixTheText,1);
function fixTheText() {
ctf.type = 'dynamic'
if (Selection.getBeginIndex() != Selection.getEndIndex()) {
bc._visible = false;
} else if (Selection.getCaretIndex() == -1) {
bc._visible = false;
clearInterval(ctf.fttID);
} else {
bc._visible = true;
var oldtext = ctf.text;
var cpos = Selection.getCaretIndex();
var twidth = ctf.textWidth;
ctf.text = 'test';
var onelineh = ctf.textHeight;
ctf.text = oldtext;
var lastEnter = Math.max(ctf.text.lastIndexOf('\n', cpos-1),
ctf.text.lastIndexOf('\r', cpos-1));
ctf.text = ctf.text.substring(lastEnter, cpos);
if (ctf.text == '' || ctf.text == '\n' || ctf.text == '\r') {
var isBlank = true;
}
var tx = ctf._x+ctf.textWidth;
ctf.text = oldtext.substring(0, cpos);
if (isBlank) {
ctf.text += 'X';
}
var theight = ctf.textHeight;
var ty = ctf._y+theight;
bc._x = tx+xOff;
bc._y = ty+yOff;
ctf.text = oldtext;
Selection.setSelection(cpos, cpos);
}
};
};
};

Create a textfield. Give it an instance name, (for example myTF). Now, on the
frame that holds your textfield, add:

myTF.addCursor('myNewCursor',1,0);

Replace myTF with the instance name of your textfield. Replace 'myNewCursor'
with the linkage id of a movieclip in the library. Replace 1, with the _x
offset of the cursor. And replace 0 with the _y offset of the cursor.

NOTE: This code will only work with Left Aligned text!!!!!!!!

Re: Flash Blink Cursor Layouts NSurveyor
1/24/2005 1:12:54 AM
To make the script a bit better:

TextField.prototype.addCursor = function(linkageID, xOff, yOff) {
Key.addListener(this);
var bc = this._parent.attachMovie(linkageID, this._name+'_bc',
this._parent.getNextHighestDepth());
bc._visible = false;
this.onSetFocus = function() {
this.onKeyDown = function() {
this.type = 'input';
};
var ctf = this;
this.fttID = setInterval(fixTheText, 1);
function fixTheText() {
ctf.type = 'dynamic';
if (Selection.getBeginIndex() != Selection.getEndIndex()) {
bc._visible = false;
} else if (Selection.getCaretIndex() == -1) {
bc._visible = false;
clearInterval(ctf.fttID);
} else {
bc._visible = true;
var oldtext = ctf.text;
var cpos = Selection.getCaretIndex();
var twidth = ctf.textWidth;
ctf.text = 'test';
var onelineh = ctf.textHeight;
ctf.text = oldtext;
var lastEnter = Math.max(ctf.text.lastIndexOf('\n', cpos-1),
ctf.text.lastIndexOf('\r', cpos-1));
ctf.text = ctf.text.substring(lastEnter, cpos);
if (ctf.text == '' || ctf.text == '\n' || ctf.text == '\r') {
var isBlank = true;
}
var tx = ctf._x+ctf.textWidth;
ctf.text = oldtext.substring(0, cpos);
if (isBlank) {
ctf.text += 'X';
}
var theight = ctf.textHeight;
var ty = ctf._y+theight;
bc._x = tx+xOff;
bc._y = ty+yOff;
ctf.text = oldtext;
Selection.setSelection(cpos, cpos);
}
}
};
return bc;
};

//To use:

myCursor = myTF.addCursor('myNewCursor',1,0);

//Now you can do whatever you want with myCursor!
//For example: (setting the color to red)
myColor = new Color(myCursor);
myColor.setRGB(0xFF0000);

//Replace myTF with the instance name of your textfield.
//Replace 'myNewCursor' with the linkage id of a movieclip in the library.
//Replace 1, with the _x offset of the cursor. And replace 0 with the _y
offset of the cursor.
//NOTE: This code will only work with Left Aligned text!!!!!!!!
Re: Flash Blink Cursor Layouts NSurveyor
1/24/2005 1:43:52 AM
Made the script a tad bit better:

TextField.prototype.addCursor = function(linkageID, xOff, yOff) {
Key.addListener(this);
var bc = this._parent.attachMovie(linkageID, this._name+'_bc',
this._parent.getNextHighestDepth());
this.onSetFocus = function() {
this.hasFocus = true;
};
this.onKillFocus = function() {
this.hasFocus = false;
//clearInterval(this.fttID);
};
this.onKeyDown = function() {
this.type = 'input';
};
var ctf = this;
this.fttID = setInterval(fixTheText, 1);
function fixTheText() {
if (!ctf.hasFocus) {
trace('dead!');
bc._visible = false;
return;
}
ctf.type = 'dynamic';
if (Selection.getBeginIndex() != Selection.getEndIndex()) {
bc._visible = false;
} else if (Selection.getCaretIndex() == -1) {
bc._visible = false;
clearInterval(ctf.fttID);
} else {
bc._visible = true;
var oldtext = ctf.text;
var cpos = Selection.getCaretIndex();
var twidth = ctf.textWidth;
ctf.text = 'test';
var onelineh = ctf.textHeight;
ctf.text = oldtext;
var lastEnter = Math.max(ctf.text.lastIndexOf('\n', cpos-1),
ctf.text.lastIndexOf('\r', cpos-1));
ctf.text = ctf.text.substring(lastEnter, cpos);
if (ctf.text == '' || ctf.text == '\n' || ctf.text == '\r') {
var isBlank = true;
}
var tx = ctf._x+ctf.textWidth;
ctf.text = oldtext.substring(0, cpos);
if (isBlank) {
ctf.text += 'X';
}
var theight = ctf.textHeight;
var ty = ctf._y+theight;
bc._x = tx+xOff;
bc._y = ty+yOff;
ctf.text = oldtext;
Selection.setSelection(cpos, cpos);
}
}
return bc;
};

//To use:

myCursor = myTF.addCursor('myNewCursor',1,0);

//Now you can do whatever you want with myCursor!
//For example: (setting the color to red)
myColor = new Color(myCursor);
myColor.setRGB(0xFF0000);

//Replace myTF with the instance name of your textfield.
//Replace 'myNewCursor' with the linkage id of a movieclip in the library.
//Replace 1, with the _x offset of the cursor. And replace 0 with the _y
offset of the cursor.
//NOTE: This code will only work with Left Aligned text!!!!!!!!
Re: Flash Blink Cursor Layouts PopUpBob
1/24/2005 5:59:54 PM
]\ \ ?] [?
(/(????????????????????????????????????????????????????(?:=/???\=:?) ] [\ \[ [
_)/) ((_)[[??][? \\_// ((=` \\_// (( )) ][???????_\ ~ ?/_
??????????????????????????????????(( ...wow dam nice script - it seems to work
fine, there is just one part that I couldnt get hang of thats the part with the
_x offset of the cursor! if you could put in a little explaination to that I
would aprisiate it even more than this - thx. /?Rango :)
AddThis Social Bookmark Button