问题
How would it be possible to have a HTML page play a flash animation only once, i.e. when a person goes back to that page, the Flash won't play again from the start but will just show the last frame of the animation (or even a simple .jpg image of that last frame)? Is it even possible?
Thanks, L.
回答1:
you could save a cookie the first time the user visits to show that the user has visited before. (http://plugins.jquery.com/project/Cookie)
Then when they return pass that value to the flash (using flashvars) so it knows only to play the last frame. (http://bowievanling.com/blog/using-flashvars-with-swfobject-20-and-as3/)
Using swfObject to embed your flash:
<script type="text/javascript">
var flashvars = {
iscookie: "true"
};
var params = {
menu: "false"
};
var attributes = { };
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0","expressInstall.swf", flashvars, params, attributes);
</script>
in AS3 to load frameNumber if flashvar iscookie = true:
for (var fv in root.loaderInfo.parameters) {
if(fv == 'iscookie'){
if(root.loaderInfo.parameters[fv] == 'true'){
gotoAndStop(frameNumber);
}
}
}
Josh
回答2:
Alternativly to normal cookies, you could use Flash SharedObject. It pretty much like a normal cookie, but you access them via ActionScript, so it might be easier if are authoring the Flash movie yourself. You just save a simple boolean, and then the Flash movie can see it the next time it opens and will know just to display the end frame.
You can read about them here: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/SharedObject.html
来源:https://stackoverflow.com/questions/1108549/have-a-html-page-play-flash-movie-only-once-not-when-revisited