Be a Supporter!

As: Flash> Asp> Txt

  • 3,545 Views
  • 2 Replies
New Topic Respond to this Topic
Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
As: Flash> Asp> Txt Nov. 30th, 2005 @ 09:59 AM Reply

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
Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to As: Flash> Asp> Txt Nov. 30th, 2005 @ 10:12 AM Reply

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
shazwoogle
shazwoogle
  • Member since: Sep. 27, 2004
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to As: Flash> Asp> Txt Nov. 30th, 2005 @ 06:42 PM Reply

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

it should