Swiff onLoad not firing

57 views
Skip to first unread message

reddrumhead

unread,
Jan 21, 2010, 12:07:10 PM1/21/10
to MooTools Users
I'm experiencing a strange problem with the Swiff class.

I was loading an Actionscript 3 swf into a div using mootools with
the following code:

var swf = new Swiff('webcam.swf', {
id: 'webcam',
width: 720,
height: 370,
container: $('swf-content'),
events: {
onLoad: function(){
alert('flash loaded!');
}
}
});

Up until a few days ago the onLoad event was giving me an alert as it
should then it suddenly stopped working. I've also tried replacing it
with:

callBacks: {
load: function(){
alert('flash loaded!');
}
}

but this does not produce an alert either. Documentation on the Swiff
class is sparse.

I've looked around and I found the following Actionscript which I
added with no results:

import flash.external.*;

ExternalInterface.call('onLoad');

I also tried:

ExternalInterface.call('load');

with no luck.

Has anyone else encountered issues with onLoad firing properly for
Swiff? I'm brand new to using Swiff and maybe I'm not understanding
how this works or something. I find it really strange that it WAS
working and then stopped.

I've got it working again by using Request and requesting a php file
that has the flash object in it and then setting the HTML of 'swf-
content'. I don't think that's an ideal solution since older versions
of IE will require the object to be activated before it can be used
(ie. ActiveXObject).

I'd really appreciate any insight, thanks!

Fábio M. Costa

unread,
Jan 21, 2010, 12:28:20 PM1/21/10
to mootool...@googlegroups.com
http://mootools.net/blog/2008/02/12/whats-new-in-12-swiff/

If you still cant solve your problem or have read it before just tell us.


--
Fábio Miranda Costa
Solucione Sistemas
Engenheiro de interfaces

Ryan Florence

unread,
Jan 21, 2010, 1:24:49 PM1/21/10
to mootool...@googlegroups.com
I was goofing with this earlier and couldn't get it work either (or Swiff.Remote).  No time to continue fiddling but I will be as soon as some of my current projects finish up.

reddrumhead

unread,
Jan 21, 2010, 1:50:35 PM1/21/10
to MooTools Users
I guess I should have mentioned that I found this link already, it did
not help. In fact, adding these lines of code in the flash file:

import flash.external.*;
ExternalInterface.call(onLoad);

as suggested causes these errors when compiling:

1120: Access of undefined property onLoad.

reddrumhead

unread,
Jan 21, 2010, 1:56:10 PM1/21/10
to MooTools Users
Not sure why it cut off the rest of my message... here's the rest:

Warning: 3553: Function value used where type Object was expected.
Possibly the parentheses () are missing after this function reference.

reddrumhead

unread,
Jan 21, 2010, 1:57:42 PM1/21/10
to MooTools Users
My messages keep getting cut off...

What I am trying to do is fade in the 'swf-content' div once the swf
has loaded. Unfortunately it's impossible to do without a working
onLoad: event.

Anyone have any thoughts?

gabriel munteanu

unread,
Jan 21, 2010, 2:17:19 PM1/21/10
to mootool...@googlegroups.com
Hi, i made it work it my jsblaster game project.
here is 1 source file :
http://code.google.com/p/js-blaster/source/browse/trunk/js-blaster/src/game/DynaSound.as
my similar line is the 28th: but my js function is called flashLoadedHandler.
you should make this line as the last line executed in flash, in order
to have all other flash resources loaded if possible.

1120: Access of undefined property onLoad. is because onLoad is not
surrounded by "".
the idea behind all this is that flash has no onLoad event, it is
"faked" by placing this ExternalInterface.call("JSFUNCTIONNAME");
method as last executed line of code in flash.

--
jgabios
http://bash.editia.info

reddrumhead

unread,
Jan 22, 2010, 4:53:36 PM1/22/10
to MooTools Users
Thanks for the reply gabriel!

I did have the "" (quotes) around onLoad at one point and it didn't
work then either.

This is the last three lines of my flash file:

if(ExternalInterface.available){
ExternalInterface.call("onLoad");
}

and my Javascript code:

var swf = new Swiff(content, {


id: 'webcam',
width: 720,
height: 370,
container: $('swf-content'),

callBacks: {


onLoad: function(){
alert('flash loaded!');
}
}
});

I must be completely confused with this, because I've tried everything
and can't get it working...

On Jan 21, 1:17 pm, gabriel munteanu <jajali...@gmail.com> wrote:
> Hi, i made it work it my jsblaster game project.

> here is 1 source file :http://code.google.com/p/js-blaster/source/browse/trunk/js-blaster/sr...


> my similar line is the 28th: but my js function is called flashLoadedHandler.
> you should make this line as the last line executed in flash, in order
> to have all other flash resources loaded if possible.
>
> 1120: Access of undefined property onLoad. is because onLoad is not
> surrounded by "".
> the idea behind all this is that flash has no onLoad event, it is
> "faked" by placing this ExternalInterface.call("JSFUNCTIONNAME");
> method as last executed line of code in flash.
>

gabriel munteanu

unread,
Jan 23, 2010, 3:12:17 AM1/23/10
to mootool...@googlegroups.com
ok, i think i know the reson why it doesn't work for you.
onLoad must be in the global space.
flashLoadedHandler function is in my global space.
flash looks for onLoad method in the global space, you have it hidden
in the Swiff class.
1. note:
i tried to set up a mooshell example, but it doesn't work. can we
upload swf files there? i guess it was because i tried to load a swf
file from my domain, instead of mooshell.net domain.

--
jgabios
http://bash.editia.info

soundseller

unread,
Jan 26, 2010, 11:11:17 AM1/26/10
to MooTools Users
Hi,
I cant get it to work either.
Could anybody shed some light on this please?
Thanks in advance
Bob

gabriel munteanu

unread,
Jan 26, 2010, 11:51:58 AM1/26/10
to mootool...@googlegroups.com
if you can setup a demo, and give us the url, i could provide more details.

--
jgabios
http://bash.editia.info

reddrumhead

unread,
Jan 26, 2010, 4:27:27 PM1/26/10
to MooTools Users
Hmmm, okay.

So if I declare the onLoad function like so:

var onLoad = function(){}

And then call it within the Swiff object, you're saying that it should
work. I don't see how it will...

gabriel munteanu

unread,
Jan 26, 2010, 4:39:30 PM1/26/10
to mootool...@googlegroups.com
not from within the swiff object but from the actionscript, from
within flash object itself.
more precisely from this actionscript statement:
ExternalInterface.call("onLoad");

--
jgabios
http://bash.editia.info

soundseller

unread,
Jan 28, 2010, 6:22:27 AM1/28/10
to MooTools Users
Hmmm,
I try to get a "player ready" callback from longtailvideo's flash
player.
I use very basic code just like reddrumhead:

var swf = new Swiff(content, {

id: 'player_1',
width: 320,
height: 120,
container: $('player_wrapper'),
callBacks: {
playerReadyCallback: function()
{
alert
('player_ready');
}
}
});

The callback is sent by the player:

ExternalInterface.call("playerReadyCallback");

I can get the callback outside the domready.
How can I get it from inside swiff?
Is it possible?
Thanks for your help!


On Jan 27, 1:39 am, gabriel munteanu <jajali...@gmail.com> wrote:
> not from within theswiffobject but from the actionscript, from


> within flash object itself.
> more precisely from this actionscript statement:
> ExternalInterface.call("onLoad");
>
>
>
>
>
> On Tue, Jan 26, 2010 at 11:27 PM, reddrumhead <reddrumh...@gmail.com> wrote:
> > Hmmm, okay.
>
> > So if I declare the onLoad function like so:
>
> > var onLoad = function(){}
>

> > And then call it within theSwiffobject, you're saying that it should

gabriel munteanu

unread,
Jan 28, 2010, 1:22:38 PM1/28/10
to mootool...@googlegroups.com
that's exactly what i said in my posts on this thread, flash can see
the global scope only.
so when you say "I can get the callback outside the domready." that's
what happens.
now, if you want to call the method playerReadyCallback from inside
thw Swiff, you should do something like:
ExternalInterface.call("swf.callBacks.playerReadyCallback");

--
jgabios
http://bash.editia.info

soundseller

unread,
Jan 28, 2010, 2:28:53 PM1/28/10
to MooTools Users
Hey gabriel,
thanks for your patience.
I think I got it now :)
All the best!

On Jan 28, 10:22 pm, gabriel munteanu <jajali...@gmail.com> wrote:
> that's exactly what i said in my posts on this thread, flash can see
> the global scope only.
> so when you say "I can get the callback outside the domready." that's
> what happens.
> now, if you want to call the method playerReadyCallback from inside

> thwSwiff, you should do something like:

Reply all
Reply to author
Forward
0 new messages