2 * Copyright (C) 2005, 2006, 2009, 2010, 2011 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 * Test "Jumping backward to the start of two DisplayObject's lifetime after depth swap"
24 * Frame | 1 | 2 | 3 | 4 |
25 * --------+---+---+---+---+
26 * Event | |PP*| M | J |
28 * P = place (by PlaceObject2)
29 * M = move to another depth (by swapDepth)
35 * frame2: two static DisplayObjects are placed
36 * frame3: the two DisplayObjects are depth-swapped
37 * frame4: jump to frame 2 and stop.
41 * A single instance of each DisplayObjects is created.
42 * First time in frame1 depths are the original ones,
43 * second time depths are swapped.
53 #include "ming_utils.h"
55 #define OUTPUT_VERSION 6
56 #define OUTPUT_FILENAME "loop_test2.swf"
60 main(int argc
, char** argv
)
63 SWFMovieClip mc1
, mc2
, dejagnuclip
;
66 const char *srcdir
=".";
71 //fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
76 Ming_useSWFVersion (OUTPUT_VERSION
);
79 SWFMovie_setDimension(mo
, 800, 600);
80 SWFMovie_setRate(mo
, 2);
82 // Frame 1: Place dejagnu clip
84 dejagnuclip
= get_dejagnu_clip((SWFBlock
)get_default_font(srcdir
), 10, 0, 0, 800, 600);
85 SWFMovie_add(mo
, (SWFBlock
)dejagnuclip
);
86 SWFMovie_nextFrame(mo
);
88 // Frame 2: Place two static DisplayObjects
90 sh1
= make_fill_square (300, 300, 60, 60, 255, 0, 0, 255, 0, 0);
91 mc1
= newSWFMovieClip();
92 SWFMovieClip_add(mc1
, (SWFBlock
)sh1
);
93 SWFMovieClip_nextFrame(mc1
);
95 sh2
= make_fill_square (330, 270, 120, 120, 0, 0, 0, 0, 0, 0);
96 mc2
= newSWFMovieClip();
97 SWFMovieClip_add(mc2
, (SWFBlock
)sh2
);
98 SWFMovieClip_nextFrame(mc2
);
100 SWFDisplayItem it1
, it2
;
101 it1
= SWFMovie_add(mo
, (SWFBlock
)mc1
); //add movieClip1 to the _root
102 SWFDisplayItem_setName(it1
, "movieClip1"); //name movieClip1
103 SWFDisplayItem_addAction(it1
, newSWFAction(
104 "_root.note(this+' constructed');"
105 "_root.mc1Constructed++;"
106 ), SWFACTION_CONSTRUCT
);
108 it2
= SWFMovie_add(mo
, (SWFBlock
)mc2
); //add movieClip2 to the _root
109 SWFDisplayItem_setName(it2
, "movieClip2"); //name movieClip2
110 SWFDisplayItem_addAction(it2
, newSWFAction(
111 "_root.note(this+' constructed');"
112 "_root.mc2Constructed++;"),
113 SWFACTION_CONSTRUCT
);
115 SWFMovie_nextFrame(mo
);
117 // Frame3: swap depths
119 SWFMovie_add(mo
, (SWFBlock
)newSWFAction(
120 "var mc1_depth = movieClip1.getDepth();"
121 "var mc2_depth = movieClip2.getDepth();"
122 "movieClip1.secretCode = 'mc1';"
123 "movieClip2.secretCode = 'mc2';"
124 "movieClip1.swapDepths(movieClip2);"
125 "check_equals(movieClip1.getDepth(), mc2_depth);"
126 "check_equals(movieClip2.getDepth(), mc1_depth);"
127 "check_equals(movieClip1.secretCode, 'mc1');"
128 "check_equals(movieClip2.secretCode, 'mc2');"
131 SWFMovie_nextFrame(mo
);
133 // Frame4: gotoAndStop(2), check..
135 SWFMovie_add(mo
, (SWFBlock
)newSWFAction(
139 // Depths have not be restored
140 // (gnash fails because create new instnaces instead)
141 "check_equals(movieClip1.getDepth(), mc2_depth);"
142 "check_equals(movieClip2.getDepth(), mc1_depth);"
144 // They are still the same instance
145 // (gnash fails because create new instnaces instead)
146 "check_equals(movieClip1.secretCode, 'mc1');"
147 "check_equals(movieClip2.secretCode, 'mc2');"
149 // Chars have not been reconstructed
150 // (gnash fails because create new instnaces instead)
151 "check_equals(mc1Constructed, 1);"
152 "check_equals(mc2Constructed, 1);"
157 SWFMovie_nextFrame(mo
);
160 puts("Saving " OUTPUT_FILENAME
);
161 SWFMovie_save(mo
, OUTPUT_FILENAME
);