A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Password almost working!!!!!!!!

Hybrid View

  1. #1
    Senior Member
    Join Date
    Dec 2000
    Posts
    147

    Password almost working!!!!!!!!

    Anyone got any idea why the following code works perfectly apart from when password number 1 is requested?

    stop();

    // master array - 2 dimentional
    var passwordArray:Array = new Array(new Array("1", "2","3","4","5","6","7","8","9","10"),
    new Array("Dave","Mike","Kol","Steve","Pete","Rick","M iles","Ian","Simon","Mark"));

    // creates a clone of passwordArray[0]
    if (!passwordPool){
    var passwordPool:Array = passwordArray[0].slice();
    trace("new passwordPool = " + passwordPool)} //refills array if all passwords used.
    else if (passwordPool.length == 0){
    passwordPool = passwordArray[0].slice();
    trace("refilled passwordPool = " + passwordPool);
    }

    trace("passwordPool = " + passwordPool);
    trace("passwordPool.length = " + passwordPool.length);
    randomNo = Math.round(Math.random()*passwordPool.length-1); // # between 0-9 - depends whats left in passwordPool
    myVar = passwordPool[randomNo-1];
    passwordPool.splice(randomNo,1); // removes the element so it cannot be chosen again

    trace("randomNo = " + randomNo);
    trace("Element removed from passwordPool = " + passwordPool);
    trace("Current Password = " + passwordArray[1][myVar]);

    nameTxt.text = int(myVar)+1;
    pwdTxt.text=""; //clears the input box




    checkButton.onRelease = function(){
    if (pwdTxt.text == passwordArray[1][myVar]){
    trace("Password Matched ");

    if (!passwordPool){
    var passwordPool:Array = passwordArray[0].slice();
    trace("new passwordPool = " + passwordPool)} //refills array if all passwords used.
    else if (passwordPool.length == 0){
    passwordPool = passwordArray[0].slice();
    trace("refilled passwordPool = " + passwordPool)}

    trace("passwordPool = " + passwordPool);
    trace("passwordPool.length = " + passwordPool.length);
    randomNo = Math.round(Math.random()*passwordPool.length-1); // # between 0-9 - depends whats left in passwordPool
    myVar = passwordPool[randomNo-1];
    passwordPool.splice(randomNo,1); // removes the element so it cannot be chosen again

    trace("randomNo = " + randomNo);
    trace("Element removed from passwordPool = " + passwordPool);
    trace("Current Password = " + passwordArray[1][myVar]);

    nameTxt.text = int(myVar)+1;
    pwdTxt.text = "";
    _parent.password_mov._visible = false;

    }
    else{
    pwdTxt.text = "";
    trace("Password Didn't Match ");
    gotoAndStop(2);
    }

    }
    mileso

  2. #2
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    Can you be more specific on what you're experiencing?
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  3. #3
    Senior Member
    Join Date
    Dec 2000
    Posts
    147
    Yeah, sorry. I have created an elearning course that has a 1 strike and your out rule. As the user progresses through the course if they click on an incorrect hotspot the course locks up and the a pop up appears asking the user to input a password. The required password will be 1 of 10 that are randomly selected. This is all working apart from when password 1 is required. Does that help?
    mileso

  4. #4
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    Well still not completely clear.....wud it be possible for u to upload ur FLA so that we can undertsand better and implement if possible directly into ur FLA.....
    As ever,
    Vinayak Kadam

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