  | | | extending core classes, as2.0 | extending core classes, as2.0 2004-03-14 - By Helen Triolo
Back 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)
|
|
 |