Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Get Flash Movie Duration

How to get the duration of the flash movies through javascript

2:43 pm on Mar 4, 2005 (gmt 0)

New User

10+ Year Member

joined:Mar 4, 2005
votes: 0

I have a webapplication, where I have to display the total display duration of a Flash File. I am using Javascript to read the Flash file properties. Can anybody tell me how we can get Flash file properties like Total movie time in seconds, Flash file height and width in pixels?

Also is it possible to stop the movie after a single loop?

Thank you for your help.

1:04 am on Mar 9, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:July 23, 2003
votes: 0

I am assuming that you have already figured out how to pass data to JavaScript and you only need to figure that data out in the Flash movie.

The movie duration is stored in the getTime () object:

mytime = getTime ();

Note that the time is in milliseconds, so divide it by 1000 to get seconds:

mytime = getTime ()/1000;

You can get the width and height of the movie like this:

mywidth = Stage.width;
myheight = Stage.height;

Strangely Flash is missing 4 pixels on the width and height, so you have to add tehm up:

mywidth = Stage.width + 4;
myheight = Stage.height + 4;

And finally, to stop the movie at the end, make a keyframe on the last frame (F6) and place a stop () action there.

I hope that helps :)

3:05 am on Mar 9, 2005 (gmt 0)

New User

10+ Year Member

joined:Mar 4, 2005
votes: 0

Thank You... I will try this.
6:18 am on Mar 11, 2005 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member whoisgregg is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Dec 9, 2003
votes: 0

Thanks Philarmon for posting those helpful actionscript snippets. :)