This is a blog about Flash & AS by betaruce :-)



Calendar

July 2007
M T W T F S S
« Jun   Aug »
  1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31  

July 1, 2007

AS3: what to do without getURL()?

Filed under: Using Flash — betaruce @ 3:15 pm

In previous versions of AS, just a few lines of simple codes will allow you to click on a button and go to another website. In AS3, however, getURL() is replaced. You have to do the following:

Actionscript:
  1. import flash.net.*;
  2. import flash.events.*;
  3. //
  4. btn.addEventListener(MouseEvent.CLICK,onClick);
  5. var ur:URLRequest = new URLRequest("http://www.adobe.com");
  6. //
  7. function onClick(e:Event):void{
  8. navigateToURL(ur, "_blank");
  9. }

btn is a movie clip on stage. When someone click on it, it will trigger the onClick() function and bring the user to adobe web.

Then, you have to declare the url with the URLRequest object. Last but not the least, we have to code the onClick() function.

getURL() is replaced by navigateToURL(), which belongs to flash.net. The syntax is:

Actionscript:
  1. public function navigateToURL(request:URLRequest, window:String = null):void

The 1st parameter is the URLRequest object that contains the target url. The 2nd parameter defines whether a new window will pop up or open the website in the current window.

• • •

Powered by: WordPress • Template by: Priss

cheap phentermine phentermine site phentermine effects online phentermine phentermine prescription buy phentermine online phentermine alternatives phentermine deit pill cheap generic phentermine order phentermine online Clenbuterol Phentermine online pharmacy phentermine buy phentermine weight loss pill Cialis Comparison Viagra Cheap Viagra Online Prescription generic viagra sale viagra online viagra viagra pill discount sale viagra Generico Impotencia Viagra viagra sildenafil citrate Xanax Online xanax order xanax valium versus xanax