Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

<< Prev 5 | Next 5

cookie counter via flash php

/* This script counts how many times an individual user or client clicks to your
page and stores it as encrypted cookie. I have encrypted the cookie because
I eventually planed to save confidential login data.
Meanwhile  the MX SharedObject sure is good for this task but
if you have php on hand or if developing for flash 5 than you might
want to take this way into consideration.*/

//in Flash use this code on the first frame:

_root.loadVariables("cookie.php");
stop();

//and create a dynamic text field with the variable maned "visit" in flash.

//here is the php file to be named "cookie.php"

<?php
$count = base64_decode($HTTP_COOKIE_VARS["visit"]);// read and decode cookie
if ($count==""){// if cookie not found than set initial value to 1
        SetCookie("visit", base64_encode("1"), time()+157248000);// cookie name,  encrypt value 1, expire time now + milliseconds
        echo "visit=1";// send variable visit to flash
}else{ // cookie was found, update the incremented cookie and send the variable to flash, here you go!
        $count++;
        SetCookie("visit", base64_encode("$count"), time()+157248000);
        echo "visit=$count";
}
?>

//That's all! Have fun!

Posted by: Folko Langner | website http://www.advance-media.com
How to use a php session variable to jump-start one and the same flash movie on different frames.
<?php
session_start();
/*
Let's say you got a small banner flash film embedded in your html page and on (some of) the following pages
you do want to display exactly the same movie again but without repeating the intro all over again.

(This session solution also is highly useful e.g. for storing the return value of the flash plugin detection.
Whenever the next flash film on your site appears simply read out the session first and use
an if statement switching between displaying the flash movie and an alternative image.)

The first PHP lines above are mandatory on each and every page of your site whenever you want to use the PHP session.
These lines do have to appear in the beginning of the document by definition.
*/
if (empty($_SESSION[flash])){// checking if the session variable named "flash" is empty. Not used before -> play intro!
        $junp_to="intro"; // if empty than set the variable called $jump_to="intro"; and...
        $_SESSION[flash]="main"; // ... set the session variable named "flash" to the value "main".
} else {
        $junp_to=$_SESSION[flash];// or $junp_to="main"; The session was used before -> play main
}
?>
<HTML>
<HEAD>
<TITLE>WWW.ADVANCE-MEDIA.COM</TITLE>
</HEAD>
<BODY bgcolor="#000000">
<!-- embed the flash movie  -->
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
WIDTH="600" HEIGHT="400">
<PARAM NAME=movie VALUE="session.swf?init=<?php /*here I add a variable called "init" to send the session result to flash and below do the same again in the embed tag*/ echo $junp_to; ?>">
<PARAM NAME=loop VALUE=false> <PARAM NAME=menu VALUE=false> <PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#000000> <EMBED src="session.swf?init=<?php echo $junp_to; ?>"
loop=false menu=false quality=high bgcolor=#000000  WIDTH="600" HEIGHT="400"
TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
</OBJECT>

</BODY>
</HTML>

<!--
Here is the action script of the flash movie called "session.swf"
I have placed it on frame 10. I sometimes did experience bugs (problems) when using the IE browser if writing the following lines to early!
if (init == undefined) { //loop until the variable "init" is set
        gotoAndPlay(9);
} else {
        gotoAndStop(init); //and than gotoAndStop(Play) the frames depending on the value of "init" (Don't forget to label two frames. One labeled "intro" and one "main")
}
/* For testing simply click the refresh or reload button of the browser and... Here you go! 2003 by www.advance-media.com
Of course a session expires when the user closes the browser window... */
-->

Posted by: Folko Langner | website http://www.advance-media.com
HTTPPostRequest
/*
Copyright (c) 2006 www.ericfeminella.com.
All rights reserved.

Author Eric J. Feminella

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
                                                                INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ignore
*/

package com.ericfeminella.dataProviders
{
        import flash.net.URLVariables;
        import flash.net.URLLoader;
        import flash.net.URLRequest;
        import mx.rpc.events.ResultEvent;
        import mx.rpc.events.FaultEvent;
        
        public class HTTPPostRequest
        {
                public static function post(uri:String, rawData:Object, result:Function, fault:Function)
                {
                        var dataLoader:URLLoader = new URLLoader();
                        dataLoader.addEventListener(ResultEvent.RESULT, result);
                        dataLoader.addEventListener(FaultEvent.FAULT, fault);
                        
                        var nameValuePairs:URLVariables = new URLVariables();
                        
                        for (var name:String in rawData) {
                                nameValuePairs[name] = rawData[prop];
                        }
                        
                        var request:URLRequest = new URLRequest(uri);
                        request.data = nameValuePairs;
                        
                        dataLoader.load(request);
                }
        }
}

Posted by: Eric Feminella | website http://www.ericfeminella.com/blog
Loading no cache images and swf files
// Loading no cache images and swf files 2007 by www.advance-media.com
// the timestamp prevents caching.
// the loaded .jpg .gif .png .swf file is renamed as "uploaded.im" to avoid tedious is_file tests


// flash 9 as3 loading jpg gif png swf
stop();
var my_date:Date = new Date();
var requestURL:URLRequest = new URLRequest("read_media.php?tstamp="+my_date.getTime());
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
function ioErrorHandler(event:IOErrorEvent):void {
	//trace("ioErrorHandler"); 
	// without this event handler the flash 9 player prompts an error window in case no image/swf is found
}
loader.load(requestURL);
addChild(loader);


// flash 8 as2 loading jpg gif png swf
stop();
var my_date:Date = new Date();
this.createEmptyMovieClip("container", getNextHighestDepth());
container.stop(); // stop to save cpu usage, a mc is running by default
var mcl:MovieClipLoader = new MovieClipLoader();
mcl.loadClip("read_media.php?tstamp="+my_date.getTime(), container);


// mx as1 loading jpg
stop();
var my_date = new Date();
this.createEmptyMovieClip("container", 666);
container.stop();
container.loadMovie("read_media.php?tstamp="+my_date.getTime());


// create a PHP file called read_media.php

// uploaded.im instead of uploaded.jpg or uploaded.gif ...

Posted by: Folko Langner | website http://www.advance-media.com
login submit button script
on(rollOver)
{
        sl.gotoAndPlay(2);
        sr.gotoAndPlay(2);
}
on(rollOut)
{
        sl.gotoAndStop(1);
        sr.gotoAndStop(1);
}
on(release)
{
        lv.username = this.txtUsername.text;
        lv.passwd = this.txtPassword.text;
        
        lv.sendAndLoad("http://www.kolliz.com/personal/loginprocess.asp",lv2,"POST");
        //s	trace(lv);
}

Posted by: Vithal C Rao | website http://www.pruthvicybertech.com

<< Prev 5 | Next 5

Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.