, But unfortunately no way this thing a few words clearly, so on the germination of the idea of writing tutorials. And then another thought, grant a man a fish, than giving the fishing, might as well say will focus on FLASH and ASP communication theory, communication theory, and specific projects can freely.
my tutorial for the primary group, started tutorial, I assume you already have basic knowledge of FLASH operation, understanding IIS configuration and operating environment. Although the FLASH and ASP communication are many, but I chose to use this tutorial LoadVars class, a class of easy to grasp because the LoadVars, easy to explain; second, because it does not involve too many other areas of knowledge. In addition, I used the JS ASP script because the script with AS very much like JS, AS long as you have some basis, JS can not learn to read and understand the basic. Finally, FLASH version, I chose to flash pro 8.0 simplified Chinese version, swf published as AS2.0, flashplayer8.0.
watching my tutorial, it is recommended to take a few read
directory:
My main focus here
my tutorial to explain the difference between the overall instill some of the tutorial, I will have really focused on the nature of these two methods and talk about an event: load, loadAndSend methods, and the onLoad event . If you need more detailed understanding of the LV class, I suggest you check help: Help → Help → flash all the books → ActionScript 2.0 Language Reference → ActionScript Class → LoadVars. Of course, you can also search LoadVars.
LV and TXT communications.
ASP
not talk about it? Let's talk about how a TXT? Oh, before you do, in fact, communication theory and LV with ASP TXT communication with the principle is the same. TXT you often, say it is easier to understand.
LV with TXT TXT communication needs in the use of For example: wenben = FLASH message I want to do this. Here Well, now we create a Then in the same folder and then create a
/ / set the code, or will be garbled
System.useCodepage = true;
/ / instantiate an object LV
var shiyan_lv = new LoadVars ();
/ / load external text
shiyan_lv.load (
/ / load successful
shiyan_lv.onLoad = function (chenggong) {
if (chenggong) {
/ / Get the content of external text
var neirong = shiyan_lv.neirong_txt;
/ / Output text
trace (
} else {
/ / loading failed to give prompt
trace (
}
};
run the above code, you'll see in the output panel, successfully loaded. Interested friends can look TXT file name changes, to test load failures.
by the above code, we learn the following knowledge:
1, how to instantiate objects of a LV (using the new keyword)
2, how to load external text files LV object (using the load method)
3, how to determine whether an external text file loaded successfully (using the onLoad event)
4, when the external text file loaded successfully, how to obtain and use its contents.
in an external text file, the reason we use object record, and in the LV object reference by AS external variables used is: LV object. external text file in the variable name. The above code is the: shiyan_lv.neirong_txt.
the example above, the LV and TXT communication about the basic principles, we now extend that, if we want to use an external TXT multiple variables do? The answer is very simple, we just use more than one TXT We still use the above example
neirong1_txt = beat LoadVar class! & Neirong2_txt = beat ASP! & Neirong3_txt = FLASH message board I can do it!
and then
System.useCodepage = true;
var shiyan_lv = new LoadVars ();
shiyan_lv.load (
shiyan_lv.onLoad = function (chenggong) {
if (chenggong) {
/ / Get the content of external text
var neirong1 = shiyan_lv.neirong1_txt;
var neirong2 = shiyan_lv.neirong2_txt;
var neirong3 = shiyan_lv.neirong3_txt;
/ / Output text
trace (
} else {
trace (
}
};
run the above code in the output window we can see
→ friends who are interested can
& neirong1_txt = beat LoadVar class!
& neirong2_txt = beat ASP!
& neirong3_txt = FLASH message board I can do it!
and then changed again to test the results of the following output:)
& neirong1_txt = beat LoadVar class! &
& neirong2_txt = beat ASP! &
& neirong3_txt = FLASH message board I can do it! &
The reason is simple, think about pulling their own:)
→ whistling, well, LV class first mentioned here, the following ASP talk about the basic format and syntax, especially the input and output statements.
ASP after a long period of accumulation, its content is very rich, but if only to develop a simple message of this, it would only need to grasp the basic input and output on it.
asp_jichu.asp we create a new file, in which the input OK, so we create an ASP file. How? It is very simple:) and then we run the ASP in the IIS documentation, you'll see the page displayed Although the contents can be displayed, but this show almost no effect on us. Why ASP is ASP? Mainly because it can complete the server and client interaction, such as it receives the client sends the variables, and according to these variables in a particular way to show clients the information needed. The above
interact to explain before the official start was also necessary to talk about what the composition of ASP files. The composition of ASP files can be summarized in one sentence only: All statements in ASP Another point to suggest that, in IIS, in general, use the default ASP VBScript, but we are using javascript, so the ASP file in the beginning, we need to add:
and then run the file in IIS, we will see the page displayed:
★ ASP in the basic input-output
pass over the contents of the address bar is: undefined
First I need to The Note that, Request receiver variable, the need to add quotation marks, while the Response output variables, then do not. Thus speaking, the above code it is not difficult to understand from the beginning we define a variable But we did not Now we use the GET method variables
've said before, GET method is passed the contents of the variable and the URL will be displayed in the browser, in fact, this display is an intermediate process, ASP It is in the middle of the process, that is, the information in the address bar to receive and process the final output of the variable content. So we can use this intermediate process, directly in the browser address bar variable. Open the operation of the
? neirong_wangzhi = I want to make their own message board FLASH
Haha, you see that? Then the page displays:
★ ASP in the basic input-output
pass over the contents of the browser is: I want to make their own message board FLASH
What does this show? We received the contents of the address bar to pass the variables, and we made it:)
doubt! ? Where do you shocked? How not to cheer it with me? GET transfer mode is not what you do not really understand? Oh, okay, by the above presentation, you only need to remember the following points on the line of knowledge:
1, ASP document composition (all the statement written in
2, ASP how to receive the outside world to pass the variable (using the Response object)
3, ASP how to display content in the browser (using the Response of the Write method)
how, I do not ask, right? Just remember these three points, you should have full confidence and I understand the contents of the following, come on!
Tips:
we
★ ASP
the basic input-output
pass over the contents of the browser is:
then replaced by the following form to see if a change?
★ ASP
the basic input-output
pass over the contents of the browser is:
we will find the results of these three forms are the same, we can see that ASP is written is very flexible, and we must seize the essence of various surface forms do not be confused:) It should be clear is the last way to write the last line of code. is a shorthand form of the output, which acts as Response.Write, only applies when the ASP statement is only one line, and only output a simple case of a variable.
whirring, ASP knowledge being that much to OK, the following exciting moment came, and we want to start the interaction between the ASP and FLASH it!
after learning the previous two sections, we are already familiar with the LV class use, and ASP, and input and output of the basic format. Now we take a look at how the integration of these two things fit together. Remember I'm talking about basic knowledge of the class when the LV cited TXT that example? LV communicate with TXT, TXT data needs to be written in the communication needs with the text file ASP file is actually a text file, ASP, when communication with the LV, it will output the contents of the format must follow the
Well, let the code to a visual experience of it, we also use name it: phrase in the lv_shiyan.txt also replaced lv_shiyan.asp, and then edit the environment directly in the FLASH press Ctrl + Enter test video, we found that the output window output: a!
faint! This can! ? What is this? FLASH and ASP communication is it? How IIS does not need anything? FLASH and TXT communication that is it? But they were suffix Mingming Ming is ? In fact, this volcano is not very clear, but I am more inclined to understand it as FLASH and ASP communication, but because there is no ASP ASP file statement supporting IIS can not display it. If you have to have a say, the most conservative answer is: FLASH communication with the text file:)
Ha ha:) Well, do not flicker for people. The above does not matter that some do not know, I actually transition to the ASP from the purpose of TXT or would like to tell you more intuitive: FLASH display the contents of the ASP is consistent with the TXT. As long as we think of ways to fiddle with ASP output data format as
TXT, he also wound in such a long time, we worry it, good, now I want to play the real thing, ASP official debut:
First, we put
★ LV and ASP communication principle
us first look at running under IIS, the page will display the following:
★ LV and ASP communication principle
& neirong1_txt = beat LoadVar class! & Neirong2_txt = beat ASP! & Neirong3_txt = FLASH message board I can do it! &
En! ? How so familiar ah, congratulations you got it, is it not But Congratulations, you have got it, how do you do it smart, the next step of course, is to display the data in the FLASH pull. Went ahead and return to Haha, success! Output window displays: That you, are you laughing? I am happy because I finally again you 忽悠, and what are you laughing? Check out our Do our FLASH software is running under IIS it? This is of course possible, that in the end how things ah? Hey:) Well, do not we all have had headaches, in fact, in our first time memory, then even though we again , while the last will be able to display the content just does not need IIS, it happened:)
it how to display new content? We only need to use ASP to pass a random function to a variable has no real meaning on it. We can load the ASP into the statements like the following:
shiyan_lv.load (
now test the movie again in the FLASH and found that the output window displays the following prompt:
failed to load
Error opening URL
En! ? Another problem, not to say that How would result in Ha ha:) In fact, here to say way? If you forget for a moment to go back under review. In fact, my suggestion is that you follow my progress the first to thoroughly understand each section, so I finished, and then read one side, then you can be a message board of their own hands. Then the above, since the
is the clouds are cleared and the time to see the sunny day. Now we are first in The first line of code into the second line:
trace (
wenben_txt.text = neirong1 +
Well, finally released dynamic text fields in the show ....
first a drink, blink of an eye for nearly two hours, how do I write so Mana, Come Come on! ASP is just mentioned how to pass data to the FLASH, which is not truly interactive, interaction is the interaction between the two sides, and now we look at how FLASH transmit data to the ASP. Prior to this, please ensure that you still remember me GET directly through the browser address bar on the Now we do is to make FLASH the address bar to do, we must, through FLASH on the
before the official start, we still have work to do the following:
1, in the
2, the
3, then add a dynamic text field, used to receive the data returned from the ASP, named as:
4, the
★ ASP
the basic input-output
5, finally
System.useCodepage = true;
var shiyan_lv = new LoadVars ();
tijiao_btn.onRelease = function () {
/ / get the input text, and to record the contents of the variable
/ / here is the equivalent of the variables
shiyan_lv.neirong_flash = shuru_txt.text;
/ / object will be stored in LV all the variables passed to the ASP, but here we only set one, is our
/ / pass to the success of ASP, we then passed back from the ASP variable is also stored in the
shiyan_lv.sendAndLoad (
};
shiyan_lv.onLoad = function (chenggong) {
if (chenggong) {
/ / Output text
shuchu_txt.text = shiyan_lv.fanhui_asp;
} else {
/ / Output text
shuchu_txt.text =
}
};
kick into gear, plenty of money to change things, ah, do not speak before the code, and direct release to test it, first have a visual understanding of: the input text box, enter , and then click the submit button, you will see a dynamic text box is: I do FLASH message board. This example of the source file can also be downloaded directly below.
Tip: If you just click refresh your browser does not correctly display the updated pages and content, please set the IE browser as follows: → Tools → Internet Options → Settings → VGH The visit to the page. So that we can use later to refresh to the test, do not worry about the IIS to refresh, and memory problems.
Finally, we come to the right data in the testing process to make a systematic analysis of the process:
FLASH
user input text box The object fanhui_asp
Through this analysis, I believe we should be able to on the whole, a rational understanding of it. Finally,
Louis Vuitton Bikini, important to emphasize that the points are:
LV object is calling the LV ASP objects in the receiving variable to pass over, just in the Request FLASH using the same variables with the name on it. ASP output data must use in. If we want to pass two or more variables FLASH, FLASH in one way we can write: (to pass the three variables as an example)
shiyan_lv.bianliang1_flash =
shiyan_lv.bianliang2_flash =
shiyan_lv.bianliang3_flash =
shiyan_lv.sendAndLoad (If we want to receive multiple FLASH FLASH passed over from the variables to the treatment according to TXT on OK. Kick into gear, catch your breath, this section was finally finished. Originally planned to write the next direct What good ideas can also mention the hope that through our concerted efforts to make this tutorial, the fastest rookie at least making a real obstacle to their own message board FLASH.
remember that we passed to the ASP variable meaningless Since we passed to the ASP that ASP should be able to receive that friends who are interested in the ASP code after the changes are as follows:
★ ASP
the basic input-output
test is found to be able to receive a digital then, and each point is not to submit that number is almost the same between the change in the 0-9999. It appears that we do receive FLASH passed over the random variable, and can pass the time, how the address bar did not show it? Because of this we have adopted a