Shishant
Shishant

Reputation: 9294

calling flash using javascript

I searched ExternalInterface but didnt got to know, how to implement it.

I want to run/execute a flash when clicked on an image element.

<img src="a.png" onclick="runFlash()" />

my Flash

<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="16" HEIGHT="16" id="flashUpload" ALIGN="">
 <PARAM NAME=movie VALUE="{swf_upload_url}?UploadSession={upload_session}&AccessKey={AccessKey}&ServerID={ServerID}&ShowTopBtn=1&TopBtnIcon={SKIN_DIR}/images/a.png">
 <PARAM NAME=quality VALUE=high>
 <PARAM NAME=allowScriptAccess VALUE=always>
 <PARAM NAME=bgcolor VALUE=#000000>
 <PARAM NAME=wmode VALUE=transparent>
 <EMBED src="{swf_upload_url}?UploadSession={upload_session}&AccessKey={AccessKey}&ServerID={ServerID}&ShowTopBtn=1&TopBtnIcon={SKIN_DIR}/images/a.png" quality=high bgcolor=#000000  WIDTH="32" HEIGHT="32" NAME="flashUpload" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
</OBJECT> 

Can you please help me with a detail example?

I tried placing an image above the flash with absolute position but when clicked the flash doesn't run.

Thank You.

Regards,

Shishant Todi

Upvotes: 0

Views: 231

Answers (2)

Michal M
Michal M

Reputation: 9480

That's how your AS3 should look like:

ExternalInterface.addCallback("runFlash", jsCallsRunFlash);

function jsCallsRunFlash()
{
    ...
}

//edit

And here's AS2 version tutorial

Upvotes: 0

Jason Miesionczek
Jason Miesionczek

Reputation: 14448

You could try using SWFObject and put something like this in your runFlash() function:

var so = new SWFObject("movie.swf", "mymovie", "400", "200", "8", "#336699");
so.write("flashcontent");

And just put a div on the page named "flashcontent" which initially contains the image.

Upvotes: 2

Related Questions