5 Replies Latest reply on Aug 10, 2009 6:06 AM by sirk214

    Sandbox Problems by loading local images

    sirk214

      Hi everyone,

      I have still problems with the sandbox settings and didn't find the answer in the worldwideweb yet. Hopefully someone knows the answer or some useful links.

       

      I'm working on a language learning tool at the moment. It should be a local swf-file in the end, which get s all data (images, videos..) from a local folder. User should download the whole package before playing.

       

      Every data is stored in folder called assets  (so, main.swf should be in same folder as the assets folder, and all files are accessable with ../assets/filename)

       

      At the moment it doesn't show any pictures! It says, (if i translate it to english)

      ***Security Sandbox Violation***

      Connection from file://myApplication/bin-debug/../assets/graphics/picture.jpg interrupted - not allowed from file:///myApplication/bin-debug/App.swf

       

      But the program doesn't have problems with loading sound or videos from the assets folder. This works fine!

       

      It also works without problems, if I save the pictures in another folder on my system!  But this won't work later on anohter pc...Any ideas?

       

      Greetings,

      Krister

       

      Further informations:

      - Pictures are included like this: <mx:Image source="../assets/graphics/picture.jpg"/>

      - I m working with flex 3 on mac os x 10.4

      - I tried to compile with use-network=false -> same result, if this should be sth right so solve the problem?!

        • 1. Re: Sandbox Problems by loading local images
          sirk214 Level 1

          - sandbox type is localTrusted

          • 2. Re: Sandbox Problems by loading local images
            ShardulSingh Level 3

            Hi,

             

            Have you embedded all images?And in which control you are showing the images,like <Image> or loader etc.

             

             

             

            Shardul Singh Bartwal

            • 3. Re: Sandbox Problems by loading local images
              sirk214 Level 1

              I'm not using a special loader for the pictures like for the sounds or the videos. Or is this needed?

               

              I built the menu with the Flex3 Design-mode and chose the pictures with the "FileChoser".

               

              I'm showing the images with f.e.

               

              <mx:Canvas id="EnterNamePanel">
                      <mx:Image>
                          <mx:source>../assets/graphics/menuEnterName-BG.jpg</mx:source>
                      </mx:Image>

               

              If I embed the picture with direct source to the local file like, it works fine. (see below). But I want the ../assets-location. Because every user should be able to install the program in a different folder!

               

              <mx:Canvas id="EnterNamePanel">
                       <mx:Image>
                           <mx:source>file:////Application/grapics/menuEnterName-BG.jpg</mx:source>
                       </mx:Image>

               

               

              Greetings, K

              • 4. Re: Sandbox Problems by loading local images
                ShardulSingh Level 3

                Hi,

                I am not able to understand your problem properly.The thing is that when you are making the flex application you are putting your images inside the

                assets foler,if I am not wrong. After building the flex application you gets the swf, also in the same folder you will be having the assets folder.Now where

                ever you want to use this swf you have to put all the files which are inside that folder which is having the swf and assets.It does't matter where you are

                putting them.There is no need to write the path of image on the local pc where the application will be run.You have to simply give the path of your asset

                folder for the source of image. And in the download user need to put the assets and swf file in the same drive.Thats all.

                If your scenario is different pls made me bit clear, that which one images you are going to show.Like the example below will create the build in which the swf and assets folder will be in the same folder.

                 

                 

                 

                 

                 

                 

                 

                 

                <?xml version="1.0"?>

                <mx:Application

                 

                xmlns:mx="http://www.adobe.com/2006/mxml">

                 

                <mx:Script>

                <![CDATA[

                [

                 

                Embed(source="assets/img1.jpg"

                )]

                [

                 

                Bindable

                ]

                 

                 

                public var

                imgClass:Class;

                ]]>

                </mx:Script>

                 

                <mx:VBox

                width="500" height="100%">

                <mx:Image width="100%" height="100%" source="{imgClass}">

                </mx:Image>

                </mx:VBox>

                </mx:Application>

                 

                 

                 

                 

                 

                Now where ever you want to run the swf use all the folders and files which are in the folder where your swf is.

                 

                 

                 

                 

                Pls let me know if your need is different than this.

                 

                 

                 

                with Regards,

                Shardul Singh Bartwal

                1 person found this helpful
                • 5. Re: Sandbox Problems by loading local images
                  sirk214 Level 1

                  Hi Shardul!

                   

                  Thanks for your help!

                  Actually I didn't understand zour example code 100%, but your hints solved my problem! I have couple of images, so I wasn't sure how to load them your way with several variable names. I have to admit, that I also didn't work with "Bindable" yet. I think I should check this out. Anyway...

                   

                  You were right. I didn't embed the pictures! I solved it like this:

                   

                  <mx:Image source="@Embed('../assets/graphics/picture.jpg')"/>

                   

                   

                  Best regards,

                  Krister