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
23 * This file was intended to test reverse execution of frame tags.
24 * However, the concept of reverse execution may be deprecated someday.
30 * frame6: remove mc and goto frame5
38 #include "ming_utils.h"
40 #define OUTPUT_VERSION 6
41 #define OUTPUT_FILENAME "reverse_execute_PlaceObject2_test2.swf"
45 main(int argc
, char** argv
)
48 SWFMovieClip mc
, dejagnuclip
;
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 add_actions(mo
, " _root.x1 = ''; _root.x2 = ''; ");
68 SWFMovie_nextFrame(mo
); /* 1st frame */
71 mc
= newSWFMovieClip();
72 sh
= make_fill_square (0, 0, 60, 60, 255, 0, 0, 255, 0, 0);
73 SWFMovieClip_add(mc
, (SWFBlock
)sh
);
74 SWFMovieClip_nextFrame(mc
);//1st frame
76 /* add mc to _root and name it as "mc" */
78 it
= SWFMovie_add(mo
, (SWFBlock
)mc
);
79 SWFDisplayItem_setDepth(it
, 10);
81 SWFDisplayItem_addAction(it
,
82 compileSWFActionCode(" _root.x1 += 'onLoad+'; "),
84 SWFDisplayItem_addAction(it
,
85 compileSWFActionCode(" _root.x2 += 'onUnload+'; "),
88 SWFDisplayItem_setName(it
, "mc");
89 check_equals(mo
, "_root.mc._x", "0");
90 SWFMovie_nextFrame(mo
); /* 2nd frame */
92 check_equals(mo
, "_root.mc._x", "300");
93 SWFDisplayItem_move(it
, 300.0, 300.0);
94 SWFMovie_nextFrame(mo
); /* 3rd frame */
96 check_equals(mo
, "_root.mc._x", "900");
97 SWFDisplayItem_move(it
, 600.0, 600.0);
98 SWFMovie_nextFrame(mo
); /* 4th frame */
100 check_equals(mo
, "_root.mc._x", "900");
101 SWFMovie_nextFrame(mo
); /* 5th frame */
103 SWFDisplayItem_remove(it
);
104 add_actions(mo
, " if(stopflag != 1) gotoAndPlay(5); stopflag = 1; ");
105 SWFMovie_nextFrame(mo
); /* 6th frame */
108 check_equals(mo
, "_root.x1", "'onLoad+onLoad+'" );
109 check_equals(mo
, "_root.x2", "'onUnload+onUnload+'" );
110 add_actions(mo
, " _root.totals(); stop(); ");
111 SWFMovie_nextFrame(mo
); /* 7th frame */
114 puts("Saving " OUTPUT_FILENAME
);
115 SWFMovie_save(mo
, OUTPUT_FILENAME
);