Flash Dynamic Resolution Web application Server path

Source: Internet
Author: User
Tags basic html page html page http request iis modify servervariables domain
web| Program | dynamic | Server with the increasing popularity of flash, flash in the web development above but the performance, since it is web-site, it is certainly inseparable from the basic HTML page, The following is my usual in the production of flash site often need to use the HTML and practical tips, not much suitable for just contact with the use of Flash web development Friends, I hope to be able to have a certain help, I am not a master, wrong place or unavoidable, please forgive me, thank you! (Related articles: Hands-on Flash Beginner course

Dynamically resolving HTTP server paths for Flashweb applications

Play flash+asp/php development friends know, in Flash software test Flash from the background script reading data, can not directly use such as "loaddata.asp" such a path, must be http://www.domain.com/ Application/loaddata.asp or http: The path to the beginning. Some of them asked? Why, then?

When the Flashplayer test receives the load ("loaddata.asp"), he reads the loaddata.asp file directly under the SWF file path. But because there is no IIS running processing, read directly into the flash inside, of course, read the result is% @LANGUAGE = "VBSCRIPT" codepage= "65001" is similar to this, so we can not process the data according to our wishes, And when Flashplayer executes load ("http://www.domain.com/Application/loaddata.asp") This command, he is no longer a local TXT file read command, but an HTTP request, Flashplayer sends this request to the HTTP server, and the server's IIS resolution script returns the results Flashplayer can handle the data correctly. (a pile of nonsense)

Of course, if you understand the relationship between the path, you can also write load ("loaddata.asp") to the Flash, upload, the. asp. swf and the HTML file containing the. swf, all in one directory. It is particularly noted that the SWF takes the path to include its HTML and. asp's relationships. Rather than the path relationship between SWF and ASP.

It's a bit faint to say, but if you understand the path relationship, it's very simple.

Okay, to get to the point, although the input HTTP path can read the data correctly, but in the program development testing phase may often require the developer to replace the server, which caused us a certain amount of trouble, you change to another server on the top of the time to modify his HTTP path, if Read n ( n≠0) A file, do you want to manually modify n times? Of course not, you can easily solve this problem by following this trick:

Embed the SWF file into an ASP page and enter the following code:

<%
Dim Pageurl,urlarry,i,applicationurl
Pageurl= "http://" & Request.ServerVariables ("Http_host") & Request.ServerVariables ("url")
Response.Write "Pageurl=" &pageurl
Urlarry=split (Pageurl, "/")
Arryubound=ubound (urlarry,1)-1
For I=0 to Arryubound
Applicationurl=applicationurl&urlarry (i) & "/"
NEXT
Response.Write "<br>applicationurl=" &applicationurl "is only the test code is correct, can save
%>

Well, the ASP has a certain understanding of friends should understand what the meaning of the code, PHP can also use this idea to write, the following in the SWF path can be written <%= "flash.swf?myserver=" &ApplicationURL%> This can pass the variable to the SWF file through the URL, in the Flash movie can directly access this variable, is _root.myserver. OK, now let's test the results, write a loaddata.asp and let him return a back variable.

Open Flash and create a new file. Then drag two dynamic text boxes into the scene, named Txt.url, and then enter the following code in the first frame:

Mytxt=new Loadvars ()
Mytxt.load (_root.myserver+ "loaddata.asp")
Mytxt.onload=function (Success) {
if (success) {
Txt.text=this. Back
url.text=_root.myserver+ "Loaddata.asp"
}else{
txt.text= "No File"
url.text=_root.myserver+ "Loaddata.asp"
}
}

OK, Ctrl+enter, release the video, and then embed the SWF file in the previous ASP page, you can see the effect, respectively, in the IE Address bar input http://127.0.0.1/****, http://localhost/*****, http://native IP address/**** if all can read correctly, that means already OK, oh, the following slowly play it!

Note: If you are debugging, use absolute path, then before the test upload, change to relative path will be more convenient for the entire directory in the site of the mobile, you can not use the above complex methods.



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.