Avatar billede dranzer Nybegynder
03. september 2006 - 13:01 Der er 1 kommentar og
1 løsning

Macromedia Flash 8 pro Login hjælp

Hejza. Jeg er lige start på at øve mig i at forstå Macromedia Flash 8 pro. Men jeg må sige det er godt nok svært.

jeg har lavet Flash før i koolmoves. Men nu er jeg ved at være lidt træt af det program det kan ikke en skid. Så derfor vil jeg prøver og lære Macromedia Flash 8 pro.

Men jeg kender det slet ikke og kan slet ikke finde ud af det. Men jeg læste mig fra i Help til at man kunne tage et Flash login som der allered var lavet. Det har jeg så putte ind i mit program. Men jeg ved ikke hvordan jeg skal lægge kode på og hvor koden ligger skrvet ind hvsi den gøre det. Så vil gerne hvae lidt hjælp. ;)

kode:


//****************************************************************************
//Copyright (C) 2005 Macromedia, Inc. All Rights Reserved.
//The following is Sample Code and is subject to all restrictions on
//such code as contained in the End User License Agreement accompanying
//this product.
//****************************************************************************

/*
Creating a Form Example
This example shows you how to create a form that captures and validates data,
which is sent to the server. The SWF file also handles a response from the server.
Correct login is: u: Herbert, p: glasses
*/

/* Import the required classes.
  Use the wildcard (*) to import all classes within the mx.controls package.
  This includes the TextInput, Button and Label. */
import mx.controls.*;

// strict type instances on the Stage.
var status_lbl:Label;
var username_ti:TextInput;
var password_ti:TextInput;

password_ti.password = true;

/* Define a click handler for the submit_btn Button instance,
  which calls the checkForm function (defined below). */
submit_btn.clickHandler = function() {
    checkForm();
};

/* Create a listener object which is used with both the
  username_ti and password_ti TextInput instances.
  This listener "listens" for the "enter" event,
  which triggers when the enter key is pressed. */
var formListener:Object = new Object();
formListener.enter = function(evt) {
    checkForm();
};
username_ti.addEventListener("enter", formListener);
password_ti.addEventListener("enter", formListener);

// set the form focus to the username_ti TextInput instance.
Selection.setFocus(username_ti);

/* define the checkForm function, which is responsible for checking that the
  required fields are filled in and using LoadVars to send login information to the server to validate. */
function checkForm() {
    // ensure that the username_ti field isn't blank.
    if (username_ti.text.length == 0) {
        // if the username_ti field is empty, display an error message in the status_lbl Label instance.
        status_lbl.text = "<font color=\"#EFDFDC\">Please enter user name.</font>";
        // set the form focus to the username_ti TextInput instance.
        Selection.setFocus(username_ti);
        // exit the checkForm function.
        return false;
    }
    /* if the password_ti TextInput instance is blank,
      display an error message in the status_lbl Label instance and exit the checkForm function. */
    if (password_ti.text.length == 0) {
        status_lbl.text = "<font color=\"#EFDFDC\">Please enter password.</font>";
        Selection.setFocus(password_ti);
        return false;
    }
    // clear the status_lbl Label instance
    status_lbl.text = "";
    /* define two instances of the LoadVars object.
      One is used to hold the variables being sent to the server-side script,
      and the other one is used to hold the variables returned by the
      LoadVars.sendAndLoad method. */
    var result_lv:LoadVars = new LoadVars();
    var login_lv:LoadVars = new LoadVars();
    // copy the value of the two TextInput components into the login_lv LoadVars instance.
    login_lv.username = username_ti.text;
    login_lv.password = password_ti.text;
    /* send the variables in the login_lv instance to the server-side script
      using the POST method (send as Form variables rather than along the URL)
      and place the results returned in the result_lv instance. */
    login_lv.sendAndLoad("http://www.flash-mx.com/mm/login.cfm", result_lv, "POST");
    // When the results are received from the server...
    result_lv.onLoad = function(success:Boolean) {
        // If Flash is able to successfully send and load the variables from the server-side script...
        if (success) {
            // if the server returned the value of isValidLogin with a value of 1...
            if (this.isValidLogin == 1) {
                /* set the status_lbl Labal to a "success" message.
                  Typically here you'd do a gotoAndPlay or set any local variables
                  related to a successful login. */
                status_lbl.text = "<font color=\"#009900\"><b>login successful.</b></font>";
                /* else the login information wasn't valid,
                  therefore display an error message in the status_lbl Label instance. */
            } else {
                status_lbl.text = "<font color=\"#EFDFDC\">invalid user name / password.</font>";
                // set the form focus to the username_ti TextInput instance and select the existing text.
                Selection.setFocus(username_ti);
                Selection.setSelection(0, username_ti.text.length);
            }
            /* this code is only executed if for some reason the SWF is
              unable to connect to the remote page defined in LoadVars.sendAndLoad */
        } else {
            status_lbl.text = "<b>Unable to connect to login URL</b>";
            username_ti.enabled = false;
            password_ti.enabled = false;
            submit_btn.enabled = false;
        }
    };
    return true;
}
Avatar billede dranzer Nybegynder
03. september 2006 - 13:04 #1
Jeg trode at det havde noget med det her kode og gøre

username_ti.addEventListener("enter", formListener);
password_ti.addEventListener("enter", formListener);


men det hjap ikke og lave om på det.

Fordi der er ikke noget at have et login hvor man ikke kan logge sig ind med. :)
Avatar billede dranzer Nybegynder
08. september 2006 - 13:07 #2
Tråden er lukket!
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Alle kurser indenfor Microsoft 365 – både til begyndere og øvede.

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester