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

Loading images from local folder

Community Beginner ,
Mar 03, 2024 Mar 03, 2024

Copy link to clipboard

Copied

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?

Views

431

Translate

Translate

Report

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
...

Votes

Translate

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 
...

Votes

Translate

Translate
Community Expert ,
Mar 09, 2024 Mar 09, 2024

Copy link to clipboard

Copied

which line code is that?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Screenshot 2024-03-09 183514.png

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

@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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

There are 10 items

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

oh, just list them in load_targetA.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

odds are, you're correct.  

 

op, is this an air app?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Thank you for the help. 👍

Votes

Translate

Translate

Report

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