Recent posts by NineFiveThree on Kongregate

Flag Post

Topic: Game Programming / Image stack

Well, as I said, you should not add it to the stage. Try to understand that the stage property is not “the stage” you have in Flash where you can draw stuff. These are two different things. Add it, just don’t add it to stage.

I didn’t understand anything else you tried to say.
Could you please try to provide a description that’s a little more clear?
Just describe in plain english what you want to do without trying to use programming terminology.

If it’s easier, post a screen shot or sketch.

 
Flag Post

Topic: Game Programming / Image stack

First of all, adding things to the stage directly is not recommended, just get rid of “stage.” so it’s attached to the main time line.

Secondly, you should always be able to click on a textbox, the question is what you expect to happen then. Do you want to make the text editable?
Post your entire code and further explanation.

 
Flag Post

Topic: Game Programming / as3 what is the most efficient way to use enterframes

Originally posted by player_03:
Originally posted by NineFiveThree:

But sure enough your logic goes haywire if that “deal one damage to the player every frame” object persist in memory and keeps on doing its thing.

This won’t happen with enter frame events (assuming you remove the object from the stage), but it could certainly happen with timers. Yet another reason to use ENTER_FRAME.

In this example, the Event keeps firing (at least for me).

package 
{
    import flash.display.Sprite;
    
    import flash.events.Event;
    
    public class FlashTest extends Sprite 
    {
        private var _count:uint = 0;
        
        public function FlashTest() 
        {
            var s:Sprite = new Sprite();
            
            s.addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true);  
            
            s = null;          
            
        }
        
        private function onEnterFrame (e:Event):void
        {
            trace(_count++);
        }

    }
}

The variable is local, but I set it to null anyway.

 
Flag Post

Topic: Game Programming / as3 what is the most efficient way to use enterframes

Originally posted by theruss16:

always remember to remove them with removeEventListener once you don’t need them (you can also use weak references by passing true as the last parameter (addEventListener(event, listener, false, 0, true);) and then the event listener should be garbage collected along with the object, but I have read that they aren’t very reliable so I’d rather be safe and remove the listeners with removeEventListener)
//

Well, there’s no such thing as an event listener being collected.
This is mixing two things up in a way that it sounds confusing.
Let’s have a look:

Adding a listener to an EventDispatcher means nothing else but adding a reference to a function to that dispatcher.
“Hey you, when that event happens, call that function”

Then you add the garbage collector to the whole thing.
This is a process that wipes all objects that are not referenced and aren’t referencing anything from memory. (that’s super simplified)
“If you don’t have any connections to it and it has no connections to you, consider it dead”

With that in mind, we can take a look at that first statement again:
Adding a listener to a dispatcher means adding a reference (to a function).
That’s why you should remove listeners from unwanted objects, because only objects without references can be collected.

So far so good.

But how is adding a weak listener different?
After all, this would add a weak reference that’s not counted as a “strong” reference.
Therefore, the object should still be collected even though this reference still exists, right?

Yes. That’s all correct.
But guess what?
Nothing guaranties it actually happens. Just because some object could possibly be collected doesn’t mean the collector actually runs.
Collecting garbage is serious work and you don’t want to run after every small piece of junk.
That’s why the garbage collector runs at some arbitrary point that you cannot determine.
After all that’s the beauty of managed memory. (pun intended)

So if you null the last reference to an object with a weak referenced ENTER_FRAME listener added to it, you have no guarantee when this function you added as a listener will be called for the last time.
Maybe the flash runtime that executes your application can never be bothered to collect that one object, because it wouldn’t make much sense from a memory management / performance point of view.

But sure enough your logic goes haywire if that “deal one damage to the player every frame” object persist in memory and keeps on doing its thing.

 
Flag Post

Topic: Game Programming / Array elements

Originally posted by AshAbeAdd:

Preferably in the prototypes?

It’s not recommended to work with prototypes.

I’m not aware of a way to truly limit the size of an array in C.
Sure enough you set an amount of elements, but nothing prevents you from crossing that line. You’d have to write a function that does this.

In As3, Arrays do not have a set size and grow as you add or remove elements.
Vectors can be set to have a fixed size.

I’d just write a function that keeps the index within your desired boundaries.

 
Flag Post

Topic: Game Programming / String conversion

Post your code. You are probably doing something else wrong. Referencing the array in a local variable for example.

 
Flag Post

Topic: Game Programming / Revolving Circles'

Originally posted by zoorroo4:
I wish i had some good idea for how to use this in a game.

In terms of games, gravitee wars comes to my mind.
I would not force it into a game if you cannot think of any. It’s really nice as an interactive piece.

If it’s interactive, you can play with it. If you can play with it, it’s some kind of game, right? ;)

 
Flag Post

Topic: Game Programming / Revolving Circles'

Congratulations on achieving your goal.

As far as feedback goes: this is just a rotation nested into itself, nothing too new or interesting.
But sure enough, that doesn’t mean it’s not interesting. I’m sure people will find a tutorial helpful if it’s done well.

If you are afraid that the simple illustration of geometric ideas scares people of, you can extend the whole thing.
This could end up being a little solar system for example, with trails of the planets, etc.

 
Flag Post

Topic: Game Programming / AS3: what containers are there

Vector is the only data structure that let’s you specify the stored type.
An Array is – as you found out – a list of anything.

If you want to associate String keys to any value, a generic object will do.
To use any kind of key similar to a Hashmap, Dictionary is the way to go.

There’s nothing as sophisticated as the STL/Collections built into the language.

 
Flag Post

Topic: Game Programming / Wait for URLRequest to Finish

As javascript, C#, java, Qt and probably many more also call it an “event”, I don’t think it’s that uncommcon for Actionscript to do the same.

 
Flag Post

Topic: Game Programming / Learning Flash

Eclipse and intellij IDEA run fine on linux (they are java based)

 
Flag Post

Topic: Game Programming / Lag test

Originally posted by PanisRahl:

interesting, but would i still be able to interact with each ‘blitted’ tile as an independent object? In other words, can my copied tiles still be independently interacted with, each holding there own unique variables extended from a base tile?

You can still create objects for each tile.
You just don’t want to have an individual DisplayObject for each one.

 
Flag Post

Topic: Game Programming / as3: Changing rotationpoint

What is the desired behaviour?

If you don’t want the object to move, why do you change its position then?

 
Flag Post

Topic: Game Programming / Lag test

Again, using an object pool is not going to get rid of every lag.

Originally posted by PanisRahl:

I know having around 1000 objects held in an array is not very good. But i assume its better than constantly having to use the New function 192 times then the delete function 192 times each time u switch areas

Assumptions are a good start, they stem from experience and often lead in a right direction.
But optimisation without measurement is pointless.

Use a profiler to check what the bottleneck actually is instead of applying random optimization techniques you heard are good to have.

When it comes to display objects, MovieClips could be considered worst practice.
They bring along quite a bit of overhead because of the time line they have.
Time lines are great for animation, but guess what? You don’t have any animation in your tiles.

Blitting refers to displaying a single BitmapData object that you draw() or better copyPixel() your content into.
Take a look at this article explaining it

Here’s another article with some tips on optimization

“somebody told you it’s faster that way” should not be the reason that you apply a certain technique, but the fact that you significantly improve performance.

 
Flag Post

Topic: Game Programming / Lag test

You mention that you use an object pool as if that would be the general solution to get rid of lag.
It’s not. It can help reduce lag when a lot of objects are created.

I’m not sure what you mean by “holding 192 of each tile type”.
It sounds like you are creating that many displayobjects.
If that’s the case, it could be your bottleneck.

Use some profiler to check what is causing the problems.
If you have nothing else going on it’s likely that the many display objects are causing issues.
Blitting can help with that.

 
Flag Post

Topic: Game Programming / Getting back into Flash

The language did not change much.

I know the book is old, but it explains the whole thing very thoroughly.
It introduces the object oriented aspects first and then applies them to the existing API of As3.
Of course new versions of the Flash player extended this API, but the knowledge still applies.

If the reason you asked for books is that you have problems with the low quality of free online resources I have to agree that some are quite bad.
This series of articles is very good, check it out

If you go through the Adobe tutorial and the other one I linked to above, you should have some basic understanding of how the language works.
If you need/want the book is up to you. If books are your thing, download a sample chapter and if you want it, get a used one. I just checked ebay and you can find them for around 6$

You will not find a tutorial for everything. Get started with small projects.
You can always come to forums like this and ask for help. Great people here.

Also note that there are other books out there that teach As3 by applying it to game development for example.
I have no such book so I cannot recommend any, but a lot of people seemed to like them.
You did not mention any application that you want to create.
Have fun.

 
Flag Post

Topic: Game Programming / Getting back into Flash

If you want to work with a Flash IDE, this is probably the best introduction:
http://tv.adobe.com/show/actionscript-11-with-doug-winnie/

However, if you want to get into coding, I recommend some coding IDE.
FlashDevelop is a free and light editor
Unless you need specific features of newer versions of the Flash IDE, you’re probably fine with Cs4.

Here’s an article containing several possible workflows with FD and Flash combined

To learn the language from published material, “Essential ActionScript 3.0 by Colin Moock” is a good option. As the title suggests, it’s just the language, applying that knowledge is up to you.

 
Flag Post

Topic: Game Programming / Html5 sprite sheet problem.

What’s wrong with those sprites exactly? They seem to work fine.

Originally posted by Drakim:

HTML5 doesn’t have spritesheets natively

but with very little css (background-image, background-clip) it does.

kongregate uses this one for example:
http://cdn3.kongcdn.com/images/presentation/sitewide_sprite.png

 
Flag Post

Topic: Game Programming / Simple Array question AS3

enimy6, as a rule of thumb: do not use or write code that includes this

MovieClip(root)

thank you

 
Flag Post

Topic: Game Programming / Collision on a tile-based system

It was As2 that introduced the class statement.

Doesn’t tonypa’s tutorial include collision detection?

 
Flag Post

Topic: Game Programming / AS3 - Calling functions (from other classes)

Originally posted by enimy6:
I learned processing in school and I remember that calling a class like that would allow you to just.. call any function in that class because of that.

Here’s a link to processing code that states otherwise: (I don’t know anything about processing.)

http://www.processing.org/examples/objects.html
I have the feeling you are confusing objects and classes here.

If you want to interact with an object, you need an object.
A variable is a variable and not an object.

Originally posted by enimy6:

I am SUSPECTING, that I’m supposed to add ‘attack = new Attack’ or something, but that goes against what I know because, I’ve already added the attack thing to the stage, so why would I want to create another one? That would just take up more space and everything.. Why can’t I just link to it and be like ‘hey, this thing I made.. everything I’m gonna say now is about that, okay?’

You should have mentioned that earlier.

This is one of those points which can be confusing when working with the time line and Adobe Flash.
generally speaking: Instance names become properties of the class of the container they are on automatically.

So if you have an mc named “banana” on the stage, your document class will have a property (btw, property == variable in a class) “banana”.
That’s why you don’t have to declare the variable again. This automation can be turned off in the actionscript settings.
see this link, (Set the source path for ActionScript 3.0) point 5
You either deactivate that functionality and proceed with your code or you get rid of the variable declaration and make sure the auto-declaration is turned on.

If you just want to learn As3, you could try a pure coding IDE like FlashDevelop. It’s free.
It’s the easiest way to learn coding without the timeline, because there is no time line, no visual drawing tools, only code.

I suggest doing that, but it takes a tiny little work to get all the graphical assets in, because you do not create them in the IDE.

If you want to keep working with the Adobe Flash IDE, check out this video series from Adobe, explaining it
(make sure you start with episode 1 at the bottom of the page)

 
Flag Post

Topic: Game Programming / AS3 - Calling functions (from other classes)

Originally posted by enimy6:

I suspect it’s because they cant access the instances of eachother or something? gosh

More or less, yes. It tells you that those instances or objects don’t exist. Or, more precisely, the variables do not point to any objects.

Suspicion is a starting point.
Follow step 2 and 3 in the link given earlier on how to resolve the error to find out what is null.

 
Flag Post

Topic: Game Programming / AS3 - Calling functions (from other classes)

Originally posted by enimy6:

EDIT: @NineFiveThree: Yeah I know I’m kind of messing things up right now, but that’s nothing a little organizing can’t fix.. I don’t want to organize my names when I can’t even get my code working! when I do I will straighten it out.

Fixing the name when you are using it all around can be a tedious task.
It doesn’t really take longer to give proper names right away.

 
Flag Post

Topic: Game Programming / AS3 - Calling functions (from other classes)

Instead of setting the keyCode in your Player class to 0, use if & else, instead of just several if’s.

Stick to the conventions, don’t put your class name in all caps.
“Level” instead of “LEVELS

This code:
Player.levelRight
Does not access the object, but the class.
Instead of the class name, you should use the variable name.

 
Flag Post

Topic: Game Programming / AS3 - Calling functions (from other classes)

Originally posted by enimy6:

because if I do I get an error, if I remove stage; I get an error;

If you have an error, try to understand it. It tells you what you are doing wrong.
Sometimes they are hard to understand. But that’s ok, you can ask what it it means. But you should post it.

If it is the 1009, read what player said, and/or:
here is an explanation of the error and how to solve it

You could add the listener in your document class without all that and it should work.
You should still use the described method if you have to access the stage.

Speaking of the document class. Are you sure the player should handle the input directly?