mercredi 22 juin 2016

AS3 Air for Android filepath

Hello and thank you in advance for any help...

I have the following function that should display all the images in a sub-folder of the app storage directory:

public function mygallery():void
        var gallery:File = File.applicationStorageDirectory.resolvePath("IMAGES/");
        var gfiles:Array = gallery.getDirectoryListing();

        var gcount:int = 0;
        gcount = gfiles.length;

        var x_counter:Number = 0;
        var y_counter:Number = 0;


        function createContainer():void
            container_mc = new MovieClip();
            container_mc.x = gx;
            container_mc.y = gy;
            //container_mc.width = gthumbw;
            //container_mc.height = gthumbh;

        function callThumbs():void
            for (var j:uint = 0; j < gcount; j++)
                var thumb_url = gfiles[j].nativePath;
                var thumb_loader = new Loader();
                thumb_loader.load(new URLRequest(thumb_url));
                thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);

                thumb_loader.x = (gthumbw+gspw)*x_counter;
                thumb_loader.y = (gthumbh+gsph)*y_counter;
                if (x_counter+1 < gcol)
                    x_counter = 0;

        function thumbLoaded(e:Event):void
            var my_thumb:Loader = Loader(;

            my_thumb.width = gthumbw;
            my_thumb.height = gthumbh;


the gcount returns the correct number of files in the folder but for some reason the images do not display at all.

When I run this in windows it works fine, which leads me to believe that it's either a sandbox issue for Android or I'm using the file paths incorrectly.

Any advice is greatly appreciated

Aucun commentaire:

Enregistrer un commentaire