Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Loading images from local folder

Community Beginner ,
Mar 03, 2024 Mar 03, 2024

I have images from a local folder that I would like to load into my flash presentation as an array.

I'm trying to do an Actionscript code. Is there anyway to do that?

2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Mar 04, 2024 Mar 04, 2024
if all those bitmaps are in a subfolder (named bmp_folder) of your published files:
 
var load_targetA:Array = ["Alaska.png", "Australia.png"];
var loaderA = [];  // this will contain the loaders that load the above bitmaps
var index:int = 0;
load_nextF();
 
function load_nextF():void{
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, load_completeF);
loader.load(new URLRequest("bmp_foloder/"+load_targetA[index]));
loaderA.push(loader);
}
 
function
...
Translate
Community Expert , Mar 09, 2024 Mar 09, 2024

Alright.

Please try this:

import flash.display.Bitmap;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.SecurityErrorEvent;
import flash.filesystem.File;
import flash.net.URLRequest;

var source:String = "./images"; // the source directory must be included in the AIR settings
var extensions:Vector.<String> = new <String>[ "bmp", "jpeg", "jpg", "png" ];
var parsedSource:String;
var foundImages:Array;
var 
...
Translate
Community Expert ,
Mar 09, 2024 Mar 09, 2024

which line code is that?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 09, 2024 Mar 09, 2024

Screenshot 2024-03-09 183514.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 09, 2024 Mar 09, 2024

@Caleb Washington : it's because you're targeting the Flash Player. You need to target AIR for Desktop. The File class is AIR-only.

image.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 09, 2024 Mar 09, 2024

And don't forget to include the source folder in the AIR settings.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 09, 2024 Mar 09, 2024

Oh, so it doesn't work in regular flash, just AIR. Ok, I got you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 09, 2024 Mar 09, 2024

There are 10 items

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 09, 2024 Mar 09, 2024

oh, just list them in load_targetA.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 09, 2024 Mar 09, 2024

odds are, you're correct.  

 

op, is this an air app?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 09, 2024 Mar 09, 2024

Yes it is. But, the file constant doesn't work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 09, 2024 Mar 09, 2024
LATEST

Thank you for the help. 👍

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines