Flex:需要嵌入式 SWF 才能与项目资产交互
我有一个 Flex 项目,其中嵌入了包含图像查看器的 Flash SWF。我嵌入的 SWF 文件由一个 XML 文件进行补充,其中包含要显示的图像列表以及包含图像的图像文件夹。
我遇到的问题是嵌入的 SWF 文件无法加载图片。我可以看到前进/后退导航按钮,但没有加载图像。当我在 Flex 项目之外查看 SWF 文件时,它工作正常。这是因为 Flex 不允许 SWF 到达外部并访问其他项目资产吗?我该如何解决这个问题?
这是我嵌入 SWF 的代码:
<mx:Script>
<![CDATA[
import mx.controls.Image;
import mx.events.CloseEvent;
import mx.managers.PopUpManager;
[Embed(source = '../components/sampleReportViewer/photo_stack_gallery.swf')]
[Bindable] public var SWFClass:Class;
private function init():void {
//add the swf to the container
var img:Image = new Image();
img.source = MovieClip(new SWFClass());
contentBox.addChild(img);
PopUpManager.centerPopUp(this);
}
]]>
<mx:VBox id="contentBox"
width="600" height="450"/>
I have a Flex project in which I am embedding a Flash SWF containing an image viewer. The SWF file I'm embedding is supplemented by an XML file, which contains a list of images to show, and an images folder containing the images.
The problem I'm running into is that the embedded SWF file is unable to load the pictures. I am able to see the forward/backward navigation buttons, but there are no loaded images. When I view the SWF file outside of the Flex project it works fine. Is this because Flex isn't allowing the SWF to reach outside and access other project assets? How can I get around this?
Here's my code for embedding the SWF:
<mx:Script>
<![CDATA[
import mx.controls.Image;
import mx.events.CloseEvent;
import mx.managers.PopUpManager;
[Embed(source = '../components/sampleReportViewer/photo_stack_gallery.swf')]
[Bindable] public var SWFClass:Class;
private function init():void {
//add the swf to the container
var img:Image = new Image();
img.source = MovieClip(new SWFClass());
contentBox.addChild(img);
PopUpManager.centerPopUp(this);
}
]]>
<mx:VBox id="contentBox"
width="600" height="450"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的猜测是你们的工作路径不一样。从 url (
../
) 中的相对路径来看,您的项目结构如下所示:如果是这种情况,您的 Flash 播放器将假定 index.html 的父文件夹为在您当前的工作路径中,如果您将 HTML 页面加载到浏览器中,则所有
../
引用将找不到正确的资源,而如果您直接双击 swf 开始,则所有内容都会找到工作正常。My guess is your workpath is not the same. Judging from the relative paths in your url (
../
) you have a project structure that looks something like this:If that is the case, your Flash player will assume the parent folder of index.html as your current workpath, if you load the HTML page into your browser, and all your
../
references won't find the correct resources, whereas if you start by double-clicking the swf directly, everything will work fine.首先你应该通过加载器加载图像,
这里,
是要加载的图像的路径,现在您可以做更多的事情,通过这种类型的设置,现在您可以检查图像是否正在加载
这是一个示例画廊,其中我开发的,它不是很完美,但图像加载是通过加载器,
http://no-refresh.com/demo/PortfolioSlideshow2/
在您的问题中,u shd首先检查路径,无论这是否正确,可能图像的来源不正确,
正如@weltraumpirat所写,也要检查一下,
我知道这对你没有帮助,但有新的方法,希望它能帮助你smway,TC
安库尔
First You should load images through loader,
Here,
is the path of the image which is to be loaded, now you can do lot more things, with this type of setup, now you can check, whether image is loading or not
This is one exmaple gallery, which i developed, it's not very perfect, but images i m loading is through loader,
http://no-refresh.com/demo/PortfolioSlideshow2/
In your problem , u shd first check the path, whether thats correct or not, may b sourec of image is not correct,
As @weltraumpirat has wrote, do check for that as well,
i know it won't help u, but n e ways, hoping it helps u smway, tc
Ankur