gnash::sprite_instance Class Reference

Stateful Sprite object. Also known as a MovieClip. More...

#include <sprite_instance.h>

Inheritance diagram for gnash::sprite_instance:

gnash::character gnash::as_object gnash::ref_counted gnash::movie_instance gnash::movie_root List of all members.

Public Types

typedef std::list< action_buffer * > ActionList
typedef std::vector< execute_tag * > PlayList
enum  mouse_state { UP = 0, DOWN, OVER }
enum  play_state { PLAY, STOP }

Public Member Functions

 sprite_instance (movie_definition *def, movie_root *r, character *parent, int id)
virtual ~sprite_instance ()
virtual void has_keypress_event ()
virtual int add_interval_timer (void *timer)
virtual void clear_interval_timer (int x)
virtual void do_something (void *timer)
 Interval timer timeout executor.
movie_rootget_root ()
sprite_instanceget_root_movie ()
 Get a pointer to the root sprite.
movie_definitionget_movie_definition ()
 Return the sprite_definition (or movie_definition) from which this sprite_instance has been created.
float get_width () const
 Returns local, untransformed width of this character in TWIPS.
float get_height () const
 Returns local, untransformed height of this character in TWIPS.
size_t get_current_frame () const
size_t get_frame_count () const
size_t get_loaded_frames () const
 Return number of completely loaded frames of this sprite/movie.
size_t get_bytes_total () const
size_t get_bytes_loaded () const
const rectget_frame_size () const
void set_play_state (play_state s)
 Stop or play the sprite.
play_state get_play_state () const
characterget_character (int character_id)
float get_background_alpha () const
float get_pixel_scale () const
virtual void get_mouse_state (int *x, int *y, int *buttons)
void set_background_color (const rgba &color)
float get_timer () const
void restart ()
virtual bool has_looped () const
virtual bool get_accept_anim_moves () const
int transition (int a, int b) const
virtual bool can_handle_mouse_event ()
 Return true if we have any mouse event handlers.
virtual characterget_topmost_mouse_entity (float x, float y)
 Return the topmost entity that the given point covers that can receive mouse events. NULL if none. Coords are in parent's frame.
virtual void advance (float delta_time)
virtual void advance_sprite (float delta_time)
void execute_frame_tags (size_t frame, bool state_only=false)
void execute_frame_tags_reverse (size_t frame)
execute_tagfind_previous_replace_or_add_tag (int frame, int depth, int id)
void execute_remove_tags (int frame)
void do_actions ()
 Take care of this frame's actions.
void goto_frame (size_t target_frame_number)
 Set the sprite state at the specified frame number.
size_t get_frame_number (const as_value &frame_spec) const
 Parse frame spec and return frame number. Frame spec can either be a number of a string (label).
bool goto_labeled_frame (const char *label)
 Look up the labeled frame, and jump to it.
void display ()
 Display (render?) this Sprite/MovieClip, unless invisible.
void swap_characters (character *ch1, character *ch2)
characterget_character_at_depth (int depth)
characteradd_empty_movieclip (const char *name, int depth)
characteradd_display_object (uint16_t character_id, const char *name, const std::vector< swf_event * > &event_handlers, uint16_t depth, bool replace_if_depth_is_occupied, const cxform &color_transform, const matrix &matrix, float ratio, uint16_t clip_depth)
 Add an object to the DisplayList.
void move_display_object (uint16_t depth, bool use_cxform, const cxform &color_xform, bool use_matrix, const matrix &mat, float ratio, uint16_t clip_depth)
void replace_display_object (uint16_t character_id, const char *name, uint16_t depth, bool use_cxform, const cxform &color_transform, bool use_matrix, const matrix &mat, float ratio, uint16_t clip_depth)
void replace_display_object (character *ch, const char *name, uint16_t depth, bool use_cxform, const cxform &color_transform, bool use_matrix, const matrix &mat, float ratio, uint16_t clip_depth)
void remove_display_object (uint16_t depth, int)
 Remove the object at the specified depth.
void add_action_buffer (action_buffer *a)
int get_id_at_depth (int depth)
sprite_instanceto_movie ()
 Cast to a sprite, or return NULL.
virtual void set_variable (const char *path_to_var, const char *new_value)
 Set the named variable to the value.
virtual void set_variable (const char *path_to_var, const wchar_t *new_value)
 Set the named variable to the wide value.
virtual const char * get_variable (const char *path_to_var) const
 Returns address to static buffer. NOT THREAD SAFE!
bool get_member (const tu_stringi &name, as_value *val)
virtual void set_member (const tu_stringi &name, const as_value &val)
 Set the named member to the value.
virtual characterget_relative_target (const std::string &name)
 Overridden to look in DisplayList for a match.
virtual void call_frame_actions (const as_value &frame_spec)
 Execute the actions for the specified frame.
virtual void set_drag_state (const drag_state &st)
virtual void stop_drag ()
virtual void get_drag_state (drag_state *st)
void clone_display_object (const std::string &name, const std::string &newname, uint16_t depth)
void remove_display_object (const tu_string &name)
 Remove the object with the specified name.
virtual bool on_event (const event_id &id)
 Dispatch event handler(s), if any.
virtual void on_event_xmlsocket_onxml ()
virtual void on_event_interval_timer ()
virtual void on_event_load_progress ()
 Do the events that happen as a MovieClip (swf 7 only) loads.
virtual const char * call_method_args (const char *method_name, const char *method_arg_fmt, va_list args)
 Call a method with a list of arguments.
virtual void attach_display_callback (const char *path_to_object, void(*callback)(void *), void *user_ptr)
as_environmentget_environment ()
 Return a reference to the variable scope of this character.
void set_textfield_variable (const std::string &name, edit_text_character *ch)
 Set a TextField variable to this timeline.
void get_invalidated_bounds (rect *bounds, bool force)
const DisplayListgetDisplayList () const
int getNextHighestDepth () const
 Return the next highest available depth.
void testInvariant () const
virtual void set_sound_stream_id (int id)
 Set the current m_sound_stream_id.
virtual int get_sound_stream_id ()
 Get the current m_sound_stream_id.

Protected Attributes

boost::intrusive_ptr< movie_definitionm_def
 This is either sprite_definition (for sprites defined by DefineSprite tag) or movie_def_impl (for the top-level movie).
bool m_on_event_load_called

Detailed Description

Stateful Sprite object. Also known as a MovieClip.

Instance of this class are also known as "timelines". This means that they define a variable scope (see the as_environment member) and are divided into "frames"


Member Typedef Documentation

typedef std::list<action_buffer*> gnash::sprite_instance::ActionList
 

typedef std::vector<execute_tag*> gnash::sprite_instance::PlayList
 


Member Enumeration Documentation

enum gnash::sprite_instance::mouse_state
 

Enumerator:
UP 
DOWN 
OVER 

enum gnash::sprite_instance::play_state
 

Enumerator:
PLAY 
STOP 


Constructor & Destructor Documentation

gnash::sprite_instance::sprite_instance movie_definition def,
movie_root r,
character parent,
int  id
 

gnash::sprite_instance::~sprite_instance  )  [virtual]
 


Member Function Documentation

void gnash::sprite_instance::add_action_buffer action_buffer a  )  [inline]
 

Add the given action buffer to the list of action buffers to be processed at the end of the next frame advance.

character * gnash::sprite_instance::add_display_object uint16_t  character_id,
const char *  name,
const std::vector< swf_event * > &  event_handlers,
uint16_t  depth,
bool  replace_if_depth_is_occupied,
const cxform color_transform,
const matrix matrix,
float  ratio,
uint16_t  clip_depth
 

Add an object to the DisplayList.

Parameters:
replace_if_dept_is_occupied unused, always true

character * gnash::sprite_instance::add_empty_movieclip const char *  name,
int  depth
 

int gnash::sprite_instance::add_interval_timer void *  timer  )  [virtual]
 

Reimplemented in gnash::movie_root.

void gnash::sprite_instance::advance float  delta_time  )  [virtual]
 

Reimplemented from gnash::character.

Reimplemented in gnash::movie_instance, and gnash::movie_root.

void gnash::sprite_instance::advance_sprite float  delta_time  )  [virtual]
 

virtual void gnash::sprite_instance::attach_display_callback const char *  path_to_object,
void(*)(void *)  callback,
void *  user_ptr
[inline, virtual]
 

void gnash::sprite_instance::call_frame_actions const as_value frame_spec  )  [virtual]
 

Execute the actions for the specified frame.

The frame_spec could be an integer or a string.

virtual const char* gnash::sprite_instance::call_method_args const char *  method_name,
const char *  method_arg_fmt,
va_list  args
[inline, virtual]
 

Call a method with a list of arguments.

Reimplemented in gnash::movie_root.

bool gnash::sprite_instance::can_handle_mouse_event  )  [virtual]
 

Return true if we have any mouse event handlers.

Implements gnash::character.

void gnash::sprite_instance::clear_interval_timer int  x  )  [virtual]
 

Reimplemented in gnash::movie_root.

void gnash::sprite_instance::clone_display_object const std::string &  name,
const std::string &  newname,
uint16_t  depth
 

Duplicate the object with the specified name and add it with a new name at a new depth.

void gnash::sprite_instance::display  )  [virtual]
 

Display (render?) this Sprite/MovieClip, unless invisible.

Reimplemented from gnash::character.

Reimplemented in gnash::movie_root.

void gnash::sprite_instance::do_actions  ) 
 

Take care of this frame's actions.

void gnash::sprite_instance::do_something void *  timer  )  [virtual]
 

Interval timer timeout executor.

Reimplemented in gnash::movie_root.

void gnash::sprite_instance::execute_frame_tags size_t  frame,
bool  state_only = false
 

Execute the tags associated with the specified frame. frame is 0-based

void gnash::sprite_instance::execute_frame_tags_reverse size_t  frame  ) 
 

Execute the tags associated with the specified frame, IN REVERSE. I.e. if it's an "add" tag, then we do a "remove" instead. Only relevant to the display-list manipulation tags: add, move, remove, replace.

frame is 0-based

void gnash::sprite_instance::execute_remove_tags int  frame  ) 
 

Execute any remove-object tags associated with the specified frame. frame is 0-based

execute_tag * gnash::sprite_instance::find_previous_replace_or_add_tag int  frame,
int  depth,
int  id
 

virtual bool gnash::sprite_instance::get_accept_anim_moves  )  const [inline, virtual]
 

Reimplemented from gnash::character.

float gnash::sprite_instance::get_background_alpha  )  const
 

Reimplemented in gnash::movie_root.

size_t gnash::sprite_instance::get_bytes_loaded  )  const [inline]
 

Return number of loaded bytes in the movie (not sprite!)

size_t gnash::sprite_instance::get_bytes_total  )  const [inline]
 

Return total number of bytes in the movie (not sprite!)

character * gnash::sprite_instance::get_character int  character_id  ) 
 

Reimplemented in gnash::movie_root.

character * gnash::sprite_instance::get_character_at_depth int  depth  ) 
 

size_t gnash::sprite_instance::get_current_frame  )  const [inline, virtual]
 

Reimplemented from gnash::character.

Reimplemented in gnash::movie_root.

void gnash::sprite_instance::get_drag_state drag_state *  st  )  [virtual]
 

as_environment& gnash::sprite_instance::get_environment  )  [inline, virtual]
 

Return a reference to the variable scope of this character.

TODO: make const/return const& ?

Reimplemented from gnash::character.

size_t gnash::sprite_instance::get_frame_count  )  const [inline]
 

size_t gnash::sprite_instance::get_frame_number const as_value frame_spec  )  const
 

Parse frame spec and return frame number. Frame spec can either be a number of a string (label).

const rect& gnash::sprite_instance::get_frame_size  )  const [inline]
 

float gnash::sprite_instance::get_height  )  const [virtual]
 

Returns local, untransformed height of this character in TWIPS.

Reimplemented from gnash::character.

int gnash::sprite_instance::get_id_at_depth int  depth  ) 
 

For debugging -- return the id of the character at the specified depth. Return -1 if nobody's home.

void gnash::sprite_instance::get_invalidated_bounds rect bounds,
bool  force
[virtual]
 

Checks if the character instance is still enclosed in the given bounds. Otherwise it will expand them to surround the character. It is used to determine what area needs to be re-rendered. The coordinates are world coordinates. Only instances with m_invalidated flag set are checked unless force is set.

Implements gnash::character.

Reimplemented in gnash::movie_root.

size_t gnash::sprite_instance::get_loaded_frames  )  const [inline]
 

Return number of completely loaded frames of this sprite/movie.

Note: the number is also the last frame accessible (frames numberes are 1-based)

bool gnash::sprite_instance::get_member const tu_stringi name,
as_value val
[virtual]
 

FIXME: use a contextual 'target' member

FIXME: add a valid 'url' member. Currently the verbatim "gnash" value is assigned to it. The 'url' member should be inherited by parent *unless* we loaded an external resource into this movieclip.

Reimplemented from gnash::as_object.

Reimplemented in gnash::movie_root.

void gnash::sprite_instance::get_mouse_state int *  x,
int *  y,
int *  buttons
[virtual]
 

Reimplemented from gnash::character.

Reimplemented in gnash::movie_root.

movie_definition* gnash::sprite_instance::get_movie_definition  )  [inline, virtual]
 

Return the sprite_definition (or movie_definition) from which this sprite_instance has been created.

Reimplemented from gnash::character.

Reimplemented in gnash::movie_root.

float gnash::sprite_instance::get_pixel_scale  )  const [virtual]
 

These have been moved down from movie.h to remove that file from the inheritance chain. It is probably still a misdesign to require these functions for all characters.

Reimplemented from gnash::character.

Reimplemented in gnash::movie_root.

play_state gnash::sprite_instance::get_play_state  )  const [inline]
 

Reimplemented in gnash::movie_root.

character * gnash::sprite_instance::get_relative_target const std::string &  name  )  [virtual]
 

Overridden to look in DisplayList for a match.

Reimplemented from gnash::character.

movie_root* gnash::sprite_instance::get_root  )  [inline, virtual]
 

Reimplemented from gnash::character.

sprite_instance * gnash::sprite_instance::get_root_movie  )  [virtual]
 

Get a pointer to the root sprite.

Reimplemented from gnash::character.

Reimplemented in gnash::movie_root.

virtual int gnash::sprite_instance::get_sound_stream_id  )  [inline, virtual]
 

Get the current m_sound_stream_id.

float gnash::sprite_instance::get_timer  )  const
 

Reimplemented in gnash::movie_root.

character * gnash::sprite_instance::get_topmost_mouse_entity float  x,
float  y
[virtual]
 

Return the topmost entity that the given point covers that can receive mouse events. NULL if none. Coords are in parent's frame.

Reimplemented from gnash::character.

const char * gnash::sprite_instance::get_variable const char *  path_to_var  )  const [virtual]
 

Returns address to static buffer. NOT THREAD SAFE!

Reimplemented in gnash::movie_root.

float gnash::sprite_instance::get_width  )  const [virtual]
 

Returns local, untransformed width of this character in TWIPS.

Reimplemented from gnash::character.

const DisplayList& gnash::sprite_instance::getDisplayList  )  const [inline]
 

int gnash::sprite_instance::getNextHighestDepth  )  const [inline]
 

Return the next highest available depth.

Placing an object at the depth returned by this function should result in a character that is displayd above all others

void gnash::sprite_instance::goto_frame size_t  target_frame_number  )  [virtual]
 

Set the sprite state at the specified frame number.

0-based frame numbers!! (in contrast to ActionScript and Flash MX)

Reimplemented from gnash::character.

Reimplemented in gnash::movie_root.

bool gnash::sprite_instance::goto_labeled_frame const char *  label  ) 
 

Look up the labeled frame, and jump to it.

Reimplemented in gnash::movie_root.

void gnash::sprite_instance::has_keypress_event  )  [virtual]
 

Reimplemented from gnash::character.

virtual bool gnash::sprite_instance::has_looped  )  const [inline, virtual]
 

Reimplemented from gnash::character.

Reimplemented in gnash::movie_root.

void gnash::sprite_instance::move_display_object uint16_t  depth,
bool  use_cxform,
const cxform color_xform,
bool  use_matrix,
const matrix mat,
float  ratio,
uint16_t  clip_depth
[inline]
 

Updates the transform properties of the object at the specified depth.

bool gnash::sprite_instance::on_event const event_id id  )  [virtual]
 

Dispatch event handler(s), if any.

Reimplemented from gnash::character.

virtual void gnash::sprite_instance::on_event_interval_timer  )  [inline, virtual]
 

Do the events that (appear to) happen on a specified interval.

virtual void gnash::sprite_instance::on_event_load_progress  )  [inline, virtual]
 

Do the events that happen as a MovieClip (swf 7 only) loads.

virtual void gnash::sprite_instance::on_event_xmlsocket_onxml  )  [inline, virtual]
 

Do the events that happen when there is XML data waiting on the XML socket connection. FIXME: unimplemented

void gnash::sprite_instance::remove_display_object const tu_string name  ) 
 

Remove the object with the specified name.

@ what happens if the we have multiple objects with the same name ?

void gnash::sprite_instance::remove_display_object uint16_t  depth,
int 
[inline]
 

Remove the object at the specified depth.

NOTE: the id parameter is unused, but currently required to avoid break of inheritance from movie.h

void gnash::sprite_instance::replace_display_object character ch,
const char *  name,
uint16_t  depth,
bool  use_cxform,
const cxform color_transform,
bool  use_matrix,
const matrix mat,
float  ratio,
uint16_t  clip_depth
 

void gnash::sprite_instance::replace_display_object uint16_t  character_id,
const char *  name,
uint16_t  depth,
bool  use_cxform,
const cxform color_transform,
bool  use_matrix,
const matrix mat,
float  ratio,
uint16_t  clip_depth
 

void gnash::sprite_instance::restart  )  [virtual]
 

Reimplemented from gnash::character.

Reimplemented in gnash::movie_root.

void gnash::sprite_instance::set_background_color const rgba color  ) 
 

Reimplemented in gnash::movie_root.

void gnash::sprite_instance::set_drag_state const drag_state &  st  )  [virtual]
 

void gnash::sprite_instance::set_member const tu_stringi name,
const as_value val
[virtual]
 

Set the named member to the value.

Return true if we have that member; false otherwise.

Reimplemented from gnash::as_object.

Reimplemented in gnash::movie_root.

void gnash::sprite_instance::set_play_state play_state  s  )  [inline]
 

Stop or play the sprite.

virtual void gnash::sprite_instance::set_sound_stream_id int  id  )  [inline, virtual]
 

Set the current m_sound_stream_id.

void gnash::sprite_instance::set_textfield_variable const std::string &  name,
edit_text_character ch
 

Set a TextField variable to this timeline.

A TextField variable is a variable that acts as a setter/getter for a TextField 'text' member.

void gnash::sprite_instance::set_variable const char *  path_to_var,
const wchar_t *  new_value
[virtual]
 

Set the named variable to the wide value.

Reimplemented in gnash::movie_root.

void gnash::sprite_instance::set_variable const char *  path_to_var,
const char *  new_value
[virtual]
 

Set the named variable to the value.

Reimplemented in gnash::movie_root.

void gnash::sprite_instance::stop_drag  )  [virtual]
 

Reimplemented in gnash::movie_root.

void gnash::sprite_instance::swap_characters character ch1,
character ch2
 

void gnash::sprite_instance::testInvariant  )  const [inline]
 

sprite_instance* gnash::sprite_instance::to_movie  )  [inline, virtual]
 

Cast to a sprite, or return NULL.

Reimplemented from gnash::as_object.

int gnash::sprite_instance::transition int  a,
int  b
const [inline]
 

Combine the flags to avoid a conditional. It would be faster with a macro.


Member Data Documentation

boost::intrusive_ptr<movie_definition> gnash::sprite_instance::m_def [protected]
 

This is either sprite_definition (for sprites defined by DefineSprite tag) or movie_def_impl (for the top-level movie).

bool gnash::sprite_instance::m_on_event_load_called [protected]
 


The documentation for this class was generated from the following files:
Generated on Thu Nov 23 22:31:35 2006 for Gnash by  doxygen 1.4.6