dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [CS3] Multiple password to link to swf

  1. #1
    Junior Member
    Join Date
    May 2008
    Posts
    10

    [CS3] Multiple password to link to swf

    Hi, I am working on a website, where there will be a restricted area only available for members. By entering a password they will get there. Now with only one password, it works. But if I want to use more password to link to different swf files (inone input text box).
    What will be the code to make this possible ?

    thnx in advance!!


    This is what i have below:

    var myPassword:String = 'abc';
    var Passwordcqc:String = '123';

    submit_btn.onRelease = function (){
    if (password_txt.text == myPassword) {
    loadMovieNum ("intro.swf", 1);
    if (password_txt.text == Passwordcqc) {
    loadMovieNum ("home.swf", 1);
    }
    } else

    {
    gotoAndStop(2);
    }
    }

  2. #2
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    you can do:

    if (password_txt.text == myPassword && password_txt2.text == myPassword2){
    //do whatever you want next if both are correct
    }

    Im not following the rest of what you want to do? use only 1 input field? so the user is propmpted to enter in another password? is that your goal?

  3. #3
    Junior Member
    Join Date
    May 2008
    Posts
    10
    My goal is to use one input field for ppl to type in different password to log in different swf files. For example, password 1 will link to password 1 page, password 2 will link to password 2 page.

    Let me try your code to see if it works.

    Thank you so much! Really appreacite!

  4. #4
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    ahh I see..

    I understand now.

    You basically have the right idea above..

    however to do this a little more 'efficiently'..

    I would try a case/switch statement like this:

    PHP Code:
    submit_btn.onRelease = function() {
        var 
    thePassWord:String someTexField.text;
        
    //trace("PASS IS: "+thePassWord);
        
    switch (thePassWord) {
        case 
    "abc" :
            
    trace("Password is abc..load abc.swf");
            
    //loadMovie() here;
            
    break;
        case 
    "123" :
            
    trace("Password is 123..load 123.swf");
            
    //loadMovie() here;
            
    break;
        case 
    "ABC" :
            
    trace("Password is ABC..load ABC.swf");
            
    //loadMovie() here;
            
    break;
        case 
    "abc123" :
            
    trace("Password is abc123..load abc123.swf");
            
    //loadMovie() here;
            
    break;
        default :
            
    trace("password is NOT recognized...please try again");
        }
    }; 
    that should check the input field for MULTIPLE password options and do something unique on each outcome.



    good luck

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