00:00
00:00
Newgrounds Background Image Theme

Kingkavvvv just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

As: Flash> Asp> Txt

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

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


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

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