home |  
Sell Downloads - Ejunkie
open db network by 19.5 degrees
LYRICS | FREE E-BOOKS | SELL DOWNLOADS WITH PAYPAL
 in   
contribute for fun & profit
brink
-Array functions..
-Flash Remoting ..
-str_pad functio..
-Detecting mouse..
-Ltrim, Rtrim an..
-Opening externa..
-Modifying Flash..
-Smoothing effec..
-Array functions..
-Drawing / Vecto..
 
See all Flash Tutorials
 
-Extensions/Plug..
-FLA..
-Flash Software..
-Flash Tutorials..
 
See all Flash
 
All Resources > Flash > Flash Tutorials > ACTIONSCRIPT TUTORIALS
spread the word around  send this page to a friend   read/write comments/corrections/additions comments  rate this 

Ltrim, Rtrim and Trim functions for flash

by 19.5 Degrees
 
 
views: 17897 | rating: 5/10
 


// parameters:
// matter, string to be trimmed
// returns:
// string, whitespaces removed from left side.

function ltrim(matter) {
    if ((matter.length>1) || (matter.length == 1 && matter.charCodeAt(0)>32 && matter.charCodeAt(0)<255)) {
        i = 0;
        while (i<matter.length && (matter.charCodeAt(i)<=32 || matter.charCodeAt(i)>=255)) {
            i++;
        }
        matter = matter.substring(i);
    } else {
        matter = "";
    }
    return matter;
}

// parameters:
// matter, string to be trimmed
// returns:
// string, whitespaces removed from right side.

function rtrim(matter) {
    if ((matter.length>1) || (matter.length == 1 && matter.charCodeAt(0)>32 && matter.charCodeAt(0)<255)) {
        i = matter.length-1;
       while (i>=0 && (matter.charCodeAt(i)<=32 || matter.charCodeAt(i)>=255)) {
            i--;
        }
        matter = matter.substring(0, i+1);
    } else {
        matter = "";
    }
    return matter;
}

// parameters:
// matter, string to be trimmed
// returns:
// string, whitespaces removed from both sides.

function trim(matter) {
    return ltrim(rtrim(matter));
}


« PREVIOUS
  INDEX
NEXT »

spread the word around
read comments

Thanks
posted by: Amit
on: Feb 19, 08 1:01 am

I think this code is very useful for me...thanks once agin.

post reply | read replies (0)



Little Modification
posted by: Tushar
on: Jan 24, 08 9:01 am

function trimString(par_String:String):String {
var sReturn:String = "";
for (i=0; i<=par_String.length-1; i++) {
if (par_String.charAt(i)<>" ") {
sReturn = sReturn+par_String.charAt(i);
}
}
return sReturn;
}

post reply | read replies (0)



Other Solution
posted by: Tushar
on: Jan 24, 08 8:30 am

You can also use this......

function trimString(par_String:String):String {
var sReturn:String = "";
for (i=0; i<par_String.length-1; i++) {
if (par_String.charAt(i)<>" ") {
sReturn = sReturn+par_String.charAt(i);
}
}
return sReturn;
}

post reply | read replies (0)



Tnx
posted by: Gx
on: Dec 23, 07 10:52 am

Tnx m8

Just what I needed. Made something like this in the past but losy almost all my code in a HD crash. This really saved me some time

post reply | read replies (0)



Thanks a lot
posted by: Elaijha
on: Nov 11, 07 9:24 am

it really saved my time!

post reply | read replies (1)



read more commentsread more comments   |   read more commentspost comment 



home | contact | contribute | terms of use | privacy policy |