00:00
00:00
Newgrounds Background Image Theme

Chan99 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

2,882,939 Views | 60,179 Replies
New Topic Respond to this Topic

Response to The Flash 'Reg' Lounge 2014-01-22 23:39:18


At 1/22/14 11:04 PM, MSGhero wrote: Took me about 30 tries for Math.random() to give me something less than .125 jeez.
private function awkwardFunctionName(lower:Number, upper:Number):Number {
 return Math.random() * (upper - lower) + lower;
}

trace(awkwardFunctionName(0, 0.125));

o.o


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-01-23 00:38:42


At 1/22/14 11:39 PM, egg82 wrote: o.o

to be fair, I'm not sure that would actually work with specific numbers and such (referring to negative values in different places) - but it was a quick thing so meh.
Speaking of things that may or may not actually work, I also quickly typed out a mod system for AS3 using Workers. It's very much untested (and hell, I'm not even sure it's a good idea) but I intend to use this in a fun little project so we'll see how it goes.

http://www.newgrounds.com/dump/item/b9b606d55c5415824d9609e0e2f5869a
^ download link
(requires AS3 Signals library because I was too lazy to use events)

-Basic implementation-
Main file:

public class SomeClass {
 private var _mod:Mod = new Mod(new File(File.applicationDirectory.nativePath + File.seperator + "myMod.swf"));
 
 public function SomeClass() {
  _mod.ON_COMPLETE.add(onComplete);
  _mod.ON_CHANNEL_MESSAGE.add(onChannelMessage);
 }
 
 private function onComplete(mod:Mod):void {
  mod.addChannel("testChannel");
  mod.load();
  mod.sendChannel("testChannel", {my:"data", more:"datas"});
 }
 private function onChannelMessage(channelName:String, data:*):void {
  trace("data: " + JSON.stringify(data));
 }
}

Mod file:

public class Main extends BaseMod {
 public function Main():void {
  ON_CHANNEL_MESSAGE.add(onChannelMessage);
  addChannel("testChannel");
 }
 
 private function onChannelMessage(channelName:String, data:*):void {
  trace("omnomnom, data: " + JSON.stringify(data));
  sendChannel(channelName, ["an", "array", "because", "why", "not", "?"]);
 }
}

this is all in theory, though, since it's largely untested. It SHOULD work in practice >.>


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-01-23 07:29:48


At 1/22/14 11:39 PM, egg82 wrote: o.o

int(Math.random() • 8) == 0 is what I was looking for. As3's random seems to randomly have random behavior, like randomly not picking from a random range of numbers for some random reason.

Response to The Flash 'Reg' Lounge 2014-01-23 08:23:32


Bringing another topic into place, I saw that today. It's true. And because some people may not know, I know it's true because I'm Egyptian :c

The Flash 'Reg' Lounge


Nav.. I'm the Nav!

Response to The Flash 'Reg' Lounge 2014-01-23 10:44:57


At 1/22/14 12:05 PM, Rustygames wrote: Sorry, that's actually my wife. She is petite, but I assure you, not 14 years old :P

No trophy wife in my photo but this is my work station.

The Flash 'Reg' Lounge


None

BBS Signature

Response to The Flash 'Reg' Lounge 2014-01-23 11:40:22


At 1/23/14 10:44 AM, Luis wrote:
At 1/22/14 12:05 PM, Rustygames wrote: Sorry, that's actually my wife. She is petite, but I assure you, not 14 years old :P
No trophy wife in my photo but this is my work station.

1) There's that mouse. It's that mouse, right? Why is the rug under it so huge?
2) Low ceiling. You surely moved into a smaller building.
3) You seem to be cutting up Newgrounds interface into some sort of grid.
4) I can't see what's on the papers on the wall. Some pictures (*interest*).

Response to The Flash 'Reg' Lounge 2014-01-23 11:50:05


At 1/23/14 11:40 AM, kkots wrote: 1) There's that mouse. It's that mouse, right? Why is the rug under it so huge?

It is that mouse. I still draw with a mouse so i need a big mousepad.


None

BBS Signature

Response to The Flash 'Reg' Lounge 2014-01-23 14:50:25


The one relaxing thing about RPGs like mine:

The Flash 'Reg' Lounge

Response to The Flash 'Reg' Lounge 2014-01-23 15:16:34


At 1/22/14 04:33 PM, Diki wrote:
At 1/22/14 12:05 PM, Rustygames wrote: Sorry, that's actually my wife. She is petite, but I assure you, not 14 years old :P
Damn, feed that woman some food. She looks like I could pick her up and shot put her. :)

Believe me she'd be extremely flattered to hear that! I think the photo is stitched weirdly (one of those panorama things you can do on your phone) and at a weird angle. She weighs a healthy amount. She's not fat... Oh god I'm just digging a hole here

At 1/22/14 12:05 PM, Rustygames wrote: Also I should have bothered to cut that out, I'm sure she won't like me putting that picture up
I can delete it if you want to re-post it.

Nah it's okay, the damage is done :P

At 1/23/14 10:44 AM, Luis wrote:
At 1/22/14 12:05 PM, Rustygames wrote: Sorry, that's actually my wife. She is petite, but I assure you, not 14 years old :P
No trophy wife in my photo but this is my work station.

lol trophy wife. I'm her throphy husband more like ;)

Is this your work desk though? I thought this was a home battle stations type dealeo?


- Matt, Rustyarcade.com

Response to The Flash 'Reg' Lounge 2014-01-23 16:36:38


At 1/23/14 03:16 PM, Rustygames wrote: Is this your work desk though? I thought this was a home battle stations type dealeo?

Oh. I dont work at home at all. I just check my tablet to answer e-mails and keep tabs. I've found I'm happier not taking my work home with me. You can only take so much newgrounds before you start going nuts.


None

BBS Signature

Response to The Flash 'Reg' Lounge 2014-01-23 16:56:22


At 1/23/14 04:36 PM, Luis wrote: Oh. I dont work at home at all. I just check my tablet to answer e-mails and keep tabs. I've found I'm happier not taking my work home with me. You can only take so much newgrounds before you start going nuts.

20 mins of general forum for me.

Response to The Flash 'Reg' Lounge 2014-01-23 17:07:07


At 1/23/14 07:29 AM, MSGhero wrote: int(Math.random() • 8) == 0 is what I was looking for. As3's random seems to randomly have random behavior, like randomly not picking from a random range of numbers for some random reason.

Well it is a psuedo-random number generator, so if you run it long enough you will see patterns. Computers are just incapable of generating true random numbers (it wouldn't make any sense for them to be able to).

At 1/23/14 11:50 AM, Luis wrote: It is that mouse. I still draw with a mouse so i need a big mousepad.

'Sup fellow huge mousepad user. I'm no artist, but I love using a low sensitivity on my mouse, so I have a big-ass mousepad (eleven inches from corner to corner).

Response to The Flash 'Reg' Lounge 2014-01-23 18:04:58


At 1/23/14 05:07 PM, Diki wrote: Well it is a psuedo-random number generator, so if you run it long enough you will see patterns. Computers are just incapable of generating true random numbers (it wouldn't make any sense for them to be able to).

I'm gonna add a less-random number generator to avoid some of the bs I saw. It's for a medal, getting all 8 things to show, so seeing the same one 3 times in a row is demotivating.

'Sup fellow huge mousepad user. I'm no artist, but I love using a low sensitivity on my mouse, so I have a big-ass mousepad (eleven inches from corner to corner).

My friend plays fps, mainly tribes when it was more popular, so he has a huge one too. I don't have room for one like that.

Response to The Flash 'Reg' Lounge 2014-01-23 18:53:38


At 1/23/14 06:04 PM, MSGhero wrote: I'm gonna add a less-random number generator to avoid some of the bs I saw. It's for a medal, getting all 8 things to show, so seeing the same one 3 times in a row is demotivating.

You mean you're going to roll out your own psuedo-random number generator? If so I wouldn't recommend that. It would be very easy to do incorrectly and make it generate numbers that are even less random.

Response to The Flash 'Reg' Lounge 2014-01-23 19:04:57


At 1/23/14 06:53 PM, Diki wrote: You mean you're going to roll out your own psuedo-random number generator? If so I wouldn't recommend that. It would be very easy to do incorrectly and make it generate numbers that are even less random.

I want numbers to be less random in this specific case. Might just be something simple like get a new number if it's the same as the last number or have more bias for the numbers that haven't been chosen yet.

I found a prng by polygonal that seems faster than normal random.

not like it matters for the rpg but still

Response to The Flash 'Reg' Lounge 2014-01-23 19:25:36


At 1/23/14 07:04 PM, MSGhero wrote: I found a prng by polygonal that seems faster than normal random.

Pretty much anything you find is a PRNG.
You can have a CSPRNG partially seeded by a TRNG, which is quite possibly the most secure you'll get, but slower than all hell.
Then, if you want a really fast "PRNG" you can just do some basic bitwise operations with a given seed.

Take this if you'd like. It's not perfect but it seems to work at any rate.


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-01-23 21:35:51


At 1/23/14 07:04 PM, MSGhero wrote: I want numbers to be less random in this specific case. Might just be something simple like get a new number if it's the same as the last number or have more bias for the numbers that haven't been chosen yet.

This may be what you were going for with your second idea, but it may be worth doing something similar to what Warcraft III called Pseudo-random distribution, where you decrease the range of numbers that a "thing" corresponds to after the RNG chooses it, and increase the range of a thing after it has gone several attempts without being chosen. Seems like a lot less hassle than making a PRNG.

Also, if it makes you feel less worried about the generator getting "stuck" or patterns forming, swap the ranges that things correspond to. The thing in the 0.5-0.625 range keeps getting chosen? Give it the range 0.0-0.125 instead, and assign whatever was in that range to the 0.5-0.625 range. That probably won't save some unlucky souls from being screwed over regardless, so use it with another system if you use it at all.


Doomsday-One, working on stuff better than preloaders. Marginally.

Response to The Flash 'Reg' Lounge 2014-01-23 21:40:25


At 1/23/14 09:35 PM, Doomsday-One wrote: This may be what you were going for with your second idea, but it may be worth doing something similar to what Warcraft III called Pseudo-random distribution, where you decrease the range of numbers that a "thing" corresponds to after the RNG chooses it, and increase the range of a thing after it has gone several attempts without being chosen. Seems like a lot less hassle than making a PRNG.

Oh yeah...we even talked about that a while ago. Good ol wc3 and dota save the day. Thanks, I'll probably do that and egg's fast prng (which I think is the same as what I linked).

Response to The Flash 'Reg' Lounge 2014-01-23 22:06:11


At 1/23/14 09:40 PM, MSGhero wrote: which I think is the same as what I linked

It's not, but close enough.
The visualiztion reminds me of poor 'ol ECB Tux, though :(

Remember, kids, block-cipher in ECB mode is bad for you

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-01-23 23:24:53


(_from[name] as MessageChannel).addEventListener(Event.CHANNEL_MESSAGE, onChannelMessage);

do {
	trace("hi");
} while (!(_from[name] as MessageChannel).messageAvailable);

trace("Hello!");

private function onChannelMessage(e:Event):void {
	trace("Hello again!");
}

No other code is executed.

output:

hi
hi
hi
hi
hi
hi
hi
hi
hi
Hello!

This is driving me absolutely insane.


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-01-24 13:31:39


Aha! Finally got it all working. Enjoy a mod system if you'd like.

Host.zip contains the classes the host (whatever's loading the mods) uses.
Mod.zip contains the classes the mod uses to contact the host.

Again, requires AS3 Signals library because I'm too lazy to make new classes. Or you could make events if you want portability.

And of course an example usage below.

Host:

public class Main extends Sprite {
 public function Main():void {
  ModLoader.ON_READY.add(onReady);
  
  ModLoader.loadMod(File.applicationDirectory.nativePath + File.separator + "mods" + File.separator + "myMod1.swf");
  ModLoader.loadMod(File.applicationDirectory.nativePath + File.separator + "mods" + File.separator + "myMod2.mod");
  ModLoader.loadMod(File.applicationDirectory.nativePath + File.separator + "mods" + File.separator + "myMod3.whateverFileExtensionYouWant");
 }
 
 private function onReady():void {
  ModLoader.onReady.remove(onReady);
  
  ModLoader.ON_MESSAGE.add(onMessage);
  
  ModLoader.addChannel("myChannel");
  ModLoader.addChannel("myChannel2");
  
  ModLoader.startMods();
  
  for (var i:uint = 0; i < ModLoader.numMods; i++) {
   ModLoader.send(i, "myChannel", ["Here", "Have", "An", "Array", "Because", "Why", "Not?"]);
  }
 }
 
 private function onMessage(modNum:uint, data:ModData):void {
  trace("Message from mod #" + modNum + " on channel " + data.channelName);
  trace("Data: " + JSON.stringify(data.data));
 }
}

Mod:

public class Main extends BaseMod {
 public function Main():void {
  if (Worker.current.isPrimorial) {
   stage.nativeWindow.close();
  }
  
  ON_CHANNEL_MESSAGE.add(onMessage);
  
  addChannel("myChannel");
  addChannel("myChannel2");
 }
 
 private function onMessage(data:ModData):void {
  trace("Message from host on channel " + data.channelName);
  trace("Data: " + JSON.stringify(data.data));
  
  sendChannel(data.channelName, {stuff:"You can out anything you want", stuff2:"In the data argument", stuff3:"It doesn't matter"});
  sendChannel("myChannel2", {data:["Ohai", "How", "Are", "You?"]});
 }
}

Both of these examples are assuming they're made in AIR, so if they aren't stuff like stage.nativeWindow won't work and all that happy fun stuff. Also I don't think traces work in a mod when loaded from the host, though I might be wrong.

When sending ByteArrays, make sure the shareable property on them is true.
mods are given the same permissions and folders/etc as the host, so think of the mod as being the host when doing stuff like File.applicationDirectory and such.

In some versions of FlashDevelop Workers are a bit broken.

Other than that, yeah, it seems to work quite well which is a big surprise :D
(If you do decide to try it out, please tell me if there's bugs D:)


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-01-24 14:05:35


Why is there a ModLoader.ON_READY and ModLoader.OnReady? They look like they're referencing the same thing.

Response to The Flash 'Reg' Lounge 2014-01-24 14:20:41


At 1/24/14 02:05 PM, Diki wrote: Why is there a ModLoader.ON_READY and ModLoader.OnReady? They look like they're referencing the same thing.

That was my mistake, it's supposed to be ModLoader.ON_READY.remove(onReady);

I also noticed I left a ton of debug stuff in the BaseMod.as in the form on FileStream.open in the constructor, I recommend removing that >.>
What would happen if I replaced the zip file in the dumping grounds? Would it still be the same download link?


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-01-24 14:22:17


At 1/24/14 02:20 PM, egg82 wrote: What would happen if I replaced the zip file in the dumping grounds? Would it still be the same download link?

If you click edit and upload something new, yes. If you just upload a new file, no.

Response to The Flash 'Reg' Lounge 2014-01-24 14:30:20


At 1/24/14 02:22 PM, MSGhero wrote: If you click edit and upload something new, yes. If you just upload a new file, no.

Quick reply, thanks :P
In that case, It's sneakily fixed.

If you're curious, the reason I posted this whole thing is because the ability to mod is becoming a fairly big thing in games, and I haven't been able to find anything like what I developed for AS3 yet so I made it myself.
My hope is that someone will take my idea and fix anything that's broken and make it usable in a release environment because right now it's got a lot of caveats (like another, for example, is that it assumes mods are on the local File System when you can very easily change it to use online sources as well as local ones)


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-01-24 23:32:15


My home command center:

The Flash 'Reg' Lounge

Response to The Flash 'Reg' Lounge 2014-01-24 23:37:13


At 1/24/14 11:32 PM, BoMToons wrote: My home command center:

Also, here's a virtual tour I made when I first decorated!

http://bomtoons.com/nickofficetour.html

Response to The Flash 'Reg' Lounge 2014-01-25 00:05:52


At 1/24/14 11:32 PM, BoMToons wrote: My home command center:

Is that a little desktop microphone I see on the desk?


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-01-25 02:57:49


At 1/22/14 11:23 AM, egg82 wrote: What's the recommended way, then? I couldn't think of anything better than "add your own header"

No, no I'm saying nobody should be using serialization (i.e., writeObject) because I thought you were going the "hackish" way

If I needed to do that, I would probably combine packets and have the server split them where the first one's supposed to end.

Wait you're not doing that already? Also you didn't understand what I was referring to, this will help out (someday?) but tricks like these probably aren't used since dialup is dead (still helpful where bandwidth needs to be maximised and used wisely!)

rather than:

writeByte(isTrue ? 1 : 0) 
writeByte(isTrue2 ? 1 : 0)

2 bytes

you squish as much flags into one byte:

flag = 0
flag |= isTrue ? 1 : 0
flag |= isTrue2 ? 2 : 0
...

1 byte up to 8 flags

..and then read it off as

flag = readByte();
isTrue = (flag & 1 != 0);
isTrue2 = (flag & 2 != 0);

Also regarding squishing all packets into one buffer

This is how a typical server/client SHOULD process packets (in pseudo code), anything other than this (this does not apply to MINA, Java's NIO, XSocket or the likes) is what I would call shortcuts:

while bufferLength - bufferPointer > 0
  read packet
  process packet
clear buffer

If you're constantly flushing out packets one by one in some real time application then you're doing something wrong, it would only make sense if the application itself isn't real time or you're using an async/non blocking socket (even then you should be buffering all incoming packets if it's a real time application).

Response to The Flash 'Reg' Lounge 2014-01-25 10:50:38


At 1/25/14 12:05 AM, egg82 wrote:
At 1/24/14 11:32 PM, BoMToons wrote: My home command center:
Is that a little desktop microphone I see on the desk?

Yes it is! I even have a spitguard in the drawer next to it!