Wednesday, November 2, 2011

A collection of fast flash tips that may be useful

How to open an URL with AS3:

 try {
   navigateToURL(new URLRequest("http://site"), '_blank'); 
 } catch (e:Error) {

   trace("Can't open site!");
 }

How to enable button mode on MovieClip (hand cursor):
        mc.buttonMode = true;
How to hide/show the mouse:
 import flash.ui.*;

 Mouse.hide();
 Mouse.show();
How to choose a random element from an array:
 var ar:Array = [0, 1, 2, 3, 4, 5, 6];
 var randomIndex:int = Math.random() * ar.length;
 trace(ar[randomIndex]);

No comments :

Post a Comment