开发者

Flex: Need embedded SWF to be able to interact with project assets

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')]
    [Bindab开发者_运维问答le] 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"/>


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:

|
index.html
|
+ swf
| |
|  main.swf
|
+ components
|
+ xml

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.


First You should load images through loader,

var loaderSmall:Loader=new Loader(); loaderSmall.load(new URLRequest(imgArr[0].path)); loaderSmall.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,loadThumbImage); loaderSmall.contentLoaderInfo.addEventListener(Event.COMPLETE,hideThumbImageLoader);

Here,

imgArr[0].path

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜