2 * Copyright (C) 2005, 2006, 2007, 2009, 2010,
3 * 2011 Free Software Foundation, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * 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
21 * Zou Lunkai, zoulunkai@gmail.com
25 * (1) Within the same frame, if PlaceObject(mc1) is before PlaceObject(mc2),
26 * then frame0 actions of mc1 should be executed before frame0 actions of mc2.
27 * (2) Within the same timeline, frame actions(frameNum>0) of fisrt placed sprites executed last.
29 * The actual order of tags are dependent on compiler, so you need to
30 * verify first if the order of tags is what you expect.
37 #include "ming_utils.h"
39 #define OUTPUT_VERSION 6
40 #define OUTPUT_FILENAME "action_execution_order_test2.swf"
44 main(int argc
, char** argv
)
47 SWFMovieClip mc_red1
, mc_red2
, mc_red3
, mc_red4
, mc_red5
, dejagnuclip
;
48 SWFDisplayItem it_red1
, it_red2
, it_red3
, it_red4
, it_red5
;
51 const char *srcdir
=".";
56 fprintf(stderr
, "Usage: %s <mediadir>\n", argv
[0]);
61 mo
= newSWFMovieWithVersion(OUTPUT_VERSION
);
62 SWFMovie_setDimension(mo
, 800, 600);
63 SWFMovie_setRate (mo
, 12.0);
65 dejagnuclip
= get_dejagnu_clip((SWFBlock
)get_default_font(srcdir
), 10, 0, 0, 800, 600);
66 SWFMovie_add(mo
, (SWFBlock
)dejagnuclip
);
67 SWFMovie_nextFrame(mo
); /* 1st frame */
70 mc_red1
= newSWFMovieClip();
71 sh_red
= make_fill_square (0, 300, 60, 60, 255, 0, 0, 255, 0, 0);
72 SWFMovieClip_add(mc_red1
, (SWFBlock
)sh_red
);
73 add_clip_actions(mc_red1
, " _root.x1 += \"depth10+\"; ");
74 SWFMovieClip_nextFrame(mc_red1
); /* mc_red1, 1st frame */
75 add_clip_actions(mc_red1
, " _root.x2 += \"depth10+\"; stop(); ");
76 SWFMovieClip_nextFrame(mc_red1
); /* mc_red1, 2nd frame */
78 mc_red2
= newSWFMovieClip();
79 sh_red
= make_fill_square (80, 300, 60, 60, 255, 0, 0, 255, 0, 0);
80 SWFMovieClip_add(mc_red2
, (SWFBlock
)sh_red
);
81 add_clip_actions(mc_red2
, " _root.x1 += \"depth12+\"; ");
82 SWFMovieClip_nextFrame(mc_red2
); /* mc_red2, 1st frame */
83 add_clip_actions(mc_red2
, " _root.x2 += \"depth12+\"; stop(); ");
84 SWFMovieClip_nextFrame(mc_red2
); /* mc_red2, 2nd frame */
86 mc_red3
= newSWFMovieClip();
87 sh_red
= make_fill_square (160, 300, 60, 60, 255, 0, 0, 255, 0, 0);
88 SWFMovieClip_add(mc_red3
, (SWFBlock
)sh_red
);
89 add_clip_actions(mc_red3
, " _root.x1 += \"depth11+\"; ");
90 SWFMovieClip_nextFrame(mc_red3
); /* mc_red3, 1st frame */
91 add_clip_actions(mc_red3
, " _root.x2 += \"depth11+\"; stop();");
92 SWFMovieClip_nextFrame(mc_red3
); /* mc_red3, 2nd frame */
95 /* add mc_red1 to _root and name it as "mc_red1" */
96 it_red1
= SWFMovie_add(mo
, (SWFBlock
)mc_red1
);
97 SWFDisplayItem_setDepth(it_red1
, 10);
98 SWFDisplayItem_setName(it_red1
, "mc_red1");
100 /* add mc_red2 to _root and name it as "mc_red2" */
101 it_red2
= SWFMovie_add(mo
, (SWFBlock
)mc_red2
);
102 SWFDisplayItem_setDepth(it_red2
, 12);
103 SWFDisplayItem_setName(it_red2
, "mc_red2");
105 /* add mc_red3 to _root and name it as "mc_red3" */
106 it_red3
= SWFMovie_add(mo
, (SWFBlock
)mc_red3
);
107 SWFDisplayItem_setDepth(it_red3
, 11);
108 SWFDisplayItem_setName(it_red3
, "mc_red3");
110 SWFMovie_nextFrame(mo
); /* 2nd frame */
112 /* Action order is not dependent on DisplayList depth here! */
113 check_equals(mo
, "_root.x1", "'depth10+depth12+depth11+'");
114 SWFMovie_nextFrame(mo
); /* 3rd frame */
116 mc_red4
= newSWFMovieClip();
117 sh_red
= make_fill_square (240, 300, 60, 60, 255, 0, 0, 255, 0, 0);
118 SWFMovieClip_add(mc_red4
, (SWFBlock
)sh_red
);
119 add_clip_actions(mc_red4
, " _root.x2 += \"depth9+\"; ");
120 SWFMovieClip_nextFrame(mc_red4
); /* mc_red4, 1st frame */
122 /* add mc_red4 to _root and name it as "mc_red4" */
123 it_red4
= SWFMovie_add(mo
, (SWFBlock
)mc_red4
);
124 SWFDisplayItem_setDepth(it_red4
, 9);
125 SWFDisplayItem_setName(it_red4
, "mc_red4");
127 mc_red5
= newSWFMovieClip();
128 sh_red
= make_fill_square (240, 300, 60, 60, 255, 0, 0, 255, 0, 0);
129 SWFMovieClip_add(mc_red5
, (SWFBlock
)sh_red
);
130 add_clip_actions(mc_red5
, " _root.x2 += \"depth13+\"; ");
131 SWFMovieClip_nextFrame(mc_red5
); /* mc_red4, 1st frame */
133 /* add mc_red5 to _root and name it as "mc_red5" */
134 it_red5
= SWFMovie_add(mo
, (SWFBlock
)mc_red5
);
135 SWFDisplayItem_setDepth(it_red5
, 13);
136 SWFDisplayItem_setName(it_red5
, "mc_red4");
138 SWFMovie_nextFrame(mo
); /* 4th frame */
141 check_equals(mo
, "_root.x2", "'depth11+depth12+depth10+depth9+depth13+'");
142 add_actions(mo
, " _root.totals(); stop(); ");
143 SWFMovie_nextFrame(mo
); /* 5th frame */
147 puts("Saving " OUTPUT_FILENAME
);
148 SWFMovie_save(mo
, OUTPUT_FILENAME
);