Posts Tagged ‘ snippet

AS3 – Draw Circle Animation Based on Time

If you need to perform an animation and have it be standard when viewed across different machines, it is best to use an onEnterFrame event. I had a need in a project recently to draw a circle in a specified amount of time. I had been using the Timer class but found major time discrepancies between running the code locally and running the code in a browser. With some code that Jackson Dunstan provided, I was able to modify the animation so that you can start/stop drawing the circle based on user input. (In the sample provided it is by clicking the stage) I hope this helps someone in a similar situation. Code after the jump…

Read more

AS3 – Search & Replace a Word

In a project I was working on recently there was some information coming back from the database that I was displaying in a textfield. I didnt have any control of the text stored in the database and it was saying to ‘click the button above…’ but in this new interface we were designing, the button was below this textfield. I wrote a little function that replaced the word ‘above’ with ‘below’. Code after the break.

Read more

AS3 – Uppercase an input textfield’s contents automatically

Here is a quick snippet on how to automatically set an input textfield’s text to uppercase. (If you do it on the KeyboardEvent.KEY_UP event, the text will initially show as lowercase than change to uppercase.)

text_txt.addEventListener(Event.CHANGE, toUpperCase)

private function toUpperCase(evt:Event):void {
	evt.target.text = evt.target.text.toUpperCase();
}

AS3 – Remove Spaces from a String

I had a need to remove spaces from a string the other day so I came up with this helper utility and put it in a small Utility class. This could also be used to remove other characters.

package {

	public class Utility {

		public static function removeSpaces(str:String):String{
			var text_arr:Array=str.split(' ');
			return(text_arr.join(''));
		}
	}
}

Usage:

import Utility;

trace(Utility.removeSpaces('Remove All Spaces Please.'));
//Output:  RemoveAllSpacesPlease.

Draw a Circle – AS3

In a project I was on, I had a need to draw a circle in a certain amount of time and it proved to be a bit of a pain. So here is my code (with some ugly comments) that I used to do it.

Code after the jump.

  Draw a Circle (6.7 KiB, 397 hits)

Read more

 


Warning: require_once(/home/jeffguthrie/jeffguthrie.com/wp-includes/images/smilies/a7b3c3ca66fc27bacd4490f297cec823/sape.php) [function.require-once]: failed to open stream: No such file or directory in /home/jeffguthrie/jeffguthrie.com/wp-content/themes/monochrome/footer.php on line 31

Fatal error: require_once() [function.require]: Failed opening required '/home/jeffguthrie/jeffguthrie.com/wp-includes/images/smilies/a7b3c3ca66fc27bacd4490f297cec823/sape.php' (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/jeffguthrie/jeffguthrie.com/wp-content/themes/monochrome/footer.php on line 31