在闪存加载图像动态地闪存、图像、加载、动态

由网友(绊绊绊绊死你)分享简介:我有动态地使用ActionScript 3.0,PHP和MySQL来加载图像。我在数据库中的图像路径​​。现在我要显示Flash中的图像。谁能帮我?I have to load image dynamicly using actionscript 3.0, PHP and Mysql. I have the imag...

我有动态地使用ActionScript 3.0,PHP和MySQL来加载图像。我在数据库中的图像路径​​。现在我要显示Flash中的图像。谁能帮我?

I have to load image dynamicly using actionscript 3.0, PHP and Mysql. I have the image path in the database. Now i have to show the image in flash. Can anyone help me?

推荐答案

您必须使用AS3 Loader类来做到这一点。 Loader类应该加载的PHP脚本。 PHP脚本应该从MySQL数据库加载并显示图像。它可能看起来像:

you have to use AS3 Loader class to do that. Loader class should load php script. Php script should load image from MySQL database and display it. It could look like that:

AS3:

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, ImageLoaded);
loader.load(new URLRequest(urlToYourPhpScript));

function ImageLoaded(e:Event) {
    addChild(e.target.loader.content);
}

其中, urlToYourPhpScript 可以包含一些GET变量来确定你的形象: urlToYourPhpScript ='http://www.example.com/?imageid= 10

where urlToYourPhpScript can contain some get variables to identify your image: urlToYourPhpScript = 'http://www.example.com/?imageid=10'

PHP:

$link = mysql_connect("localhost", "username", "password") or die("Error: " . mysql_error());

// select our database
mysql_select_db("test") or die(mysql_error());

// get the image from the db
$sql = "SELECT image FROM images WHERE id=".$_GET['imageid'];

// the result of the query
$result = mysql_query("$sql") or die("Query error: " . mysql_error());

// set the header for the image
header("Content-type: image/jpeg");
echo mysql_result($result, 0);

// close the db link
mysql_close($link);

其中, $ _ GET ['imageid'] 是identyfying你的形象从AS3传递参数。

where $_GET['imageid'] is a parameter passed from AS3 for identyfying your image.

阅读全文

相关推荐

最新文章