Flash and ASP Communication Introductory Course--do the really own message this 1th/5 page _flash as

Source: Internet
Author: User

Often someone asked me the flash message board production methods, but this thing a sentence can not be said clearly, so the germination of the idea of writing a tutorial. But then another thought, teach people to fish, not better to teach people to fishing, or better concentrate on the flash and ASP communication principle, the principle of the specific project can be free to play.

This tutorial is for beginners, and before I begin the tutorial, I assume you have the basics of flash operations, understanding the IIS configuration and the operating environment. Although there are many ways for flash to communicate with ASP, in this tutorial I choose to use the Loadvars class, because the Loadvars class is easy to master, easy to explain, and two because it does not involve too many other aspects of knowledge. In addition, I used in the ASP is a JS script, because the JS script and as very much like, as long as you have a certain as the basis, JS can not learn to understand the basic. Finally, flash version, I choose Flash Pro 8.0 Simplified Chinese version, SWF released as as2.0,flashplayer8.0.

Before reading my tutorial, it is recommended that you take a few minutes to read the "Flash Basics Development Habits " to help you understand my code.

Directory :

  • Loadvars Class Basic explanation (Loadvars category hereinafter referred to as LV)
  • Basic input and output in ASP
  • The principle of LV and ASP communication
  • Getting Started with ASP operations database
  • The comprehensive application of LV and ASP
  • On the principle of other communication methods

    Here I will mainly focus on my tutorials, to distinguish some of the overall indoctrination of the tutorial, I would have a real focus on this class of two methods and an event: Load, Loadandsend method, and onload events. If you need a more detailed understanding of the LV class, suggest you check help: Help →flash help → all books →actionscript 2.0 Language Reference →actionscript class →loadvars. Of course you can also search loadvars directly.

    LV and TXT newsletter .
    Not to talk about ASP? How do you speak of txt? Oh, do not worry, in fact, the LV and ASP communication principle and the principle of txt communication is the same. TXT you often use, speaking up more easily understand.
    LV and TXT communication need to use the "variable"/"value" pairing data mode in TXT. For example: wenben= I want to do flash message book. Here "Wenben" is a variable, "I want to do flash message book" is the value, and "=" is their pairing way, that is, the way to establish contact. OK, now we build a "lv_shiyan.txt" text file and enter in it: neirong_txt= I want to make a flash message book. Then in the same folder to create a "Lv_shiyan.fla", in the first write code:

    Set the encoding, or it will display garbled
    System.usecodepage = true;
    Instantiate a LV Object
    var shiyan_lv = new Loadvars ();
    Load external text
    Shiyan_lv.load ("Lv_shiyan.txt");
    After successful loading
    Shiyan_lv.onload = function (Chenggong) {
    if (Chenggong) {
    Get External text content
    var neirong = Shiyan_lv.neirong_txt;
    Output text content
    Trace ("The textual content that you load is:" +neirong);
    }else{
    Load failure give prompt
    Trace ("Load failed");
    }
    };

    Run the above code, you will see in the output panel "You loaded text content is: I want to do flash message book", this shows that the external "lv_shiyan.txt" in the content has been successfully loaded. Interested friends can change the txt filename, test the failure of loading.

    through the above code, we learned the following knowledge :
    1, how to instantiate a LV object (using the New keyword)
    2. How to load an external text file with the LV object (using the Load method)
    3, how to determine whether the external text file is loaded successfully (using the OnLoad event)
    4, how to obtain and utilize the contents of an external text file after it has been successfully loaded.
    In an external text file, we use the "variable/value" pairing data format, in order to be used by the LV object, when the external text file loaded successfully, the variables will be recorded by the LV object, and in as as the LV object reference external variables in the way: Lv object. The name of the variable in the external text file. The above code is: Shiyan_lv.neirong_txt.

    The above example tells the basic principles of LV and TXT communication, and now let's expand, what if we want to use multiple variables in an external txt? The answer is actually very simple, we only need to use multiple "variable/value" pairs in txt, and separate each "variable/value" pair with "&". We still use the "lv_shiyan.txt" file of the above example, this time to change the contents of the content into the following form:
    Neirong1_txt= beat Loadvar Class! &neirong2_txt= victory over asp! &neirong3_txt= I can make flash message board!
    Then replace the code in "Lv_shiyan.fla" with the following:

    System.usecodepage = true;
    var shiyan_lv = new Loadvars ();
    Shiyan_lv.load ("Lv_shiyan.txt");
    Shiyan_lv.onload = function (Chenggong) {
    if (Chenggong) {
    Get External text content
    var neirong1 = Shiyan_lv.neirong1_txt;
    var neirong2 = Shiyan_lv.neirong2_txt;
    var neirong3 = Shiyan_lv.neirong3_txt;
    Output text content
    Trace ("The textual content that you load is:" +neirong1+ "/" +neirong2+ "/" +neirong3 ");
    }else{
    Trace ("Load failed");
    }
    };

    Run the above code, in the Output window we can see "Beat Loadvar Class!" /victory over asp! /I can make flash message board! , which shows that we have all the variable contents in the external txt.

    Interested friends can change the contents of "Lv_shiyan.txt" into the following form to see if the output has changed:

    &neirong1_txt= beat Loadvar Class!
    &neirong2_txt= victory over asp!
    &neirong3_txt= I can make flash message board!
    And then we'll try it again. Output results:)
    &neirong1_txt= beat Loadvar Class! &
    &neirong2_txt= victory over asp! &
    &neirong3_txt= I can make flash message board! &
    The reason is actually very simple, oneself think about pull:

    Shout, OK, LV class first here, the basic format and syntax of ASP, especially input and output statements.

    Current 1/5 page 12345 Next read the full text
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.