[Swfdec] Branch 'as' - 5 commits - libswfdec/swfdec_mouse_as.c libswfdec/swfdec_movie_asprops.c test/trace
Benjamin Otte
company at kemper.freedesktop.org
Sun Jun 10 14:50:09 PDT 2007
libswfdec/swfdec_mouse_as.c | 29 +++++++++++++++++------------
libswfdec/swfdec_movie_asprops.c | 4 ++--
test/trace/Makefile.am | 7 +++++++
test/trace/mouse-show-hide-5.swf |binary
test/trace/mouse-show-hide-5.swf.trace | 4 ++++
test/trace/mouse-show-hide-6.swf |binary
test/trace/mouse-show-hide-6.swf.trace | 4 ++++
test/trace/mouse-show-hide-7.swf |binary
test/trace/mouse-show-hide-7.swf.trace | 4 ++++
test/trace/mouse-show-hide.as | 8 ++++++++
10 files changed, 46 insertions(+), 14 deletions(-)
New commits:
diff-tree 7bd2ff52ba93f0405bd99cb4162649e92ba4c1fd (from 5aaf2949c83ea9131fd18ebe35a2cf6c69c45951)
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Jun 10 23:45:56 2007 +0200
Mouse.addListener() and Mouse.removeListener() don't exist in Flash 5
This should be using AsBroadcaster anyway, but since that's not implemented...
diff --git a/libswfdec/swfdec_mouse_as.c b/libswfdec/swfdec_mouse_as.c
index 81187a3..01b6c9d 100644
--- a/libswfdec/swfdec_mouse_as.c
+++ b/libswfdec/swfdec_mouse_as.c
@@ -76,8 +76,10 @@ swfdec_mouse_init_context (SwfdecPlayer
SWFDEC_AS_VALUE_SET_OBJECT (&val, mouse);
swfdec_as_object_set_variable (SWFDEC_AS_CONTEXT (player)->global, SWFDEC_AS_STR_Mouse, &val);
- swfdec_as_object_add_function (mouse, SWFDEC_AS_STR_addListener, 0, swfdec_mouse_addListener, 1);
- swfdec_as_object_add_function (mouse, SWFDEC_AS_STR_removeListener, 0, swfdec_mouse_removeListener, 1);
+ if (version > 5) {
+ swfdec_as_object_add_function (mouse, SWFDEC_AS_STR_addListener, 0, swfdec_mouse_addListener, 1);
+ swfdec_as_object_add_function (mouse, SWFDEC_AS_STR_removeListener, 0, swfdec_mouse_removeListener, 1);
+ }
swfdec_as_object_add_function (mouse, SWFDEC_AS_STR_hide, 0, swfdec_mouse_hide, 0);
swfdec_as_object_add_function (mouse, SWFDEC_AS_STR_show, 0, swfdec_mouse_show, 0);
}
diff-tree 5aaf2949c83ea9131fd18ebe35a2cf6c69c45951 (from bf1161936e46439b9d51305f0d90e6f6c321331c)
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Jun 10 23:33:12 2007 +0200
it test for Mouse.show() and Mouse.hide()
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index ed08012..a39696a 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -265,6 +265,13 @@ EXTRA_DIST = \
load-5.swf.trace \
local.swf \
local.swf.trace \
+ mouse-show-hide.as \
+ mouse-show-hide-5.swf \
+ mouse-show-hide-5.swf.trace \
+ mouse-show-hide-6.swf \
+ mouse-show-hide-6.swf.trace \
+ mouse-show-hide-7.swf \
+ mouse-show-hide-7.swf.trace \
name.swf \
name.swf.trace \
name2.swf \
diff --git a/test/trace/mouse-show-hide-5.swf b/test/trace/mouse-show-hide-5.swf
new file mode 100644
index 0000000..61aa665
Binary files /dev/null and b/test/trace/mouse-show-hide-5.swf differ
diff --git a/test/trace/mouse-show-hide-5.swf.trace b/test/trace/mouse-show-hide-5.swf.trace
new file mode 100644
index 0000000..680eb50
--- /dev/null
+++ b/test/trace/mouse-show-hide-5.swf.trace
@@ -0,0 +1,4 @@
+1
+0
+0
+1
diff --git a/test/trace/mouse-show-hide-6.swf b/test/trace/mouse-show-hide-6.swf
new file mode 100644
index 0000000..5bf9dca
Binary files /dev/null and b/test/trace/mouse-show-hide-6.swf differ
diff --git a/test/trace/mouse-show-hide-6.swf.trace b/test/trace/mouse-show-hide-6.swf.trace
new file mode 100644
index 0000000..680eb50
--- /dev/null
+++ b/test/trace/mouse-show-hide-6.swf.trace
@@ -0,0 +1,4 @@
+1
+0
+0
+1
diff --git a/test/trace/mouse-show-hide-7.swf b/test/trace/mouse-show-hide-7.swf
new file mode 100644
index 0000000..5c03233
Binary files /dev/null and b/test/trace/mouse-show-hide-7.swf differ
diff --git a/test/trace/mouse-show-hide-7.swf.trace b/test/trace/mouse-show-hide-7.swf.trace
new file mode 100644
index 0000000..680eb50
--- /dev/null
+++ b/test/trace/mouse-show-hide-7.swf.trace
@@ -0,0 +1,4 @@
+1
+0
+0
+1
diff --git a/test/trace/mouse-show-hide.as b/test/trace/mouse-show-hide.as
new file mode 100644
index 0000000..c331e39
--- /dev/null
+++ b/test/trace/mouse-show-hide.as
@@ -0,0 +1,8 @@
+// makeswf -v 7 -s 200x150 -r 1 -o mouse-show-hide.swf mouse-show-hide.as
+
+trace (Mouse.hide ());
+trace (Mouse.hide ());
+trace (Mouse.show ());
+trace (Mouse.show ());
+
+loadMovie ("FSCommand:quit", "");
diff-tree bf1161936e46439b9d51305f0d90e6f6c321331c (from 5cce0bbbe05d849ae76874d4aae5f9425db59bc5)
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Jun 10 23:31:36 2007 +0200
Mouse.hide() and Mouse.show() return the previous state of the mouse
diff --git a/libswfdec/swfdec_mouse_as.c b/libswfdec/swfdec_mouse_as.c
index f060bfb..81187a3 100644
--- a/libswfdec/swfdec_mouse_as.c
+++ b/libswfdec/swfdec_mouse_as.c
@@ -47,15 +47,21 @@ swfdec_mouse_removeListener (SwfdecAsObj
}
static void
-swfdec_mouse_show (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *return_value)
+swfdec_mouse_show (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
- SWFDEC_PLAYER (object->context)->mouse_visible = TRUE;
+ SwfdecPlayer *player = SWFDEC_PLAYER (object->context);
+
+ SWFDEC_AS_VALUE_SET_INT (retval, player->mouse_visible ? 1 : 0);
+ player->mouse_visible = TRUE;
}
static void
-swfdec_mouse_hide (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *return_value)
+swfdec_mouse_hide (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
- SWFDEC_PLAYER (object->context)->mouse_visible = FALSE;
+ SwfdecPlayer *player = SWFDEC_PLAYER (object->context);
+
+ SWFDEC_AS_VALUE_SET_INT (retval, player->mouse_visible ? 1 : 0);
+ player->mouse_visible = FALSE;
}
void
diff-tree 5cce0bbbe05d849ae76874d4aae5f9425db59bc5 (from f43ebc571a0c7aeae64c126c58f955c4466dc2ee)
Author: Nguyá»
n Thái Ngá»c Duy <pclouds at gmail.com>
Date: Sun Jun 10 23:05:52 2007 +0200
the mouse coordinates are scaled once too often
diff --git a/libswfdec/swfdec_movie_asprops.c b/libswfdec/swfdec_movie_asprops.c
index ff5f416..c037a2c 100644
--- a/libswfdec/swfdec_movie_asprops.c
+++ b/libswfdec/swfdec_movie_asprops.c
@@ -327,7 +327,7 @@ mc_xmouse_get (SwfdecMovie *movie, Swfde
double x, y;
swfdec_movie_get_mouse (movie, &x, &y);
- x = rint (x * SWFDEC_TWIPS_SCALE_FACTOR) / SWFDEC_TWIPS_SCALE_FACTOR;
+ x = SWFDEC_TWIPS_TO_DOUBLE (rint (x));
SWFDEC_AS_VALUE_SET_NUMBER (rval, x);
}
@@ -337,7 +337,7 @@ mc_ymouse_get (SwfdecMovie *movie, Swfde
double x, y;
swfdec_movie_get_mouse (movie, &x, &y);
- y = rint (y * SWFDEC_TWIPS_SCALE_FACTOR) / SWFDEC_TWIPS_SCALE_FACTOR;
+ y = SWFDEC_TWIPS_TO_DOUBLE (rint (y));
SWFDEC_AS_VALUE_SET_NUMBER (rval, y);
}
diff-tree f43ebc571a0c7aeae64c126c58f955c4466dc2ee (from d3ff93817f2931e6f6e9bb8400fe807c92e8f414)
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Jun 10 22:21:19 2007 +0200
Mouse is an object, not a function
diff --git a/libswfdec/swfdec_mouse_as.c b/libswfdec/swfdec_mouse_as.c
index ef36dc7..f060bfb 100644
--- a/libswfdec/swfdec_mouse_as.c
+++ b/libswfdec/swfdec_mouse_as.c
@@ -58,20 +58,17 @@ swfdec_mouse_hide (SwfdecAsObject *objec
SWFDEC_PLAYER (object->context)->mouse_visible = FALSE;
}
-static void
-swfdec_mouse_construct (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *return_value)
-{
-}
-
void
swfdec_mouse_init_context (SwfdecPlayer *player, guint version)
{
+ SwfdecAsValue val;
SwfdecAsObject *mouse;
- mouse = SWFDEC_AS_OBJECT (swfdec_as_object_add_function (SWFDEC_AS_CONTEXT (player)->global,
- SWFDEC_AS_STR_Mouse, 0, swfdec_mouse_construct, 0));
+ mouse = swfdec_as_object_new (SWFDEC_AS_CONTEXT (player));
if (!mouse)
return;
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, mouse);
+ swfdec_as_object_set_variable (SWFDEC_AS_CONTEXT (player)->global, SWFDEC_AS_STR_Mouse, &val);
swfdec_as_object_add_function (mouse, SWFDEC_AS_STR_addListener, 0, swfdec_mouse_addListener, 1);
swfdec_as_object_add_function (mouse, SWFDEC_AS_STR_removeListener, 0, swfdec_mouse_removeListener, 1);
More information about the Swfdec
mailing list