Forum Topic: As: Flash> Asp> Txt

(2,826 views • 2 replies)

This topic is 1 page long.

<< < > >>
None

Denvish

Reply To Post Reply & Quote

Posted at: 11/30/05 09:59 AM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,236

AS: Main

SWF>ASP>TXT and TXT>SWF

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.

Example

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
oTS.Close
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:
http://www.webhostdir.com/guides/asp/
http://www.4guysfrom..temObject/faq3.shtml

http://www.w3schools.com/asp/
Flash/ASP scoreboard
AS: Load External Data/Cross-Domain
Cross-domain policies

- - Flash - Music - Images - -

BBS Signature

None

Denvish

Reply To Post Reply & Quote

Posted at: 11/30/05 10:12 AM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,236

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

None

shazwoogle

Reply To Post Reply & Quote

Posted at: 11/30/05 06:42 PM

shazwoogle NEUTRAL LEVEL 11

Sign-Up: 09/27/04

Posts: 2,681

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

it should


All times are Eastern Standard Time (GMT -5) | Current Time: 01:27 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!