Copy link to clipboard
Copied
In the current project I am working now, using flash 3cs and 5.5 but intending to export as an air app, I have run with lots of problems, sometimes they appear both in flash and air, sometimes they appear just in air, with not much left to do as they are supposed to run with the same code, which I had to tweak and see if I could find or make a hack. Anyway, in case somebody else runs with similar problems:
Problem like an object defined in certain frame. The movie line moves to another frame, and then goes back. It turns out than when it turns to the original frame, the changes I may have made in a certain object are gone. The behavior is like if I move to another frame, the runtime executes a 'remove child' on the object that does not appear in the next frame, and generates a new object when it goes back to the first frame.
Solution: if a movieclip is gonna be in different frames, but not in others, instead of defining the object in some frames and not others, the movieclip appears in all frames, but is made invisible via script in the frame where it should not appear
Problem, related with previous one: a movie clip class that contains another movieclip inside, as part of its definition. Some movieclips are generated in runtime from that class, and the movie clips generated sometimes have the movieclip contained, some times not, depending on the mood of the runtime. It may generate 'references to null object' errors. I searched and it seems kinda common, but the posts and threads (not only here but in many forums) seem to be from around 2012 or so, so maybe this has been resolved in newer air versions.
Solution, a combination of previous solution plus the next one
the gotoandstop problem: at the execution beginning, some movie clips are created, but not used all the time. This is to prevent that while running it will be destroying and generating again the same movie clips; so they are created once and then recycled. When the movie clips are used, they can be scaled and transformed correctly, but they will not goto and stop at the desired frame. When asked, they will say they are in the requested frame, even though they are not. At first it seemed like the random behavior occurred when told to goto and stop at frame 1, so a possible solution was to shift every movie clip that needed to gotoandstop, leaving the first frame blank, and adding one to every gotoandstop sentence. It did not work.
Another apparent reason had to do with the fact that the behavior seemed to occur in movie clips generated at run time; a possible solution would be to have the most movie clips possible created in design time; in my case it was over 400 movie clips named by hand in design time. Nope, that did not work either.
Solution: what seems to be the most stable solution so far (as in, it seems to be working correctly, but take with caution), is under the assumption that the errors by changing frame, or movie clips that think they are behaving normally when they are not, occurs in movie clips that are removed, then added again etc. It seems as when they are removed (or the time line moves to a frame where they do not appear), they are recalled for garbage collection, but when the runtime notices they were still in use, it generates them again, but in the wrong way (just a theory). The solution in this case is to avoid garbage collection. As I said before, this seems to be the most stable solution so far, and it seems to be behaving correctly, but there are no guarantees
to avoid garbage collection, which seems to occur not if the object is not linked from a variable, but if the object does not appear to be contained in another movieclip that appears on stage, is to create an empty, generic movieclip that extends through all frames, and make it invisible in the first time, at the beginning of all execution; let's call this movie clip 'recycle_bin'. So instead of saying 'something.removeChild(other_something)', say instead recycle_bin.addChild(other_something). This way, the movie clip still appears on stage, but contained within an invisible movie clip
Have something to add?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now