gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog testsuite/misc-ming.all/Makefil...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog testsuite/misc-ming.all/Makefil...
Date: Thu, 10 May 2007 13:50:44 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/05/10 13:50:44

Modified files:
        .              : ChangeLog 
        testsuite/misc-ming.all: Makefile.am 
Added files:
        testsuite/misc-ming.all: SpriteButtonEventsTest-Runner.cpp 
                                 SpriteButtonEventsTest.c 

Log message:
                * testsuite/misc-ming.all/: Makefile.am,
                  SpriteButtonEventsTest-Runner.cpp, SpriteButtonEventsTest.c:
                  Produced a MovieClip versio of the ButtonEventTest.swf movie.
                  Seems to work fine, test automated.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3154&r2=1.3155
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/Makefile.am?cvsroot=gnash&r1=1.105&r2=1.106
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/SpriteButtonEventsTest-Runner.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/SpriteButtonEventsTest.c?cvsroot=gnash&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3154
retrieving revision 1.3155
diff -u -b -r1.3154 -r1.3155
--- ChangeLog   10 May 2007 13:14:41 -0000      1.3154
+++ ChangeLog   10 May 2007 13:50:44 -0000      1.3155
@@ -1,5 +1,12 @@
 2007-05-10 Sandro Santilli <address@hidden>
 
+       * testsuite/misc-ming.all/: Makefile.am,
+         SpriteButtonEventsTest-Runner.cpp, SpriteButtonEventsTest.c:
+         Produced a MovieClip versio of the ButtonEventTest.swf movie.
+         Seems to work fine, test automated.
+
+2007-05-10 Sandro Santilli <address@hidden>
+
        * server/event_id.h, server/vm/action.cpp: add
          event_id::is_button_event() method
        * server/sprite_instance.{cpp,h}: add isEnabled() method,

Index: testsuite/misc-ming.all/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/Makefile.am,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -b -r1.105 -r1.106
--- testsuite/misc-ming.all/Makefile.am 9 May 2007 22:02:42 -0000       1.105
+++ testsuite/misc-ming.all/Makefile.am 10 May 2007 13:50:44 -0000      1.106
@@ -55,6 +55,8 @@
 check_PROGRAMS = \
        ButtonEventsTest \
        ButtonEventsTest-Runner \
+       SpriteButtonEventsTest \
+       SpriteButtonEventsTest-Runner \
        DefineEditTextTest \
        DefineEditTextVariableNameTest \
        DefineEditTextVariableNameTest-Runner \
@@ -908,6 +910,28 @@
        -DTGTDIR='"$(abs_builddir)"' \
        $(NULL)
 
+SpriteButtonEventsTest_SOURCES =       \
+       SpriteButtonEventsTest.c        \
+       ming_utils.h    \
+       ming_utils.c    \
+       $(NULL)
+SpriteButtonEventsTest_LDADD = $(MING_LIBS)
+SpriteButtonEventsTest.swf: SpriteButtonEventsTest
+       ./SpriteButtonEventsTest $(top_srcdir)/testsuite/media
+SpriteButtonEventsTest_Runner_SOURCES = \
+       SpriteButtonEventsTest-Runner.cpp \
+       $(NULL)
+SpriteButtonEventsTest_Runner_LDADD = \
+       $(top_builddir)/testsuite/libtestsuite.la \
+       $(NULL)
+SpriteButtonEventsTest_Runner_DEPENDENCIES = \
+       $(top_builddir)/testsuite/libtestsuite.la \
+       SpriteButtonEventsTest.swf      \
+       $(NULL)
+SpriteButtonEventsTest_Runner_CXXFLAGS = \
+       -DTGTDIR='"$(abs_builddir)"' \
+       $(NULL)
+
 loadMovieTest_SOURCES =        \
        loadMovieTest.c \
        ming_utils.h    \
@@ -1084,6 +1108,7 @@
        DefineEditTextVariableNameTest-Runner \
        RollOverOutTest-Runner \
        ButtonEventsTest-Runner \
+       SpriteButtonEventsTest-Runner \
        timeline_var_test-Runner \
        root_stop_testrunner \
        loop_test-Runner \

Index: testsuite/misc-ming.all/SpriteButtonEventsTest-Runner.cpp
===================================================================
RCS file: testsuite/misc-ming.all/SpriteButtonEventsTest-Runner.cpp
diff -N testsuite/misc-ming.all/SpriteButtonEventsTest-Runner.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/SpriteButtonEventsTest-Runner.cpp   10 May 2007 
13:50:44 -0000      1.1
@@ -0,0 +1,257 @@
+/* 
+ *   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ *
+ */ 
+
+#define INPUT_FILENAME "ButtonEventsTest.swf"
+
+#include "MovieTester.h"
+#include "sprite_instance.h"
+#include "character.h"
+#include "dlist.h"
+#include "container.h"
+#include "log.h"
+
+#include "check.h"
+#include <string>
+#include <cassert>
+
+using namespace gnash;
+using namespace std;
+
+void
+test_mouse_activity(MovieTester& tester, const character* text, const 
character* text2, bool covered, bool enabled)
+{
+       rgba red(255,0,0,255);
+       rgba covered_red(127,126,0,255); // red, covered by 50% black
+       rgba yellow(255,255,0,255);
+       rgba covered_yellow(128,255,0,255); // yellow, covered by 50% black
+       rgba green(0,255,0,255);
+
+       // roll over the middle of the square, this should change
+       // the textfield value, if enabled
+       tester.movePointerTo(60, 60);
+       if ( enabled ) {
+               check_equals(string(text->get_text_value()), 
string("MouseOver"));
+               check_equals(string(text2->get_text_value()), 
string("RollOver"));
+               check(tester.isMouseOverMouseEntity());
+               // check that pixel @ 60,60 is yellow !
+               if ( covered ) { check_pixel(60, 60, 2, covered_yellow, 2);  }
+               else { check_pixel(60, 60, 2, yellow, 2);  }
+       } else {
+               check_equals(string(text->get_text_value()), 
string("MouseOut"));
+               check_equals(string(text2->get_text_value()), 
string("RollOut"));
+               check(!tester.isMouseOverMouseEntity());
+               // check that pixel @ 60,60 is red !
+               if ( covered ) { check_pixel(60, 60, 2, covered_red, 2);  }
+               else { check_pixel(60, 60, 2, red, 2);  }
+       }
+
+       // press the mouse button, this should change
+       // the textfield value, if enabled.
+       tester.pressMouseButton();
+       if ( enabled ) {
+               check_equals(string(text->get_text_value()), 
string("MouseDown"));
+               check_equals(string(text2->get_text_value()), string("Press"));
+               check(tester.isMouseOverMouseEntity());
+               // check that pixel @ 60,60 is green !
+               check_pixel(60, 60, 2, green, 2);
+       } else {
+               check_equals(string(text->get_text_value()), 
string("MouseOut"));
+               check_equals(string(text2->get_text_value()), 
string("RollOut"));
+               check(!tester.isMouseOverMouseEntity());
+               // check that pixel @ 60,60 is red !
+               if ( covered ) { check_pixel(60, 60, 2, covered_red, 2);  }
+               else { check_pixel(60, 60, 2, red, 2);  }
+       }
+
+       // depress the mouse button, this should change
+       // the textfield value, if enabled
+       tester.depressMouseButton();
+       if ( enabled ) {
+               check_equals(string(text->get_text_value()), string("MouseUp"));
+               check_equals(string(text2->get_text_value()), 
string("Release"));
+               check(tester.isMouseOverMouseEntity());
+               // check that pixel @ 60,60 is yellow !
+               if ( covered ) { check_pixel(60, 60, 2, covered_yellow, 2);  }
+               else { check_pixel(60, 60, 2, yellow, 2);  }
+       } else {
+               check_equals(string(text->get_text_value()), 
string("MouseOut"));
+               check_equals(string(text2->get_text_value()), 
string("RollOut"));
+               check(!tester.isMouseOverMouseEntity());
+               // check that pixel @ 60,60 is red !
+               if ( covered ) { check_pixel(60, 60, 2, covered_red, 2);  }
+               else { check_pixel(60, 60, 2, red, 2);  }
+       }
+
+       // roll off the square, this should change
+       // the textfield value, if enabled
+       tester.movePointerTo(39, 60);
+       check_equals(string(text->get_text_value()), string("MouseOut"));
+       check_equals(string(text2->get_text_value()), string("RollOut"));
+       check(!tester.isMouseOverMouseEntity());
+       // check that pixel @ 60,60 is red !
+       if ( covered ) { check_pixel(60, 60, 2, covered_red, 2); }
+       else { check_pixel(60, 60, 2, red, 2); }
+
+       // press the mouse button, this should not change anything
+       // as we're outside of the button.
+       tester.pressMouseButton();
+       check_equals(string(text->get_text_value()), string("MouseOut"));
+       check_equals(string(text2->get_text_value()), string("RollOut"));
+       check(!tester.isMouseOverMouseEntity());
+       // check that pixel @ 60,60 is red !
+       if ( covered ) { check_pixel(60, 60, 2, covered_red, 2); }
+       else { check_pixel(60, 60, 2, red, 2); }
+
+       // depress the mouse button, this should not change anything
+       // as we're outside of the button.
+       tester.depressMouseButton();
+       check_equals(string(text->get_text_value()), string("MouseOut"));
+       check_equals(string(text2->get_text_value()), string("RollOut"));
+       check(!tester.isMouseOverMouseEntity());
+       // check that pixel @ 60,60 is red !
+       if ( covered ) { check_pixel(60, 60, 2, covered_red, 2); }
+       else { check_pixel(60, 60, 2, red, 2); }
+
+       // Now press the mouse inside and release outside
+
+       tester.movePointerTo(60, 60); 
+
+       if ( enabled ) {
+               check_equals(string(text->get_text_value()), 
string("MouseOver"));
+               check_equals(string(text2->get_text_value()), 
string("RollOver"));
+               check(tester.isMouseOverMouseEntity());
+               // check that pixel @ 60,60 is yellow !
+               if ( covered ) { check_pixel(60, 60, 2, covered_yellow, 2);  }
+               else { check_pixel(60, 60, 2, yellow, 2);  }
+       } else {
+               check_equals(string(text->get_text_value()), 
string("MouseOut"));
+               check_equals(string(text2->get_text_value()), 
string("RollOut"));
+               check(!tester.isMouseOverMouseEntity());
+               // check that pixel @ 60,60 is red !
+               if ( covered ) { check_pixel(60, 60, 2, covered_red, 2); }
+               else { check_pixel(60, 60, 2, red, 2); }
+       }
+       
+       tester.pressMouseButton();
+
+       if ( enabled ) {
+               check_equals(string(text->get_text_value()), 
string("MouseDown"));
+               check_equals(string(text2->get_text_value()), string("Press"));
+               check(tester.isMouseOverMouseEntity());
+               // check that pixel @ 60,60 is green !
+               check_pixel(60, 60, 2, rgba(0,255,0,255), 2);
+       } else {
+               check_equals(string(text->get_text_value()), 
string("MouseOut"));
+               check_equals(string(text2->get_text_value()), 
string("RollOut"));
+               check(!tester.isMouseOverMouseEntity());
+               // check that pixel @ 60,60 is red !
+               if ( covered ) { check_pixel(60, 60, 2, covered_red, 2); }
+               else { check_pixel(60, 60, 2, red, 2); }
+       }
+
+       tester.movePointerTo(39, 60);
+
+       // The following might be correct, as the character still catches 
releaseOutside events
+       //check(tester.isMouseOverMouseEntity());
+       tester.depressMouseButton();
+
+       if ( enabled ) {
+               xcheck_equals(string(text->get_text_value()), 
string("MouseUpOutside"));
+               xcheck_equals(string(text2->get_text_value()), 
string("ReleaseOutside"));
+       } else {
+               check_equals(string(text->get_text_value()), 
string("MouseOut"));
+               check_equals(string(text2->get_text_value()), 
string("RollOut"));
+       }
+}
+
+int
+main(int /*argc*/, char** /*argv*/)
+{
+       //string filename = INPUT_FILENAME;
+       string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
+       MovieTester tester(filename);
+
+       std::string idleString = "Idle";
+
+       sprite_instance* root = tester.getRootMovie();
+       assert(root);
+
+       check_equals(root->get_frame_count(), 4);
+
+       check_equals(root->get_current_frame(), 0);
+
+       const character* mc1 = tester.findDisplayItemByName(*root, "square1");
+       check(mc1);
+       check_equals(mc1->get_depth(), 2+character::staticDepthOffset);
+
+       const character* text = tester.findDisplayItemByName(*root, 
"textfield");
+       check(text);
+
+       const character* text2 = tester.findDisplayItemByName(*root, 
"textfield2");
+       check(text2);
+
+       const character* text3 = tester.findDisplayItemByName(*root, 
"textfield3");
+       check(text3);
+
+       check_equals(string(text->get_text_value()), idleString);
+       check_equals(string(text2->get_text_value()), idleString);
+       check_equals(string(text3->get_text_value()), idleString);
+       check(!tester.isMouseOverMouseEntity());
+       // check that pixel @ 60,60 is red !
+       rgba red(255,0,0,255);
+       check_pixel(60, 60, 2, red, 2);
+
+       for (size_t fno=0; fno<root->get_frame_count(); fno++)
+       {
+               const character* square_back = 
tester.findDisplayItemByDepth(*root, 1+character::staticDepthOffset);
+               const character* square_front = 
tester.findDisplayItemByDepth(*root, 3+character::staticDepthOffset);
+
+               switch (fno)
+               {
+                       case 0:
+                               check(!square_back);
+                               check(!square_front);
+                               break;
+                       case 1:
+                               check(square_back);
+                               check(!square_front);
+                               break;
+                       case 2:
+                               check(square_back);
+                               check(square_front);
+                               break;
+               }
+
+               check_equals(root->get_current_frame(), fno);
+
+               info (("testing mouse activity in frame %d", 
root->get_current_frame()));
+               test_mouse_activity(tester, text, text2, square_front!=NULL, 
fno != root->get_frame_count()-1);
+
+               // TODO: test key presses !
+               //       They seem NOT to trigger immediate redraw
+
+               tester.advance();
+
+       }
+
+       // last advance should restart the loop...
+       check_equals(root->get_current_frame(), 0);
+
+}
+

Index: testsuite/misc-ming.all/SpriteButtonEventsTest.c
===================================================================
RCS file: testsuite/misc-ming.all/SpriteButtonEventsTest.c
diff -N testsuite/misc-ming.all/SpriteButtonEventsTest.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/SpriteButtonEventsTest.c    10 May 2007 13:50:44 
-0000      1.1
@@ -0,0 +1,289 @@
+/***********************************************************************
+ *
+ *   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ *
+ ***********************************************************************
+ *
+ * Test case for mouse events.
+ *
+ * In a movie of 120x120 pixels, it places a movieclip containing a squared
+ * sprite-button in the middle of the stage, and a text area on top.
+ *
+ * The movie has 3 frames, with the second adding a shape at a lower depth
+ * and the third one at an higher depth respect to the button.
+ *
+ * The following events print the event name in the text area
+ * (called _root.textfield) and change the color of the button:
+ *
+ * MouseOut  : red button (initial state)
+ * MouseOver : yellow button
+ * MouseDown : green button
+ * MouseUp   : yellow button (same as MouseOver, but the label on top changes)
+ *
+ ***********************************************************************/
+
+#include "ming_utils.h"
+
+#include <ming.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define OUTPUT_VERSION 6
+#define OUTPUT_FILENAME "SpriteButtonEventsTest.swf"
+
+SWFFont font;
+
+void add_event(SWFMovie mo, const char* name, const char* event, const char* 
action);
+void add_code(SWFMovie mo, const char* code);
+void add_text_field(SWFMovie mo, const char* name, const char* varname, const 
char* initial_label, int depth, int x, int y);
+void set_text(SWFMovie mo, const char* text);
+SWFDisplayItem add_square(SWFMovie mo, byte r, byte g, byte b, int depth);
+
+void
+add_event(SWFMovie mo, const char* name, const char* event, const char* action)
+{
+       SWFAction ac;
+       char buf[1024];
+
+       sprintf(buf,
+       "event=undefined;"
+       "%s.on%s=function() { %s; };"
+       , name, event, action
+       );
+       ac = compileSWFActionCode(buf);
+
+       SWFMovie_add(mo, (SWFBlock)ac);
+}
+
+void
+add_code(SWFMovie mo, const char* code)
+{
+       SWFAction ac;
+
+       ac = compileSWFActionCode(code);
+
+       SWFMovie_add(mo, (SWFBlock)ac);
+}
+
+SWFDisplayItem add_button(SWFMovie mo);
+SWFDisplayItem
+add_button(SWFMovie mo)
+{
+       SWFDisplayItem it;
+       SWFMovieClip mc;
+       SWFShape sh1, sh2, sh3, sh4;
+       SWFMovieClip bu = newSWFMovieClip();
+
+       mc = newSWFMovieClip();
+
+       sh1 = make_fill_square(0, 0, 40, 40, 0, 0, 0, 0, 0, 0); // black
+       sh2 = make_fill_square(0, 0, 40, 40, 255, 0, 0, 255, 0, 0); // red
+       sh3 = make_fill_square(0, 0, 40, 40, 0, 255, 0, 0, 255, 0); // green
+       sh4 = make_fill_square(0, 0, 40, 40, 255, 255, 0, 255, 255, 0); // 
yellow
+
+       SWFMovieClip_add(bu, (SWFBlock)sh2); // red when idle
+       SWFMovieClip_add(bu, (SWFBlock)compileSWFActionCode(
+                               "onRollOut = function() { _root.msg='MouseOut'; 
_root.msg2='RollOver'; gotoAndStop(1); };"
+                               "onRollOver = function() { 
_root.msg='MouseOver'; _root.msg2='RollOut'; gotoAndStop(3); };"
+                               "onMouseDown = function() { 
_root.msg='MouseDown'; gotoAndStop(2); };"
+                               "onRelease = function() { _root.msg='MouseUp'; 
_root.msg2='Release'; gotoAndStop(1); };"
+                               "onReleaseOutside = function() { 
_root.msg='MouseUpOutside'; _root.msg2='ReleaseOutside'; gotoAndStop(1); };"
+                               "stop();"
+                       ));
+       SWFMovieClip_nextFrame(bu);
+
+       SWFMovieClip_add(bu, (SWFBlock)sh3); // green on button press
+       SWFMovieClip_add(bu, (SWFBlock)newSWFAction("stop();"));
+       SWFMovieClip_nextFrame(bu);
+
+       SWFMovieClip_add(bu, (SWFBlock)sh4); //  yellow on mouse over
+       SWFMovieClip_add(bu, (SWFBlock)newSWFAction("stop();"));
+       SWFMovieClip_nextFrame(bu);
+
+       it = SWFMovieClip_add(mc, (SWFBlock)bu);
+       SWFDisplayItem_setName(it, "button");
+       SWFMovieClip_nextFrame(mc); /* showFrame */
+
+       it = SWFMovie_add(mo, (SWFBlock)mc);
+       return it;
+}
+
+void
+add_text_field(SWFMovie mo, const char* name, const char* varname, const char* 
initial_label, int depth, int x, int y)
+{
+       SWFDisplayItem it;
+       SWFTextField tf = newSWFTextField();
+       SWFTextField_setFont(tf, (void*)font);
+       SWFTextField_addChars(tf, " 
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345689:.,/address@hidden");
+       SWFTextField_setVariableName(tf, varname);
+       SWFTextField_addString(tf, "Idle");
+       SWFTextField_setBounds(tf, 120, 12);
+       SWFTextField_setFlags(tf, SWFTEXTFIELD_DRAWBOX|SWFTEXTFIELD_NOEDIT);
+
+       it = SWFMovie_add(mo, (SWFBlock)tf);
+       SWFDisplayItem_moveTo(it, x, y+2);
+       SWFDisplayItem_setDepth(it, depth);
+       SWFDisplayItem_setName(it, name); // "textfield");
+
+       // Label 
+       tf = newSWFTextField();
+       SWFTextField_setFont(tf, (void*)font);
+       SWFTextField_addString(tf, initial_label);
+       SWFTextField_setFlags(tf, SWFTEXTFIELD_DRAWBOX|SWFTEXTFIELD_NOEDIT);
+       it = SWFMovie_add(mo, (SWFBlock)tf);
+       SWFDisplayItem_scale(it, 0.3, 0.3);
+       SWFDisplayItem_setDepth(it, depth*10);
+       SWFDisplayItem_moveTo(it, x, y);
+}
+
+void
+set_text(SWFMovie mo, const char* text)
+{
+       char buf[1024];
+       sprintf(buf, "_root.msg=\"%s\";", text);
+       add_code(mo, buf);
+}
+
+int
+main(int argc, char **argv)
+{
+       SWFMovie mo;
+       SWFDisplayItem it;
+       const char *srcdir=".";
+       char fdbfont[256];
+
+       /*********************************************
+        *
+        * Initialization
+        *
+        *********************************************/
+
+       puts("Setting things up");
+
+       Ming_init();
+        Ming_useSWFVersion (OUTPUT_VERSION);
+       Ming_setScale(20.0); 
+ 
+       mo = newSWFMovie();
+       SWFMovie_setDimension(mo, 120, 120);
+       SWFMovie_setRate(mo, 1);
+
+       if ( argc>1 ) srcdir=argv[1];
+       else
+       {
+               fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
+               return 1;
+       }
+
+       sprintf(fdbfont, "%s/Bitstream Vera Sans.fdb", srcdir);
+       FILE *font_file = fopen(fdbfont, "r");
+       if ( font_file == NULL )
+       {
+               perror(fdbfont);
+               exit(1);
+       }
+       /*SWFBrowserFont bfont = newSWFBrowserFont("_sans");*/
+       font = loadSWFFontFromFile(font_file);
+
+       add_text_field(mo, "textfield", "_root.msg", "Button events", 10, 0, 5);
+       add_text_field(mo, "textfield2", "_root.msg2", "Mouse events", 11, 0, 
100);
+       add_text_field(mo, "textfield3", "_root.msg3", "Key events", 12, 0, 80);
+
+       /*****************************************************
+        *
+        * Add button
+        *
+        *****************************************************/
+
+       it = add_button(mo);
+       SWFDisplayItem_moveTo(it, 40, 30);
+       SWFDisplayItem_setName(it, "square1");
+       SWFDisplayItem_setDepth(it, 2);
+
+       // Mouse pointer events
+       //add_actions(mo, "square1.button.onRollOver = function() { _root.msg2 
= 'RollOver'; };");
+       //add_actions(mo, "square1.button.onRollOut = function() { _root.msg2 = 
'RollOut'; };");
+
+       // Mouse buttons events
+       add_actions(mo, "square1.button.onPress = function() { _root.msg2 = 
'Press'; };");
+       //add_actions(mo, "square1.button.onRelease = function() { _root.msg2 = 
'Release'; gotoAndStop(1); };");
+       //add_actions(mo, "square1.button.onReleaseOutside = function() { 
_root.msg2 = 'ReleaseOutside'; };");
+
+       // Focus events
+       add_actions(mo, "square1.button.onSetFocus = function() { _root.msg3 = 
'SetFocus'; };");
+
+       // Key events - button needs focus for these to work
+       add_actions(mo, "square1.button.onKeyDown = function() { _root.msg3 = 
'KeyDown'; };");
+       add_actions(mo, "square1.button.onKeyUp = function() { _root.msg3 = 
'KeyUp'; };");
+
+
+       SWFMovie_nextFrame(mo); /* showFrame */
+
+       /*****************************************************
+        *
+        * On second frame, add a shape at lower depth 
+        *
+        *****************************************************/
+
+       {
+               SWFShape sh = make_fill_square(0, 0, 120, 120, 0, 0, 0, 0, 255, 
0);
+               SWFDisplayItem itsh = SWFMovie_add(mo, (SWFBlock)sh);
+               SWFDisplayItem_setDepth(itsh, 1);
+
+               SWFMovie_nextFrame(mo); /* showFrame */
+       }
+
+       /*****************************************************
+        *
+        * On third frame, add a shape at higher depth 
+        *
+        *****************************************************/
+
+       {
+               SWFShape sh = make_fill_square(0, 0, 120, 120, 0, 0, 0, 0, 255, 
0);
+               SWFDisplayItem itsh = SWFMovie_add(mo, (SWFBlock)sh);
+               SWFDisplayItem_setDepth(itsh, 3);
+               SWFDisplayItem_setColorAdd(itsh, 0, 0, 0, -128);
+
+               SWFMovie_nextFrame(mo); /* showFrame */
+       }
+
+       /*****************************************************
+        *
+        * On third frame, add a shape at higher depth 
+        *
+        *****************************************************/
+
+       {
+
+               add_actions(mo, "square1.button.enabled = false;");
+               SWFMovie_nextFrame(mo); /* showFrame */
+       }
+
+       /*****************************************************
+        *
+        * Save it...
+        *
+        *****************************************************/
+
+       puts("Saving " OUTPUT_FILENAME );
+
+       SWFMovie_save(mo, OUTPUT_FILENAME);
+
+       return 0;
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]