Mailing List
Home
Forum Home
Flash Pro
Subjects
Firework Effect
setInterval bug identified and fixed
setInterval bug identified and fixed
ScrollPane component doesn 't auto update
Help: MX 2004 How to script a print button to print the entire sli
Event Dispatcher between classes
memory management removeMovieClip /
MX2004 Dataset itemClassName
Order of events per frame
XML to Object help
Textfield prototype question
Flash and QuickTime VR
Reading and displaying RSS feeds in Flash MX
Flash MX 2004 Sucks
AW: [Flashcoders] Switch/Case vs If/else
AW: [Flashcoders] Switch/Case vs If/else
Flash Interface with 10mb xml file
Web Service Results
Listener Object 's best practice
 
extending core classes, as2.0

extending core classes, as2.0

2004-03-14       - By Helen Triolo

 Back
Reply:     1     2     3     4     5     6     7     8     9     10  

Is there a way to extend the String class that is more straightforward
to use (or otherwise better) than this:

StringExtra.as:

dynamic class com.mydomain.core.StringExtra extends String {
   function StringExtra (input) {
       super(input);
   }
   public function replace(sFind:String, sReplace:String):String {
       return this.split(sFind).join(sReplace);
   }
}

in fla:
import com.mydomain.core.StringExtra;
var x:StringExtra = new StringExtra("This is my address");
_txt.text = x.replace('address', 'phone');

so that, for example, I could use the replace method on a String object
instead of having to declare an object of type StringExtra to do this?  
It was so straightforward to do with String.prototype in Flash MX -- I
seem to have made this too complicated, but I can't find another way to
get it to work with as2 classes. Does anyone have a library or some
examples of extensions of core classes like String, Math, Date...?

tia (floundering around in as2-land),
Helen

--
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
Owner, i-Technica (http://i-technica.com)
Web Design, Flash for Websites & CD's, Web Database Applications
ph: 301.424.6037, fax: 305.723.8546, email: info@(protected)
Flash resource site: http://actionscript-toolbox.com






=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Supported by Fig Leaf Software
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Be sure to check the archives and the wiki:
http://chattyfig.figleaf.com/
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:106903
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe send a blank e-mail to:
Normal Mode: flashcoders-unsubscribe@(protected)
Digest Mode: flashcoders-digest-unsubscrive@(protected)