Posted July 22nd, 2008 in Code Examples | No Comments »
This is a fun little snippet. Executing this will copy a string to the local computer’s clipboard and then highlight all of the text in that text field to alert the user.
on(release) {
// copies the contents of the copy_txt textfield
System.setClipboard(copy_txt.text);
// Highlights the copy_txt textfield text
Selection.setFocus(”copy_txt”);
}
Posted July 22nd, 2008 in Code Examples | No Comments »
Ok, this little nugget is not easy to find and does not show up color-coded in the actionscript panel. When motion such as a tween is finished, this will execute a function:
// Import tweening classes
import mx.transitions.Tween;
import mx.transitions.easing.*;
// After my_mc fades in a trace message will run
my_tween = new Tween(my_mc, “_alpha”, Regular.easeIn, 0, 100, 2, true);
[...]
Posted July 22nd, 2008 in Code Examples | No Comments »
Every now and then you need to strip characters out of a string. Who knows why, but it needs to be done. Here is a way to strip from the beginning and/or from the end:
// Strip ending characters function
String.prototype.removeLast150Chars = function()
{
arr = this.split(”");
idx = this.length-150;
arr.splice(idx,150);
return [...]
Posted July 22nd, 2008 in Code Examples | No Comments »
This is pretty simple logic, but very useful in creating simple flash forms from scratch. This code will disable the submit button until the “Agree” checkbox has been checked.
// Create the checkbox status variable
var is_Checked:boolean = false;
// Function that happens when the checkbox is clicked
my_checkbox.onRelease = function():Void
{
// the ! swaps the true/false
[...]
Posted July 22nd, 2008 in Code Examples | No Comments »
I’m not sure why this was so difficult for me to figure out the first time because it’s simple, just not straight forward. Here is an example adding the blur filter to a movieclip:
// Load the filter(s) class. In this case I’ve specifically loaded
// the BlurFilter.
import flash.filters.BlurFilter;
// Create the filter with it’s attributes
// (blur [...]
Posted July 22nd, 2008 in Code Examples | No Comments »
This is the quick and dirty way to get this done.
First, create a new movieclip (my demo uses one named my_mc) with a blank first frame and throw a stop(); action on it so it doesn’t just play through all your stuff when the SWF loads.
On frames 2-infinity put your sound/image/whatever you want to happen, [...]