2011-11-21 35 views
1

我正在为多个客户做这个闪光横幅,一个主要的要求是有某种计数器,所以他们知道横幅被点击了多少次。计数器在ActionScript 3.0中与... PHP或?

我知道如何在ActionScript 3.0中做到这一点,我做了一个简单的var:int,并且在横幅上点击时我增加了+1。我该如何处理这个var的值(比如说121),我在哪里可以在线存储它,所以它的安全性可以通过多个flash横幅(as3)来改变。

但是,如何在下次加载横幅广告时(在不同的网页上)点击次数是上次加载时的点击次数。

我应该看看PHP吗?我不知道如何做到这一点...一些例子,教程,任何作品...将不胜感激(我是一名设计师,而不是程序员......请不要说php-ish,或者你知道...... :D)

我搜索了一下,发现了一些帮助,但我仍然感到困惑,其中很多不是AS3,我想也许东西已经发展了一些,因为我发现的东西2008)...

非常感谢。

回答

0

您需要存储你想成为检索/数据从多个更新,能够客户端,存储在服务器上。

您可以在数据库中使用任何服务器端语言。

服务器语言:PHP,ASP.net,JSP,ColdFusion的
数据库:MySQL和MSSQL和PostgreSQL,甲骨文,DB2等。

使用任何组合,你是舒服。

一般:

  1. 你有一个Web应用程序在数据库
  2. 通话使用的URLLoader从AS3横幅页面计数器加1。

数据库

counter_table 
------------- 
counter  INT 

PHP文件

$db = mysql_connect('localhost', 'mysql_user', 'mysql_password'); 
mysql_select_db('database_name'); 
mysql_query('UPDATE counter_table SET counter = counter + 1'); 

AS3横幅

// url request with your php page address 
var scriptRequest:URLRequest = new URLRequest("http://www.example.com/script.php"); 

// loader 
var scriptLoader:URLLoader = new URLLoader(); 

// load page to trigger database update 
scriptLoader.load(scriptRequest); 

您是否还想检索横幅中的点击次数值?

0

简单的解决方案(真的不是最好的:)你应该使用其他答案之一..反正,使一个PHP文件读取包含访问计数的txt文件..并在你的flashbanner中调用php文件。它会增加每次调用一重击..

PHP:从

<?php 

/** 
* Create an empty text file called counterlog.txt and 
* upload to the same directory as the page you want to 
* count hits for. 
* 
* 
* @Flavius Frantz: YOU DONT NEED THESE: 
* Add this line of code on your page: 
* <?php include "text_file_hit_counter.php"; ?> 
*/ 

// Open the file for reading 
$fp = fopen("counterlog.txt", "r"); 

// Get the existing count 
$count = fread($fp, 1024); 

// Close the file 
fclose($fp); 

// Add 1 to the existing count 
$count = $count + 1; 

// Display the number of hits 
// If you don't want to display it, comment out this line 
//echo "<p>Page views:" . $count . "</p>"; 

// Reopen the file and erase the contents 
$fp = fopen("counterlog.txt", "w"); 

// Write the new count to the file 
fwrite($fp, $count); 

// Close the file 
fclose($fp); 

?> 

示例代码:(谷歌:PHP计数器文件)http://www.totallyphp.co.uk/text-file-hit-counter 代码没有进行测试,但看起来OK。我只评论了一点..