Posts Tagged ‘prototype’

Design Patterns in ActionScript-Prototype

aquarium-128x128 When I want to write the Prototype pattern, I firstly look up the ActionScript 3.0 manual. I want to find out whether there is a clone method in Object class. If so, I will use this as an example. But, unfortunately, I can’t find this method in the Object class. Then I found the prototype attribute, but the explanation confused me. So, I decide to show you this pattern in my own way without using the Object class.

Firstly, you need to know the intent of this pattern. You can read the following text.

(more…)

trim a string from white space by JavaScript function

trackball-K1-48x48 Some times we need to trim a string from white space at the front and end,even all in the string.How can we do that elegantly?Add the following string prototype function to your code. You will call it like predefined String member functions like Substring(),charAt() and indexOf().
The code below shows the function declaration and how to use it.

(more…)