我必须使用actionscript 3.0,PHP和Mysql动态加载图像。我在数据库中有图像路径。现在我必须在Flash中显示图像。谁能帮我?在Flash中动态加载图像
回答
你必须使用AS3 Loader类来做到这一点。 Loader类应该加载php脚本。 PHP脚本应该从MySQL数据库加载图像并显示它。它可能看起来像:
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'
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']
是一个参数为了识别您的图像而从AS3传递。
我不知道PHP的一部分,但在ActionScript最好是添加装载机,而不是阶段性增加它的内容:
- 在这种情况下,代码更简单,因为你不必处理完成事件在所有。
- 如果您尝试直接从不同服务器加载的图像访问'content'字段 - 您将获得安全性异常,并且必须将crossdomain.xml放置在带图像的服务器上(并且如果图像服务器不属于你)。
所以AS3部分看起来是这样的:
const loader:Loader = new Loader();
loader.load(new URLRequest(imageURL));
addChild(loader)
检查这些从Flash /传道的Actionscript李布赖姆洛教程:
Introduction to AmfPHP part 2
Introduction to Zend AMF
如果你不知道,gotoandlearn.com是一切Flash的优秀资源。
希望这会有所帮助!
我是新的网络。那么你可以通过简单的PHP来帮助我吗? –
我刚刚做到了!你有没有看过视频?... – PatrickS
我是新的网络,我preper简单的PHP。我可以使用php从数据库中拉出图像路径。你能告诉我如何在Flash中显示这些图像,也可以用作符号吗? –
- 1. 动态加载的图像在Flash中无法正确显示
- 2. 如何在Flash中反动态加载动态加载的PNG
- 3. 在表中加载动态图像HeaderView
- 4. 使图像动态出现在FLASH中
- 5. 动态加载图像
- 6. PHP动态图像加载
- 7. 动态加载图像
- 8. 无法在Flash图库中添加动态图像(Joomla模块)
- 9. 在Silverlight上动态加载图像
- 10. 动态加载WPF中的图像
- 11. Processing.js中的动态图像加载
- 12. 我如何浏览器缓存在Flash中动态加载的图像
- 13. 如何获取动态加载的图像的图像加载?
- 14. 从Flash Builder中的Facebook加载图像
- 15. flash/flex的图像加载图标?
- 16. Phaser在预加载后动态加载图像
- 17. 如何在javascript中移动动态加载的图像
- 18. 为ASPX动态加载jquery图像
- 19. actionscript 3.0动态加载图像
- 20. 预加载的PHP动态图像
- 21. 动态加载图像 - Windows Phone 7的
- 22. Android的动态图像加载
- 23. Internet Explorer动态图像加载
- 24. Silverlight动态图像加载问题
- 25. 将图像动态加载到ReportView
- 26. 动态元素的XAML图像加载
- 27. Silverlight图像:动态加载URL?
- 28. 动态WPF图像加载问题
- 29. 从TripAdvisor抓取动态加载图像
- 30. 将图像动态加载到灯箱
请帮帮我。我褪色了........ –