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



Calendar

August 2007
M T W T F S S
« Jul    
  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 20, 2007

Papervision3D 1.5 official release

Filed under: Using Flash — betaruce @ 8:21 pm

check it out here :)

• • •

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.

• • •

June 1, 2007

AS tips: \ in String

Filed under: Using Flash, Actionscript — betaruce @ 2:01 am

If there is "\" in a String variable, it will be "deleted" automatically and immediately (since "\" is usually used to represent something e.g. "\n" means a line break), and you won't be able to replace it e.g. with regular expression. To overcome this, you may use "\\".

Actionscript:
  1. var link:String="C:\Program Files\Adobe";
  2. trace(link);
  3. // ouput --> C:Program FilesAdobe
  4.  
  5. var link2:String="C:\\Program Files\\Adobe";
  6. trace(link2);
  7. // ouput --> C:\Program Files\Adobe

However, if the value is taken from a textfield (either dynamic or input textfield), the "\" will still remain.

Actionscript:
  1. // There is a dynamic text field on stage
  2. // with value "C:\Program Files\Adobe"
  3.  
  4. trace(txtField.text)
  5.  
  6. // output --> C:\Program Files\Adobe

• • •

May 13, 2007

AS3 tips: “/” but not “\”

Filed under: Using Flash — betaruce @ 11:56 am

In AS3, if you want to type a link to a website or load in something, make sure you use "/" but not "\". For example:

http://......
C:/program files/....

This is because if you use Windows, the links shown in the file browers will use "\", and if you simply copy that into your AS, you will fail to load in that thing and then you will keep searching for bugs without a clue.

• • •

Hong Kong Flash bloggers

Filed under: Using Flash — betaruce @ 11:42 am

If you are from HK and you have a blog about stuff like Flash, Flex, AS, etc, please join the following blogline :)

_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
• • •

December 29, 2006

AS 3 tips: addEventListener

Filed under: Using Flash — betaruce @ 12:10 am

I was typing some AS3 one day and was a bit lazy. I did the following:

Actionscript:
  1. // I did not specify the object to add the event
  2. addEventListener(Event.ENTER_FRAME,some_fct);
  3. addEventListener(MouseEvent.MOUSE_MOVE,some_fct_2);
  4.  
  5. // but actually the above is equivalent to the following
  6.  
  7. this.addEventListener(Event.ENTER_FRAME,some_fct);
  8. this.addEventListener(MouseEvent.MOUSE_MOVE,some_fct_2);

The EnterFrame work, but not the Mouse event. This is because the mouse event does not respond to the timeline ("this" refers to the timeline).

Therefore, to make the mouse respond to the movement, I add the event to some object e.g. stage in my case.

Actionscript:
  1. this.addEventListener(Event.ENTER_FRAME,some_fct);
  2. stage.addEventListener(MouseEvent.MOUSE_MOVE,some_fct_2);

This is also true for Keyboard events.

• • •

December 28, 2006

AS 3 tips: Stage & stage

Filed under: Using Flash — betaruce @ 5:53 pm

Stage is only the class name i.e. flash.display.Stage, whereas stage is the thing referring to the real stage.

This can create lots of confusion, esp in the Flash 9 Alpha Stage is highlighted in blue but not stage.

• • •

September 8, 2006

AS 3: TextField.getCharBoundaries()

Filed under: Using Flash, Tutorials — betaruce @ 10:56 pm

This new feature is definitely one that many users had been looking forward to for ages. It returns a rectangle that is the bounding box of a character.

How to use it?

Syntax:

Actionscript:
  1. public function getCharBoundaries(charIndex:int):Rectangle

First you have to get the position of a character in a string. e.g. "FLASH", then "F" corresponds to 0, "L" corresponds to 1, etc. This is the parameter charIndex. You will get back the rectangle that bound the character at the location charIndex.

Read livedocs for more details.

Here's an example. Search for sth and the match will be highlighted. The yellow highlighting patch is drawn by the drawing API. Get the source here.

However there are some limitations or skills in using this new method....

(more...)

• • •

September 6, 2006

Learn Regular Expression in AS3 now

Filed under: Using Flash — betaruce @ 1:02 pm

A regular expression describes a pattern that is used to find and manipulate matching text in strings. A typical example of its usage is to validate whether a user has typed in an email in the correct format.

Regular expression is new in AS3, although it is included in other languages for a long time. It is very useful and if you haven't come across it, why not learn it now?

Start reading Adobe livedocs on Regular expression :)

• • •

July 23, 2006

Some articles on AS 3 for more advanced users

Filed under: Using Flash — betaruce @ 1:54 pm

Grant Skinner has some good analysis on the backend garbage management of AS. Unlike the previous AS versions, AS 3 is more like a "traditional" OOP programming language e.g. Java or C. Thus there's more resources problem for programmer to think when they program in AS 3.

Read the article here:
http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html
http://www.gskinner.com/blog/archives/2006/07/as3_resource_ma_1.html

Visit his blog for some other related articles.

• • •
— Next Page »

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