Solved

Can I limit a flash .swf object to replay three times without having .fla file

Posted on 2011-02-10
2
542 Views
Last Modified: 2012-05-11
Is there a way to limit a flash .swf object to only repeating three times.

I do not have access to the .fla file, so I can't do this from within the code.

0
Comment
Question by:birwin
2 Comments
 
LVL 3

Expert Comment

by:dtocci
ID: 34866381
Using the flash embed parameters you can only tell it whether to loop indefinitely or not. There's no direct way to specify the number of times without the .fla file. If you know how long the swf takes to play once, I suppose you could remove the embedded object with javascript after that amount of time multiplied by three, but that's not a very elegant workaround.
http://kb2.adobe.com/cps/127/tn_12701.html
0
 
LVL 18

Accepted Solution

by:
Antonio Estrada earned 500 total points
ID: 34867412
There's no elegant solution, but there is a solution...

You need to create a new Flash file that will act as the loader and "checker" for the loaded movie.

Add this code:
 
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;

var loader:Loader = new Loader();
var loopMax:int = 3;
var loopCount:int = 0;

startUp();

function startUp():void
{
	var urlRequest:URLRequest = new URLRequest("NeverStops.swf");
	loader.load(urlRequest);
	loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
}

function loadComplete(event:Event):void
{
	addChild(loader);
	loader.content.addEventListener(Event.ENTER_FRAME, checkFrame);
}

function checkFrame(event:Event):void
{
	var currObj:Object = event.currentTarget;
	if (currObj.currentFrame == currObj.totalFrames)
	{
		loopCount++;
		if (loopCount == loopMax)
		{
			currObj.gotoAndStop(currObj.totalFrames);
		}
	}
}

Open in new window


Change "NeverStops.swf" to whatever the file you have is named. Also, this works for ActionScript 3.0. If the file you're loading is AS2 it won't work, and you'll need the "AS2" version, if so just let me know and I'll post it over here.

Attached are the fla and the swfs.

Good luck,
-V
NeverStops.swf
FrameChecker.swf
FrameChecker.fla
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access RV042 GUI / Browser Issues 25 47
How to format numbers and letters in nested lists 5 32
Tracking uptime for a bunch of sites 3 35
Only allow one check box 17 24
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question