2 * Copyright (C) 2005, 2006, 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.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * Zou Lunkai, zoulunkai@gmail.com
22 * From this testcase, we can see that, the execution order of the
23 * actions are like this:
24 * actions in 1st frame of _root
25 * actions in 1st frame of mc_red
26 * actions in 1st target frame of _root
27 * actions in 1st target frame of mc_red
28 * actions in 2nd target frame of _root
29 * actions in 2nd target frame of mc_red
30 * actions in 3rd target frame of _root
31 * actions in 3rd target frame of mc_red
33 * another testcase for ActionGotoFrame
40 #include "ming_utils.h"
42 #define OUTPUT_VERSION 6
43 #define OUTPUT_FILENAME "consecutive_goto_frame_test.swf"
47 main(int argc
, char** argv
)
50 SWFMovieClip mc_red
, dejagnuclip
;
53 const char *srcdir
=".";
58 fprintf(stderr
, "Usage: %s <mediadir>\n", argv
[0]);
63 mo
= newSWFMovieWithVersion(OUTPUT_VERSION
);
64 SWFMovie_setDimension(mo
, 800, 600);
65 SWFMovie_setRate (mo
, 1.0);
67 dejagnuclip
= get_dejagnu_clip((SWFBlock
)get_default_font(srcdir
), 10, 0, 0, 800, 600);
68 SWFMovie_add(mo
, (SWFBlock
)dejagnuclip
);
69 SWFMovie_nextFrame(mo
); /* 1st frame - so we can use _root.note */
71 mc_red
= newSWFMovieClip();
72 sh_red
= make_fill_square (0, 300, 60, 60, 255, 0, 0, 255, 0, 0);
73 SWFMovieClip_add(mc_red
, (SWFBlock
)sh_red
);
74 add_clip_actions(mc_red
, " _root.note('frm1 of mc_red - gotoAndStop(2)'); "
75 "x = 'as_in_frm1_of_mc_red'; "
77 SWFMovieClip_nextFrame(mc_red
); /* 1st frame */
78 add_clip_actions(mc_red
, " _root.note('frm2 of mc_red - gotoAndStop(3)'); "
79 "x = 'as_in_frm2_of_mc_red'; "
81 SWFMovieClip_nextFrame(mc_red
); /* 2nd frame */
82 add_clip_actions(mc_red
, " _root.note('frm3 of mc_red - gotoAndStop(4)'); "
83 "x = 'as_in_frm3_of_mc_red'; "
85 SWFMovieClip_nextFrame(mc_red
); /* 3rd frame */
86 SWFMovieClip_nextFrame(mc_red
); /* 4th frame */
89 SWFDisplayItem it_red
;
90 it_red
= SWFMovie_add(mo
, (SWFBlock
)mc_red
);
91 SWFDisplayItem_setDepth(it_red
, 3);
92 SWFDisplayItem_setName(it_red
, "mc_red");
94 add_actions(mo
, " _root.note('frm2 of root - gotoAndStop(3)'); "
95 "mc_red.x = 'as_in_frm2_of_root'; "
97 SWFMovie_nextFrame(mo
); /* 2nd frame */
99 /* mc_red.x has been set after playing the 1st frame, check it here */
100 add_actions(mo
, " check_equals(mc_red.x, 'as_in_frm1_of_mc_red'); "
101 " _root.note('frm3 of root - gotoAndStop(4)');"
102 "mc_red.x = 'as_in_frm3_of_root'; "
104 SWFMovie_nextFrame(mo
); /* 3rd frame */
106 /* mc_red.x has been set again after playing the 2nd frame, check it again */
107 add_actions(mo
, " check_equals(mc_red.x, 'as_in_frm2_of_mc_red'); "
108 " _root.note('frm4 of root - gotoAndStop(5)');"
109 " mc_red.x = \"as_in_frm4_of_root\"; "
110 " gotoAndStop(5); ");
111 SWFMovie_nextFrame(mo
); /* 4th frame */
113 /* mc_red.x has been set again after playing the 3rd frame, check it again */
114 check_equals(mo
, "mc_red.x", "'as_in_frm3_of_mc_red'");
115 add_actions(mo
, " _root.totals(); stop(); ");
116 SWFMovie_nextFrame(mo
); /* 5th frame */
119 puts("Saving " OUTPUT_FILENAME
);
120 SWFMovie_save(mo
, OUTPUT_FILENAME
);