Flash 不能显示图片,急~~~~~~~~~~··

GOALSTAR 2009-04-14 01:22:19
脚本:ActionScript 2.0
问题:
我要读取XML里面的保存的图片名字,请看我以下的代码,我在FLASH CS3 中 用Ctrl + Enter 可以显示图片,单独打开SWF文件也可以显示图片,
但是放到网站上面用http://localhost/website 这样就不能显示图片出来了,请问是怎么回事。有达人遇到相应的问题么。
var fullPath = "./";
var introURL = new String();
var xmlconnection = new XML();
xmlconnection.ignoreWhite = true;
xmlconnection.load("./info_flash_path.xml");
xmlconnection.onLoad = function (success){

if (success){
_root.introURL = xmlconnection.firstChild.childNodes[0].childNodes[0].nodeValue;
gotoAndPlay(_currentframe + 1);
}else{
trace ("fail~~~~, can not load info_flash_path.xml file .");
}
};
stop ();

======================================================================
var xmlIntroImage = new XML();
xmlIntroImage.ignoreWhite = true;
xmlIntroImage.load(fullPath + "xml/" + introURL);
xmlIntroImage.onLoad = function (success)
{
gotoAndPlay(_currentframe + 1);
};
stop ();
...全文
408 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
GOALSTAR 2009-04-18
  • 打赏
  • 举报
回复
我自己下载到别人的读取xml的再现实图片的demo,就可以显示出图片

估计是代码的问题,但是本地调试又没有问题。只是放到网上才有问题。
maninwater 2009-04-16
  • 打赏
  • 举报
回复
贴XML的内容出来
GOALSTAR 2009-04-16
  • 打赏
  • 举报
回复
下面是XML的

<?xml version='1.0' encoding='utf-8'?>
<fileList>
<filesList category_id="20060215162232-218467" product_id="20060216113405-452303" fileName="file/index/img-20060216113405-452303.jpg" /><filesList category_id="20060215162232-218467" product_id="20060217153046-672603" fileName="file/index/img-20060217153046-672603.jpg" /><filesList category_id="20060220165702-154985" product_id="20060221161457-809446" fileName="file/index/img-20060221161457-809446.jpg" /><filesList category_id="20060220165722-042503" product_id="20060227191806-230237" fileName="file/index/img-20060227191806-230237.jpg" /><filesList category_id="20060215162232-218467" product_id="20060227192026-051553" fileName="file/index/img-20060227192026-051553.jpg" /><filesList category_id="20060220165708-806439" product_id="20060323161307-078498" fileName="file/index/img-20060323161307-078498.jpg" /><filesList category_id="20060215162232-218467" product_id="20060323161430-473719" fileName="file/index/img-20060323161430-473719.jpg" /><filesList category_id="20060220165653-729594" product_id="20060323161544-636249" fileName="file/index/img-20060323161544-636249.jpg" /><filesList category_id="20060220165722-042503" product_id="20081018104830-183440" fileName="file/index/img-20081018104830-183440.jpg" /><filesList category_id="20060220165722-042503" product_id="20060328161602-372483" fileName="file/index/img-20060328161602-372483.jpg" /><filesList category_id="20060220165722-042503" product_id="20060410144504-821017" fileName="file/index/img-20060410144504-821017.jpg" /><filesList category_id="20060220165708-806439" product_id="20060418143414-553070" fileName="file/index/img-20060418143414-553070.jpg" />
</fileList>
GOALSTAR 2009-04-16
  • 打赏
  • 举报
回复
下面是 ActionScript 2.0 的脚本。主要负责随机产生图片。
class as.randomImage extends MovieClip
{
var _name, loaderTotal, max, min, frameRate, randProcedure, nowEndLoader, mclListener, loaderShowNumber, nowLoaderComplete, loaderShowArray, category_idGoTo, project_idGoTo;
function randomImage()
{
super();
} // End of the function
function onLoad()
{
loaderTotal = Number(_name.substr(20, 1));
if (loaderTotal == 8)
{
max = loaderTotal / 2 + 1;
min = 2;
}
else
{
max = loaderTotal / 2;
min = 1;
} // end else if
frameRate = 2;
randProcedure = new as.randomProcedure();
nowEndLoader = 0;
mclListener = new Object();
mclListener.onLoadComplete = movieClipLoadCompleteFun;
loaderShowNumber = this.startImageChg(this, randProcedure);
} // End of the function
function startImageChg(targetMovieClip, randProcedure)
{
var _loc6 = new MovieClipLoader();
var _loc8 = new MovieClipLoader();
_loc6.addListener(mclListener);
var _loc7 = Math.round(Math.random() * (max - min)) + min;
var _loc5 = new Array();
if (_root.xmlIntroImage.firstChild.childNodes.length < _loc7)
{
return (0);
} // end if
nowLoaderComplete = 0;
loaderShowArray = new Array();
loaderShowArray = randProcedure.getRandomResult(1, loaderTotal, _loc7);
_loc5 = randProcedure.getRandomResult(0, _root.xmlIntroImage.firstChild.childNodes.length - 1, _loc7);
for (var _loc3 = 1; _loc3 <= loaderTotal; ++_loc3)
{
targetMovieClip["imageLoader" + _loc3].onRelease = null;
targetMovieClip["imageLoader" + _loc3].useHandCursor = false;
} // end of for
for (var _loc3 = 0; _loc3 < loaderShowArray.length; ++_loc3)
{
if (loaderTotal == 8)
{
targetMovieClip["imageLoader" + loaderShowArray[_loc3]].onRelease = imageRelease;
}
else
{
targetMovieClip["imageLoader" + loaderShowArray[_loc3]].onRelease = imageReleaseIntro;
} // end else if
targetMovieClip["imageLoader" + loaderShowArray[_loc3]].useHandCursor = true;
targetMovieClip["imageLoader" + loaderShowArray[_loc3]].category_idGoTo = _root.xmlIntroImage.firstChild.childNodes[_loc5[_loc3]].attributes.category_id;
targetMovieClip["imageLoader" + loaderShowArray[_loc3]].project_idGoTo = _root.xmlIntroImage.firstChild.childNodes[_loc5[_loc3]].attributes.product_id;
targetMovieClip["imageLoader" + loaderShowArray[_loc3]].imageLoader.createEmptyMovieClip("image_mc", 1);
_loc6.loadClip(_root.fullPath + _root.xmlIntroImage.firstChild.childNodes[_loc5[_loc3]].attributes.fileName, targetMovieClip["imageLoader" + loaderShowArray[_loc3]].imageLoader.image_mc);
trace(_root.fullPath + _root.xmlIntroImage.firstChild.childNodes[_loc5[_loc3]].attributes.fileName);
if (loaderShowArray[_loc3] >= loaderTotal / 2 + 1)
{
targetMovieClip._parent["imageLoader" + loaderShowArray[_loc3] + "_shadow"].imageLoader.createEmptyMovieClip("image_mc", 1);
_loc6.loadClip(_root.fullPath + _root.xmlIntroImage.firstChild.childNodes[_loc5[_loc3]].attributes.fileName, targetMovieClip._parent["imageLoader" + loaderShowArray[_loc3] + "_shadow"].imageLoader.image_mc);
} // end if
} // end of for
return (_loc7);
} // End of the function
function imageRelease()
{
_root.subMenuAppear = true;
_root.back2 = true;
_level0.category_id = category_idGoTo;
_level0.project_id = project_idGoTo;
_root.gotoAndPlay("pdetail");
_root.menu.gotoAndPlay("subCategoryLoad");
} // End of the function
function imageReleaseIntro()
{
_level0.category_id = category_idGoTo;
_level0.project_id = project_idGoTo;
_level0.fromIntro = true;
_level0.pageName = "project.swf";
_root.gotoAndPlay("selfClose");
} // End of the function
function movieClipLoadCompleteFun(target_mc)
{
++target_mc._parent._parent._parent.nowLoaderComplete;
if (target_mc._parent._parent._parent.nowLoaderComplete >= target_mc._parent._parent._parent.loaderShowNumber)
{
for (var _loc2 = 0; _loc2 < target_mc._parent._parent._parent.loaderShowArray.length; ++_loc2)
{
target_mc._parent._parent._parent["imageLoader" + target_mc._parent._parent._parent.loaderShowArray[_loc2]].gotoAndPlay(target_mc._parent._parent._parent.max * target_mc._parent._parent._parent.frameRate - _loc2 * target_mc._parent._parent._parent.frameRate);
if (target_mc._parent._parent._parent.loaderShowArray[_loc2] >= target_mc._parent._parent._parent.loaderTotal / 2 + 1)
{
target_mc._parent._parent._parent._parent["imageLoader" + target_mc._parent._parent._parent.loaderShowArray[_loc2] + "_shadow"].gotoAndPlay(target_mc._parent._parent._parent.max * target_mc._parent._parent._parent.frameRate - _loc2 * target_mc._parent._parent._parent.frameRate);
} // end if
} // end of for
} // end if
} // End of the function
} // End of Class
GOALSTAR 2009-04-15
  • 打赏
  • 举报
回复
没有跨域啊
楼上的方法,我试过了也没用
咋了啦 2009-04-14
  • 打赏
  • 举报
回复
同意楼上的,然后还有一个问题就是你要注意flash的发布设置中,你在网络上应用,需要设置“仅仅从网络读取”这个选项,不要选择“仅仅从本地读取”
maninwater 2009-04-14
  • 打赏
  • 举报
回复
跨域访问的话,会有限制,你先把xml里的图片改成和swf同目录里的文件试一下,如果没问题就是跨域方面的问题,如果还有问题,可能是加载比较慢或其他什么问题,就好解决了。

2,278

社区成员

发帖
与我相关
我的任务
社区描述
多媒体/设计/Flash/Silverlight 开发 Flash流媒体开发
社区管理员
  • Flash流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧