PDA

View Full Version : AS 3.0 to call Jquery Function + Detect the end of the movie



chris.a.moore
March 23rd, 2010, 01:20 AM
Hello,

I have website I am developing and I have an intro SWF that I have placed the following AS 3.0 code in the last frame to call the Jquery function "trigger" ; or I might be able to detect the end of the movie and then fire the function.



import flash.external.ExternalInterface;
ExternalInterface.call("trigger")
trace ("the movieEnded");
stop();

Here is the function in Jquery in my HTML page.



$(function trigger(str)
{
//right now this is a link to fire the function.
$("#trigger").click(function (event) {
event.preventDefault();
//this is a div that collapses
$("#media").slideToggle();
});

$("#media a").click(function (event) {
event.preventDefault();
$("#media").slideUp();
});
});
and here is the html embed code



<div id"movie"align="center">
<!---->
<object id="intro" classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=10,1,1,0" width="900" height="430" param name="allowScriptAccess" value="always" />
<param name="allowScriptAccess" value="always"/>
<param name="src" value="imgs/Camdesignsintro.swf" />
<embed src="imgs/intro.swf" allowScriptAccess="always" pluginspage="http://www.adobe.com/shockwave/download/" width="900" height="430"></embed>
</object>
</div>
Any help would be greatly appreciated
V/R
-CM

toad013
March 23rd, 2010, 02:12 AM
i dont think this is it but your object tag is all messed up

chris.a.moore
March 23rd, 2010, 02:26 PM
first let me thank you for replying Toad,

It could very well be messed up... It functions in sandbox and live as a movie... but the ExternalIterface.call is not working.

back to the point, I did use dreamweaver to import the movie to the html.

how can I make the object tag more conventional/ proper?

gangstareef
March 23rd, 2010, 03:18 PM
I'm thinking maybe you need to replace "trigger" in your ExternalInterface.call argument with "trigger()"... That would be more along the lines of how it's done here (http://codingrecipes.com/calling-a-javascript-function-from-actionscript-3-flash).

toad013
March 23rd, 2010, 03:55 PM
<object id="intro" classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=10,1,1,0" width="900" height="430" param name="allowScriptAccess" value="always" />

the object tag is incorrect. at the end it's already closed. the ">" should be after "height=430" and there shouldn't be the "/". "param name="allowScriptAccess" value="always" />" portion should be it's own tag <param name="allowScriptAccess" value="always" /> ... i'm guessing if that's the cause it wasn't allowing any script access.

chris.a.moore
March 24th, 2010, 06:59 PM
Thanks for the replies guys I will test them out tonight and let you know what is up... until then.
CM

chris.a.moore
March 25th, 2010, 01:23 PM
OK,
Got it working.... thanks.

Solution ...
I enveloped the Jquery in a JS function.
I removed the .click bindings.
I repaired the object tag
and I added the "()" to the AS3 call string.

thanks team.