00:00
00:00
Newgrounds Background Image Theme

Forsynth 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!

The Flash 'Reg' Lounge

3,047,142 Views | 60,186 Replies
New Topic Respond to this Topic

Response to The Flash 'Reg' Lounge 2014-02-19 21:10:10


Started off as a test game for my component system and surprisingly I've come to create an actual game.

Only problem is.. Flash + Web Browser + Policies.

This whole time I've been working with AIR. Any documents/links detailing how to create a socket policy for this game? Bonus: what would be a good background colour for dark nights?

http://www.newgrounds.com/dump/item/7040e2882decb16f139c04ff5ad55193

Response to The Flash 'Reg' Lounge 2014-02-19 21:37:38


At 2/19/14 09:10 PM, slugrail wrote: http://www.newgrounds.com/dump/item/7040e2882decb16f139c04ff5ad55193

I tried using those slopes and it was painful. I added a "butt offset" so I could have him slide down the slope without looking dumb, but that screwed up a lot since the dude is taller than the tiles. No slopes now.

Response to The Flash 'Reg' Lounge 2014-02-19 22:05:50


At 2/19/14 09:10 PM, slugrail wrote: Any documents/links detailing how to create a socket policy for this game?

This article explains what you need to know. Long story short you need to send this to the client when it requests the socket policy:

<?xml version="1.0"?> <cross-domain-policy> <allow-access-from domain="*" to-ports="*" /> </cross-domain-policy>

Though you might want to limit the domain and port access. You will also need to null-terminate the string that is sent if that is not done for you automatically.

Also keep in mind that Flash Player only supports TCP, which is not suitable for real-time data transmission. If your game is turn-based, like how a game of chess is, then TCP will be just fine, but if you need updates to occur in real-time, and based on the single player version I'm assuming you do, then you're out of luck as you would need UDP for that. On the other hand you could use HTML5 instead, as it does support UDP in the form of WebRTC, but considering that you've already put a lot of work into the Flash version that might not be a viable option.

Response to The Flash 'Reg' Lounge 2014-02-20 12:02:44


At 2/19/14 10:05 PM, Diki wrote: This article explains what you need to know. Long story short you need to send this to the client when it requests the socket policy:

Here's the code I use for policy requests
TCPServer class:

private function onData(e:ProgressEvent):void { var temp:ByteArray; var info:ClientInfo = new ClientInfo(e.target.remoteAddress, e.target.remotePort); if (e.bytesLoaded >= e.bytesTotal) { for (var i:uint = 0; i < _clients.length; i++) { if (_clients[i].remoteAddress == e.target.remoteAddress && _clients[i].remotePort == e.target.remotePort) { temp = new ByteArray(); e.target.readBytes(temp, 0, e.target.bytesAvailable); if (!_isPolicyServer && expectCompressedData) { temp.uncompress(CompressionAlgorithm.LZMA); } temp.position = 0; if (_isPolicyServer) { respondData(i, temp); remove(i, i); } ON_DATA.dispatch(this, i, temp); if (_isPolicyServer) { ON_CLOSED.dispatch(this, i, info); } return; } } } } private function respondData(index:uint, data:ByteArray):void { var dataString:String = data.readUTFBytes(data.length); var returnData:ByteArray = new ByteArray(); var returnString:String; if (dataString.search("policy-request") > -1) { returnString = "<?xml version=\"1.0\"?>" + "<!DOCTYPE cross-domain-policy SYSTEM \"/xml/dtds/cross-domain-policy.dtd\">" + "<cross-domain-policy>" + "<site-control permitted-cross-domain-policies=\"master-only\"/>" + "<allow-access-from domain=\"*\" to-ports=\"" + _ports.join(", ") + "\"/>" + "</cross-domain-policy>\x00"; returnData.writeUTFBytes("Content-Type: application/xml \r\n" + "Content-Length: " + returnString.length + " \r\n" + returnString); send(returnData, index, index, false); } }

TCPClient class:

public function connect(host:String, port:uint, policyPort:uint, timeout:uint = 3000):void { if (!host || port > 65535 || policyPort > 65535) { ON_ERROR.dispatch(this, "Values given are not allowed."); return; } if (_socket && _socket.connected) { disconnect(); } _sending = true; _backlog = new Vector.<ByteArray>(); _socket = new Socket(); try { Security.allowDomain(host); Security.allowInsecureDomain(host); } catch (e:Error) { } if (host.search("://") > -1) { Security.loadPolicyFile(host + ":" + policyPort); } else { Security.loadPolicyFile("xmlsocket://" + host + ":" + policyPort); Security.loadPolicyFile("https://" + host + ":" + policyPort); Security.loadPolicyFile("http://" + host + ":" + policyPort); } _socket.addEventListener(IOErrorEvent.IO_ERROR, onIOError); _socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError); _socket.addEventListener(Event.CLOSE, onClose); _socket.addEventListener(Event.CONNECT, onConnect); _socket.addEventListener(OutputProgressEvent.OUTPUT_PROGRESS, onProgress); _socket.addEventListener(ProgressEvent.SOCKET_DATA, onData); _socket.timeout = timeout; try { _socket.connect(host, port); } catch (e:Error) { ON_ERROR.dispatch(this, e.message); return; } }

That seems to work well enough for me. It looks messy without context behind the functions, but it would be a very long post and I wanted to show the relevant bits.

Also the "loadPolicyFile" block looks a bit bruteforce-y to me, but I guess if it 'aint broke don't fit it

Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature

Response to The Flash 'Reg' Lounge 2014-02-20 21:04:49


At 2/20/14 07:15 PM, Innermike wrote: Do you guys make to-do lists for things your working on? If so, do you have boundaries? like a thing has to be this big of a project before I'll start keeping track or do you do it regardless of size? Do you setup a google doc or just a plain text file in your project folder? Do you keep it open in a tab in your editor or a separate window hovering above it all?
TELL ME YOUR WAYS

If I'm the project lead, I'll write down my ideas and what I need to do in a text file. Otherwise, no.

I complained about this how a computer works + machine/asm/c class that I'm currently taking, but fuck man, lc3's are amazing. We touched on machine code but mostly talked about asm, and we program a gameboy (emulator) game later on in the semester.

in order to learn about the lc3, you must become the lc3

The Flash 'Reg' Lounge

Response to The Flash 'Reg' Lounge 2014-02-20 21:17:15


At 2/20/14 09:04 PM, MSGhero wrote: in order to learn about the lc3, you must become the lc3

That looks like tkgate without the bugs.


BBS Signature

Response to The Flash 'Reg' Lounge 2014-02-20 23:36:41


Pass the tissues, we all got z sorting issues.

The Flash 'Reg' Lounge

Response to The Flash 'Reg' Lounge 2014-02-20 23:48:28


At 2/20/14 11:36 PM, PrettyMuchBryce wrote: Pass the tissues, we all got z sorting issues.

What language are you doing this in, and how are you doing the hexa-iso? I want an isometric engine for openfl, but I don't want to use a port of as3isolib if I don't have to cuz of the slow z sorting.

Response to The Flash 'Reg' Lounge 2014-02-20 23:53:24


At 2/20/14 11:48 PM, MSGhero wrote:
At 2/20/14 11:36 PM, PrettyMuchBryce wrote: Pass the tissues, we all got z sorting issues.
What language are you doing this in, and how are you doing the hexa-iso? I want an isometric engine for openfl, but I don't want to use a port of as3isolib if I don't have to cuz of the slow z sorting.

MGHero, my goo friend. I am doing this in AS3. How am I doing the Hexa-iso ? Hmm I have never heard that term. Well... I figured out the math on how to lay out a 2D array in a hexagonal grid. There are many tutorials about it. Who needs as3isowhatever ?

Response to The Flash 'Reg' Lounge 2014-02-21 00:01:57


At 2/20/14 11:53 PM, PrettyMuchBryce wrote: MGHero, my goo friend. I am doing this in AS3. How am I doing the Hexa-iso ? Hmm I have never heard that term. Well... I figured out the math on how to lay out a 2D array in a hexagonal grid. There are many tutorials about it. Who needs as3isowhatever ?

I just made it up. I didn't want to deal with z sorting myself when an engine could handle it, but it seems like I'll have to. Omar's CJ blog post about using floats instead of ints will smooth it out I assume.

Response to The Flash 'Reg' Lounge 2014-02-21 00:56:57


At 2/21/14 12:01 AM, MSGhero wrote: Omar's CJ blog post about using floats instead of ints will smooth it out I assume.

If you for some reason needed a number such as 1.000000000000000001 (because that'll ever happen) I would recommend floating points since they round. I noticed this flaw when using scientific measurements in Kelvin with Java; I had to use the BigDecimal class.

or if you're using AS3, try a String or a ByteArray instead.

Question: What does a standard float round to? Nearest thousandth, I think, right?


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature

Response to The Flash 'Reg' Lounge 2014-02-21 01:15:50


At 2/21/14 12:56 AM, egg82 wrote: Question: What does a standard float round to? Nearest thousandth, I think, right?

Depends on the accuracy. IIRC the mantissa of 32 bit is 23 bits long, so eps = 2^(exponent - 23). So big exponents have less accuracy because the decimal digits matter less compared to the huge ass integer. But to answer your question in general, I have no clue, try numbers and see :D

I learned so much from that class last semester, too bad everyone did poorly

Response to The Flash 'Reg' Lounge 2014-02-21 14:49:30


I forgot we had a writing portal.

Talking with omar about someone named nick is hard because I'm nick and xelu is nick. Therefore, Nick Pasto is now pasta nick or just pasta.

Response to The Flash 'Reg' Lounge 2014-02-21 16:11:53


At 2/21/14 12:56 AM, egg82 wrote: Question: What does a standard float round to? Nearest thousandth, I think, right?

You get digits of precision, not rounding. Float is something like 6 digits of precision, double is like 15

Response to The Flash 'Reg' Lounge 2014-02-22 16:46:38


At 2/21/14 04:11 PM, Glaiel-Gamer wrote: You get digits of precision, not rounding. Float is something like 6 digits of precision, double is like 15

articles I read called it a "rounding error", so I assumed it meant "rounding"
what happens after the six-digit dropoff?


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature

Response to The Flash 'Reg' Lounge 2014-02-22 16:57:11


At 2/22/14 04:46 PM, egg82 wrote:
At 2/21/14 04:11 PM, Glaiel-Gamer wrote: You get digits of precision, not rounding. Float is something like 6 digits of precision, double is like 15
articles I read called it a "rounding error", so I assumed it meant "rounding"
what happens after the six-digit dropoff?

just read up on floating point numbers http://en.wikipedia.org/wiki/IEEE_floating_point

the difference between digits of precision and rounding is that rounding is fixed place (round to the hundredths place) and precision is floating place (6.132592x10^50)

Response to The Flash 'Reg' Lounge 2014-02-24 13:04:43


Idk anything about udp, but I saw the abbreviation in here.

Response to The Flash 'Reg' Lounge 2014-02-24 15:04:27


At 2/24/14 01:04 PM, MSGhero wrote: Idk anything about udp, but I saw the abbreviation in here.

Universal Data Protocol? I think?
~15% packet loss, chance of duplicate packets, packets that don't fully get there, no automatic packet splitting (so packet size limit), no extra headers.
Much faster than TCP, though. Good for packets that you don't care about losing and need to be sent as frequently as possible (like player positions)


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature

Response to The Flash 'Reg' Lounge 2014-02-24 15:25:28


At 2/24/14 03:04 PM, egg82 wrote:
At 2/24/14 01:04 PM, MSGhero wrote: Idk anything about udp, but I saw the abbreviation in here.
Universal Data Protocol? I think?
~15% packet loss, chance of duplicate packets, packets that don't fully get there, no automatic packet splitting (so packet size limit), no extra headers.
Much faster than TCP, though. Good for packets that you don't care about losing and need to be sent as frequently as possible (like player positions)

They're both built on top of IP, the speed difference is not as significant as it seems at first, most of the delay in TCP comes from if it loses a packet, the endpoint needs to wait till the missing packet arrives before it can continue processing the new ones (since not only are the packets guaranteed to arrive, but guaranteed to arrive in order), but packet loss is pretty rare in the first place (unless your connection is really shitty to begin with), and even 3-4% packet loss can significantly affect a multiplayer game.

Response to The Flash 'Reg' Lounge 2014-02-24 15:39:45


At 2/24/14 03:25 PM, Glaiel-Gamer wrote: They're both built on top of IP, the speed difference is not as significant as it seems at first, most of the delay in TCP comes from if it loses a packet, the endpoint needs to wait till the missing packet arrives before it can continue processing the new ones (since not only are the packets guaranteed to arrive, but guaranteed to arrive in order), but packet loss is pretty rare in the first place (unless your connection is really shitty to begin with), and even 3-4% packet loss can significantly affect a multiplayer game.

I would say most of the waiting comes from ACK. Also the fact that the packets generally have a large (comparatively-speaking) header that needs to be parsed out before any real information is actually given. Processing power/wait time is larger compared to UDP. I'd still use UDP for things that require a lot of packets and don't matter if something happens to them.


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature

Response to The Flash 'Reg' Lounge 2014-02-24 15:49:18


At 2/24/14 03:04 PM, egg82 wrote: Universal Data Protocol? I think?

UDP stands for User Datagram Protocol.

And I have no idea how that AppWarp thing could possibly achieve high performance real-time data transmission in Flash Player; that seems rather dubious to me. I tried finding out how it actually works on their website, but they offer no explanation, at least not that I could find, and it's not open source.

Response to The Flash 'Reg' Lounge 2014-02-24 15:57:33


At 2/24/14 03:49 PM, Diki wrote: UDP stands for User Datagram Protocol.

Fuck. I was close! Ish.

And I have no idea how that AppWarp thing could possibly achieve high performance real-time data transmission in Flash Player; that seems rather dubious to me. I tried finding out how it actually works on their website, but they offer no explanation, at least not that I could find, and it's not open source.

Honestly it might just be as simple as "it's just that fast"
When I use a loopback with AS3 clients and servers, data transmission is pretty damn quick. Much quicker than what they showed, actually.


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature

Response to The Flash 'Reg' Lounge 2014-02-24 16:15:57


At 2/24/14 03:49 PM, Diki wrote: And I have no idea how that AppWarp thing could possibly achieve high performance real-time data transmission in Flash Player; that seems rather dubious to me. I tried finding out how it actually works on their website, but they offer no explanation, at least not that I could find, and it's not open source.

I found the git link, but there's just a swc :(

When I bother NG servers to give me save file info or whatever, is that tcp or udp or neither? What's the preferred way of doing multiplayer in general?

Response to The Flash 'Reg' Lounge 2014-02-24 16:35:57


At 2/24/14 04:15 PM, MSGhero wrote: When I bother NG servers to give me save file info or whatever, is that tcp or udp or neither?

That would be TCP.

At 2/24/14 04:15 PM, MSGhero wrote: What's the preferred way of doing multiplayer in general?

I wouldn't say there's any preferred way of implementing mutliplayer in general; all depends on what it is you're doing. If you're making a real-time multiplayer game, such as pretty much any MMO, or shooters like Team Fortress 2, then you'll want to use UDP. If it's something that is turn-based, like a game of chess, or a chat system, you would want to use TCP (especially so if you're making a chat application).

Basically if you need to guarantee that your data will arrive, like you would with chess or chatting, you want TCP. If you don't need a guarantee of the data's arrival, and just want to send/receive the most up-to-date information, such as in MMOs, or VoIP programs, you want UDP.

Response to The Flash 'Reg' Lounge 2014-02-24 18:03:06


Response to The Flash 'Reg' Lounge 2014-02-24 19:20:58


Thanks for the docs and help Diki, it's a drag that FP doesn't support UDP but I can do without it I guess.

Second day of uni and we're going to be getting into networking in a couple of hours. Had to make a Cisco student account and read through a whole load of crap I think has nothing to do with the subject.

The Flash 'Reg' Lounge

Response to The Flash 'Reg' Lounge 2014-02-24 20:33:34


At 2/24/14 07:20 PM, slugrail wrote: Second day of uni and we're going to be getting into networking in a couple of hours. Had to make a Cisco student account and read through a whole load of crap I think has nothing to do with the subject.

We had to install ubuntu for some reason. The terminal terrifies me. No idea why we have to use it right now, eventually we program GBA games in C, but that's not for a while.

Response to The Flash 'Reg' Lounge 2014-02-24 21:13:18


At 2/24/14 08:33 PM, MSGhero wrote: We had to install ubuntu for some reason. The terminal terrifies me.

I miss terminal every time I use command prompt, which is a useless pile of crap in comparison. PowerShell is certainly a lot better than command prompt, but it's still a poor man's terminal.

Response to The Flash 'Reg' Lounge 2014-02-24 21:21:56


At 2/24/14 09:13 PM, Diki wrote: I miss terminal every time I use command prompt, which is a useless pile of crap in comparison. PowerShell is certainly a lot better than command prompt, but it's still a poor man's terminal.

all of my this.

also, this is a thing. It's a thing that seems to have blown my mind. Excuse me while I pick up pieces of my brain again.


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature

Response to The Flash 'Reg' Lounge 2014-02-24 21:22:10


At 2/24/14 09:13 PM, Diki wrote: I miss terminal every time I use command prompt, which is a useless pile of crap in comparison. PowerShell is certainly a lot better than command prompt, but it's still a poor man's terminal.

Updating haxe libs, attempting to rename files and failing, and javac/java-ing during the first couple weeks of java class before they let us use editors. Never touched it otherwise.