Flash AS3 – Random Time Pause

Tuesday, May 19th, 2009

When your looking to create a delay say on multiple movie clips so that the animations, play at different times, but you need to have a stop state here’s some code that will make it easier.

This allows you to setup a time delay before playing the next frames so you can have different start times.

stop();
var timer:Timer = new Timer(Math.random() * (10000 – 2000) + 1000, 1);
timer.start();
timer.addEventListener(TimerEvent.TIMER_COMPLETE, hope);

function hope(event:TimerEvent):void{
play();
}

Flash Button Action Script 3

Wednesday, April 22nd, 2009

New to action script 3 and looking to make your button link to a website, add your movie clip and give it the instance name of – myButton

Then add this code to your actionscript frame and update the url as required.

myButton.addEventListener(MouseEvent.MOUSE_UP , myButtonClick );

function myButtonClick(event:MouseEvent):void
{

var yourURL:URLRequest = new URLRequest(“http://www.elitegd.com”);
navigateToURL( yourURL , “_self”);
}

If you have mulitple buttons just duplicate the code and add a number to your vars and instance name.

If your looking to link to a different frame just change the middle var request

var yourURL:URLRequest = new URLRequest(“http://www.elitegd.com”);
navigateToURL( yourURL , “_self”);

to

gotoAndStop(2);

Hopefully this will help you to get control of one of the basic tasks that requires just a bit more code in Action Script 3.

Note for the _self to work i did have to upload to a webserver to test and it worked correctly offline using _blank worked correctly.

Tips and Tricks #1

Thursday, April 16th, 2009

I’m going to start consolidating different information i get from other websites on my blog that I think will be beneficial to people who read along.

First up is Adobe TV: Everyday Timesavers: Web – Preview Pages in Dreamweaver CS4

The new Live View feature in Dreamweaver CS4 helps you be more productive by letting you preview your web pages without having to load them in a browser.