Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Ming functions for Flash : SWFAction

SWFAction

SWFAction Class ()

Example 1332. swfaction() example

<?php
 $s
= new SWFShape();
 
$f = $s->addFill(0xff, 0, 0);
 
$s->setRightFill($f);

 
$s->movePenTo(-500, -500);
 
$s->drawLineTo(500, -500);
 
$s->drawLineTo(500, 500);
 
$s->drawLineTo(-500, 500);
 
$s->drawLineTo(-500, -500);

 
$p = new SWFSprite();
 
$i = $p->add($s);
 
$i->setDepth(1);
 
$p->nextFrame();

 for (
$n=0; $n<5; ++$n) {
   
$i->rotate(-15);
   
$p->nextFrame();
 }

 
$m = new SWFMovie();
 
$m->setBackground(0xff, 0xff, 0xff);
 
$m->setDimension(6000, 4000);

 
$i = $m->add($p);
 
$i->setDepth(1);
 
$i->moveTo(-500,2000);
 
$i->setName("box");

 
$m->add(new SWFAction("/box.x += 3;"));
 
$m->nextFrame();
 
$m->add(new SWFAction("gotoFrame(0); play();"));
 
$m->nextFrame();

 
header('Content-type: application/x-shockwave-flash');
 
$m->output();
?>

Example 1333. swfaction() example

<?php

 $m
= new SWFMovie();
 
$m->setRate(36.0);
 
$m->setDimension(1200, 800);
 
$m->setBackground(0, 0, 0);

 
/* mouse tracking sprite - empty, but follows mouse so we can
    get its x and y coordinates */

 
$i = $m->add(new SWFSprite());
 
$i->setName('mouse');

 
$m->add(new SWFAction("
   startDrag('/mouse', 1); /* '1' means lock sprite to the mouse */
 "
));

 
/* might as well turn off antialiasing, since these are just squares. */

 
$m->add(new SWFAction("
   this.quality = 0;
 "
));

 
/* morphing box */
 
$r = new SWFMorph();
 
$s = $r->getShape1();

 
/* Note this is backwards from normal shapes.  No idea why. */
 
$s->setLeftFill($s->addFill(0xff, 0xff, 0xff));
 
$s->movePenTo(-40, -40);
 
$s->drawLine(80, 0);
 
$s->drawLine(0, 80);
 
$s->drawLine(-80, 0);
 
$s->drawLine(0, -80);

 
$s = $r->getShape2();

 
$s->setLeftFill($s->addFill(0x00, 0x00, 0x00));
 
$s->movePenTo(-1, -1);
 
$s->drawLine(2, 0);
 
$s->drawLine(0, 2);
 
$s->drawLine(-2, 0);
 
$s->drawLine(0, -2);

 
/* sprite container for morphing box -
    this is just a timeline w/ the box morphing */

 
$box = new SWFSprite();
 
$box->add(new SWFAction("
   stop();
 "
));
 
$i = $box->add($r);

 for (
$n=0; $n<=20; ++$n) {
   
$i->setRatio($n/20);
   
$box->nextFrame();
 }

 
/* this container sprite allows us to use the same action code many times */

 
$cell = new SWFSprite();
 
$i = $cell->add($box);
 
$i->setName('box');

 
$cell->add(new SWFAction("

   setTarget('box');

   /* ...x means the x coordinate of the parent, i.e. (..).x */
   dx = (/mouse.x + random(6)-3 - ...x)/5;
   dy = (/mouse.y + random(6)-3 - ...y)/5;
   gotoFrame(int(dx*dx + dy*dy));

 "
));

 
$cell->nextFrame();
 
$cell->add(new SWFAction("

   gotoFrame(0);
   play();

 "
));

 
$cell->nextFrame();

 
/* finally, add a bunch of the cells to the movie */

 
for ($x=0; $x<12; ++$x) {
   for (
$y=0; $y<8; ++$y) {
     
$i = $m->add($cell);
     
$i->moveTo(100*$x+50, 100*$y+50);
   }
 }

 
$m->nextFrame();

 
$m->add(new SWFAction("

   gotoFrame(1);
   play();

 "
));

 
header('Content-type: application/x-shockwave-flash');
 
$m->output();
?>

Example 1334. swfaction() example

<?php

 $m
= new SWFMovie();
 
$m->setDimension(11000, 8000);
 
$m->setBackground(0x00, 0x00, 0x00);

 
$m->add(new SWFAction("

this.quality = 0;
/frames.visible = 0;
startDrag('/mouse', 1);

 "
));

 
// mouse tracking sprite
 
$t = new SWFSprite();
 
$i = $m->add($t);
 
$i->setName('mouse');

 
$g = new SWFGradient();
 
$g->addEntry(0, 0xff, 0xff, 0xff, 0xff);
 
$g->addEntry(0.1, 0xff, 0xff, 0xff, 0xff);
 
$g->addEntry(0.5, 0xff, 0xff, 0xff, 0x5f);
 
$g->addEntry(1.0, 0xff, 0xff, 0xff, 0);

 
// gradient shape thing
 
$s = new SWFShape();
 
$f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT);
 
$f->scaleTo(0.03);
 
$s->setRightFill($f);
 
$s->movePenTo(-600, -600);
 
$s->drawLine(1200, 0);
 
$s->drawLine(0, 1200);
 
$s->drawLine(-1200, 0);
 
$s->drawLine(0, -1200);

 
// need to make this a sprite so we can multColor it
 
$p = new SWFSprite();
 
$p->add($s);
 
$p->nextFrame();

 
// put the shape in here, each frame a different color
 
$q = new SWFSprite();
 
$q->add(new SWFAction("gotoFrame(random(7)+1); stop();"));
 
$i = $q->add($p);

 
$i->multColor(1.0, 1.0, 1.0);
 
$q->nextFrame();
 
$i->multColor(1.0, 0.5, 0.5);
 
$q->nextFrame();
 
$i->multColor(1.0, 0.75, 0.5);
 
$q->nextFrame();
 
$i->multColor(1.0, 1.0, 0.5);
 
$q->nextFrame();
 
$i->multColor(0.5, 1.0, 0.5);
 
$q->nextFrame();
 
$i->multColor(0.5, 0.5, 1.0);
 
$q->nextFrame();
 
$i->multColor(1.0, 0.5, 1.0);
 
$q->nextFrame();

 
// finally, this one contains the action code
 
$p = new SWFSprite();
 
$i = $p->add($q);
 
$i->setName('frames');
 
$p->add(new SWFAction("

dx = (/:mousex-/:lastx)/3 + random(10)-5;
dy = (/:mousey-/:lasty)/3;
x = /:mousex;
y = /:mousey;
alpha = 100;

 "
));
 
$p->nextFrame();

 
$p->add(new SWFAction("

this.x = x;
this.y = y;
this.alpha = alpha;
x += dx;
y += dy;
dy += 3;
alpha -= 8;

 "
));
 
$p->nextFrame();

 
$p->add(new SWFAction("prevFrame(); play();"));
 
$p->nextFrame();

 
$i = $m->add($p);
 
$i->setName('frames');
 
$m->nextFrame();

 
$m->add(new SWFAction("

lastx = mousex;
lasty = mousey;
mousex = /mouse.x;
mousey = /mouse.y;

++num;

if (num == 11)
 num = 1;

removeClip('char' & num);
duplicateClip(/frames, 'char' & num, num);

 "
));

 
$m->nextFrame();
 
$m->add(new SWFAction("prevFrame(); play();"));

 
header('Content-type: application/x-shockwave-flash');
 
$m->output();
?>

Related Examples ( Source code ) » ming.swfaction




Change Language


Follow Navioo On Twitter
SWFAction
SWFAction->__construct()
SWFBitmap
SWFBitmap->__construct()
SWFBitmap->getHeight()
SWFBitmap->getWidth()
SWFButton
SWFButton->__construct()
SWFButton->addAction()
SWFButton->addASound()
SWFButton->addShape()
SWFButton->setAction()
SWFButton->setDown()
SWFButton->setHit()
SWFButton->setMenu()
SWFButton->setOver()
SWFButton->setUp()
SWFDisplayItem
SWFDisplayItem->addAction()
SWFDisplayItem->addColor()
SWFDisplayItem->endMask()
SWFDisplayItem->getRot()
SWFDisplayItem->getX()
SWFDisplayItem->getXScale()
SWFDisplayItem->getXSkew()
SWFDisplayItem->getY()
SWFDisplayItem->getYScale()
SWFDisplayItem->getYSkew()
SWFDisplayItem->move()
SWFDisplayItem->moveTo()
SWFDisplayItem->multColor()
SWFDisplayItem->remove()
SWFDisplayItem->rotate()
SWFDisplayItem->rotateTo()
SWFDisplayItem->scale()
SWFDisplayItem->scaleTo()
SWFDisplayItem->setDepth()
SWFDisplayItem->setMaskLevel()
SWFDisplayItem->setMatrix()
SWFDisplayItem->setName()
SWFDisplayItem->setRatio()
SWFDisplayItem->skewX()
SWFDisplayItem->skewXTo()
SWFDisplayItem->skewY()
SWFDisplayItem->skewYTo()
SWFFill
SWFFill->moveTo()
SWFFill->rotateTo()
SWFFill->scaleTo()
SWFFill->skewXTo()
SWFFill->skewYTo()
SWFFont
SWFFont->__construct()
SWFFont->getAscent()
SWFFont->getDescent()
SWFFont->getLeading()
SWFFont->getShape()
SWFFont->getUTF8Width()
SWFFont->getWidth()
SWFFontChar
SWFFontChar->addChars()
SWFFontChar->addUTF8Chars()
SWFGradient
SWFGradient->__construct()
SWFGradient->addEntry()
SWFMorph
SWFMorph->__construct()
SWFMorph->getShape1()
SWFMorph->getShape2()
SWFMovie
SWFMovie->__construct()
SWFMovie->add()
SWFMovie->addExport()
SWFMovie->addFont()
SWFMovie->importChar()
SWFMovie->importFont()
SWFMovie->labelFrame()
SWFMovie->nextFrame()
SWFMovie->output()
SWFMovie->remove()
SWFMovie->save()
SWFMovie->saveToFile()
SWFMovie->setbackground()
SWFMovie->setDimension()
SWFMovie->setFrames()
SWFMovie->setRate()
SWFMovie->startSound()
SWFMovie->stopSound()
SWFMovie->streamMP3()
SWFMovie->writeExports()
SWFPrebuiltClip
SWFPrebuiltClip->__construct()
SWFShape
SWFShape->__construct()
SWFShape->addFill()
SWFShape->drawArc()
SWFShape->drawCircle()
SWFShape->drawCubic()
SWFShape->drawCubicTo()
SWFShape->drawCurve()
SWFShape->drawCurveTo()
SWFShape->drawGlyph()
SWFShape->drawLine()
SWFShape->drawLineTo()
SWFShape->movePen()
SWFShape->movePenTo()
SWFShape->setLeftFill()
SWFShape->setLine()
SWFShape->setRightFill()
SWFSound
SWFSound
SWFSoundInstance
SWFSoundInstance->loopCount()
SWFSoundInstance->loopInPoint()
SWFSoundInstance->loopOutPoint()
SWFSoundInstance->noMultiple()
SWFSprite
SWFSprite->__construct()
SWFSprite->add()
SWFSprite->labelFrame()
SWFSprite->nextFrame()
SWFSprite->remove()
SWFSprite->setFrames()
SWFSprite->startSound()
SWFSprite->stopSound()
SWFText
SWFText->__construct()
SWFText->addString()
SWFText->addUTF8String()
SWFText->getAscent()
SWFText->getDescent()
SWFText->getLeading()
SWFText->getUTF8Width()
SWFText->getWidth()
SWFText->moveTo()
SWFText->setColor()
SWFText->setFont()
SWFText->setHeight()
SWFText->setSpacing()
SWFTextField
SWFTextField->__construct()
SWFTextField->addChars()
SWFTextField->addString()
SWFTextField->align()
SWFTextField->setBounds()
SWFTextField->setColor()
SWFTextField->setFont()
SWFTextField->setHeight()
SWFTextField->setIndentation()
SWFTextField->setLeftMargin()
SWFTextField->setLineSpacing()
SWFTextField->setMargins()
SWFTextField->setName()
SWFTextField->setPadding()
SWFTextField->setRightMargin()
SWFVideoStream
SWFVideoStream->__construct()
SWFVideoStream->getNumFrames()
SWFVideoStream->setDimension()
ming_keypress
ming_setcubicthreshold
ming_setscale
ming_setswfcompression
ming_useconstants
ming_useswfversion
eXTReMe Tracker