tags:

views:

458

answers:

4

I want an animation play only once in the browser. If any user seen the movie and if goes to any other page or refresh(F5) and then come back on the animation page then animation should not play from start. I want to play it from another frame.

I think it can be done by set cookie or somthing using javascript or php.

Please anybody help me. Thanks in advance. I will appreciate ,if some code help please

A: 

With PHP you can set a cookie with the SetCookie function. In JavaScript you set it like this.

Jan Hancic
+1  A: 

You can set a session

session_start();

And then set a session variable after the flash data

$_SESSION["noflash"] = true;

And do a check above the flash

if(isset($_SESSION["noflash"]) && $_SESSION["noflash"] == true)
{
    // set the correct flashvars
}

That way the session data is set after the flash is initialized, and the session data is still on when the user comes to the site again.

Ólafur Waage
If you wan't this effect to remain even after user has closed and reopened the browser, you will have to use a cookie.
Jan Hancic
Using $_SESSION comes to much the same thing as using cookies. A cookie on the browser is how the server identifies which session is associated with the user.
ctford
+1  A: 

You could do something like this

<?php
session_start();

$animation_start = isset( $_SESSION['seen_animation'] ) ? 'animation_start=middle' : 'animation_start=start';
$_SESSION['seen_animation'] = true;
?>

<!-- simplified flash embed -->
<object width="550" height="400">
    <param name="movie" value="myflash.swf" />
    <param name="FlashVars" value="<?php echo $animation_start ?>" />
    <embed src="myflash.swf" width="550" height="400" FlashVars = "<?php echo $animation_start ?>"></embed>
</object>

You will have a global variable in your swf called 'animation_start' which will contain 'start' or 'middle' to let you know where to play your movie from

meouw
A: 

Don't forget to set the string $domain to '/' or maybe they don't work on all subdirectories. Regards.

skateboard