Load images from folder

I havent used flash in a couple years and i'm feeling a
little lost (not that i knew what i was doing before!) I am however
determined and can understand the code, i just am a little
overwhelmed.
I'd like to tell a movie clip to look into a specific folder
(via url or whatever) and load all images from that folder into the
movie clip. I do not want to have to give the movie the exact
address of each image, as they files may change / be added to over
time.
i know in AS3 i have to use the loader class and then the
addChild to put the loaded stuff into the movie (and thats all i
know), but i just dont know how to get all available images
blindly. any help? please and thank you

You have the right info for the Loader and addChild part.
But I'm afraid you can't use flash to request a directory
listing on your server directly. You can have a script on your
server return the directory listing to flash after the script
performs a directory listing (e.g. php).
Other than that approach (using serverside scripting)...
You could have all the images with a common naming convention
and a numeric suffix and just keep loading in turn until you
encounter a loading error (which your code is set up to
detect).....
e.g. image1.jpg, image2,jpg etc
or:
You could set up some manually coded xml to point to the urls
of each image etc. It seems you want to avoid this though. (This is
pretty much the same idea as the server side scripting except that
instead of using scripting you create the data by 'hand' as xml).

Similar Messages

  • How do i load images from a folder?

    Hello everyone,
    Please can someone help me as i am stuck.
    I am trying to research loading images from a folder called /images/unknown (unknown is a customer number and is stored in a variable called customerNo).
    I feel that i will need to load the images into an array then display them to the screen with a viewer.
    Can anybody help me.
    Thanks in advance

    Welcome to the Sun forums.
    irknappers wrote:
    ...Please can someone help me as i am stuck.You might want to be more exact in future, about what you are stuck on.
    import javax.imageio.ImageIO;
    import java.io.FileFilter;
    import java.io.File;
    import javax.swing.JFileChooser;
    class LoadImages {
        public static void main(String[] args) {
            String[] suffixes = ImageIO.getReaderFileSuffixes();
            FileFilter fileFilter = new FileFilterType(suffixes);
            File directory = null;
            if (args.length==1) {
                directory = new File( args[0] );
            } else {
                JFileChooser fileChooser = new JFileChooser();
                fileChooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
                int result = fileChooser.showOpenDialog( null );
                if ( result == JFileChooser.APPROVE_OPTION ) {
                    directory = fileChooser.getSelectedFile();
                } else {
                    System.err.println("Must select a directory to proceed, exiting.");
            File[] images = directory.listFiles( fileFilter );
            for (File file : images) {
                System.out.println(file);
            System.out.println( "The rest is left an exercise for the reader.  ;-)" );
    class FileFilterType implements FileFilter {
        String[] types;
        FileFilterType(String[] types) {
            this.types = types;
        public boolean accept(File file) {
            for (String type : types) {
                if ( file.getName().toLowerCase().endsWith( type.toLowerCase() ) ) {
                    return true;
            return false;
    }

  • Problem loading image from jar file referenced by jar file

    First, I searched this one and no, I didn't find an answer. Loading images from jar files has been pretty much done to death but my problem is different. Please read on.
    I have my application, a straight up executable running from Eclipse. It uses a jar file, call it JarA. JarA launches a GUI that is located in another jar file. Call it JarB. To recap:
    My application calls JarA -> JarA loads classes from JarB -> JarB looks for images to place in a GUI it wants to show on the screen
    When JarB goes to load an image the following happens:
    java.lang.NullPointerException
         at sun.misc.URLClassPath$3.run(URLClassPath.java:316)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.misc.URLClassPath.getLoader(URLClassPath.java:313)
         at sun.misc.URLClassPath.getLoader(URLClassPath.java:290)
         at sun.misc.URLClassPath.findResource(URLClassPath.java:141)
         at java.net.URLClassLoader$2.run(URLClassLoader.java:362)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findResource(URLClassLoader.java:359)
         at java.lang.ClassLoader.getResource(ClassLoader.java:977)
         at org.cubrc.gmshell.gui.MainWin.preInit(MainWin.java:152)
         at org.cubrc.gmshell.gui.MainWin.<init>(MainWin.java:135)
    The code from JarB that loads the image looks like this:
              URL[] oSearch = {Main.class.getResource("images/")};
              URLClassLoader oLoader = new URLClassLoader(oSearch);
              imgIcon = new ImageIcon(oLoader.getResource("icon.gif"));
              imgMatchRunning = new ImageIcon(oLoader.getResource("gears.gif"));
              imgMatchStill = new ImageIcon(oLoader.getResource("gears-still.gif"));
              imgMagnify = new ImageIcon(oLoader.getResource("magnify.gif"));This looks right to me and JarB certainly has an images directory with those files. But I'm in hell right now because I don't know where to place the images to make this work or if you can even attempt to load images with a dependency chain like this.
    Any help very appreciated!

    Have you tried to move your image-files out of the jar file and place them in the sam folder as the jar-file? I think that would help.
    When you try to load the image-file you get the NullPointerException because the program tries to read a file it can't find. Remember that a jar file IS a file and not a directory.
    If you want to read somthing inside the jar-file you need to encode it first.
    Have you tried to read the jar-file with winRar. It makes it easy to add and remove files in your jar-file.

  • Adobe Flex unable to load images from Amazon S3

    I have a flex 3 app that is attempting to load images from Amazon S3. The images fail to load, so I fired up debug mode. In debug mode, the images load, but I also get the following output in the debugger:
        *** Security Sandbox Violation ***
        SecurityDomain 'http://mybucket.s3.amazonaws.com/logos/mylogo.png' tried to access incompatible context 'http://localhost/myapp/bin-debug/index.html?debug=true'
    I have added a crossdomain.xml file into the root of my bucket as follows, but this does not seem to help:
        <?xml version="1.0" encoding="utf-8" ?>
        <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
        <cross-domain-policy>
          <site-control permitted-cross-domain-policies="master-only" />
          <allow-access-from domain="*" />
          <allow-http-request-headers-from domain="*" />
        </cross-domain-policy>
    I then tried the following:
    Security.loadPolicyFile('http://mybucket.s3.amazonaws.com/crossdomain.xml');
    Security.allowInsecureDomain('http://mybucket.s3.amazonaws.com/');
    Security.allowDomain('http://mybucket.s3.amazonaws.com/');
    At this point, it seems that there are not any more errors reported in debug mode. However, when not in debug mode, then the image still does not load.
    Am I missing something obvious here?

    If you are not getting creationComplete in release vs debug builds, it is best to try to identify the differences between the two runtime environments.
    Is the URL to the SWF the same?  Some folks find that their release folder is missing some important file.
    Is the URL to the HTML wrapper the same?  Some folks launch their debug from file:// and their release from http:// which have different security rules
    Is the launch step the same?  Some folks launch their debug from FlashBuilder and their export via some other mechanism.  This can alter the initial size of the app and that difference can cause some apps to get into a “layout loop” and never hit creationComplete.  To find out if you are in such a loop, report calls to updateDisplayList, and measure() on various compoonents and see if they keep getting called.
    Is there a timing difference?  Some apps may have subtle timing dependencies that change when the release build runs faster.

  • How to get all images from folder in c#?

    I am trying to get all images from folder. But it is not executing from following:
     string path=@"C:\wamp\www\fileupload\user_data";
                string[] filePaths = Directory.GetFiles(path,".jpg");
                for (int i = 0; i < filePaths.Length; i++)
                    dataGridImage.Controls.Add(filePaths[i]);
    Please give me the correct solution.

    How to display all images from folder in picturebox in c#?
    private void Form1_Load(object sender, EventArgs e)
    string[] files = Directory.GetFiles(Form1.programdir + "\\card_images", "*", SearchOption.TopDirectoryOnly);
    foreach (var filename in files)
    Bitmap bmp = null;
    try
    bmp = new Bitmap(filename);
    catch (Exception e)
    // remove this if you don't want to see the exception message
    MessageBox.Show(e.Message);
    continue;
    var card = new PictureBox();
    card.BackgroundImage = bmp;
    card.Padding = new Padding(0);
    card.BackgroundImageLayout = ImageLayout.Stretch;
    card.MouseDown += new MouseEventHandler(card_click);
    card.Size = new Size((int)(this.ClientSize.Width / 2) - 15, images.Height);
    images.Controls.Add(card);
    Free .NET Barcode Generator & Scanner supporting over 40 kinds of 1D & 2D symbologies.

  • Disk Utility 'Disk Image from Folder' looses file create date?

    Hi,
    I have been working on creating backups that maintain the files' create dates. I have found the following anomoly using Disk Utility.
    If I create a Disk Image From Folder, the create dates of all files are changed to be the same as the last modify dates. Not what I want.
    If I creat a Blank Disk Image, and then using Finder to copy the files to the Disk Image, the create dates remain unchanged.
    I can then burn the backup CD's with the Disk Image and the files' create dates are maintained. So, future restore from the backup CD will contain the original files' create dates.
    Does anyone know if Disk Utility's Create Disk Image from Folder is supposed to loose the files' create dates? What other file attributes are being lost? Mac OS X maintains all of these attributes, and create dates via Finder copies, I would expect the Disk Utility Create Disk Image from Folder to do the same.
    Bob Horton

    To follow up on this post, I know at least part of the answer. The difference between the two becomes clearer if you read the documentation (man pages) for hdiutil and asr. Image 1 will be created in file mode, whereas image 2 will be in block mode, ie bypassing the file system. Image 1 will consist of a series of files, whereas image 2 will contain a series of blocks, mirroring the original layout of the hard disk.
    Technically the latter should be faster to restore (in block mode), although Apple recommend the first procedure (see man page for hdiutil). I haven't seen any evidence that images created in block mode can be mounted or restored, although you might be able to burn such images to a optical disks if applicable.
    As I've pointed out in another thread (http://discussions.apple.com/thread.jspa?threadID=1508199&tstart=0) I believe that this functionality should not be offered in disk utility, and I consider it a serious bug.

  • Loader will load images from another server, but then we get error on Bitmap operation

    I'm developing an app that currently is using Loader to get images from another server.  This shouldn't currently work since we are still waiting for the owner of that server to put a crossdomain file in place.  However, it does work -- sort of .
    Loader can load the images fine, without an error.  But then the app has a feature in which we are making a larger duplicate of the image to display in a sidebar, we do this in this manner:
    var myBitmap:Bitmap = Bitmap(loader.content);
    and when this runs we get a Flash player security error 2122, sandbox violation.
    So while I'm hoping all this will fix itself when the crossdomain.xml file is put in place, I'm confused as to why we only get the sandbox error when we make a Bitmap from the image, and not when we initially try to retrieve the image.
    (Incidentally: is there a better way to make a "copy" of an image loaded by a Loader, and then change its width and height for simultaneous display in another part of the stage?  I don't need to change its actual dimensions -- I just need to change its display width and height.)
    Thanks!

    The sandbox allows viewing, not editing from another server without a crossdomain.
    So, when you try to load it up, it loads it, but "read-only" and gives you an error when you try to "edit" it by making a new Bitmap out of it.
    This should resolve itself once that crossdomain is in place.
    ||EDIT||
    I just realized I should clarify my statement a little more.
    When you load images from another server without a crossdomain, it allows the load for display only.  When you try to load data, it will fail.  This is because, XML data, or some other type of data is editable by default, and images are only viewable by default.  So, the image fails when you try to convert it into an editable form.

  • How to load images from css file in JavaFX 8

    I have this css file which loads images in JavaFX 8 application:
    #pill-left {
        -fx-padding: 5;
         -fx-border-image-source: url("/com/dx57dc/images/left-btn.png");
        -fx-border-image-slice: 4 4 4 4 fill;
        -fx-border-image-width: 4 4 4 4;
        -fx-border-image-insets: 0;
        -fx-border-image-repeat: stretch;
         -fx-background-color: null !important;
    #pill-left:selected { -fx-border-image-source: url("/com/dx57dc/images/left-btn-selected.png"); }
    #pill-left .label {
        -fx-text-fill: #d3d3d3;
        -fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.75) , 0, 0.0 , 0 , -1 );
    #pill-left:selected .label {
        /* -fx-text-fill: black; */
        -fx-text-fill: white;
        -fx-effect: dropshadow( one-pass-box , white , 0, 0.0 , 0 , 1 );
    #pill-center {
        -fx-padding: 5;
         -fx-border-image-source: url("/com/dx57dc/images/center-btn.png");
        -fx-border-image-slice: 4 4 4 4 fill;
        -fx-border-image-width: 4 4 4 4;
        -fx-border-image-insets: 0;
        -fx-border-image-repeat: stretch;
         -fx-background-color: null !important;
    #pill-center:selected { -fx-border-image-source: url("/com/dx57dc/images/center-btn-selected.png"); }
    #pill-center .label {
        -fx-text-fill: #d3d3d3;
         -fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.75) , 0, 0.0 , 0 , -1 );
    #pill-center:selected .label {
        -fx-text-fill: black;
        -fx-effect: dropshadow( one-pass-box , white , 0, 0.0 , 0 , 1 );
    #pill-right {
        -fx-padding: 5;
        -fx-border-image-source: url("/com/dx57dc/images/right-btn.png");
        -fx-border-image-slice: 4 4 4 4 fill;
        -fx-border-image-width: 4 4 4 4;
        -fx-border-image-insets: 0;
         -fx-border-image-repeat: stretch;
        -fx-background-color: null !important;
    #pill-right:selected { -fx-border-image-source: url("/com/dx57dc/images/right-btn-selected.png"); }
    #pill-right .label {
         -fx-text-fill: #d3d3d3;
        -fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.75) , 0, 0.0 , 0 , -1 );
    #pill-right:selected .label {
        -fx-text-fill: black;
        -fx-effect: dropshadow( one-pass-box , white , 0, 0.0 , 0 , 1 );
    The images are located at the Java package com.dx57dc.images
    In Java 7_25 this code works as expected but in JavaFX 8 b99 I get this error:
    ava.lang.NullPointerException
    at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:1129)
    at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:1598)
    at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1520)
    at com.sun.javafx.sg.prism.NGGroup.renderChildren(NGGroup.java:233)
    at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:199)
    at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:1249)
    at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:1598)
    at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1520)
    at com.sun.javafx.sg.prism.NGGroup.renderChildren(NGGroup.java:233)
    at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:199)
    at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:1249)
    at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:1598)
    at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1520)
    at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:99)
    at com.sun.javafx.tk.quantum.AbstractPainter.paintImpl(AbstractPainter.java:210)
    at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:95)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
    at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:129)
    at java.lang.Thread.run(Thread.java:724)
    D3D Vram Pool: 13,331,480 used (5.0%), 13,331,480 managed (5.0%), 268,435,456 total
    20 total resources being managed
    4 permanent resources (20.0%)
    1 resources locked (5.0%)
    7 resources contain interesting data (35.0%)
    0 resources disappeared (0.0%)
    D3D Vram Pool: 13,331,480 used (5.0%), 13,331,480 managed (5.0%), 268,435,456 total
    20 total resources being managed
    4 permanent resources (20.0%)
    1 resources locked (5.0%)
    7 resources contain interesting data (35.0%)
    0 resources disappeared (0.0%)
    D3D Vram Pool: 13,331,480 used (5.0%), 13,331,480 managed (5.0%), 268,435,456 total
    20 total resources being managed
    4 permanent resources (20.0%)
    1 resources locked (5.0%)
    7 resources contain interesting data (35.0%)
    0 resources disappeared (0.0%)
    What is the proper way to load images from css in Java 8?
    Ref
    How to load images from css file in JavaFX 8 - Stack Overflow

    There is nothing special to do - you execute the statement from your program just like any other SQL statement.  The only thing to be aware of are the privilege/permission issues:
    When loading from a file on a client computer:
    READ CLIENT FILE privilege is also required for the database user.
    Read privileges are required on the directory being read from.
    The allow_read_client_file database option must be enabled.
    The read_client_file secure feature must be enabled.
    Revoking these privileges is also the only way you can prevent a user from executing the statement.

  • Problem loading images from a return value of a function

    hello, I write because I uin problem in loading images from a return value of a function.
    I created a database with a field "image" of type string, where I put the physical address of the image. I have written like this: {__DIR__ }foto.jpg
    Place the code, so you understand better
    function imageViewImage(): javafx.scene.image.Image {
    connetti();
    lass.forName(driverName);
    con = DriverManager.getConnection(url,user,"");
    stmt = con.createStatement();
    var richiesta:String = "SELECT image from viaggio WHERE id_viaggio=7";
    rs1 = stmt.executeQuery(richiesta);
    var result :String;
    rs1.next();
    risultato = rs1.getString("image");
    JOptionPane.showMessageDialog(null, result);
    var imagez = Image{
    url:"{result}";
    return imagez;
    The image is in the source code package
    First I connect to the database, run the query and I take the contents of the image.
    Can anyone help me?
    Is right to put in the database {__DIR__} foto.jpg or do I put only foto.jpg?

    Hello unkus_nob,
    I would rather suggest you to save only filename of that image like "foto.jpg" in database. And just concat it with the String variable containing "{__DIR__}".
    Actually the javafx compiler converts the {__DIR__} to the existing class directory path something like : "jar:file:/..../".
    var currentDir ="{__DIR__}";
    risultato = "{currentDir}{rs1.getString("immagine"})"; 
    var image = Image{
        url:risultato
    return image;--NARAYAN G.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Load image from a cursor .cur file.

    Hi all,
    I want to create a customized cursor, and I have a Microsoft cursor .CUR file. Can I load this .cur file as an image? - Thank you
    Edited by: trangkd on Aug 9, 2011 3:08 PM

    Hi,
    I've been google-ing up-and-down, but couldn't find any implementation of .cur and Java. If anyone has done so, please post... I was looking for an easy way i.e. couple lines of code to load image from a .cur file .. like we do with gif or jpeg out of the box. The JIMI has an extensive support of many other formats, and it will be an alternative if the graphics department won't give us a new set of cursor images in gif/jpg format.
    Thanks so much.

  • How do you load images from a Win7 machine to iPhone?

    Hi. How do you load images from a Windows 7 PC to an iPhone 4? I'd like to load the pictures to use as wallpapers. Thanks.

    You CANNOT transfer photos from your computer to your iPhone when connected to your computer as an external drive. This is for transferring photos and/or video from your iPhone's Camera Roll to your computer's hard drive ONLY.
    To transfer photos from your computer's hard drive to your iPhone, this is selected under the Photo's tab for your iPhone's sync preferences with iTunes followed by a sync.

  • How to load images from BLOB to javascript?

    hi, Guys:
    I need to load thumbnail images from BLOB to multiple markers' infowindow in Google map . I have implemented Google map in APEX. I load the data suchas text for every marker's infowindow from Oracle database table with PL/JSON, and infowindow works fine. Could anyone give me a suggestion or example so I know how to load images to javascript?
    Thanks a lot.
    Database: Oracle 11g R2
    APEX: APEX 4.1
    Thanks.
    Sam

    lxiscas wrote:
    hi, VC:
    Thanks for your kind reply. I need to render these images out of APEX session, actually in javascript that is related to Google map markers' infowindow.
    I checked the documents of APEX_UTIL.GET_BLOB_FILE_SRC, but my impression is I need to use it in APEX instead of javascript if my understanding is correct. I already implemented a procedure with PL/SQL to load images from a BLOB column in Oracle database. But the problem is, how can I pass it to javascript code out of APEX to javascript (I could pass text or number from APEX to javascript with PL/JSON though,But I assume that still google map will be within a valid apex session? if so you should be able to use the above api.
    Basically what this api does is generates a kind of url to each blob in the database, not sure how google api's deal with this though. Why don't you give it a try?
    The other option is to make your pl/sql procedure public and then you can generate the json to include the images urls such as:
         "employees" : [{
                   "firstName" : "John",
                   "lastName" : "Doe",
                   "imgSrc" : "http://somewhere/db_schema.your_download_proc?p_file=#ID#",
                   "firstName" : "Anna",
                   "lastName" : "Smith"
                   "imgSrc" : "http://somewhere/db_schema.your_download_proc?p_file=#ID#",
                   "firstName" : "Peter",
                   "lastName" : "Jones"
                   "imgSrc" : "http://somewhere/db_schema.your_download_proc?p_file=#ID#",
    }And then you can use this new attribute to populate the images in javascript using standard img tag
    See this tutorial http://docs.oracle.com/cd/E14373_01/appdev.32/e13363/up_dn_files.htm
    I did not find any method in PL/JSON to pass image object)? So far I only found example to load images from local files to javascript.Hmm..I don't think you should load image objects.
    Vikram

  • Loading image from jars only once in oracle forms 10g

    Hi,
    I have an oracle forms 10g application which loads image from a jar. Every time i click on a button "A" that loads the image "image" on another button "B" in the same screen, a message is displayed in the java console "Loaded image: jar:https://+IP+/forms/java/+myjar+.jar!/image.gif". So after 10 clicks, i get the same message displayed 10 times. In the form, i've called:
    SET_CUSTOM_PROPERTY(p_object_name, 1, 'IMAGE_NAME_ON', '/'||p_image_name);My question is the following:
    - is there a way to load this image once and use it later without having to load it every time i clik on "A"? if yes, how?
    P.S.: if this thread shouldn't be posted in this forum, please redirect me to the right one.
    Thanks in advance

    Ah okay.
    I'm using the rolloverbutton.jar (RollOver Button PJC) [RolloverButton.java -> authors: Steve Button, Duncan Mills].
    Here is the part concerning the IMAGE_NAME_ON function:
    // make sure we are in rollover mode
    enableRollover();
    log("setProperty - IMAGE_NAME_ON value=" + value.toString());
    // load the requested image
    m_imageNameOn = (String) value;
    loadImage(ON,m_imageNameOn);
    // reset the currrently drawn image if needed
    setImage(ON,m_state);
    return true;where loadImage function is:
        URL imageURL = null;
        boolean loadSuccess = false;
        //JAR
        log("Searching JAR for " + imageName);
        imageURL = getClass().getResource(imageName);
        if (imageURL != null)
          log("URL: " + imageURL.toString());
          try
            m_images[which] = Toolkit.getDefaultToolkit().getImage(imageURL);
            loadSuccess = true;
            log("Image found: " + imageURL.toString());
          catch (Exception ilex)
            log("Error loading image from JAR: " + ilex.toString());
        else
          log("Unable to find " + imageName + " in JAR");
        //DOCBASE
        if (loadSuccess == false)
          log("Searching docbase for " + imageName);
          try
            if (imageName.toLowerCase().startsWith("http://")||imageName.toLowerCase().startsWith("https://"))
              imageURL = new URL(imageName);
            else
              imageURL = new URL(m_codeBase.getProtocol() + "://" + m_codeBase.getHost() + ":" + m_codeBase.getPort() + imageName);
            log("Constructed URL: " + imageURL.toString());
            try
              m_images[which] = createImage((java.awt.image.ImageProducer) imageURL.getContent());
              loadSuccess = true;
              log("Image found: " + imageURL.toString());
            catch (Exception ilex)
              log("Error reading image - " + ilex.toString());
          catch (java.net.MalformedURLException urlex)
            log("Error creating URL - " + urlex.toString());
        //CODEBASE
        if (loadSuccess == false)
          log("Searching codebase for " + imageName);
          try
            imageURL = new URL(m_codeBase, imageName);
            log("Constructed URL: " + imageURL.toString());
            try
              m_images[which] = createImage((java.awt.image.ImageProducer) imageURL.getContent());
              loadSuccess = true;
              log("Image found: " + imageURL.toString());
            catch (Exception ilex)
                    log("Error reading image - " + ilex.toString());
          catch (java.net.MalformedURLException urlex)
            log("Error creating URL - " + urlex.toString());
        if (loadSuccess == false)
          log("Error image " + imageName + " could not be located");In this case, what shall i modify?
    Thanks in advance

  • Issues with Loading Images from a Jar File

    This code snippet basically loops through a jar of gifs and loads them into a hashmap to be used later. The images all load into the HashMap just fine, I tested and made sure their widths and heights were changing as well as the buffer size from gif to gif. The problem comes in when some of the images are loaded to be painted they are incomplete it looks as though part of the image came through but not all of it, while other images look just fine. The old way in which we loaded the graphics didn't involve getting them from a jar file. My question is, is this a common problem with loading images from a jar from an applet? For a while I had tried to approach the problem by getting the URL of the image in a jar and passing that into the toolkit and creating the image that way, I was unsuccessful in getting that to work.
    //app is the Japplet
    MediaTracker tracker = new MediaTracker(app);
    //jf represents the jar file obj, enum for looping through jar entries
    Enumeration e = jf.entries();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    //buffer for reading image stream
    byte buffer [];
    while(e.hasMoreElements())
    fileName = e.nextElement().toString();
    InputStream inputstream = jf.getInputStream(jf.getEntry(fileName));
    buffer = new byte[inputstream.available()];
    inputstream.read(buffer);
    currentIm = toolkit.createImage(buffer);
    tracker.addImage(currentIm, 0);
    tracker.waitForAll();
    images.put(fileName.substring(0, fileName.indexOf(".")), currentIm);
    } //while
    }//try
    catch(Exception e)
    e.printStackTrace();
    }

    compressed files are not the problem. It is just the problem of the read not returning all the bytes. Here is a working implementation:
    InputStream is = jar.getInputStream(entry);
    ByteArrayOutputStream os = new ByteArrayOutputStream(1024);
    try{
    byte[] buf = new byte[1024];
    int read;
    while((read = is.read(buf)) > 0) {
    os.write(buf, 0, read);
    catch(Exception e){
         e.printStackTrace();
         return null;
    image = Toolkit.getDefaultToolkit().createImage(os.toByteArray());
    This works but I think you end up opening the jar a second time and downloading it from the server again. Another way of getting the images is using the class loader:
    InputStream is = MyApplet.class.getResourceAsStream(strImageName);
    In this case, the image file needs to be at the same level than MyApplet.class but you don't get the benefit of enumerating of the images available in the jar.

  • Load image from SQL database with ASP?

    Hello,
    Does anyone know a tutorial where you can load an image from
    a SQL database ?
    I would like to show this image in Flash, but i don't know
    how to load in from a SQL database using ASP.
    Regards,
    Micheal

    Flash cannot load images from an SQL database.
    Flash can load JPEG, PNG, GIF, SWF, MP3, and FLV files.
    An SQL database can be used to store the file names and their
    location. ASP can retrieve that data from the SQL and return to
    Flash to load the above file formats.
    For Flash to do the communication with ASP you need to
    determine if you are using URL Encoded or XML data structures.
    For URL Encoded data you look at
    LoadVars.sendAndLoad
    For XML Encoded data you look at
    XML.sendAndLoad
    Then in their onLoad methods you use
    MovieClip.loadMovie
    to load JPEG, GIF, PNG and SWF;
    Sound.loadSound
    for MP3,
    NetConnection.connect,
    Video.attachVideo and NetStream.play for FLV.
    For the ASP side the work with the database has nothing to do
    with Flash other than using any search variable sent from Flash
    with LoadVars.sendAndLoad or XML.sendAndLoad. In other words it
    could be an HTML form sending the same variable and calling the
    same ASP script. Same with returning values except with Flash only
    URL Encoded or XML data structures are sent back and not
    HTML.

Maybe you are looking for