A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Weird Question?

  1. #1
    Member
    Join Date
    Sep 2008
    Posts
    71

    Weird Question?

    I have an input textfield, instance name 'show_txt' and I have a button instance name 'show_btn'

    Is it possible so that on the button press, it sees if the user_txt starts with "!show", and if so, strip the "!show" and trace the text after that?

  2. #2
    Senior Member
    Join Date
    Apr 2009
    Posts
    138
    Quote Originally Posted by programma View Post
    I have an input textfield, instance name 'show_txt' and I have a button instance name 'show_btn'

    Is it possible so that on the button press, it sees if the user_txt starts with "!show", and if so, strip the "!show" and trace the text after that?
    this is really easy, look up substring!
    it will extract the info from to indexs.

    !show_hotdogs

    [0][4] !show [5][show_text.length] basically thats hwat you do. look up substr with F1

  3. #3
    Member
    Join Date
    Sep 2008
    Posts
    71
    can anyone help?

  4. #4
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    actionscript Code:
    show_btn.onPress = function(){
        var targetString:String = show_txt.text;   
       
        //check first four characters of our string match
        var firstFour:String = targetString.substr(0,5);
        if(firstFour == "!show"){
            //yes it is there
            var finalString:String = targetString.substr(5);
            trace("FINAL STRING: "+finalString);
        }else{
            //no it isnt there
            var finalString:String = targetString;
            trace("FINAL STRING: "+finalString);
        }
    }

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