在闪存加载图像动态地 [英] Load image dynamicly in flash

查看:116
本文介绍了在闪存加载图像动态地的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有动态地使用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.

这篇关于在闪存加载图像动态地的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆