<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>The SWFAction class</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ming-useswfversion.html">ming_useswfversion</a></div> <div class="next" style="text-align: right; float: right;"><a href="swfaction.construct.html">SWFAction::__construct</a></div> <div class="up"><a href="book.ming.html">Ming</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="class.swfaction" class="reference"> <h1 class="title">The SWFAction class</h1> <div class="partintro"><p class="verinfo">(PHP 5 <= 5.3.0, PECL ming SVN)</p> <div class="section" id="swfaction.intro"> <h2 class="title">Introduction</h2> <p class="para"> SWFAction. </p> </div> <div class="section" id="swfaction.synopsis"> <h2 class="title">Class synopsis</h2> <div class="classsynopsis"> <div class="ooclass"></div> <div class="classsynopsisinfo"> <span class="ooclass"> <strong class="classname">SWFAction</strong> </span> {</div> <div class="classsynopsisinfo classsynopsisinfo_comment">/* Methods */</div> <div class="methodsynopsis dc-description"> <span class="methodname"><a href="swfaction.construct.html" class="methodname">__construct</a></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$script</code></span> )</div> }</div> </div> <div class="section"> <h2 class="title">Description</h2> <p class="para"> The script syntax is based on the C language, but with a lot taken out- the SWF bytecode machine is just too simpleminded to do a lot of things we might like. For instance, we can't implement function calls without a tremendous amount of hackery because the jump bytecode has a hardcoded offset value. No pushing your calling address to the stack and returning- every function would have to know exactly where to return to. </p> <p class="para"> So what's left? The compiler recognises the following tokens: <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> break </span> </li> <li class="listitem"> <span class="simpara"> for </span> </li> <li class="listitem"> <span class="simpara"> continue </span> </li> <li class="listitem"> <span class="simpara"> if </span> </li> <li class="listitem"> <span class="simpara"> else </span> </li> <li class="listitem"> <span class="simpara"> do </span> </li> <li class="listitem"> <span class="simpara"> while </span> </li> </ul> </p> <p class="para"> There is no typed data; all values in the SWF action machine are stored as strings. The following functions can be used in expressions: <dl> <dt> <span class="term">time()</span> <dd> <span class="simpara"> Returns the number of milliseconds (?) elapsed since the movie started. </span> </dd> </dt> <dt> <span class="term">random(seed)</span> <dd> <span class="simpara"> Returns a pseudo-random number in the range 0-seed. </span> </dd> </dt> <dt> <span class="term">length(expr)</span> <dd> <span class="simpara"> Returns the length of the given expression. </span> </dd> </dt> <dt> <span class="term">int(number)</span> <dd> <span class="simpara"> Returns the given number rounded down to the nearest integer. </span> </dd> </dt> <dt> <span class="term">concat(expr, expr)</span> <dd> <span class="simpara"> Returns the concatenation of the given expressions. </span> </dd> </dt> <dt> <span class="term">ord(expr)</span> <dd> <span class="simpara"> Returns the ASCII code for the given character </span> </dd> </dt> <dt> <span class="term">chr(num)</span> <dd> <span class="simpara"> Returns the character for the given ASCII code </span> </dd> </dt> <dt> <span class="term">substr(string, location, length)</span> <dd> <span class="simpara"> Returns the substring of length <em><code class="parameter">length</code></em> at location <em><code class="parameter">location</code></em> of the given string <em><code class="parameter">string</code></em>. </span> </dd> </dt> </dl> </p> <p class="para"> Additionally, the following commands may be used: <dl> <dt> <span class="term">duplicateClip(clip, name, depth)</span> <dd> <span class="simpara"> Duplicate the named movie <em><code class="parameter">clip</code></em> (aka sprite). The new movie clip has name <em><code class="parameter">name</code></em> and is at depth <em><code class="parameter">depth</code></em>. </span> </dd> </dt> <dt> <span class="term">removeClip(expr)</span> <dd> <span class="simpara"> Removes the named movie clip. </span> </dd> </dt> <dt> <span class="term">trace(expr)</span> <dd> <span class="simpara"> Write the given expression to the trace log. Doubtful that the browser plugin does anything with this. </span> </dd> </dt> <dt> <span class="term">startDrag(target, lock, [left, top, right, bottom])</span> <dd> <span class="simpara"> Start dragging the movie clip <em><code class="parameter">target</code></em>. The <em><code class="parameter">lock</code></em> argument indicates whether to lock the mouse (?)- use 0 (<strong><code>FALSE</code></strong>) or 1 (<strong><code>TRUE</code></strong>). Optional parameters define a bounding area for the dragging. </span> </dd> </dt> <dt> <span class="term">stopDrag()</span> <dd> <span class="simpara"> Stop dragging my heart around. And this movie clip, too. </span> </dd> </dt> <dt> <span class="term">callFrame(expr)</span> <dd> <span class="simpara"> Call the named frame as a function. </span> </dd> </dt> <dt> <span class="term">getURL(url, target, [method])</span> <dd> <span class="simpara"> Load the given URL into the named target. The <em><code class="parameter">target</code></em> argument corresponds to HTML document targets (such as "_top" or "_blank"). The optional <em><code class="parameter">method</code></em> argument can be POST or GET if you want to submit variables back to the server. </span> </dd> </dt> <dt> <span class="term">loadMovie(url, target)</span> <dd> <span class="simpara"> Load the given URL into the named target. The <em><code class="parameter">target</code></em> argument can be a frame name (I think), or one of the magical values "_level0" (replaces current movie) or "_level1" (loads new movie on top of current movie). </span> </dd> </dt> <dt> <span class="term">nextFrame()</span> <dd> <span class="simpara"> Go to the next frame. </span> </dd> </dt> <dt> <span class="term">prevFrame()</span> <dd> <span class="simpara"> Go to the last (or, rather, previous) frame. </span> </dd> </dt> <dt> <span class="term">play()</span> <dd> <span class="simpara"> Start playing the movie. </span> </dd> </dt> <dt> <span class="term">stop()</span> <dd> <span class="simpara"> Stop playing the movie. </span> </dd> </dt> <dt> <span class="term">toggleQuality()</span> <dd> <span class="simpara"> Toggle between high and low quality. </span> </dd> </dt> <dt> <span class="term">stopSounds()</span> <dd> <span class="simpara"> Stop playing all sounds. </span> </dd> </dt> <dt> <span class="term">gotoFrame(num)</span> <dd> <span class="simpara"> Go to frame number <em><code class="parameter">num</code></em>. Frame numbers start at 0. </span> </dd> </dt> <dt> <span class="term">gotoFrame(name)</span> <dd> <span class="simpara"> Go to the frame named <em><code class="parameter">name</code></em>. Which does a lot of good, since I haven't added frame labels yet. </span> </dd> </dt> <dt> <span class="term">setTarget(expr)</span> <dd> <span class="simpara"> Sets the context for action. Or so they say- I really have no idea what this does. </span> </dd> </dt> </dl> And there's one weird extra thing. The expression frameLoaded(num) can be used in if statements and while loops to check if the given frame number has been loaded yet. Well, it's supposed to, anyway, but I've never tested it and I seriously doubt it actually works. You can just use /:framesLoaded instead. </p> <p class="para"> Movie clips (all together now- aka sprites) have properties. You can read all of them (or can you?), you can set some of them, and here they are: <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> x </span> </li> <li class="listitem"> <span class="simpara"> y </span> </li> <li class="listitem"> <span class="simpara"> xScale </span> </li> <li class="listitem"> <span class="simpara"> yScale </span> </li> <li class="listitem"> <span class="simpara"> currentFrame - (read-only) </span> </li> <li class="listitem"> <span class="simpara"> totalFrames - (read-only) </span> </li> <li class="listitem"> <span class="simpara"> alpha - transparency level </span> </li> <li class="listitem"> <span class="simpara"> visible - 1=on, 0=off (?) </span> </li> <li class="listitem"> <span class="simpara"> width - (read-only) </span> </li> <li class="listitem"> <span class="simpara"> height - (read-only) </span> </li> <li class="listitem"> <span class="simpara"> rotation </span> </li> <li class="listitem"> <span class="simpara"> target - (read-only) (???) </span> </li> <li class="listitem"> <span class="simpara"> framesLoaded - (read-only) </span> </li> <li class="listitem"> <span class="simpara"> name </span> </li> <li class="listitem"> <span class="simpara"> dropTarget - (read-only) (???) </span> </li> <li class="listitem"> <span class="simpara"> url - (read-only) (???) </span> </li> <li class="listitem"> <span class="simpara"> highQuality - 1=high, 0=low (?) </span> </li> <li class="listitem"> <span class="simpara"> focusRect - (???) </span> </li> <li class="listitem"> <span class="simpara"> soundBufTime - (???) </span> </li> </ul> So, setting a sprite's x position is as simple as <em>/box.x = 100;</em>. Why the slash in front of the box, though? That's how flash keeps track of the sprites in the movie, just like a Unix filesystem- here it shows that box is at the top level. If the sprite named box had another sprite named biff inside of it, you'd set its x position with /box/biff.x = 100;. At least, I think so; correct me if I'm wrong here. </p> </div> </div> <h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="swfaction.construct.html">SWFAction::__construct</a> — Creates a new SWFAction</li></ul> </div> <hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ming-useswfversion.html">ming_useswfversion</a></div> <div class="next" style="text-align: right; float: right;"><a href="swfaction.construct.html">SWFAction::__construct</a></div> <div class="up"><a href="book.ming.html">Ming</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>