Forums → Programming Forum → Sending information back and forth thru a GoDaddy server? (as2)
22 | 14916 |
How could I send information, like x and y positions to a GoDaddy server, and also retrieve that information from another Flash Player in As2?
- 22 Replies
So if I used xml no godaddy stuff? If so then that's even better because I also run my site with the same server so it'd slow down my site.
Once I can get on my computer that has flash I'll start reading up on that first link you gave me.
So would this XML stuff be like a locally hosted server?
Thanks for all your help!
the XML would be stored in the same location as your .swf, file maybe in a separate folder with .htaccess but still in the same directory.
Lets say someone loads the page containing the .swf, at that point they would need to log in to join some kind of lobby or chat system then join a match from there (correct so far?).
In order to log in there would need to be a data base containing all the information needed (username, password, and misc data), this is where the XML would come in. The code in the .swf would need to make changes on the fly (like a new user signs up). The .swf cannot do this internally otherwise you would have to constantly make changes to your .fla or class file, republish, and upload a new .swf each time. Instead, the code makes changes to the .XML then as someone returns to play, the .XML still holds all the data and the .swf just checks for existing data and loads as needed.
Easier said then done. Making the connection and simply sending the first bit of data can be frustrating. Once you have figured out a way to make it work, coding should really start progressing from that point.
It is to my understanding you need to first create a connection (var netConnect:NetConnection = new NetConnection(), when the connection has been established you then create group data (var groupspec:GroupSpecifier = new GroupSpecifier("netTest" then create the group itself (var group = new NetGroup(netConnect,groupspec) to send data back and forth.
Well I'm having trouble with writing the XML.
This is what i got:
hey you!
100
xml-stuff
The one called mynumber I want to be a number, but I can't get it to work, the only one that seems to work is "image name"
your post isn't very detailed... this is what I do
//import the file location (in my case the XML file is in the common folder)
import common.*;
//add the private XML variables
private var xmlData:XML;
private var userNames:XMLList;
//the variable inside the main constructor
var usrL:URLLoader = new URLLoader(new URLRequest("common/userList.xml");
//once the data has been loaded
usrL.addEventListener(Event.COMPLETE, dataLoaded);
function dataLoaded(event:Event):void
{
//the newly loaded data
xmlData = new XML(event.target.data);
//look only at name
userNames = xmlData.name;
//trace all the information to see if it is correct
trace(xmlData+" = xmlData"
trace(userNames+" = userNames"
}
//data on the XML file
weirdlike
//output panel should look like this
weirdlike
= xmlData
weirdlike = userNames
of course this is as3... good luck
sigh... another case of symbol misinterpretation
//data on the XML file
everything after this^ has gaps
Oh dang it sorry when I posted it removed all the code and just put down its content which was
"hey you!
100
xml-stuff"
Well what I meant was flash is reading the "100" part as a string, but I want it to see it as a number, so I can make an x or y position to be affected by that.
I've looked at many ways to convert strings to numbers, none of them seem to work. Is there anyway I could just tell the XML file that it's a number so when flash imports it, it sees it as one?
And I'm assuming once it is all working I'd have to upload the XML file to the server? (along with the swfs in the same folder?)
Even though that code there is as3, it did give me a few ideas. Thanks!
read the bottom of my post before
"hey you!
100
xml-stuff"
-------------------------------
listen for events
group.addEventListener(NetStatusEvent.NET_STATUS, networkStatus);
function networkStatus(event):void
{
switch(event.info.code)
{
case "NetConnection.Connect.Success":
trace("NetConnection Success"
break;
case "NetConnection.Connect.Failed":
trace("NetConnection Failed"
break;
case "NetConnection.Connect.Rejected":
trace("NetConnection Rejected"
break;
case "NetGroup.Connect.Success":
trace("NetGroup Success"
break;
case "NetGroup.Connect.Rejected":
trace("NetGroup Rejected"
break;
case "NetGroup.Connect.Failed":
trace("NetGroup Failed"
break;
case "NetGroup.Posting.Notify":
trace("NetGroup Notify"
//RECEIVE DATA HERE
break;
case "NetGroup.Neighbor.Connect":
trace("NetGroup New Connection"
break;
}
}
then after you have it all setup you can send messages via
group.post("whatever you want"
again its as3, it doesn't need XML, and you can test it by opening the .swf 2 times do an action on the first window then see the response on the second
You must be logged in to post a reply!