Hi list. I have some problems with loops in my files, so I have 2 questions. Short version: 1) What is "morph" parameter in PlaceObject2? (And why does it affect loops?) 2) What exactly happens when I call "gotoAndPlay"?
Long version:
I'm trying to create a single animated sprite with several different
animations, and then toggle between them using gotoAndPlay method.
I've stumbled upon a problem where the first frame (or several, if
they're identical) of the animation fails to show. I tried to research
that and found some weird things. Hence my questions.
1) Low level PlaceObject2 tag has a "morph" parameter. I discovered it
affects how the objects behave if the movie loops. It's pretty weird
and surprising, and I don't understand it fully, so I'll post an
example:
In default simple stylesheet it's set to "0" on first operation on
the given depth, and to "1" on subsequent ones. Accidentally(?), this
setup actually works in simple cases. (It fails if there is a
gotoAndPlay action to any frame but the first.) So, to better
showcase the problem I've modified the stylesheet to allow custom
values for "morph". And used it with this code:
<clip id="loop">
<frame>
<place id="sprite1" depth="1" scale="0.75" x="-60" morph="0" />
<place id="sprite1" depth="2" scale="0.75" morph="1" />
</frame>
<frame>
<place id="sprite2" depth="1" x="-60" morph="1" />
<place id="sprite2" depth="2" morph="1" />
</frame>
</clip>
Upon placing it on the scene, the object at x="-60" oscilates between
sprite1 scaled down to 0.75 and sprite2
The other object always looks as sprite2 but oscilates between scaled
to 0.75 and full size.
It works for different values of morph- if and only if they are
identical in the first and the last frame, the first frame object will
retain the looks (same id, or ObjectID in low-level) of the last one
upon looping back to the first frame.
Inserting explicit "RemoveObject2" at the end of the loop helps.
Inserting it at the beginning doesn't.
The "bug" also happens if the looping is a result of a gotoAndPlay
action. If the action was a part of a frame, the object will retain
the looks (ObjectID) from that frame. If the action was called from an
event handler, then the object will get the looks of the NEXT object
placed on that depth (unless the two have different values of
"morph").
(For for example, if the object has frames 1,2 and 3, and onPress goes
to frame 1, but the frame 1 has the same "morph" as frame2, then upon
clicking you will see frame2. Sorry if this was confusing, but the
whole thing makes my head spin.)
I'm including an example file.
Note: I do realize there's a simple work-around, for example
morph="{$id}". I just want to know why would it be needed.
2) The above issue brought me to conclusion I don't understand what
exactly happens when a clip loops back to beginning or has gotoAndPlay
method called.
I know it "goes to the target frame", but it can't be as simple as
that. How does it know what objects are on the scene?
If sprites placed on the scene have actions in their frames, are they
called? Are existing objects removed? What about objects created by
action script? I need a flow chart...
I could try experimenting on that, and I probably will, but this whole
reverse engineering makes me feel odd. Damm, and now I feel like a
medieval alchemist asking a chemistry major about the properties and
usage of saltpeter.
loopTest.rar
Description: application/rar
_______________________________________________ swfmill mailing list [email protected] http://osflash.org/mailman/listinfo/swfmill_osflash.org
