📄 class.swfaction.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>The SWFAction class</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div 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="function.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> <h1 class="title">The SWFAction class</h1> <div class="partintro"> <div id="swfaction.intro" class="section"> <h2 class="title">Introduction</h2> <p class="para"> SWFAction. </p> </div> <div id="swfaction.synopsis" class="section"> <h2 class="title">Class synopsis</h2> <div class="classsynopsis"> <div class="ooclass"><b class="classname">SWFAction</b></div> <div class="classsynopsisinfo"> <span class="ooclass"> <b class="classname">SWFAction</b> </span> {</div> <div class="classsynopsisinfo classsynopsisinfo_comment">/* Methods */</div> <div class="methodsynopsis dc-description"> <span class="type">SWFAction</span> <span class="methodname"><b><b>__construct</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$script</tt></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 <i><tt class="parameter">length</tt></i> at location <i><tt class="parameter">location</tt></i> of the given string <i><tt class="parameter">string</tt></i>. </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 <i><tt class="parameter">clip</tt></i> (aka sprite). The new movie clip has name <i><tt class="parameter">name</tt></i> and is at depth <i><tt class="parameter">depth</tt></i>. </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 <i><tt class="parameter">target</tt></i>. The <i><tt class="parameter">lock</tt></i> argument indicates whether to lock the mouse (?)- use 0 (<b><tt>FALSE</tt></b>) or 1 (<b><tt>TRUE</tt></b>). 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 <i><tt class="parameter">target</tt></i> argument corresponds to HTML document targets (such as "_top" or "_blank"). The optional <i><tt class="parameter">method</tt></i> 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 <i><tt class="parameter">target</tt></i> 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 <i><tt class="parameter">num</tt></i>. Frame numbers start at 0. </span> </dd> </dt> <dt> <span class="term">gotoFrame(name)</span> <dd> <span class="simpara"> Go to the frame named <i><tt class="parameter">name</tt></i>. 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 <i>/box.x = 100;</i>. 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="function.swfaction.construct.html">SWFAction->__construct</a> 鈥
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -