"Fossies" - the Fresh Open Source Software Archive

Member "gnash-0.8.10/testsuite/misc-ming.all/action_order/action_execution_order_test1.c" (19 Jan 2012, 4486 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  * Within the same frame, ActionScript in DoAction tags can referance movieClip 
   23  * placed after DoAction tags. 
   24  *
   25  * Within the same frame, ActionScript in onClipLoad handlers can referance
   26  * movieClip placed after the PlaceObject2 tag defining the clip event. 
   27  *
   28  * The actual order of tags are dependent on compiler, so you need to 
   29  * verify first if the order of tags is what you expect.
   30  */
   31 
   32 #include <stdlib.h>
   33 #include <stdio.h>
   34 #include <ming.h>
   35 
   36 #include "ming_utils.h"
   37 
   38 #define OUTPUT_VERSION 6
   39 #define OUTPUT_FILENAME "action_execution_order_test1.swf"
   40 
   41 
   42 int
   43 main(int argc, char** argv)
   44 {
   45   SWFMovie mo;
   46   SWFMovieClip  mc_red, mc_blu, dejagnuclip;
   47   SWFShape  sh_red, sh_blu;
   48   SWFDisplayItem it_red, it_blu;
   49 
   50   const char *srcdir=".";
   51   if ( argc>1 ) 
   52     srcdir=argv[1];
   53   else
   54   {
   55       fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
   56       return 1;
   57   }
   58 
   59   Ming_init();
   60   mo = newSWFMovieWithVersion(OUTPUT_VERSION);
   61   SWFMovie_setDimension(mo, 800, 600);
   62   SWFMovie_setRate (mo, 12.0);
   63 
   64   dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
   65   SWFMovie_add(mo, (SWFBlock)dejagnuclip);
   66   SWFMovie_nextFrame(mo); /* 1st frame */
   67 
   68   /* This will add a DoAction Tag, which be compiled before PlaceObject(mc_red) tag. */
   69   check_equals(mo, "typeof(_root.mc_red)", "'movieclip'");
   70   
   71   mc_red = newSWFMovieClip();
   72   sh_red = make_fill_square (0, 300, 60, 60, 255, 0, 0, 255, 0, 0);
   73   SWFMovieClip_add(mc_red, (SWFBlock)sh_red);  
   74   SWFMovieClip_nextFrame(mc_red);//1st frame
   75 
   76   mc_blu = newSWFMovieClip();
   77   sh_blu = make_fill_square (0, 300, 60, 60, 0, 0, 255, 0, 0, 255);
   78   SWFMovieClip_add(mc_blu, (SWFBlock)sh_blu);  
   79   SWFMovieClip_nextFrame(mc_blu);//1st frame
   80  
   81   /*
   82    * Add mc_red to _root and name it as "mc_red"
   83    * Have onClipLoad reference mc_blu (yet to be placed)
   84    */
   85   it_red = SWFMovie_add(mo, (SWFBlock)mc_red);  
   86   SWFDisplayItem_addAction(it_red,
   87     compileSWFActionCode(
   88     "_root.mcRedLoadCalls++;"
   89     "_root.typeofMcBluFromMcRedLoad = typeof(_root.mc_blu);"
   90         "_root.typeofMcRedFromMcRedLoad = typeof(_root.mc_red);"
   91     ), SWFACTION_ONLOAD);
   92   SWFDisplayItem_setDepth(it_red, 3); 
   93   SWFDisplayItem_setName(it_red, "mc_red"); 
   94 
   95   /*
   96    * Add mc_blu to _root and name it as "mc_blu"
   97    * Have onClipLoad reference mc_red (placed before)
   98    */
   99   it_blu = SWFMovie_add(mo, (SWFBlock)mc_blu);  
  100   SWFDisplayItem_addAction(it_blu,
  101     compileSWFActionCode(
  102     "_root.mcBluLoadCalls++;"
  103     "_root.typeofMcRedFromMcBluLoad = typeof(_root.mc_red);"
  104         "_root.typeofMcBluFromMcBluLoad = typeof(_root.mc_blu);"
  105     ), SWFACTION_ONLOAD);
  106   SWFDisplayItem_setDepth(it_blu, 4); 
  107   SWFDisplayItem_setName(it_blu, "mc_blu"); 
  108   SWFDisplayItem_moveTo(it_blu, 200, 0);
  109 
  110   SWFMovie_nextFrame(mo); /* 2nd frame */
  111 
  112   // onLoad handler for mc_red DO can see mc_blu (not yet placed)
  113   check_equals(mo, "_root.typeofMcBluFromMcRedLoad", "'movieclip'");
  114 
  115   // onLoad handler for mc_red DO can see itself 
  116   check_equals(mo, "_root.typeofMcRedFromMcRedLoad", "'movieclip'");
  117 
  118   // onLoad handler for mc_blu DO can see mc_red (placed before)
  119   check_equals(mo, "_root.typeofMcRedFromMcBluLoad", "'movieclip'");
  120 
  121   // onLoad handler for mc_blu DO can see itself 
  122   check_equals(mo, "_root.typeofMcBluFromMcBluLoad", "'movieclip'");
  123 
  124   // onLoad handlers of mc_red and mc_blu called once
  125   check_equals(mo, "_root.mcBluLoadCalls", "1");
  126   check_equals(mo, "_root.mcRedLoadCalls", "1");
  127 
  128   add_actions(mo, " _root.totals(); stop(); ");
  129   SWFMovie_nextFrame(mo); /* 3rd frame */
  130 
  131   //Output movie
  132   puts("Saving " OUTPUT_FILENAME );
  133   SWFMovie_save(mo, OUTPUT_FILENAME);
  134 
  135   return 0;
  136 }
  137 
  138 
  139