<!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> time()</dt> <dd> <span class="simpara"> Returns the number of milliseconds (?) elapsed since the movie started. </span> </dd> <dt> random(seed)</dt> <dd> <span class="simpara"> Returns a pseudo-random number in the range 0-seed. </span> </dd> <dt> length(expr)</dt> <dd> <span class="simpara"> Returns the length of the given expression. </span> </dd> <dt> int(number)</dt> <dd> <span class="simpara"> Returns the given number rounded down to the nearest integer. </span> </dd> <dt> concat(expr, expr)</dt> <dd> <span class="simpara"> Returns the concatenation of the given expressions. </span> </dd> <dt> ord(expr)</dt> <dd> <span class="simpara"> Returns the ASCII code for the given character </span> </dd> <dt> chr(num)</dt> <dd> <span class="simpara"> Returns the character for the given ASCII code </span> </dd> <dt> substr(string, location, length)</dt> <dd> <span class="simpara"> Returns the substring of length <code class="parameter">length</code> at location <code class="parameter">location</code> of the given string <code class="parameter">string</code>. </span> </dd> </dl> </p> <p class="para"> Additionally, the following commands may be used: <dl> <dt> duplicateClip(clip, name, depth)</dt> <dd> <span class="simpara"> Duplicate the named movie <code class="parameter">clip</code> (aka sprite). The new movie clip has name <code class="parameter">name</code> and is at depth <code class="parameter">depth</code>. </span> </dd> <dt> removeClip(expr)</dt> <dd> <span class="simpara"> Removes the named movie clip. </span> </dd> <dt> trace(expr)</dt> <dd> <span class="simpara"> Write the given expression to the trace log. Doubtful that the browser plugin does anything with this. </span> </dd> <dt> startDrag(target, lock, [left, top, right, bottom])</dt> <dd> <span class="simpara"> Start dragging the movie clip <code class="parameter">target</code>. The <code class="parameter">lock</code> 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> stopDrag()</dt> <dd> <span class="simpara"> Stop dragging my heart around. And this movie clip, too. </span> </dd> <dt> callFrame(expr)</dt> <dd> <span class="simpara"> Call the named frame as a function. </span> </dd> <dt> getURL(url, target, [method])</dt> <dd> <span class="simpara"> Load the given URL into the named target. The <code class="parameter">target</code> argument corresponds to HTML document targets (such as "_top" or "_blank"). The optional <code class="parameter">method</code> argument can be POST or GET if you want to submit variables back to the server. </span> </dd> <dt> loadMovie(url, target)</dt> <dd> <span class="simpara"> Load the given URL into the named target. The <code class="parameter">target</code> 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> nextFrame()</dt> <dd> <span class="simpara"> Go to the next frame. </span> </dd> <dt> prevFrame()</dt> <dd> <span class="simpara"> Go to the last (or, rather, previous) frame. </span> </dd> <dt> play()</dt> <dd> <span class="simpara"> Start playing the movie. </span> </dd> <dt> stop()</dt> <dd> <span class="simpara"> Stop playing the movie. </span> </dd> <dt> toggleQuality()</dt> <dd> <span class="simpara"> Toggle between high and low quality. </span> </dd> <dt> stopSounds()</dt> <dd> <span class="simpara"> Stop playing all sounds. </span> </dd> <dt> gotoFrame(num)</dt> <dd> <span class="simpara"> Go to frame number <code class="parameter">num</code>. Frame numbers start at 0. </span> </dd> <dt> gotoFrame(name)</dt> <dd> <span class="simpara"> Go to the frame named <code class="parameter">name</code>. Which does a lot of good, since I haven't added frame labels yet. </span> </dd> <dt> setTarget(expr)</dt> <dd> <span class="simpara"> Sets the context for action. Or so they say- I really have no idea what this does. </span> </dd> </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>