"Fossies" - the Fresh Open Source Software Archive

Member "gnash-0.8.10/testsuite/misc-ming.all/action_order/action_execution_order_test11.c" (19 Jan 2012, 9200 Bytes) of package /linux/www/old/gnash-0.8.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2  *   Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
    3  * 
    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 2 of the License, or
    7  * (at your option) any later version.
    8  * 
    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
   16  *
   17  */ 
   18 
   19 /*
   20  * Zou Lunkai, zoulunkai@gmail.com
   21  * 
   22  * movieclips hiberarchy:
   23  *
   24  *   _root.frame2.mc1;  
   25  *   _root.frame2.mc2;  
   26  
   27  *     mc1.frame2.mc11
   28  *     mc1.frame4.mc12
   29  *     mc1.frame5.DoAction
   30  *
   31  *       mc2.frame3.mc21
   32  *       mc2.frame5.DoAction
   33  * 
   34  *       mc11.frame4.DoAction
   35  *       mc12.frame2.DoAction
   36  *       mc21.frame3.DoAction
   37  *
   38  * This file is complex, but completely sane.
   39  * It is used to test complex actions order. If passed, then congratulations:)!
   40  */
   41 
   42 #include <stdlib.h>
   43 #include <stdio.h>
   44 #include <ming.h>
   45 
   46 #include "ming_utils.h"
   47 
   48 #define OUTPUT_VERSION 7
   49 #define OUTPUT_FILENAME "action_execution_order_test11.swf"
   50 
   51 
   52 int
   53 main(int argc, char** argv)
   54 {
   55   SWFMovie mo;
   56   SWFMovieClip  mc1, mc11, mc12, mc2, mc21, dejagnuclip;
   57   SWFDisplayItem it1, it11, it12, it2, it21;
   58 
   59   const char *srcdir=".";
   60   if ( argc>1 ) 
   61     srcdir=argv[1];
   62   else
   63   {
   64       fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
   65       return 1;
   66   }
   67 
   68   Ming_init();
   69   mo = newSWFMovieWithVersion(OUTPUT_VERSION);
   70   SWFMovie_setDimension(mo, 800, 600);
   71   SWFMovie_setRate (mo, 12.0);
   72 
   73   dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
   74   SWFMovie_add(mo, (SWFBlock)dejagnuclip);
   75   add_actions(mo, " _root.loadOrder = '0+'; "
   76                   " _root.enterFrameOrder = '0+'; "
   77                   " _root.unloadOrder = '0+'; "
   78                   " _root.doActionOrder = '0+'; "
   79                   " _root.asOrder = '0+'; ");
   80   SWFMovie_nextFrame(mo); // _root frame 1
   81 
   82   /*===================== Start of defining movieClips ==========================*/
   83   mc11 = newSWFMovieClip();
   84   SWFMovieClip_nextFrame(mc11);  // mc11 frame1
   85   SWFMovieClip_nextFrame(mc11);  // mc11 frame2
   86   SWFMovieClip_nextFrame(mc11);  // mc11 frame3
   87   add_clip_actions(mc11, "_root.doActionOrder += '3+'; "
   88                          "_root.asOrder += '27+';");
   89   SWFMovieClip_nextFrame(mc11);  // mc11 frame4
   90 
   91 
   92   mc12 = newSWFMovieClip();
   93   SWFMovieClip_nextFrame(mc12); // mc12 frame1
   94   add_clip_actions(mc12, "_root.doActionOrder += '1+'; "
   95                          "_root.asOrder += '25+'; ");
   96   SWFMovieClip_nextFrame(mc12); // mc12 frame2
   97     
   98   mc1 = newSWFMovieClip();
   99   SWFMovieClip_nextFrame(mc1);  // mc1 frame1
  100   it11 = SWFMovieClip_add(mc1, (SWFBlock)mc11); 
  101   SWFDisplayItem_setName(it11, "mc11"); 
  102   // clip actions for mc11
  103   SWFDisplayItem_addAction(it11,
  104     compileSWFActionCode(" _root.note('mc11 onLoad called'); "
  105                          " _root.loadOrder += '3+'; "
  106                          " _root.asOrder += '5+'; "),
  107     SWFACTION_ONLOAD);
  108   SWFDisplayItem_addAction(it11,
  109     compileSWFActionCode(" _root.note('mc11 onEnterFrame called'); "
  110                          " _root.enterFrameOrder += '3+'; "
  111                          " _root.asOrder += '6+';"),
  112     SWFACTION_ENTERFRAME);
  113   SWFDisplayItem_addAction(it11,
  114     compileSWFActionCode(" _root.note('mc11 onUnload called'); "
  115                          " _root.unloadOrder += '1+'; "
  116                          " _root.asOrder += '20+';"),
  117     SWFACTION_UNLOAD);
  118   SWFMovieClip_nextFrame(mc1);  // mc1 frame2
  119   SWFMovieClip_nextFrame(mc1);  // mc1 frame3
  120   it12 = SWFMovieClip_add(mc1, (SWFBlock)mc12); 
  121   SWFDisplayItem_setName(it12, "mc12"); 
  122   // clip actions for mc12
  123   SWFDisplayItem_addAction(it12,
  124     compileSWFActionCode(" _root.note('mc12 onLoad called'); "
  125                          "  _root.loadOrder += '5+'; "
  126                          " _root.asOrder += '14+';"),
  127     SWFACTION_ONLOAD);
  128   SWFDisplayItem_addAction(it12,
  129     compileSWFActionCode(" _root.note('mc12 onEnterFrame called'); "
  130                          " _root.enterFrameOrder += '5+'; "
  131                          " _root.asOrder += '15+'; "),
  132     SWFACTION_ENTERFRAME);
  133   SWFDisplayItem_addAction(it12,
  134     compileSWFActionCode(" _root.note('mc12 onUnload called'); "
  135                          " _root.unloadOrder += '2+'; "
  136                          " _root.asOrder += '21+'; "),
  137     SWFACTION_UNLOAD);
  138   SWFMovieClip_nextFrame(mc1);  // mc1 frame4
  139   add_clip_actions(mc1, "_root.doActionOrder += '5+';"
  140                         " _root.asOrder += '29+'; ");
  141   SWFMovieClip_nextFrame(mc1);  // mc1 frame5
  142   SWFMovieClip_nextFrame(mc1);  // mc1 frame6
  143   
  144   mc21 = newSWFMovieClip();
  145   SWFMovieClip_nextFrame(mc21); // mc21 frame1
  146   SWFMovieClip_nextFrame(mc21); // mc21 frame2
  147   add_clip_actions(mc21, "_root.doActionOrder += '2+';"
  148                          "_root.asOrder += '26+'; ");
  149   SWFMovieClip_nextFrame(mc21); // mc21 frame3
  150   
  151   mc2 = newSWFMovieClip();
  152   SWFMovieClip_nextFrame(mc2);  // mc2 frame1
  153   SWFMovieClip_nextFrame(mc2);  // mc2 frame2
  154   it21 = SWFMovieClip_add(mc2, (SWFBlock)mc21); 
  155   SWFDisplayItem_setName(it21, "mc21"); 
  156   // clip actions for mc21
  157   SWFDisplayItem_addAction(it21,
  158     compileSWFActionCode(" _root.note('mc21 onLoad called'); "
  159                          " _root.loadOrder += '4+'; "
  160                          " _root.asOrder += '8+';"),
  161     SWFACTION_ONLOAD);
  162   SWFDisplayItem_addAction(it21,
  163     compileSWFActionCode(" _root.note('mc21 onEnterFrame called'); "
  164                          "  _root.enterFrameOrder += '4+'; "
  165                          " _root.asOrder += '10+'; "),
  166     SWFACTION_ENTERFRAME);
  167   SWFDisplayItem_addAction(it21,
  168     compileSWFActionCode(" _root.note('mc21 onUnload called'); "
  169                          " _root.unloadOrder += '4+'; "
  170                          " _root.asOrder += '23+'; "),
  171     SWFACTION_UNLOAD);
  172   SWFMovieClip_nextFrame(mc2);  // mc2 frame3
  173   SWFMovieClip_nextFrame(mc2);  // mc2 frame4
  174   add_clip_actions(mc2, "_root.doActionOrder += '4+';"
  175                         "_root.asOrder += '28+';");
  176   SWFMovieClip_nextFrame(mc2);  // mc2 frame5
  177   SWFMovieClip_nextFrame(mc2);  // mc2 frame6
  178   
  179   // Place mc1 and mc2 and add clipEvents for them.
  180   it1 = SWFMovie_add(mo, (SWFBlock)mc1);  
  181   SWFDisplayItem_setName(it1, "mc1"); 
  182   it2 = SWFMovie_add(mo, (SWFBlock)mc2); 
  183   SWFDisplayItem_setName(it2, "mc2");   
  184   
  185   // clip actions for mc1
  186   SWFDisplayItem_addAction(it1,
  187     compileSWFActionCode(" _root.note('mc1 onLoad called'); "
  188                          " _root.loadOrder += '1+'; "
  189                          " _root.asOrder += '1+'; "),
  190     SWFACTION_ONLOAD);
  191   SWFDisplayItem_addAction(it1,
  192     compileSWFActionCode(" _root.note('mc1 onEnterFrame called'); "
  193                          " _root.enterFrameOrder += '1+'; "
  194                          " _root.asOrder += '4+'; "),
  195     SWFACTION_ENTERFRAME);
  196   SWFDisplayItem_addAction(it1,
  197     compileSWFActionCode(" _root.note('mc1 onUnload called'); "
  198                          " _root.unloadOrder += '3+'; "
  199                          " _root.asOrder += '22+'; "),
  200     SWFACTION_UNLOAD);
  201 
  202   
  203   // clip actions for mc2
  204   SWFDisplayItem_addAction(it2,
  205     compileSWFActionCode(" _root.note('mc2 onLoad called'); "
  206                          " _root.loadOrder += '2+'; "
  207                          " _root.asOrder += '2+'; "),
  208     SWFACTION_ONLOAD);
  209   SWFDisplayItem_addAction(it2,
  210     compileSWFActionCode(" _root.note('mc2 onEnterFrame called'); "
  211                          " _root.enterFrameOrder += '2+'; "
  212                          " _root.asOrder += '3+'; "),
  213     SWFACTION_ENTERFRAME);
  214   SWFDisplayItem_addAction(it2,
  215     compileSWFActionCode(" _root.note('mc2 onUnload called'); "
  216                          " _root.unloadOrder += '5+';"
  217                          " _root.asOrder += '24+'; "),
  218     SWFACTION_UNLOAD);
  219   
  220   SWFMovie_nextFrame(mo); // _root frame 2
  221   /*===================== End of defining movieClips ==========================*/
  222   
  223   SWFMovie_nextFrame(mo); // _root frame3
  224   
  225   SWFMovie_nextFrame(mo); // _root frame4
  226   
  227   SWFMovie_nextFrame(mo); // _root frame5
  228   
  229   SWFMovie_nextFrame(mo); // _root frame6
  230 
  231   SWFDisplayItem_remove(it1);  
  232   SWFDisplayItem_remove(it2);
  233   SWFMovie_nextFrame(mo); // _root frame7
  234   
  235   check_equals(mo, "_root.loadOrder", "'0+1+2+3+4+5+'");
  236   check_equals(mo, "_root.enterFrameOrder", "'0+2+1+3+2+1+4+3+2+1+5+4+3+2+1+'");
  237   check_equals(mo, "_root.unloadOrder", "'0+1+2+3+4+5+'");
  238   check_equals(mo, "_root.doActionOrder", "'0+1+2+3+4+5+'");
  239   check_equals(mo, "_root.asOrder", "'0+1+2+3+4+5+6+3+8+4+10+6+3+4+14+15+25+10+26+6+27+3+28+4+29+20+21+22+23+24+'");
  240   add_actions(mo, " _root.totals(); stop(); ");
  241   SWFMovie_nextFrame(mo); // _root frame8
  242   
  243   //Output movie
  244   puts("Saving " OUTPUT_FILENAME );
  245   SWFMovie_save(mo, OUTPUT_FILENAME);
  246 
  247   return 0;
  248 }