downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/class.swfaction.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/book.ming.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'class.swfaction.php',
   
1 => 'SWFAction',
  ),
 
'up' =>
  array (
   
0 => 'book.ming.php',
   
1 => 'Ming (flash)',
  ),
 
'prev' =>
  array (
   
0 => 'function.ming-useswfversion.php',
   
1 => 'ming_useswfversion',
  ),
 
'next' =>
  array (
   
0 => 'function.swfaction.construct.php',
   
1 => 'SWFAction->__construct',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<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>__construct</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&#039;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&#039;s left? The compiler recognises the following tokens:
   </p><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>
  <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:
   </p><dl>

    <dt class="varlistentry">

     <span class="term">time()</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Returns the number of milliseconds (?) elapsed since the movie started.
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">random(seed)</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Returns a pseudo-random number in the range 0-seed.
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">length(expr)</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Returns the length of the given expression.
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">int(number)</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Returns the given number rounded down to the nearest integer.
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">concat(expr, expr)</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Returns the concatenation of the given expressions.
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">ord(expr)</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Returns the ASCII code for the given character
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">chr(num)</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Returns the character for the given ASCII code
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">substr(string, location, length)</span>

     </dt><dd class="listitem">

      <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>

   
   </dl>
<p>
  </p>
  <p class="para">
   Additionally, the following commands may be used:
   </p><dl>

    <dt class="varlistentry">

     <span class="term">duplicateClip(clip, name, depth)</span>

     </dt><dd class="listitem">

      <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 class="varlistentry">

     <span class="term">removeClip(expr)</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Removes the named movie clip.
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">trace(expr)</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Write the given expression to the trace log. Doubtful that the browser
       plugin does anything with this.
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">startDrag(target, lock, [left, top, right, bottom])</span>

     </dt><dd class="listitem">

      <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 class="constant">FALSE</tt></b>) or 1 (<b><tt class="constant">TRUE</tt></b>). Optional parameters
       define a bounding area for the dragging. 
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">stopDrag()</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Stop dragging my heart around. And this movie clip, too. 
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">callFrame(expr)</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Call the named frame as a function. 
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">getURL(url, target, [method])</span>

     </dt><dd class="listitem">

      <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 &quot;_top&quot; or &quot;_blank&quot;).
       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 class="varlistentry">

     <span class="term">loadMovie(url, target)</span>

     </dt><dd class="listitem">

      <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 &quot;_level0&quot; (replaces
       current movie) or &quot;_level1&quot; (loads new movie on top of current movie).
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">nextFrame()</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Go to the next frame. 
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">prevFrame()</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Go to the last (or, rather, previous) frame. 
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">play()</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Start playing the movie. 
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">stop()</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Stop playing the movie. 
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">toggleQuality()</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Toggle between high and low quality. 
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">stopSounds()</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Stop playing all sounds. 
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">gotoFrame(num)</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Go to frame number <i><tt class="parameter">num</tt></i>
. Frame numbers start at 0. 
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">gotoFrame(name)</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Go to the frame named <i><tt class="parameter">name</tt></i>
. Which does a lot of good, since I
       haven&#039;t added frame labels yet. 
      </span>
     </dd>

   
    <dt class="varlistentry">

     <span class="term">setTarget(expr)</span>

     </dt><dd class="listitem">

      <span class="simpara">
       Sets the context for action. Or so they say- I really have no
       idea what this does.
      </span>
     </dd>
  
   
   </dl>
<p>
   And there&#039;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&#039;s supposed to, anyway, but I&#039;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:
    </p><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><p>
    So, setting a sprite&#039;s x position is as simple as <i>/box.x = 100;</i>.
    Why the slash in front of the box, though? That&#039;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&#039;d set its x
    position with /box/biff.x = 100;. At least, I think so; correct
    me if I&#039;m wrong here.
  </p>
 </div>
 
 </div>
 
 






 
<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="function.swfaction.construct.php">SWFAction->__construct</a> — Creates a new SWFAction</li></ul>
</div>
<?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites