navigateToURL
Monday, July 6th, 2009Here’s the getURL replacement:
var itemUrl:URLRequest = new URLRequest("http://www.damienmason.com");
var itemWindow:String = "_blank";
navigateToURL(itemUrl, itemWindow);
Here’s the getURL replacement:
var itemUrl:URLRequest = new URLRequest("http://www.damienmason.com");
var itemWindow:String = "_blank";
navigateToURL(itemUrl, itemWindow);
Here’s the timer, much easier to control than the old setInterval (or onEnterFrame)
var timer:Timer = new Timer(1000) // one second
timer.addEventListener(TimerEvent.TIMER, updateTimer);
function updateTimer(event:TimerEvent):void {
// do something
};
Then you can start it with
timer.start();
and stop it with
timer.stop();
Check out the other properties and methods here.
Ok, I’m going to use the Flash section of this site to display finished work, but I’ll also use it for code snippets and other tips I discover as I work. I’ve just started using Actionscript 3, so it will be useful for me to have this stuff on hand, and hopefully useful for any of you who are also learning.
To start off with – buttons. Buttons have changed to fit with the event dispatcher model that AS3 uses extensively. Previously, a button link would be something like this:
button.onRelease = function():void {
// do something
};
Now, however, it need to be linked to an event, like so:
function buttonFunction(event:MouseEvent):void {
// do something
};
button.addEventListener(MouseEvent.CLICK, buttonFunction);
Otherwise if you want a cut-down version you can also drop the function into the button event:
button.addEventListener(MouseEvent.CLICK, function() {
// do something
});