Contact ZenDuo


Posts Tagged ‘flash’

Actionscript 2 key listener

Tuesday, February 23rd, 2010

A simple and effective way of attaching a listener to a flash document. Great for using keyboard presses to perform actions on a website. The example below can be used to call a function when the user hits the enter key on their keyboard.

keyListener = new Object();
keyListener.onKeyDown = function() {
if (Key.getCode() == Key.ENTER){
trace('you just hit the enter button')
}
};
Key.addListener(keyListener);

Tags: ,
Posted in ActionScript & Flash | 1 Comment »

Find and Replace AS2

Friday, February 19th, 2010

A nice simple function to find and replace characters in a string using actionscript 2. This is perfect if you want to replace words or even remove words/characters from a string.

function stringReplace(myString:String, findThis:String, replaceThis:String):String{
return myString.split(findThis).join(replaceThis);
}

myString = "example-of-some-words-with-dashes"
/////Strip out all of the dashes by replacing -'s with nothing
myString = stringReplace(linkname, "-", "");
trace(myString)

Tags: , ,
Posted in ActionScript & Flash | No Comments »

Spacer: Perfect layout spacing

Friday, February 12th, 2010

Get Adobe Flash player

When creating any website design layout, its crucial to pay attention to detail. A common layout formation is the three column. This often requires you to calculate the width of each box taking into account any margins you wish to apply to these boxes. This handy little tool does all of the calculations for you. Simply enter all of the information in the boxes above to retrieve the exact width to set each box to.

Tags: , , , ,
Posted in ActionScript & Flash, Website Design Tools | No Comments »

Pausing a Flash movie with actionscript 2

Wednesday, February 25th, 2009

Quite often you don’t want to drag your time line out say 60 seconds just to add a delay to your animation or event.

There are many different ways to delay you flash movie from playing but the one that i have included below is one of the most simplest. Using the timer below you can set your time line to pause/stop (or delay) for a set period of time.

function freezeTime(howLong:Number);void{
stop();
var t:Timer = new Timer(howLong, 1);
t.addEventListener(
TimerEvent.TIMER,
function(evt:TimerEvent);void{
play();
}
}
t.start('4000');
};

Tags: ,
Posted in ActionScript & Flash | No Comments »