views:

223

answers:

2

I am working on a short animated story, which has a scrubbable timeline and chapter headings. I used TimelineMax for sequencing it. For the most part, it is working fine. I am seeing some strange behavior that pop up, though: sprites disappear, functions stop responding to user input, seams of the sprites become transparent -- all small issues but pretty hard to nail down because they happen in Mac only.

So I am wondering what is wrong with Flash, and why it misbehaves on a Mac?

A: 

I've encountered some rendering issues between plugin versions especially when dealing with transparency, fonts, and embed settings.

If you are doing this in a web browser try playing with the WMODE embed setting and see if your results change.

Jasconius
+2  A: 

I frequently work on the same projects on Windows at work and then my Mac at home. I also see some difference on the Mac compared to Windows. I find that various Flash Player versions for the Mac are generally slower than the Windows players, and I've seen some odd behavior on the Mac that is not happening on Windows.

In most cases I've narrowed this down to AS3's garbage collection. Garbage collection happens when the player determines that an object no longer has a reference in the movie, so it removes that object to free up memory. Let's say you have a class method like this:

function myTweenFunction():void {
    var myTween:Tween = new Tween(myDisplayObject, 'x', Strong.easeInOut, 0, 500, 10, true);
    myTween.addEventListener(TweenEvent.MOTION_FINISH, onMyTweenDone);
}

The method above will tween myDisplayObject's x value from 0 to 500 over the course of 10 seconds. When that tween is done, it should fire the onMyTweenDone method (not shown). However, myTween was created inside myTweenFunction so it only exists in the scope of myTweenFunction. When myTweenFunction is done, the myTween object is no longer referenced by any object in the movie so it becomes a candidate for garbage collection. You will start to see the tween, but at some point it will stop before it gets to 500 and the finish event will not fire. This means that myTween has been destroyed. To fix this problem, myTween needs to be a member of the class, or just needs to have a reference outside of a class function.

Getting back to the Mac vs. Windows issues, I see that garbage collection on runtime-created objects on the Mac is more apparent than on Windows. Garbage collection happens in the Windows Flash Player, but the tweens and other events may be finishing before garbage collection occurs since the Windows Flash Player has better performance. If the Mac Flash Player is slower (ie. the same tween might take longer), then the garbage collection might happen before the tween is done. Garbage collection does not occur frame-by-frame like an animation; it's a background process that can happen at any time, or not at all if there's enough memory for the Flash Player. Your windows machine might have a pile of RAM and the movie can play fine without the need for garbage collection, so myTween might never go away. If your Mac has less memory, or if you have a ton of apps open at once and the Flash Player memory allotment is limited, then the Flash Player will perform garbage collection more frequently.

I've also used TimelineMax, and there's an auto garbage collection feature that is turned on by default. Try turning that off and test on the Mac.

Ultimately, you should design your project with the assumption that a user may have very limited memory, so your objects need to be created, referenced, and garbage collected accordingly.

wmid