00:00
00:00
Newgrounds Background Image Theme
Upgrade Your Account!

HO HO HOPE you become a Newgrounds Supporter this year!

We're working hard to give you the best site possible, but we have bills to pay and community support is vital to keep things going and growing. Thank you for considering!

Become a Supporter so NG can see another Christmas!

The Flash 'Reg' Lounge

3,084,232 Views | 60,186 Replies
New Topic Respond to this Topic

Response to The Flash 'Reg' Lounge 2014-01-14 13:51:43


Decided to create a scripting language a couple of hours ago (its 6 am right now). Really great progress so far, it will be running on a multithreaded engine once I clean up the project and switch the base from FP to AIR.

I'll be using this in my game on both the server and client side to promote modding; custom maps, vehicles, weapons and game modes!

http://youtu.be/ArQA9lnk2UI

Response to The Flash 'Reg' Lounge 2014-01-14 14:27:17


At 1/14/14 01:51 PM, slugrail wrote: Decided to create a scripting language a couple of hours ago (its 6 am right now).

Programmers have inspiration too.

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


Wow, this lounge is still going?!! It used to be full of artists. Now it's all programmers. You guys are boring! ;-)

Response to The Flash 'Reg' Lounge 2014-01-14 14:51:59


At 1/14/14 01:51 PM, slugrail wrote: Decided to create a scripting language a couple of hours ago (its 6 am right now). Really great progress so far, it will be running on a multithreaded engine once I clean up the project and switch the base from FP to AIR.

You're nuts for trying to make your own language, doubly so for trying to do it in AS3/AIR.

I'll be using this in my game on both the server and client side to promote modding; custom maps, vehicles, weapons and game modes!

Triple nuts for trying to put into production.

I mean, I see the appeal of making your own language because why the hell not, but you can't seriously be thinking about using it for realzies? 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-14 15:04:42


At 1/14/14 02:50 PM, BoMToons wrote: Wow, this lounge is still going?!! It used to be full of artists. Now it's all programmers. You guys are boring! ;-)

The programming lounde is super dead, and all the recent posts are just me posting updates about my projects and coln asking questions about them.

So you guys are stuck with me. >:)

Response to The Flash 'Reg' Lounge 2014-01-14 15:13:35


At 1/14/14 02:23 PM, PSvils wrote:
At 1/14/14 01:51 PM, slugrail wrote: Decided to create a scripting language a couple of hours ago (its 6 am right now). Really great progress so far, it will be running on a multithreaded engine once I clean up the project and switch the base from FP to AIR.

I'll be using this in my game on both the server and client side to promote modding; custom maps, vehicles, weapons and game modes!

http://youtu.be/ArQA9lnk2UI
It doesn't seem to have for/while loops or if statements, or functions.

Why don't you just use hscript?
http://code.google.com/p/hscript/

Download a .swc for use with AS3:
https://plus.google.com/+AndreasR%C3%B8nning/posts/LEFUqnSoKxS

P.

I'm using an unordered bytestack and just seeking into different pointers in mem depending on the current branch of operation, I don't rely on the underlying OOP base of AS3 to handle objects or data types (apart from floating points and integers where it is obviously required) - there is too much overhead running a script engine within another runtime. If what you have posted does anything remotely similar and doesnt rely on the AS3 runtime to handle memory and objects then I'll consider using it. For now I want to keep brainstorming ways to structure some of the logic before I keep working on it so I don't end up wasting hours refactoring the entire thing. It's a good learning experience too.

Response to The Flash 'Reg' Lounge 2014-01-14 17:11:35


At 1/14/14 02:50 PM, BoMToons wrote: Wow, this lounge is still going?!! It used to be full of artists. Now it's all programmers. You guys are boring! ;-)

The topic changes drastically each new page or two.

Response to The Flash 'Reg' Lounge 2014-01-14 17:26:42


At 1/14/14 05:11 PM, MSGhero wrote: The topic changes drastically each new page or two.

New page needs a new topic:

Catapult v.s. Trebuchet: Which is Better? You Decide!

Response to The Flash 'Reg' Lounge 2014-01-14 17:54:54


At 1/14/14 05:11 PM, MSGhero wrote:
At 1/14/14 02:50 PM, BoMToons wrote: Wow, this lounge is still going?!! It used to be full of artists. Now it's all programmers. You guys are boring! ;-)
The topic changes drastically each new page or two.

Do you disagree that it's mostly coders now though?

Response to The Flash 'Reg' Lounge 2014-01-14 18:08:22


At 1/14/14 05:54 PM, BoMToons wrote: Do you disagree that it's mostly coders now though?

Us and luis. Anyone coming here would get put off by all the regex and C that's been in the past 2-3 pages, it's not usually like that.

Response to The Flash 'Reg' Lounge 2014-01-14 19:16:11


At 1/14/14 05:54 PM, BoMToons wrote: Do you disagree that it's mostly coders now though?

Pretty much everyone working in Flash knows how to code, at least to some degree.
Code talk just comes with the territory. I like being able to ask question when I'm absolutely stuck and google can't help (which doesn't happen very often)

for example: Why in the world is the downloader portion of this launcher not working?
So I have a downloader class/thingy which runs in a Worker and pipes back some information as to what's going on for debugging. When I hit run with FD in Release mode, it works absolutely flawlessly. However, when I package it all up into a bundle for redist, it gets stuck at specific points.

From the debug logs, I can see that two files are failing to hash. However, if it were that easy it wouldn't be a problem because I have an error handler for that which just skips the file. It seems like it's not erroring out when opening the files, but rather just... Not... Doing anything? Like, at all? I'll add another debug thing to see which files they are, but it's really strange that the progress shows "done" but two files are just completely missing from the supposed 26 that are supposed to be there.


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-14 23:41:20


I'm about to venture into a whole new world.

I've been preparing myself for this for the past 3 years.

I've largely glossed over this until now because my mind, body, and soul were not ready.

But it's time.

bmd.copyPixels(src, rect, pt, null, null, true);

no longer.

I'm gonna use the alphaBitmapData parameter of copyPixels.

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


At 1/14/14 11:41 PM, MSGhero wrote: I'm gonna use the alphaBitmapData parameter of copyPixels.

It's a trap.

Response to The Flash 'Reg' Lounge 2014-01-15 01:26:33


Seeing as this a new page I think it would be a great idea to change the subject to servers and multithreading issues.

If you've ever tried to work with NIO before, you'll realise how awesomely simplified my event based wrapper is and how much it takes care of the behind-the-scene stuff:

public void accept(SelectionKey key) throws Exception { if (key == null || Server.is("stopLogins")) { return; } if (server == null) { server = Server.getInstance();//Engine.getInstance().getThreadPool().select("server").syncWait(); } ServerSocketChannel ssc = getServerSocketChannel(); SocketChannel sc = ssc.accept(); String host = sc.socket().getInetAddress().getHostAddress(); if (connections.contains(host) && connections.countOf(host) > Server.MAX_CONNECTIONS_CLIENT) { sc.close(); return; } sc.configureBlocking(false); connections.addSocketInfo(sc); Player p = new Player(server.getComponentManager().getEntityManager().all(EntityManager.PLAYERS_TYPE).incAtomic(), sc); Server.log("Registered player at index of " + p.getIndex(),p.attached()); server.getComponentManager().getEntityManager().addEntityModel(p); if (isValid(host)) { Engine.getInstance().getControlPanel().appendConnection(host); } sc.register(getSelector(), sc.validOps(), p); //.queue(p); }

Couple this with the new multithreading APIs in jdk 7 and 8 and you've got yourself a beast of a server. if you could actually get a proper parallel code structure that 1) works independently from other tasks 2) isnt greedy and 3) can process other things while waiting for data to get synchronised (bonus: avoiding deadlocks with ~200 players)

if you want to know why you can't use those 4+ cores of your PC then remember how complex the multithreaded version of a program looks, chances are those 2 extra cores are being used for minor background things and not actual program logic. "Concurrency does not exist without atomicity" is my motto :P

also @egg82 use a shared bytearray instead, using messages means youre very limited and you're copying data back and forth in memory when you can easily point to the amended data in memory (I'm not sure if it's threadsafe but it should be when you consider how friendly the Flash/AIR APIs are)

Response to The Flash 'Reg' Lounge 2014-01-15 06:30:21


Daaaaamn you guys are kewl, writing some networking code.
And I'm programming interface. Buttons, sliders, animations, selections, etc.
On ActionScript 2.0. Because the artist (project leader) insists on using Flash 8, so I must program on AS2 so that he is able to open and edit graphics in the FLA. So far he hasn't made a slightest change to the project FLA. And convincing him to switch the project over to AS3, until I've wrote too much code, is going to be as ridiculously easy as asking him and mentioning that it is necessary to, for example, be able to export PNG images from Flash to user's machine.

Writing on AS2 in class files is pretty fun, sorting them in packages is thrilling to the bone.
It does report compile errors if I mistype things.
But yeah it's slow and can't create files on the user's machine. All it can is just upload a file to a server.

Response to The Flash 'Reg' Lounge 2014-01-15 17:37:05


At 1/15/14 06:30 AM, kkots wrote: On ActionScript 2.0. Because the artist (project leader) insists on using Flash 8, so I must program on AS2 so that he is able to open and edit graphics in the FLA. So far he hasn't made a slightest change to the project FLA.

You can import graphics in AS3 via an swf, you're aware of that 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-01-15 17:55:20


At 1/15/14 05:37 PM, egg82 wrote: You can import graphics in AS3 via an swf, you're aware of that right?

Hm. I'm going to try to make a test with that.
SWF would be generated in Flash 8, and downloaded in AS3 project and then I need to do some uncertain actions that are not yet known to me to access movie clips from the loaded SWF.

I cannot use FlashDevelop's embed tag for SWF, because an ActionScript 2.0 SWF has no classes for movie clip, movie clips are exported for linkages, and embedding them in an AS3 project is impossible.

Do I understand everything correctly?

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


Hell no, I've read a bit of info on loading AS2 SWFs in AS3 SWFs, and hell no, it is not trivial.
In my test I could not access any movie clips in loader.content.
It displays a picture and that's it.
I cannot load interface graphics in a single SWF.
I would have to load every symbol (or even animation frame) in a separate AS2 SWF, and operate the loader to position the picture as I want, and that's just not convenient.

I'd rather store all graphics in a Flash 8 FLA document, copy-paste them to Flash CS4 FLA document when I use them.
And when I make updates to graphics I'll need to make the updates in both FLAs.
And when I need the artist to interfere with graphical affairs of the FLAs I need to give him Flash 8 FLA, and then copy-paste his changes to Flash CS4 FLA.

Or I just need to somehow convince him to move over to AS3, get latest Flash and not torture Flash.

Response to The Flash 'Reg' Lounge 2014-01-15 18:18:10


At 1/15/14 06:15 PM, kkots wrote: In my test I could not access any movie clips in loader.content.

...what? When you embed a swf, you don't have to use a loader. It's embedded, just use it. The assets are inside.

Response to The Flash 'Reg' Lounge 2014-01-15 19:10:59


At 1/15/14 05:55 PM, kkots wrote: Hm. I'm going to try to make a test with that.
SWF would be generated in Flash 8, and downloaded in AS3 project and then I need to do some uncertain actions that are not yet known to me to access movie clips from the loaded SWF.

Never embedded an SWF before (always image assets) but after some google-fu here'a apparently what you need to do

Reg.as

[Embed(source="../res/assets.swf")] public static const ASSETS:Class;

Main.as

private var _assets:MovieClipLoaderAsset = new Reg.ASSETS() as MovieClipLoaderAsset; _assets.addEventListener(Event.COMPLETE, onAssetsLoaded); private fucntion onAssetsLoaded(e:Event):void { var loader:Loader = _assets.getChildAt(0) as Loader; var assetStage:DisplayObjectContainer = loader.content as DisplayObjectContainer; for (var i:uint = 0; i < assetStage.numChildren; i++) { addChild(assetStage.getChildAt(i)); } }

(messy code)

this is, of course, assuming the assets are on the stage and where they need to be. If not, they're in the library in which case you use the more "standard" way of embedding swf assets.

Reg.as

[Embed(source="../res/assets.swf", symbol="mySprite1")] public static const SPRITE1:Class;

Main.as

var sprite1:Sprite = new Reg.SPRITE1() as Sprite; addChild(aprite1);
I cannot use FlashDevelop's embed tag for SWF, because an ActionScript 2.0 SWF has no classes for movie clip, movie clips are exported for linkages, and embedding them in an AS3 project is impossible.

AS2 has all of the same DisplayObject classes as AS3.
Okay, most of. AS3 added some special ones in because fuck AS2. In any case, AS2 and AS3 both have MovieClips and Sprites and SimpleButtons and Bitmaps and...


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-15 20:57:47


At 1/15/14 08:48 PM, Innermike wrote: So is screenshot saturday/sunday still a thing then or what?

Yes. I haven't had anything worth screenshotting in a while, but if you do go ahead.

Response to The Flash 'Reg' Lounge 2014-01-15 21:14:56


At 1/15/14 08:48 PM, Innermike wrote: So is screenshot saturday/sunday still a thing then or what?

The launcher, it is done!
For now, until things get changed around and I have a new login/download server to play with.

The Flash 'Reg' Lounge


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-15 21:36:14


now, for a quick thing:
Be careful about how you have your loops placed when iterating through an array you remove items from!

Here's what I mean.
Say, for example, you have a list of files. You want to remove specific files from this list for whatever reason. The easiest way to accomplish this is to create another list of "blacklist" files to remove from the original list. This is where you need to be careful

Now, for an example direct from the Joe launcher.

the setup:

var blacklist:Vector.<String> = new Vector.<String>(); var dirLength:int = (File.applicationDirectory.nativePath + File.separator).length; blacklist.push("META-INF" + File.separator + "signatures.xml"); blacklist.push("META-INF" + File.separator + "AIR" + File.separator + "application.xml"); blacklist.push("META-INF" + File.separator + "AIR" + File.separator + "hash"); blacklist.push("ConcernedLauncher.exe"); blacklist.push("ConcernedLauncher.swf"); blacklist.push("exceptions.txt"); blacklist.push("hashes.txt"); blacklist.push("launcher.propertes"); blacklist.push("launcherErrors.txt"); blacklist.push("launcherInfo.txt"); blacklist.push("mimetype");

loop one:

for (var i:uint = 0; i < blacklist.length; i++) { for (var j:uint = 0; j < DirectoryScanner.files.length; j++) { if (blacklist[i] == DirectoryScanner.files[j].substring(dirLength)) { DirectoryScanner.files.splice(j, 1); break; } } }

loop two:

for (var i:uint = 0; i < DirectoryScanner.files.length; i++) { for (var j:uint = 0; j < blacklist.length; j++) { if (blacklist[j] == DirectoryScanner.files[i].substring(dirLength)) { DirectoryScanner.files.splice(i, 1); break; } } }

both of those should work the same, correct? Nope! Here's why.

Loops don't really "restart" very well. Say the length of DirectoryScanner.files is 10.
If there's a match at i=5, then element #5 will be removed from the array, and element #6 becomes element #5. The loop then goes on to element #6, skipping the previous element #6 which is now element #5. This can result in random elements being skipped.

Loop #1 avoids this by having the array that gets elements removed from it as the inner loop, effectively "restarting" the search after each match.

There's much more effective and efficient ways of searching an array than going through each element, but this method is common enough to actually make a post on it :P


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-15 22:20:56


At 1/15/14 10:08 PM, Innermike wrote: Don't know if I'm missing something but isn't this something you can solve by just going backwards?

Who goes backwards? O.o
But yes, that would solve it.

It's a pretty specific issue with a ton of ways to solve it, but I've needed to do something like this many times and I'm a normal human being and don't iterate through arrays backwards.


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-15 22:48:24


You could just decrement the index each time you remove an element:

var data = [1,2,3,4,5,6,7,8,9,10]; for (var i = 0; i < data.length; i++) { if (data[i]%2) { data.splice(i--, 1); } }

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


At 1/15/14 10:48 PM, Diki wrote: You could just decrement the index each time you remove an element:

the problem with that is I'm not that smart xD

actually, it might decrement before it removes. Might need to check that.

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-15 23:30:47


At 1/15/14 11:23 PM, egg82 wrote:
actually, it might decrement before it removes. Might need to check that.

You mean in my example? It doesn't because I used the postfix decrement operator.

Response to The Flash 'Reg' Lounge 2014-01-16 05:09:40


At 1/15/14 07:10 PM, egg82 wrote: Never embedded an SWF before (always image assets) but after some google-fu here'a apparently what you need to do

Main.as

private var _assets:MovieClipLoaderAsset = new Reg.ASSETS() as MovieClipLoaderAsset;

_assets.addEventListener(Event.COMPLETE, onAssetsLoaded);

OK. These lines are working.


private fucntion onAssetsLoaded(e:Event):void {
var loader:Loader = _assets.getChildAt(0) as Loader;

This line is working.
loader is a Loader, with content, yes.

var assetStage:DisplayObjectContainer = loader.content as DisplayObjectContainer;

This will set assetStage to null, because loader.content is a AVM1Movie, which extends DisplayObject and does not have children. All it does have useful is maybe root property, but that refers to itself!


for (var i:uint = 0; i < assetStage.numChildren; i++) {

Here it's an error referring to null, assetStage is null.

"standard" way of embedding swf assets.

Reg.as

[Embed(source="../res/assets.swf", symbol="mySprite1")] public static const SPRITE1:Class;

This works fine. Maybe I can actually use this method in production!
Thanks egg!
Problem solved.

Response to The Flash 'Reg' Lounge 2014-01-16 12:30:06


At 1/16/14 05:09 AM, kkots wrote: This will set assetStage to null, because loader.content is a AVM1Movie, which extends DisplayObject and does not have children. All it does have useful is maybe root property, but that refers to itself!

I probably read the example given incorrectly because again I've never imported SWF files, but I know DisplayObjects can (and in the case of artists, often do) have children. You're sure there's stuff on the stage?

Here's (an easier-to-understand copy of) the page (which I wish I had read before posting the first time) for the "objects on stage" thing for all those interested, I figure it'd probably come in handy at some point because trying to get that Sprite to sit exactly where you want it to in code is a pain in the ass.


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-16 13:00:16