dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: get leftmost or rightmost characters from a textfield?

  1. #1
    Member
    Join Date
    Jan 2004
    Posts
    43

    get leftmost or rightmost characters from a textfield?

    I have a combobox component and I can grab it contents with cboBox.text But I really need to grab just the leftmost 2 characters or the rightmost 2 characters out of this text field, so I can use it elsewhere in my function.

    I can't find any way to grab this, I tried using LEFT() but that doesn't work. Is this even possible?

    Any help is greatly appreciated, thanks!

  2. #2
    Senior Member
    Join Date
    Mar 2001
    Posts
    247
    The String.substring method should do the trick ......

    Returns a string comprising the characters between
    the points specified by the start and end parameters.

    mark

  3. #3
    FlashCLUE.com Wizzz's Avatar
    Join Date
    Nov 2005
    Location
    Warsaw Poland
    Posts
    451

  4. #4
    Member
    Join Date
    Jan 2004
    Posts
    43
    Ok, thanks! That worked, but it creates the substring as a string. This is fine, except I'm trying to put it into a Date variable.

    So I have:

    var time:String = mc.time.text //this is a combobox with times to choose (ex: 07:30 AM)
    var mySubstring:String = time.substring(0,2); //this grabs the "07" from the time

    But Now I need to compare this time to another time, so I'm trying to use the getTime() method:

    var my_dateate = new Date(2004,4,15,mySubstring,0,0)

    But I get an error on this b/c I'm trying to insert a string into where a number should be.

    Ultimately, I'm trying to get a time so that I can compare it to another time. Any help is appreciated, thanks!!

  5. #5
    FlashCLUE.com Wizzz's Avatar
    Join Date
    Nov 2005
    Location
    Warsaw Poland
    Posts
    451

  6. #6
    Senior Member ellings's Avatar
    Join Date
    Sep 2001
    Posts
    155
    Not to complaint, but why not direct people to the livedocs?
    I believe people would learn more by themselves by learning to use the livedocs..

    /Per-Henrik

  7. #7
    FlashCLUE.com Wizzz's Avatar
    Join Date
    Nov 2005
    Location
    Warsaw Poland
    Posts
    451
    it's simply easier 4 me but u can use your way, I don't care

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center