当前位置: 动力学知识库 > 问答 > 编程问答 >

Flash+PHP+cookie

问题描述:

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

网友答案:

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.

网友答案:

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

网友答案:

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

网友答案:

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

分享给朋友:
您可能感兴趣的文章:
随机阅读: