"Fossies" - the Fresh Open Source Software Archive

Member "gnash-0.8.10/testsuite/misc-ming.all/action_order/action_execution_order_test6.c" (19 Jan 2012, 7794 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  * To verify that:
   23  *    onClipConstruct, onClipLoad and onClipUnload are triggerd for passing-by MovieClips.
   24  *
   25  * 1st frm of _root
   26  *     place dejagunClip;
   27  * 2nd frm of _root: 
   28  *    gotoAndPlay(9);
   29  * 3rd frm of _root:
   30  *    place mc1 and  mc2;
   31  * 4th frm of _root:
   32  *    record the order of all triggered events and goto the 10th frame
   33  * 5th frm of _root
   34  *    gotoAndPlay(4);
   35  *    remove mc1 and mc2; 
   36  * 6th frm of _root
   37  *    place mc3;
   38  * 7th frm of _root
   39  *    do nothing;
   40  * 8th frm of _root
   41  *    remove mc3;
   42  * 9th frm of _root
   43  *    gotoAndPlay(5);
   44  * 10th frm of _root
   45  *    stop and check
   46  *
   47  * expected actions order:
   48  * At frame2 go forward to frame9:
   49  *   mc1.Construct 
   50  *   mc2.Construct
   51  *   mc3.Construct
   52  *   mc1.Load
   53  *   mc2.Load
   54  *   mc1.Unload
   55  *   mc2.Unload
   56  *   mc3.Load
   57  *   mc3.Unload
   58  * At frame9 go backward to frame5:
   59  *   (no events triggered)
   60  * At frame5 go backward to frame4:
   61  *   mc1.Construct
   62  *   mc2.Construct
   63  *   mc1.Load
   64  *     actions in 1st frame of mc1
   65  *   mc2.Load 
   66  *     actions in 1st frame of mc2
   67  *
   68  * The actual order of tags are dependent on compiler, so you need to 
   69  * verify first if the order of tags is what you expect. 
   70  */
   71 
   72 #include <stdlib.h>
   73 #include <stdio.h>
   74 #include <ming.h>
   75 
   76 #include "ming_utils.h"
   77 
   78 #define OUTPUT_VERSION  7
   79 #define OUTPUT_FILENAME "action_execution_order_test6.swf"
   80 
   81 
   82 int
   83 main(int argc, char** argv)
   84 {
   85   SWFMovie mo;
   86   SWFMovieClip  mc1, mc2, mc3, dejagnuclip;
   87   SWFDisplayItem it1, it2, it3;
   88 
   89   const char *srcdir=".";
   90   if ( argc>1 ) 
   91       srcdir=argv[1];
   92   else
   93   {
   94       fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
   95       return 1;
   96   }
   97 
   98   Ming_init();
   99   mo = newSWFMovieWithVersion(OUTPUT_VERSION);
  100   SWFMovie_setDimension(mo, 800, 600);
  101   SWFMovie_setRate (mo, 1);
  102 
  103   dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
  104   SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  105   SWFMovie_nextFrame(mo); /* 1st frame */
  106   
  107   add_actions(mo, " _root.x1=''; gotoAndPlay(9);");
  108   SWFMovie_nextFrame(mo); /* 2nd frame */
  109   
  110   mc1 = newSWFMovieClip();
  111   add_clip_actions(mc1, " _root.note('actions in 1st frame of mc1'); "
  112                         " _root.x1 += 'x+'; ");
  113   SWFMovieClip_nextFrame(mc1); /* mc1, 1st frame */
  114   add_clip_actions(mc1, " _root.note('actions in 2nd frame of mc1'); "
  115                         " _root.x1 += 'x+'; "
  116                         " stop(); ");
  117   SWFMovieClip_nextFrame(mc1); /* mc1, 2nd frame */
  118  
  119   mc2 = newSWFMovieClip();
  120   add_clip_actions(mc2, " _root.note('actions in 1st frame of mc2'); "
  121                         " _root.x1 += 'xx+'; "); 
  122   SWFMovieClip_nextFrame(mc2); /* mc2, 1st frame */
  123   add_clip_actions(mc2, " _root.note('actions in 2nd frame of mc2'); "
  124                         " _root.x1 += 'xx+'; "
  125                         " stop(); "); 
  126   SWFMovieClip_nextFrame(mc2); /* mc2, 2nd frame */
  127   
  128   mc3 = newSWFMovieClip();
  129   add_clip_actions(mc3, " _root.note('actions in 1st frame of mc3'); "
  130                         " _root.x1 += 'xxx+'; "); 
  131   SWFMovieClip_nextFrame(mc3); /* mc3, 1st frame */
  132   add_clip_actions(mc3, " _root.note('actions in 2nd frame of mc3'); "
  133                         " _root.x1 += 'xxx+'; "
  134                         " stop(); "); 
  135   SWFMovieClip_nextFrame(mc3); /* mc3, 2nd frame */
  136   
  137   
  138   /* add mc1 to _root and name it as "mc1" */
  139   it1 = SWFMovie_add(mo, (SWFBlock)mc1);  
  140   SWFDisplayItem_setDepth(it1, 10); 
  141   SWFDisplayItem_setName(it1, "mc1"); 
  142   /* Define Construct ClipEvent */
  143   SWFDisplayItem_addAction(it1,
  144     compileSWFActionCode(" _root.note('mc1 Construct called');"
  145                          " _root.x1 += '1+'; "),
  146     SWFACTION_CONSTRUCT);
  147   /* Define Load ClipEvent */
  148   SWFDisplayItem_addAction(it1,
  149     compileSWFActionCode(" _root.note('mc1 Load called');"
  150                          " _root.x1 += '4+'; "),
  151     SWFACTION_ONLOAD);
  152   /* Define Unload ClipEvent */
  153   SWFDisplayItem_addAction(it1,
  154     compileSWFActionCode(" _root.note('mc1 Unload called'); "
  155                          " _root.x1 += '6+'; "),
  156     SWFACTION_UNLOAD);
  157   /* Define EnterFrame ClipEvent */
  158   SWFDisplayItem_addAction(it1,
  159     compileSWFActionCode(" _root.note('mc1 EnterFrame called'); "), 
  160     SWFACTION_ENTERFRAME);
  161     
  162   /* add mc2 to _root and name it as "mc2" */
  163   it2 = SWFMovie_add(mo, (SWFBlock)mc2);  
  164   SWFDisplayItem_setDepth(it2, 12); 
  165   SWFDisplayItem_setName(it2, "mc2"); 
  166   /* Define Construct ClipEvent */
  167   SWFDisplayItem_addAction(it2,
  168     compileSWFActionCode(" _root.note('mc2 Construct called');"
  169                          " _root.x1 += '2+'; "),
  170     SWFACTION_CONSTRUCT);
  171   /* Define Load ClipEvent */
  172   SWFDisplayItem_addAction(it2,
  173     compileSWFActionCode(" _root.note('mc2 Load called'); "
  174                          " _root.x1 += '5+'; "),
  175     SWFACTION_ONLOAD);
  176   /* Define Unload ClipEvent */
  177   SWFDisplayItem_addAction(it2,
  178     compileSWFActionCode(" _root.note('mc2 Unload called'); "
  179                          " _root.x1 += '7+'; "),
  180     SWFACTION_UNLOAD);
  181   /* Define EnterFrame ClipEvent */
  182   SWFDisplayItem_addAction(it2,
  183     compileSWFActionCode(" _root.note('mc2 EnterFrame called'); "),
  184     SWFACTION_ENTERFRAME);
  185     
  186   SWFMovie_nextFrame(mo); /* 3rd frame */
  187   
  188   add_actions(mo, " if(flag == 1) { _root.check_result = _root.x1; gotoAndStop(10); } ");
  189   SWFMovie_nextFrame(mo); /* 4th frame */
  190   
  191   add_actions(mo, " gotoAndPlay(4); ");
  192   SWFDisplayItem_remove(it1);
  193   SWFDisplayItem_remove(it2);
  194   SWFMovie_nextFrame(mo); /* 5th frame */
  195   
  196   /* add mc3 to _root and name it as "mc3" */
  197   it3 = SWFMovie_add(mo, (SWFBlock)mc3);  
  198   SWFDisplayItem_setDepth(it3, 11); 
  199   SWFDisplayItem_setName(it3, "mc3"); 
  200   /* Define Construct ClipEvent */
  201   SWFDisplayItem_addAction(it3,
  202     compileSWFActionCode(" _root.note('mc3 Construct called');"
  203                          " _root.x1 += '3+'; "),
  204     SWFACTION_CONSTRUCT);
  205   /* Define Load ClipEvent */
  206   SWFDisplayItem_addAction(it3,
  207     compileSWFActionCode(" _root.note('mc3 Load called'); "
  208                          " _root.x1 += '8+'; "),
  209     SWFACTION_ONLOAD);
  210   /* Define Unload ClipEvent */
  211   SWFDisplayItem_addAction(it3,
  212     compileSWFActionCode(" _root.note('mc3 Unload called'); "
  213                          " _root.x1 += '9+';" ),
  214     SWFACTION_UNLOAD);
  215   /* Define EnterFrame ClipEvent */
  216   SWFDisplayItem_addAction(it3,
  217     compileSWFActionCode(" _root.note('mc3 EnterFrame called'); "),
  218     SWFACTION_ENTERFRAME);
  219   
  220   SWFMovie_nextFrame(mo); /* 6th frame */
  221   SWFMovie_nextFrame(mo); /* 7th frame */
  222 
  223   SWFDisplayItem_remove(it3); 
  224   SWFMovie_nextFrame(mo); /* 8th frame */
  225   
  226   add_actions(mo, " gotoAndPlay(5); flag = 1;");
  227   SWFMovie_nextFrame(mo); /* 9th frame */
  228   
  229   xcheck_equals(mo, "_root.check_result", "'1+2+3+4+5+6+7+8+9+1+2+4+x+5+xx+'");
  230   add_actions(mo, " _root.totals(); stop(); ");
  231   SWFMovie_nextFrame(mo); /* 10th frame */
  232   
  233   //Output movie
  234   puts("Saving " OUTPUT_FILENAME );
  235   SWFMovie_save(mo, OUTPUT_FILENAME);
  236 
  237   return 0;
  238 }
  239 
  240 
  241