SWF::DisplayItem(3) SWF DisplayItem class


use SWF::DisplayItem;
$dispitem = $movie->add($shape);


When you place an SWF object (one of the types that can be seen with eyes by user) in a frame of a SWF::Movie or SWF::MovieClip, the return value will be in a SWF::DisplayItem.

You can now modify that item in current and every following frames of the clip where you added the SWF object.

Further it is accessible by ActionScript too. Just give the DisplayItem a name with method setName($name) after you added the SWF object to a SWF::Movie or SWF::MovieClip


$displayItem->moveTo($x, $y);
Move $displayItem to ($x, $y) in global co-ordinates.
$displayItem->move($x, $y);
Displace $displayItem by ($x, $y)
$displayItem->scaleTo($x [,$y]);
Set $displayItem scale to $x in the x-direction and $y in the y-direction. If $y is not specified, $y=$x is assumed.
$displayItem->scale($x [,$y]);
Multiply $displayItem scale by $x in the x-direction and $y in the y-direction. If $y is not specified, $y=$x is assumed.
Set $displayItem rotation to $degrees.
Rotate $displayItem by $degrees.
Add $x to the current x-skew.
Set x-skew to $x. 1.0 is 45-degree forward slant. More is more forward while less is more backward.
Add $y to the current y-skew.
Set y-skew to $y. 1.0 is 45-degree upward slant. More is more upward while less is more downward.
$displayItem->setMatrix($a, $b, $c, $d, $e, $f)
Do an operation of rotating/skewing (b,c), moving (e,f) and scaling (a,d) at once. The default initial values of an SWF::DisplayItem object's matrix are 1.0, 0, 0, 1.0, 0, 0 . So calling setMatrix with these defaults (setMatrix(1.0, 0, 0, 1.0, 0, 0);) will reset results of earlier calls of SWF::DisplayItem methods (like rotate(45) etc. etc.)
Set Z-order of $displayItem to $depth.
Useful for SWF::Morph. Sets $displayItem ratio to $ratio.
$displayItem->setColorAdd($r, $g, $b [,$a]))
$displayItem->addColor($r, $g, $b [,$a]);
Add RGB color to the $displayItem's color transform. Default value of $a is 1.0
$displayItem->setColorMult($r, $g, $b [,$a]))
$displayItem->multColor($r, $g, $b [,$a]);
Multiplies the $displayItem's color transform by the given values. Default value of $a is 1.0
Set $displayItem's name to $name (used for targetting with SWF::Action).
Remove $displayItem from the movie display list.
($x, $y) = $displayItem->getPosition(();
Returns displace coordinates of $displayitem.
$degrees = $displayItem->getRotation();
Returns rotation of $displayItem.
($x, $y) = $displayItem->getScale();
Returns scale of $displayItem in x- and y-direction.
($x, $y) = $displayItem->getSkew();
Returns x- and y-skew of $displayItem.
$depth = $displayItem->getDepth();
Returns Z-order of $displayItem.
Sets a mask level: display items with lower or equal depth are masked, any other display items are not masked. Use setDepth() to control desired masking.
End masking started by prior setMask() call.
$displayItem->addAction( $action, $flags )
Add $action, an object of SWF::Action class. The flags are exported from SWF::Constants.


Using this flags you have control at which events the action will run.

Set an alternative blend mode instead of default alpha blend. Possible modes are:


Here comes some demonstration code:

        use SWF::Constants qw(:DisplayItem); 
        # ....
        $sh=new SWF::Shape();
        $fill = $sh->addFill(255, 0, 0, 255);                           # red
        $sh->drawLine(440, 0);
        $sh->drawLine(0, 380);
        $sh->drawLine(-440, 0);
        $sh->drawLine(0, -380);
        $sh2=new SWF::Shape();
        $fill2 = $sh2->addFill(0, 255, 0, 255);                         # green
        $sh2->drawLine(240, 0);
        $sh2->drawLine(0, 280);
        $sh2->drawLine(-240, 0);
        $sh2->drawLine(0, -280);
        #  $di2->setBlendMode( SWFBLEND_MODE_NORMAL);                   # would be green  ( as you have expected )
        $di2->setBlendMode(  SWFBLEND_MODE_ADD);                        # y e l l o w  ( surprising, a litle bit )
Set a flag (value 0 or 1) showing the character can be cached as a bitmap. This might improve rendering speed, if the object does no change often. This feature is available for SWF version >= 8 only.
Writes the SWF::DisplayItem object immediately to the blocklist. Usually MING waits with writing a display item until a frame is closed through a nextFrame() call, because a display items state could be altered for the current frame. By using the flush() method MING does not wait and writes the frame immediately. Therefore an user can influence the swf tag order. Changing a display items state after calling flush() takes effect in the next frame.
$matrix = $displayItem->getMatrix()
Returns an associated SWF::Matrix object.
$character = $displayItem->getCharacter()
Returns the associated SWF::Character object.
$displayItem->addFilter( $filter )
Process the DisplayItem object thru a prepared filter: an object of SWF::Filter class, e.g. BlurFilter or DropShadowFilter. Filters are available since player version 8.
$displayItem->setCXform( $cxform )
Process the DisplayItem object thru $cxform: a prepared color transformation object of SWF::CXform class.


Soheil Seyfaie (soheil AT users.sourceforge.net) Peter Liscovius Albrecht Kleine