<?
Ming_setScale(20.0);
function makeTree($s)
{
$p = new SWFSprite();
$i = $p->add($s);
$i->setName("left");
$i->multColor(1.0, 0.8, 0.8);
$i = $p->add($s);
$i->setName("middle");
$i->multColor(0.8, 1.0, 0.8);
$i = $p->add($s);
$i->setName("right");
$i->multColor(0.8, 0.8, 1.0);
$p->nextFrame();
return $p;
}
$s = new SWFShape();
$s->setRightFill(0xff, 0xff, 0xff, 0x7f);
$s->movePenTo(-20, -20);
$s->drawLineTo(20, -20);
$s->drawLineTo(20, 20);
$s->drawLineTo(-20, 20);
$s->drawLineTo(-20, -20);
// base shape has to be a sprite so that we can setName it
$p = new SWFSprite();
$p->add($s);
$p->nextFrame();
$m = new SWFMovie();
$m->setDimension(640, 480);
$i = $m->add(makeTree(makeTree(makeTree(makeTree($p)))));
$i->moveTo(320, 240);
$i->addAction(new SWFAction('
// how often we change drift values: lower is more often
freq = 50;
// how much we change the value in each step
rate = 0.02;
leftxscale = 100;
leftyscale = 100;
leftx = 0;
lefty = 0;
leftrotation = 90;
middlexscale = 100;
middleyscale = 100;
middlex = 0;
middley = 0;
middlerotation = 90;
rightxscale = 100;
rightyscale = 100;
rightx = 0;
righty = 0;
rightrotation = 90;
function doXform(clip, which)
{
// doing clip._xscale = this[which+"xscale"]
// is much, much slower..
if(which == "left")
{
clip._xscale = leftxscale;
clip._yscale = leftyscale;
clip._x = leftx;
clip._y = lefty;
clip._rotation = leftrot;
}
else if(which == "middle")
{
clip._xscale = middlexscale;
clip._yscale = middleyscale;
clip._x = middlex;
clip._y = middley;
clip._rotation = middlerot;
}
else
{
clip._xscale = rightxscale;
clip._yscale = rightyscale;
clip._x = rightx;
clip._y = righty;
clip._rotation = rightrot;
}
if(clip.left)
doXform(clip.left, "left");
if(clip.middle)
doXform(clip.middle, "middle");
if(clip.right)
doXform(clip.right, "right");
}
function adjust(name, dname, min, max)
{
this[name] += this[dname];
if(this[name] > max)
chance = freq*(this[name]-max)/(max-min)/2;
else if(this[name] < min)
chance = freq*(min-this[name])/(max-min)/2;
else
chance = 1;
if(Math.random()*freq > chance)
return;
if(this[name] < min)
{
// push it back up
this[dname] = Math.random()*(max-min)*rate;
}
else if(this[name] > max)
{
// push it back down
this[dname] = -Math.random()*(max-min)*rate;
}
else
this[dname] = (Math.random()-0.5)*(max-min)*rate;
}
'), SWFACTION_ONLOAD);
$i->addAction(new SWFAction('
adjust("leftxscale", "dleftxscale", -120, 120);
adjust("leftyscale", "dleftyscale", -120, 120);
adjust("middlexscale", "dmiddlexscale", -120, 120);
adjust("middleyscale", "dmiddleyscale", -120, 120);
adjust("rightxscale", "drightxscale", -120, 120);
adjust("leftxscale", "dleftxscale", -120, 120);
adjust("rightrot", "drightrot", -90, 90);
adjust("middlerot", "dmiddlerot", -90, 90);
adjust("leftrot", "dleftrot", -90, 90);
adjust("leftx", "dleftx", -40, 40);
adjust("lefty", "dlefty", -40, 40);
adjust("middlex", "dmiddlex", -40, 40);
adjust("middley", "dmiddley", -40, 40);
adjust("rightx", "drightx", -40, 40);
adjust("righty", "drighty", -40, 40);
doXform(left, "left");
doXform(middle, "middle");
doXform(right, "right");
'), SWFACTION_ENTERFRAME);
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
All content Copyright (C) 2000-2001 Opaque Industries except where noted otherwise.