As: Flash> Asp> Txt

4,375 Views | 2 Replies
New Topic Respond to this Topic

As: Flash> Asp> Txt 2005-11-30 09:59:11

AS: Main


Following on from AS: PHP & Flash by shazwoogle and AS: Load External Data/Cross-Domain, this is the version for users of ASP. ASP is short for Active Server Pages, and it basically allows for dynamic content on the web. A very simple example of ASP code:

<% Response.Write("Hello, Mother!") %>

Generally ASPages pull from and write to an MSAccess database, but this is another use for them - writing through them from Flash to a textfile.


The ASP version uses basically the same AS and symbols as shazwoogle's PHP example - 2 Input Textboxes with the VAR names tname and info (for sending), 2 Dynamic Textboxes with the VAR names tname2 and info2 (for receiving), and a button InstanceNamed submit

Code on the first (only) frame is:

var path = "http://sitename.com/folder/" //FOLDER
var myData:LoadVars = new LoadVars();
info = "";
tname = "";

submit.onPress = function() { //SEND DATA
if (tname != "" && info != "") {
myData.info = info;
myData.tname = tname;
info = "";
tname = "";
myData.sendAndLoad (path + "gb.asp", myData, "POST");

myData.onLoad = function() { //LOAD FROM TXT
info2 = this.info; tname2 = this.tname;

myData.load (path + "gb.txt"); //LOAD TXT ON STARTUP

The ASP code is (obviously) a bit different from PHP:

'Prepare file for write, use TF = 8 for appending
Const TF = 2
Dim oFSO, oTS, nam, inf
Set oFSO = Server.CreateObject ("Scripting.FileSystemObject")
nam = "&tname=" & Request.Form("tname")
inf = "&info=" & Request.Form("info")
'Open textfile.
'Use ( Server.MapPath("gb.txt"), fsoForAppend) for appending
Set oTS = oFSO.OpenTextFile( Server.MapPath("gb.txt"), TF, True)
'Write to textfile
oTS.WriteLine "k=3" & nam & inf
'Clean up
Set oTS = Nothing
Set oFSO = Nothing

Source files


PHP has an advantage over ASP in terms of cost. Since the majority of webhost services run on Unix/Linux machines, and ASP requires a Windows-based server, you'll generally find that ASP-enabled domains cost a bit more than PHP-based ones. Personally, I have 2 domains with http://www.easyasphosting.com/ ($4.99/month) and have been very satisfied with their service and support.

In terms of free ASP domains, try here and here


Associated reading:

Flash/ASP scoreboard
AS: Load External Data/Cross-Domain
Cross-domain policies

- - Flash - Music - Images - -

BBS Signature

Response to As: Flash> Asp> Txt 2005-11-30 10:12:39

Bear in mind that this code WILL NOT WORK unless the Flash is published (F12) and the HTML produced is viewed in a browser.
Preview mode in Flash will show a connection error in the output window.
Not sure if it works in the standalone Flash Player, use the browser to be on the safe side.

- - Flash - Music - Images - -

BBS Signature

Response to As: Flash> Asp> Txt 2005-11-30 18:42:27

At 11/30/05 10:12 AM, Denvish wrote: Not sure if it works in the standalone Flash Player

it should