PDA

View Full Version : [AS3] Static instances issues in tile-based game


julifos
02-16-2010, 09:04 AM
Hi all!

This is the stage: I have one hundred of tiles in the stage, instances of the same movie-clip named as "a1", "a2", "a3"...

Now, I set manually some of them to alpha = 0, which means that "tiles" are the walkable path the characters must follow.

Depending on various actions, some of the other tiles will change their alpha value dynamically and so on.

All works fine till now.

Then, when this "round" is finished, I go to a new map (nextFrame()). In this new frame, I have the same tiles, but the walkable path is different (movie-clips in alpha) in the IDE.

But, at run-time, seems that the movie-clips of the second frame inherit the properties (alpha value) of some of the previous dynamically changed tiles (in the previous frame).

I know I could rename the tiles to "b1", "b2"... Or hardcode the walkable path in some kind of Array and apply dynamically.

But I'd prefer to know WHY this happens and how can I prevent it... Why mcs with the same name in the next frame inherit dynamically changed properties in the previous one and how can I prevent this behaviour?

Thanks in advance for any hints!

ProNoob13
02-16-2010, 10:03 AM
Well, I might be a noob, but isn't it a solution to just reset all tiles to ".alpha=100" at the end of the round? It sounds logical to me that the Alpha-values of the tiles are still the same in the new frame.

henke37
02-16-2010, 02:02 PM
Instances are not recreated unless needed. Just store the map in an array instead.

julifos
02-17-2010, 07:50 AM
Well, I might be a noob, but isn't it a solution to just reset all tiles to ".alpha=100" at the end of the round? It sounds logical to me that the Alpha-values of the tiles are still the same in the new frame.

Nope, as I say, if I set alpha to 1.0, mcs will preserve this value 1.0 in the next frame, although in the Flash IDE they are 0.0...

Instances are not recreated unless needed. Just store the map in an array instead.

Yep, I'm sticking with that solution but I believe "unless needed" should include what you designed in the Flash IDE. I think it used to work so in AS2?

Thanks for your answers!