The Illusive Man Wrote:If I may, I'll be voice for newbie flash animators/programers and ask the question: What commands would serve as the most effective replacements for gotoAndPlay loops?
function SetArmour(s : string)
{
switch s
case "armour1": armour.gotoAndStop(1); break;
case "armour2": armour.gotoAndStop(2); break;
case "armour3": armour.gotoAndStop(3); break;
}
OwnerOfSuccuby Wrote: but i really do not understand what is it for ? :
IrrelevantComment Wrote:The Illusive Man Wrote:If I may, I'll be voice for newbie flash animators/programers and ask the question: What commands would serve as the most effective replacements for gotoAndPlay loops?
add/removeEventListener can be used, depending on the situation.
In this situation however, there were three armour settings, and 2 frames for each. The game looped over a set of two frames and on the second frame checked which armour was being worn, and then started a loop of the two frames containing that armour (if that makes sense).
My solution was to put each armour on a seperate frame, and then add a function something like this:
- Code: Select All Code
function SetArmour(s : string)
{
switch s
case "armour1": armour.gotoAndStop(1); break;
case "armour2": armour.gotoAndStop(2); break;
case "armour3": armour.gotoAndStop(3); break;
}
Basically in many cases you can replace small loops (where there is no animation) with a function that sets the frame only when necessary.OwnerOfSuccuby Wrote: but i really do not understand what is it for ? :
It solves a problem with Flash's garbage collection. Basically, when you create objects in Flash, they take up memory even when they are removed from stage, so every time you leave the screen in LoK, another huge chunk of data is created. Normally Flash would remove the old data which is not being used, but as I discovered, it will not remove it if small parts of the data chunk are still running animations.
IrrelevantComment Wrote:When developing locally in AS3, LoK lags like hell and it took me a while to work out why. Turns out that repeated calls to gotoAndPlay() can cause a huge memory leak if the object is running code in the nested frames. For example, I called gotoAndStop() about 50 times on a Krytal template and my frame rate halved. I then went back and changed it so that the armour and cum symbols were not looping and repeated the experiment: no frame rate loss. So basically if you have a memory leak you cant account for, remove code from symbols that are nested deeply as they stop the object from being garbage collected.
Users browsing this forum: No registered users