Archive for the ‘Actionscript’ Category
How do I prevent a textfield in Actionscript from scrolling 1 line when it shouldn’t scroll?
There is a strange bug in Actionscript which makes a textfield which shouldn’t scroll still scroll one line. I only found this bug in Windows and only when scrolling using the scroll-wheel.
The code below, although not very beautiful, will prevent the textfield from scrolling. I found it here.
myTextField.addEventListener(Event.SCROLL, onScroll);
function onScroll(evt:Event):void {
myTextField.scrollV = 0;
}
Link: http://www.kirupa.com/forum/showthread.php?t=288955
Status: Tested it, works
How can I convert vector drawings to actionscript code?
This on-line tool extracts shapes from Flash .swf files and returns them in a format which can be rendered by actionscript. This way you can manipulate drawn vector graphics with actionscript.
Link: Quasimondo’s Actionscript Shape Decoder
Status: Tested it, works
How do I find and replace a string in actionscript 2?
I use this findReplace function to replace a string in actionscript:
// (from http://proto.layer51.com/d.aspx?f=23)
var findReplace = function(searchStr:String, findStr:String, replaceStr:String) {
var locationNum:Number = searchStr.indexOf(findStr, 0);
while (locationNum != -1) {
var sub1 = searchStr.substr(0, locationNum);
locationNum += findStr.length;
var sub2 = searchStr.substr(locationNum, searchStr.length);
var searchStr = sub1 + replaceStr + sub2;
var locationNum = searchStr.indexOf(findStr, sub1.length);
}
return(searchStr);
}
Status: tested it, like it