2 // Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #ifndef GNASH_SWF_DOINITACTIONTAG_H
19 #define GNASH_SWF_DOINITACTIONTAG_H
21 #include "ControlTag.h" // for inheritance
22 #include "SWF.h" // for TagType definition
23 #include "action_buffer.h" // for composition
24 #include "MovieClip.h" // for inlines
25 #include "SWFStream.h" // for inlines
27 // Forward declarations
29 class movie_definition
;
35 /// SWF Tag DoInitAction (59)
37 /// Thin wrapper around action_buffer.
39 class DoInitActionTag
: public ControlTag
43 DoInitActionTag(SWFStream
& in
, movie_definition
& md
, int cid
)
51 /// Execute 'state' tags.
53 /// State tags change the current state of a MovieClip. They are executed
54 /// even for skipped frames to ensure that the state is consistent.
56 /// Even though DoInitAction tags contain ActionScript, they are considered
57 /// to be state tags. They are executed only once.
58 virtual void executeState(MovieClip
* m
, DisplayList
& /*dlist*/) const {
59 m
->execute_init_action_buffer(_buf
, _cid
);
62 static void loader(SWFStream
& in
, TagType tag
, movie_definition
& m
,
63 const RunResources
& /*r*/)
66 IF_VERBOSE_MALFORMED_SWF(
67 log_swferror("SWF contains DoInitAction tag, but is an "
70 throw ParserException("DoInitAction tag found in AS3 SWF!");
74 const boost::uint16_t cid
= in
.read_u16();
77 log_parse(_(" tag %d: do_init_action_loader"), tag
);
78 log_parse(_(" -- init actions for sprite %d"), cid
);
81 // TODO: Currently, tags are only be executed for already parsed
82 // character ids. This is known to be wrong: a more accurate
85 // The DoInitAction tag is executed only for characters on the stage
86 // or exported characters. It is only executed once.
88 // It's not known whether characters that were placed on the stage
89 // but then removed before the InitAction tag is encountered cause
90 // the actions to be executed.
92 // Gnash currently doesn't know which characters are on the stage, or
93 // which IDs have been exported.
94 boost::intrusive_ptr
<ControlTag
> da(new DoInitActionTag(in
, m
, cid
));
95 m
.addControlTag(da
); // ownership transferred
100 /// Read a DoInitAction block from the SWFStream
102 void read(SWFStream
& in
)
104 _buf
.read(in
, in
.get_tag_end_position());
110 // id of referenced DisplayObject definition
114 } // namespace gnash::SWF
118 #endif // GNASH_SWF_DOINITACTIONTAG_H
123 // indent-tabs-mode: t