btw, archmage how do u get it so in your sig that it has the name of your game??
Offline
☻☻☻☻☻☺☻☻☻☻☻☺☻☻☻☻☻Red text
Offline
hello people i am happy
Offline
archmage wrote:
Magnie wrote:
So How Close Are You Done With This and SSBS? (Super Smash Brothers Scratch)
Not that close at all. Still fixing the character attacks. Right now I am working on the scratch networking features. I've had a lot of school work lately so that is slowing me down.
Ok.
Something To Help You:
[blocks]
<set{ Homework }to( 99% Done )
[/blocks]
Golfer3, Do Not Spam.
Offline
golfer3 wrote:
hello people i am happy
![]()
That's great, but please refrain from spamming.
Offline
golfer3 wrote:
btw, archmage how do u get it so in your sig that it has the name of your game??
Its just an image I created.
Offline
oh, anyway i figured out how to on my own, but thx anyway
Offline
I am having a bit of trouble sending messages to my remote pc. Here is my error message.
ReferenceError: Error #1069: Property NaN not found on flash.utils.ByteArray and there is no default value.
at NetTest4_fla::MainTimeline/SendToScratch()
at NetTest4_fla::MainTimeline/SendScratchSensorUpdate()
at NetTest4_fla::MainTimeline/parseInput()
at NetTest4_fla::MainTimeline/dataInHandler()
Here is my script
var mySocket=new Socket();
var friendSocket=new Socket();
var dataOut:String;
var player1Connected:Boolean;
var player2Connected:Boolean;
/*var player1X:String;
var player2X:String;
var player1Y:String;
var player2Y:String;
var test:String;
*/
myStatus.text=String("Waiting to connect to your computer");
friendStatus.text=String("Waiting to connect to your friends computer");
var socketNum:int=1;
inputIP.text='192.168.1.103';
my_btn.addEventListener(MouseEvent.CLICK, enterMyIP);
function enterMyIP(evt:MouseEvent):void {
socketNum=1;
mySocket.connect("localhost",42001);
mySocket.addEventListener(Event.CONNECT,socket);
mySocket.addEventListener(Event.CLOSE,socket);
mySocket.addEventListener(IOErrorEvent.IO_ERROR,socket);
mySocket.addEventListener(ProgressEvent.SOCKET_DATA, dataInHandler);
}
ip_btn.addEventListener(MouseEvent.CLICK, enterIP);
function enterIP(evt:MouseEvent):void {
socketNum=2;
//192.168.1.103
friendSocket.connect(inputIP.text,42001);
friendSocket.addEventListener(Event.CONNECT,socket);
friendSocket.addEventListener(Event.CLOSE,socket);
friendSocket.addEventListener(IOErrorEvent.IO_ERROR,socket);
friendSocket.addEventListener(ProgressEvent.SOCKET_DATA, fdataInHandler);
}
function socket(Event):void {
if (socketNum==1) {
switch (Event.type) {
case 'ioError' :
myStatus.text=String("Cannot connect to your computer");
break;
case 'connect' :
myStatus.text=String("Connected to your computer");
player1Connected=true;
if (player1Connected==true&&player2Connected==true) {
SendToScratch('broadcast "StartGame"',1);
SendToScratch('broadcast "StartGame"',2);
}
break;
case 'close' :
myStatus.text=String("Cannot connect to your computer");
break;
}
} else {
switch (Event.type) {
case 'ioError' :
friendStatus.text=String("Cannot connect to your friends computer");
break;
case 'connect' :
friendStatus.text=String("Connected to your friends computer");
player2Connected=true;
if (player1Connected==true&&player2Connected==true) {
SendToScratch('broadcast "StartGame"',1);
SendToScratch('broadcast "StartGame"',2);
}
break;
case 'close' :
friendStatus.text=String("Cannot connect to your friends computer");
break;
}
}
}
//sendToScratch('broadcast "StartGame"');
function SendToScratch(dataOut:String,playerNum:int) {
var sizeBytes:ByteArray = new ByteArray();
sizeBytes[0]=0;
sizeBytes[1]=0;
sizeBytes[2]=0;
sizeBytes[3]=dataOut.length;
if (playerNum==1) {
for (var i:Number=0; i<4; i++) {
mySocket.writeByte(sizeBytes[i]);//send each element in the array to scratch
}
mySocket.writeMultiByte(dataOut, "us-ascii");
mySocket.flush();
}
if (playerNum==2) {
for (var j:Number=0; j<4; j++) {
friendSocket.writeByte(sizeBytes[i]);//send each element in the array to scratch
}
friendSocket.writeMultiByte(dataOut, "us-ascii");
friendSocket.flush();
}
}
//Handle data sent from Scratch
function dataInHandler(event:ProgressEvent):void {
var inString:String="";
while (mySocket.bytesAvailable) {
inString+=mySocket.readUTF();
}
//trace(inString);
parseInput(inString,2);
}
//Handle data sent from Scratch
function fdataInHandler(event:ProgressEvent):void {
var inString:String="";
while (friendSocket.bytesAvailable) {
inString+=friendSocket.readUTF();
}
parseInput(inString,1);
}
// Parse the data received from Scratch
function parseInput(input:String, socket:int) {
// Look for broadcast from Scratch
var pattern1:RegExp=/broadcast\s\"(\w+)\"/;
var result:Object=pattern1.exec(input);
if (result!=null) {
trace('Scratch broadcasted:'+result[1]);
}
// Look for sensor-update from Scratch
var pattern2:RegExp=/sensor-update\s\"Scratch-(\w+)\"\s(\w+)/;
result=pattern2.exec(input);
if (result!=null) {
trace('Scratch changed variable '+result[1]+' to '+result[2]);
SendScratchSensorUpdate(result[1],result[2],socket);
}
}
// Send a broadcast message to Scratch
function SendScratchBroadcast(broadcast:String,socketNum:int) {
SendToScratch('broadcast "'+broadcast+'"',socketNum);
}
// Send a sensor variable update to Scratch
function SendScratchSensorUpdate(variable:String, value:String, socketNum:int) {
SendToScratch('sensor-update '+variable+' '+value,socketNum);
}Offline
archmage: I probably can't direct my attention to this until the weekend, but typically this sort of NaN error happens when you try to access a non-existent array value (i.e., if you use a value that is higher than the array's dimension). You may want to look at the trace() values. In some cases perhaps the regular expressions may produce unexpected results.
Offline
Im still quite new with AS, but i would say, when you make the variables (first couple of lines) a lot of your strings and booleans aren't being set values, which i have found causes a lot of NaN problems for me
Edit:
you might want to run more traces where its giving you problems.
Last edited by yambanshee (2009-02-27 14:03:42)
Offline
Guys, what are you speaking about in this post?!?!? What are Scratch networking command? Where can I start from with this, apparently awesome, new possibility of Scratch? Please, list here URLs, tutorials or whatever you like from which I will be able to start!
Offline
s_federici wrote:
Guys, what are you speaking about in this post?!?!? What are Scratch networking command? Where can I start from with this, apparently awesome, new possibility of Scratch? Please, list here URLs, tutorials or whatever you like from which I will be able to start!
go to http://scratchconnections.wik.is
Last edited by abeair (2009-03-08 09:56:50)
Offline
archmage:
I'm working on a generalized program to allow a couple instances of Scratch to communicate (using Flex 3), and, as I expected, the simplistic regular expressions I used in the above example only really handle a narrow range of what Scratch actually sends your way. Typically, the buffer may fill up with a bunch of broadcasts and sensor updates, and each sensor update may include multiple variable/value pairs. I've found that the following actionscript regular expressions work 99% of the time, if this is any help (note the use of the 'g' global flag). It also works on negative real numbers and integers:
for updates of string values:
var pattern2:RegExp = /"Scratch-(.*?)"\s"(.*?)"/g;
for updates of numeric values:
var pattern3:RegExp = /"Scratch-(.*?)"\s([-|\d|.]+)/g;
for broadcasts:
var pattern1:RegExp = /broadcast\s"(.*?)"/g;
Last edited by chalkmarrow (2009-03-12 21:57:00)
Offline
Magnie wrote:
I Can't Program At All. Only In Scratch. Everything else is too hard even squeak is too hard lol i can't even follow a tutorial right. AHHH. I'm More Of A Suggester. Archmage: I Hope You Can Do It! I Bet It Would Be Fun To Have That Part Of Scratch!
I can program a little bit on AppleScript. I am very good at programming with Scratch.
Offline
hamsterkirby wrote:
Magnie wrote:
I Can't Program At All. Only In Scratch. Everything else is too hard even squeak is too hard lol i can't even follow a tutorial right. AHHH. I'm More Of A Suggester. Archmage: I Hope You Can Do It! I Bet It Would Be Fun To Have That Part Of Scratch!
I can program a little bit on AppleScript. I am very good at programming with Scratch.
ActionScript not AppleScript sorry
Offline
I'm working on online networking using python and some php.
Offline
I use As2, and i have been looking at information about networking with flash.
Nothing i find is straight forward. Someone needs to create a tutorial that tells you how to create a multiplayer game!
Ive read about sockets, and how xml can use sockets, and how xml can link up with flash somehow, but it just doesnt tell me exactly how to use sockets!!
god!!
Although a few days ago i found out about local storage, so that should tide me over for this current game im working on.
Anyway, archmage, if you do figure out how to use sockets with As2, could you help me out... like from the very beggining.
Offline
I usually use AS2 but I could not get it working so I learned a bit of AS3.
You can try reading this thread, it has some good advice it in.
I am not working on my connections thing at the moment but if you want to work on it I can give you the fla file.
Offline
archmage wrote:
I usually use AS2 but I could not get it working so I learned a bit of AS3.
You can try reading this thread, it has some good advice it in.
I am not working on my connections thing at the moment but if you want to work on it I can give you the fla file.
PLEASE do.
Offline
Goon94 wrote:
so its not possible with as2?
I think there might be a bit of an unorthodox solution but I haven't tested it yet...I found an excellent program called mProjector that literally allows you to turn your .swf's into executable files, and more importantly, includes six new AS2 classes (mSystem, mApplication, mWindow, mFTP, mRegistry, mFile) that let you do more our less anything with Flash... I think mApplication.sendMessage(); might be what you're looking for. mProjector is paid software, but I've had the trial for a good three months now and it hasn't bothered me about buying it...it just won't let me compile for macs, but I've been able to write a couple of interesting apps with it. Hope this helps!

Offline
Your mProjector program is useless. Flash can turn swfs to exe all by its self. Just open your flash file and create a projector (AKA exe file)
Also my fla (for flash CS3) is coming
Offline
Goon94 wrote:
that has nothing to do with networking... wow
umm... yea it does. Their testing sending variables through the internet for another computer to receave
Offline
To anyone that cares, here is the download link for my networking program
It needs 2 pcs running scratch to work
http://rapidshare.com/files/214987709/NetTest_CS3.fla.html
Offline