"Fossies" - the Fresh Open Source Software Archive

Member "gnash-0.8.10/testsuite/misc-ming.all/action_order/action_execution_order_test5.c" (19 Jan 2012, 9299 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 3 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  * For nested movieClips:
   23  * (1) parent onLoad called first; 
   24  * (2) child unload called first;  
   25  * (3) child onEnterFrame called first;
   26  *
   27  * yes, parent could be a child of another parent,
   28  *    and child could be a parent of another child:)
   29  * Just always keep (1)(2)(3) in mind.
   30  *
   31  * movieClips hiberarchy:
   32  * _root  (5 frames)
   33  *   |----dejagnuclip(placed at 1st frame of main timeline)
   34  *   |----mc1
   35  *         |----mc11
   36  *         |----mc12
   37  *               |----mc121
   38  *                      |----mc1211    
   39  *
   40  * expected onClipEvents order:
   41  * mc1.OnLoad;
   42  * mc11.OnLoad;
   43  * mc12.OnLoad; mc121.OnLoad; mc1211.OnLoad;
   44  * mc1211.OnEnterFrame; mc121.OnEnterFrame; mc12.OnEnterFrame
   45  * mc11.OnEnterFrame; 
   46  * mc1.OnEnterFrame;
   47  * mc1211.OnUnload; mc121.OnUnload; mc12.OnUnload;
   48  * mc11.OnUnload;
   49  * mc1.OnUnload;
   50  *
   51  * The actual order of tags are dependent on compiler, so you need to 
   52  * verify first if the order of tags is what you expect.  
   53  */
   54 
   55 #include <stdlib.h>
   56 #include <stdio.h>
   57 #include <ming.h>
   58 
   59 #include "ming_utils.h"
   60 
   61 #define OUTPUT_VERSION 6
   62 #define OUTPUT_FILENAME "action_execution_order_test5.swf"
   63 
   64 
   65 int
   66 main(int argc, char** argv)
   67 {
   68   SWFMovie mo;
   69   SWFMovieClip  mc1, mc11, mc12, mc121, mc1211, dejagnuclip;
   70   SWFDisplayItem it1, it11, it12, it121, it1211;
   71 
   72   const char *srcdir=".";
   73   if ( argc>1 ) 
   74     srcdir=argv[1];
   75   else
   76   {
   77       fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
   78       return 1;
   79   }
   80 
   81   Ming_init();
   82   mo = newSWFMovieWithVersion(OUTPUT_VERSION);
   83   SWFMovie_setDimension(mo, 800, 600);
   84   SWFMovie_setRate (mo, 12.0);
   85 
   86   dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
   87   SWFMovie_add(mo, (SWFBlock)dejagnuclip);
   88   SWFMovie_nextFrame(mo); /* 1st frame of _root */
   89 
   90   /*===================== Start of defining movieClips ==========================*/
   91   
   92   mc1211 = newSWFMovieClip();
   93   SWFMovieClip_nextFrame(mc1211); /* mc1211, 1st frame */
   94   SWFMovieClip_nextFrame(mc1211); /* mc1211, 2nd frame */
   95     
   96   mc121 = newSWFMovieClip();
   97   
   98   /* add mc1211 to mc121 and name it as "mc1211" */
   99   it1211 = SWFMovieClip_add(mc121, (SWFBlock)mc1211);  
  100   SWFDisplayItem_setDepth(it1211, 1); 
  101   SWFDisplayItem_setName(it1211, "mc1211"); 
  102   
  103   /* add onClipEvents */
  104   SWFDisplayItem_addAction(it1211, // the inner most child
  105     compileSWFActionCode(" _root.note('mc1211 onInitialize called'); "
  106                          " _root.check_equals(this.__proto__, MovieClip.prototype);"
  107                          " _root.check_equals(this._parent.__proto__, MovieClip.prototype);"
  108                          " _root.check_equals(this._parent._parent.__proto__, MovieClip.prototype);"),
  109     SWFACTION_INIT);
  110 
  111   SWFDisplayItem_addAction(it1211,
  112     compileSWFActionCode(" _root.note('mc1211 onLoad called'); "
  113                          " _root.x1 += '5+'; "),
  114     SWFACTION_ONLOAD);
  115   SWFDisplayItem_addAction(it1211,
  116     compileSWFActionCode(" _root.note('mc1211 onUnload called'); "
  117                          " _root.x1 += '11+'; "),
  118     SWFACTION_UNLOAD);
  119   SWFDisplayItem_addAction(it1211,
  120     compileSWFActionCode(" _root.note('mc1211 onEnterFrame called'); "
  121                          " _root.x1 += '6+'; "),
  122     SWFACTION_ENTERFRAME);
  123     
  124   SWFMovieClip_nextFrame(mc121); /* mc121, 1st frame */
  125   SWFMovieClip_nextFrame(mc121); /* mc121, 2nd frame */
  126 
  127   
  128   mc12 = newSWFMovieClip();
  129   /* add mc121 to mc12 and name it as "mc121" */
  130   it121 = SWFMovieClip_add(mc12, (SWFBlock)mc121);   
  131   SWFDisplayItem_setDepth(it121, 1); 
  132   SWFDisplayItem_setName(it121, "mc121"); 
  133   
  134   /* add onClipEvents */
  135   SWFDisplayItem_addAction(it121,
  136     compileSWFActionCode(" _root.note('mc121 onLoad called'); "
  137                          " _root.x1 += '4+'; "),
  138     SWFACTION_ONLOAD);
  139   SWFDisplayItem_addAction(it121,
  140     compileSWFActionCode(" _root.note('mc121 onUnload called'); "
  141                          " _root.x1 += '12+'; "),
  142     SWFACTION_UNLOAD);
  143   SWFDisplayItem_addAction(it121,
  144     compileSWFActionCode(" _root.note('mc121 onEnterFrame called'); "
  145                          " _root.x1 += '7+'; "),
  146     SWFACTION_ENTERFRAME);
  147     
  148   SWFMovieClip_nextFrame(mc12); /* mc12, 1st frame */
  149   SWFMovieClip_nextFrame(mc12); /* mc12, 2nd frame */
  150   
  151   
  152   mc11 = newSWFMovieClip(); 
  153   SWFMovieClip_nextFrame(mc11); /* mc11, 1st frame */
  154   SWFMovieClip_nextFrame(mc11); /* mc11, 2nd frame */
  155  
  156  
  157   mc1 = newSWFMovieClip();
  158   
  159   /* add mc11 to mc1 and name it as "mc11" */
  160   it11 = SWFMovieClip_add(mc1, (SWFBlock)mc11);   
  161   SWFDisplayItem_setDepth(it11, 2); 
  162   
  163   /* add onClipEvents */
  164   SWFDisplayItem_setName(it11, "mc11"); 
  165     SWFDisplayItem_addAction(it11,
  166     compileSWFActionCode(" _root.note('mc11 onLoad called'); "
  167                          " _root.x1 += '2+'; "),
  168     SWFACTION_ONLOAD);
  169   SWFDisplayItem_addAction(it11,
  170     compileSWFActionCode(" _root.note('mc11 onUnload called'); "
  171                          " _root.x1 += '14+'; "),
  172     SWFACTION_UNLOAD);
  173   SWFDisplayItem_addAction(it11,
  174     compileSWFActionCode(" _root.note('mc11 onEnterFrame called'); "
  175                          " _root.x1 += '9+'; "),
  176     SWFACTION_ENTERFRAME);
  177     
  178   /* add mc12 to mc1 and name it as "mc12" */
  179   it12 = SWFMovieClip_add(mc1, (SWFBlock)mc12);   
  180   SWFDisplayItem_setDepth(it12, 1); 
  181   SWFDisplayItem_setName(it12, "mc12"); 
  182   
  183   /* add onClipEvents */
  184   SWFDisplayItem_addAction(it12, 
  185     compileSWFActionCode(" _root.note('mc12 onInitialize called'); "
  186                          " _root.check_equals(this, _root.mc1.mc12);"
  187                          " _root.check_equals(this.__proto__, MovieClip.prototype);"
  188                          " _root.check_equals(this._parent.__proto__, MovieClip.prototype);"
  189                          " _root.check_equals(this._parent.mc11.__proto__, MovieClip.prototype);"
  190                          // test child __proto__
  191                          " _root.check_equals(this.mc121.__proto__, MovieClip.prototype);"),
  192     SWFACTION_INIT);
  193 
  194   SWFDisplayItem_addAction(it12, // the inner most child
  195     compileSWFActionCode(" _root.note('mc12 onConstruct called'); "
  196                          " _root.check_equals(this, _root.mc1.mc12);"
  197                          " _root.check_equals(this.__proto__, MovieClip.prototype);"
  198                          " _root.check_equals(this._parent.__proto__, MovieClip.prototype);"
  199                          " _root.check_equals(this._parent.mc11.__proto__, MovieClip.prototype);"
  200                          " _root.check_equals(this.mc121.__proto__, MovieClip.prototype);"),
  201     SWFACTION_CONSTRUCT);
  202     
  203   SWFDisplayItem_addAction(it12,
  204     compileSWFActionCode(" _root.note('mc12 onLoad called'); "
  205                          " _root.x1 += '3+'; "),
  206     SWFACTION_ONLOAD);
  207   SWFDisplayItem_addAction(it12,
  208     compileSWFActionCode(" _root.note('mc12 onUnload called'); "
  209                          " _root.x1 += '13+'; "),
  210     SWFACTION_UNLOAD);
  211   SWFDisplayItem_addAction(it12,
  212     compileSWFActionCode(" _root.note('mc12 onEnterFrame called'); "
  213                          "  _root.x1 += '8+'; "),
  214     SWFACTION_ENTERFRAME);
  215     
  216   SWFMovieClip_nextFrame(mc1); /* mc1, 1st frame */
  217   SWFMovieClip_nextFrame(mc1); /* mc1, 2nd frame */
  218   
  219   /*===================== End of defining movieClips ==========================*/
  220   
  221   
  222 
  223   it1 = SWFMovie_add(mo, (SWFBlock)mc1); 
  224   
  225   /* add onClipEvents */
  226   SWFDisplayItem_addAction(it1,
  227     compileSWFActionCode(" _root.note('mc1 onLoad called'); "
  228                          " _root.x1 += '1+'; "),
  229     SWFACTION_ONLOAD);
  230   SWFDisplayItem_addAction(it1,
  231     compileSWFActionCode(" _root.note('mc1 onUnload called'); "
  232                          " _root.x1 += '15+'; "),
  233     SWFACTION_UNLOAD);
  234   SWFDisplayItem_addAction(it1,
  235     compileSWFActionCode(" _root.note('mc1 onEnterFrame called'); "
  236                          " _root.x1 += '10+'; "),
  237     SWFACTION_ENTERFRAME);
  238  
  239   
  240   /* place _root.mc1 */
  241   SWFDisplayItem_setDepth(it1, 10); 
  242   SWFDisplayItem_setName(it1, "mc1"); 
  243   SWFMovie_nextFrame(mo); /* 2nd frame of _root */
  244 
  245 
  246   SWFMovie_nextFrame(mo); /* 3rd frame of _root */
  247   
  248   /* remove _root.mc1 */
  249   SWFDisplayItem_remove(it1);  
  250   SWFMovie_nextFrame(mo); /* 4th frame of _root */
  251 
  252   /* checks */
  253   check_equals(mo, "_root.x1", "'1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+'");
  254   add_actions(mo, " _root.totals(); stop(); ");
  255   SWFMovie_nextFrame(mo); /* 5th frame of _root */
  256   
  257   
  258   //Output movie
  259   puts("Saving " OUTPUT_FILENAME );
  260   SWFMovie_save(mo, OUTPUT_FILENAME);
  261 
  262   return 0;
  263 }