René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

Action [Ming wrapper class]

The source

Action.h
#ifndef ACTION_H
#define ACTION_H

#include <string>
#include "ming.h"
#include "Character_.h"

/*

   Sprites have the following properties:
   --------------------------------------
  x
  y
  xScale
  yScale
  currentFrame   read/only
  totalFrames    read/only
  alpha         (transparency level)
  visible:       1=on, 0=off (?)
  width          read/only
  height         read/only
  rotation
  target         read/only
  framesLoaded   read/only
  name
  dropTarget     read/only
  url            read/only
  highQuality:   1=high, 0=low (?)
  focusRect      ???
  soundBufTime   ???

*/

class Action {
  friend class Button;
  friend class Movie;
  friend class MovieClip;
	friend class DisplayClip;

  public:
    Action(std::string const& script);

  private:
    SWFAction action_;

  protected:
    // HACK?
    virtual SWFBlock_s* swf_block() const;
};


#endif
Action.cpp
#include "Action.h"

Action::Action(std::string const& script) {
  action_ =  compileSWFActionCode(script.c_str());
}

SWFBlock_s* Action::swf_block() const {
  return reinterpret_cast<SWFBlock_s*>(action_);
}

Examples

The following examples demonstrate this class:
  • Following the mouse
    demonstrates the Action Script functions setTarget, gotoFrame and Play.
  • Simple movie clip
    demonstrates the Action Script functions prevFrame and play.
  • Hit test
    demonstrates the Action Script functions hitTest, startDrag and stopDrag.
  • Multiple Action
    Creates an Action Script function which is then called.
  • Sparks
    Demonstrates Action Script functions and arrays.