"Fossies" - the Fresh Open Source Software Archive

Member "gnash-0.8.10/testsuite/misc-ming.all/action_order/action_execution_order_test3.c" (19 Jan 2012, 3964 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,
    3  *   2011 Free Software Foundation, Inc.
    4  * 
    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.
    9  * 
   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
   17  *
   18  */ 
   19 
   20 /*
   21  * Zou Lunkai, zoulunkai@gmail.com
   22  *
   23  * Within the same frame, if PlaceObject is after DoAction, then OnLoad is also 
   24  * called after executing actionscripts in DoAction; if RemoveObject is after DoAction, 
   25  * then OnUnload is also called after executing actionscripts in DoAction.
   26  *
   27  * The actual order of tags are dependent on compiler, so you need to 
   28  * verify first if the order of tags is what you expect.
   29  */
   30 
   31 #include <stdlib.h>
   32 #include <stdio.h>
   33 #include <ming.h>
   34 
   35 #include "ming_utils.h"
   36 
   37 #define OUTPUT_VERSION 6
   38 #define OUTPUT_FILENAME "action_execution_order_test3.swf"
   39 
   40 
   41 int
   42 main(int argc, char** argv)
   43 {
   44   SWFMovie mo;
   45   SWFMovieClip  mc_red1, dejagnuclip;
   46   SWFShape  sh_red;
   47 
   48   const char *srcdir=".";
   49   if ( argc>1 ) 
   50     srcdir=argv[1];
   51   else
   52   {
   53       fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
   54       return 1;
   55   }
   56 
   57   Ming_init();
   58   mo = newSWFMovieWithVersion(OUTPUT_VERSION);
   59   SWFMovie_setDimension(mo, 800, 600);
   60   SWFMovie_setRate (mo, 12.0);
   61 
   62   dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
   63   SWFMovie_add(mo, (SWFBlock)dejagnuclip);
   64   SWFMovie_nextFrame(mo); /* 1st frame */
   65 
   66   add_actions(mo, "_root.x1 += \"as_in_DoAction1+\"; ");
   67   add_actions(mo, "_root.x1 += \"as_in_DoAction2+\"; ");
   68   
   69   mc_red1 = newSWFMovieClip();
   70   sh_red = make_fill_square (0, 300, 60, 60, 255, 0, 0, 255, 0, 0);
   71   SWFMovieClip_add(mc_red1, (SWFBlock)sh_red);  
   72   SWFMovieClip_nextFrame(mc_red1); /* mc_red1, 1st frame */
   73    
   74   /* add mc_red1 to _root and name it as "mc_red1" */
   75   SWFDisplayItem it_red1, it_red2;
   76   it_red1 = SWFMovie_add(mo, (SWFBlock)mc_red1);  // PlaceObject2
   77   SWFDisplayItem_setDepth(it_red1, 10); 
   78   SWFDisplayItem_addAction(it_red1,
   79     compileSWFActionCode("_root.x1 += \"onLoadRed1+\";"),
   80     SWFACTION_ONLOAD);
   81   SWFDisplayItem_addAction(it_red1,
   82     compileSWFActionCode("_root.x1 += \"onUnloadRed1+\";"),
   83     SWFACTION_UNLOAD);
   84   SWFDisplayItem_setName(it_red1, "mc_red1"); 
   85 
   86   /* add mc_red1 to _root and name it as "mc_red2" */
   87   it_red2 = SWFMovie_add(mo, (SWFBlock)mc_red1);  // PlaceObject2
   88   SWFDisplayItem_setDepth(it_red2, 11); 
   89   SWFDisplayItem_addAction(it_red2,
   90     compileSWFActionCode("_root.x1 += \"onLoadRed2+\";"),
   91     SWFACTION_ONLOAD);
   92   SWFDisplayItem_addAction(it_red2,
   93     compileSWFActionCode("_root.x1 += \"onUnloadRed2+\";"),
   94     SWFACTION_UNLOAD);
   95   SWFDisplayItem_setName(it_red2, "mc_red2"); 
   96 
   97   SWFMovie_nextFrame(mo); /* 2nd frame */
   98 
   99   add_actions(mo, "_root.x1 += \"as_in_DoAction3+\"; ");
  100   // Don't try to remove mc_red2 before mc_red1, you *can not* control
  101   // this in the source level! Or at least it is more difficult than you imagine.
  102   SWFDisplayItem_remove(it_red1); // RemoveObject2
  103   SWFDisplayItem_remove(it_red2); // RemoveObject2
  104   SWFMovie_nextFrame(mo); /* 3th frame */
  105   
  106   check_equals(mo, "_root.x1", "'as_in_DoAction1+as_in_DoAction2+onLoadRed1+onLoadRed2+as_in_DoAction3+onUnloadRed1+onUnloadRed2+'");
  107   add_actions(mo, " _root.totals(); stop(); ");
  108   SWFMovie_nextFrame(mo); /* 4th frame */
  109 
  110   //Output movie
  111   puts("Saving " OUTPUT_FILENAME );
  112   SWFMovie_save(mo, OUTPUT_FILENAME);
  113 
  114   return 0;
  115 }