Very short snippet: cutString()

mercoledì 4 giugno, 2008

Utile e rapido! Con i valori Number di Actionscript, ad esempio, è un essenziale aiuto per il “print” a video.

1
2
3
4
5
6
7
/*
** @name        : cutString()
** @description : cut a string for n chars
*/

protected function cutString(s:String, v:uint = 4):String {
    return ( (s.length > v)?s.substr(0,v):s );
}

Spesso lo uso anche in versione sub() o _s()

Post correlati

Questo articolo ti è stato utile?: Per nientePocoAbbastanzaMoltoMoltissimo
Loading ... Loading ...

Non ci sono commenti per questo Post

Lascia un commento

TAG XHTML PERMESSI: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> INSERIMENTO CODICE:
<pre></pre>                                  // blocco generico
<code></code>                                // blocco generico
[cc_actionscript][/cc_actionscript]          // Actionscript
[cc_actionscript3][/cc_actionscript3]        // Actionscript 3
[cc_css][/cc_css]                            // CSS Style Sheet
[cc_html][/cc_html]                          // HTML
[cc_js][/cc_js]                              // Javascript
[cc_objc][/cc_objc]                          // Objective-C
[cc_php][/cc_objc]                           // PHP
[cc_sql][/cc_sql]                            // SQL