Hi Sebastian,

2009/10/19 Sebastian Lucas <delsilu...@gmail.com>:
> I was doing a tool in C with OpenGL to show simple animations on the screen.
>
> So far I've got some animations working on it.
> What I do to show them it's to parse the xml generated by swfmill.
> It's good speed and it works perfect but I've a problem.
> What does it mean the attributes "replace" and "morph" on the PlaceObject2
> tag?

They mean different things depending on context.

replace="1" means:
 * If objectId is also set: Replace the object at the specified depth
with the object referenced by objectId. However, this doesn't work if
the object to be replaced is a sprite (symbol, i.e. defined with
DefineSprite*), as opposed to a shape (see below).
 * If objectID is not set: Change the attributes of the object at the
specified depth. For example, in the snippet posted above, change the
transformation matrix of the object at the specified depth.

morph means:
 * If the object is a morph shape (tween, i.e. defined with
DefineMorphShape*): how far the morph has progressed, 0=start of the
morph, 65535=end of the morph.
 * Otherwise: Used to make looping, gotoAndStop etc. work correctly in
conjunction with RemoveObject2 (see below).


Usually when replacing an object at a particular depth, it is
sufficient to say <PlaceObject2 replace="1" ...>. However, for some
reason this doesn't work for sprites, so it is necessary to use
<RemoveObject2> followed by <PlaceObject2>. However, in this case, the
Flash Player is no longer able to return to a frame once it has
entered a subsequent frame, so looping/gotoAndStop etc. don't work.

To fix this, it is necessary to use an incrementing morph attribute on
each PlaceObject2 tag as follows (transforms omitted for brevity):

<!-- Frame 1: Just place an object. Morph tag is required to make
looping work. -->
<PlaceObject2 replace="0" depth="1" objectID="1" morph="0"/>
<ShowFrame/>

<!-- Frame 2: Remove the previous object. Place replacement with
incremented morph tag. -->
<RemoveObject2 depth="1"/>
<PlaceObject2 replace="0" depth="1" objectID="2" morph="1"/>

<!-- Frame 3: Same again. -->
<RemoveObject2 depth="1"/>
<PlaceObject2 replace="0" depth="1" objectID="3" morph="2"/>

<!-- And so on. -->

This weird requirement is imposed by the Flash Player; it disagrees
with the SWF specification published by Adobe. The official spec says
that replace="1" (called "PlaceFlagMove" in the spec) should work for
sprites, and it says nothing of this alternative use of the morph
attribute (called "ratio" in the official spec).

See also this bug: https://bugs.launchpad.net/swfmill/+bug/409165


> ---- example start ----
> <PlaceObject2 replace="0" depth="1" objectID="4" morph="1">
>             <transform>
>               <Transform transX="-4280" transY="-6429"/>
>             </transform>
>           </PlaceObject2>
>           <ShowFrame/>
>           <RemoveObject2 depth="1"/>
>           <PlaceObject2 replace="0" depth="1" objectID="10" morph="2">
>             <transform>
>               <Transform transX="2" transY="-262"/>
>             </transform>
>           </PlaceObject2>
>           <ShowFrame/>
>           <PlaceObject2 replace="1" depth="1">
>             <transform>
>               <Transform transX="-1" transY="-359"/>
>             </transform>
>           </PlaceObject2>
>           <ShowFrame/>
>           <PlaceObject2 replace="1" depth="1">
>             <transform>
>               <Transform transX="-4" transY="-456"/>
>             </transform>
>           </PlaceObject2>
>           <ShowFrame/>
> ---- end of example ----
> This is just a simple tween action of the same MovieClip.
> I thought that when Flash compiles an swf movie he writes something
> like "tween from frame 1 to 40 on the object xx, from x,y to x,y" but it
> seems like me and my pal were completely wrong.
> For what I understand from that xml the positions of the whole tween are
> there frame by frame.

I don't think that there are any tweens in the snippet you posted. I
would hazard a guess that the object with ID 4 is a sprite, so that
may internally reference some tweened shapes. The other objects are
replaced with <PlaceObject replace="1">, so they must be plain old
shapes, without tweens. However, it is also possible and indeed quite
likely that I am wrong. The SWF format is quite baroque in places and
there are sure to be constructions that I haven't seen before. It's
hard to be sure without the rest of the file.


> So that's my second question...
> Is this something related to swfmill or flash?

I'm not sure how to answer this except to refer you to everything I've
said above :).

Hope this helps,
Dan.

_______________________________________________
swfmill mailing list
swfmill@osflash.org
http://osflash.org/mailman/listinfo/swfmill_osflash.org

Reply via email to