Problems loading images dynamically with XML

Hi Everyone,
I am working with a project that was build by another
developer and I have been asked to modify it several ways. This is
an interactive map for a hotel brand where when you click on the
USA, you get a list of all the states, click a state and a list of
all the hotels in that state comes up, click a hotel, the hotel's
information is displayed. I understand the structure of the files,
how they make them work, though I couldn't build it myself.
The problem I am having is this. can't make the hotels'
photos load into the flash through the XML. I created a target
movie file that the image could load into but something is not
happening as far as loading the images. I don't know if the movie
clip that I created is the right way to go (it was made as an
object in the library that is exported via AS), or if I should
create one in the action script file that loads the XML data.
I looked at some tutorials about how to load images with XML
but those didn't get into the level of detail that I need for this
project.
I've attached some partial code to see if anyone can help me
work through this.
Any and all suggestions are welcome.
Thanks for the help in advance.
Jeremiah

I'm a noob at AS3 and trying to learn this XML stuff myself,
but i have been able to load pictures to the stage...this might
help you...my xml file photo section is similar to yours, only I
have it labeled as "href" instead of "source"...
var imageLoader:Loader;
var xml:XML;
var xmlList:XMLList;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("xmldata/images.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
function xmlLoaded(event:Event) :void {
xml = XML(event.target.data);
xmlList = xml.children();
for (var i:int = 0; i<xmlList.length(); i++) {
imageLoader = new Loader();
imageLoader.load(new URLRequest(xmlList
.attribute("href")));
imageLoader.x = 0;
imageLoader.y = 0;
addChild(imageLoader);

Similar Messages

  • Problem loading jpg's with xml

    I have looked through the forum to see if my problem was
    raised but I could not find any topic that could help me out. So
    here's my problem.
    I have a simple photo viewer that load jpg's via xml.
    Everything work perfect when I preview the movie in Flash or on my
    desktop but as soon as it's uploaded to the server the jpg's so not
    load. And everything is placed correct on the server.
    Anyone got a clue why?

    Ok I found out that if you go directly to the movie in the
    browser (http//www.url.com/name.swf) then it work perfect and the
    photos load.
    I got two other movies in the same html document. It's surely
    here the problem occur. But why and what can I do to solve
    it?

  • Problem loading Image data with French accent in file name

    We have a very complex commercial application that has been working perfectly in English for over a year. We have now localized it to French and Spanish, and discovered a serious show-stopping problem. We need help fast, with the scheduled release being less than 2 weeks away...!
    We iterate over a folder to find all the images in it, then display those in a user window.  The code for loading the images is:
                for each (var name:String in filenames){
                    var image:SmoothImageTransformable = new SmoothImageTransformable();
                    var imagePath:String = dir + "/" + name;
                    image.source = imagePath;
                    trace("Adding Item to picture carousel with url " + image.source);
                    image.data = {directory:dir, filename:name};
                    image.isDragEnabled = true;
                    image.setStyle("horizontalCenter", 0);
                    image.setStyle("verticalCenter", 0);
                    _images.push(image);
    Our SmoothImageTransformable class is an internal class that inherits from Image.  This all works fine for image names like 'myFavoritePhoto', 'test', 'photo346', etc.  However, it fails to load the data if the file name is something like 'caméra'  Any name with a UTF-8 character causes the data load to fail.
    To be sure we weren't doing a load somewhere else in the code that I had overlooked, I added a "image.autoLoad = false' line in there.  That did exactly as expected -- all image squares then show a grey blank, with no image shown.  Removing that line (reverting to the original code, as shown above) causes all the images to work perfectly, except for those with French accent characters like the é.
    HELP!  Is this a known bug?  Is there some additional setting I need to make it understand the extended character set?  I can't find any mention about this at all in the documentation.

    @markerline:
    We have a fix!  Almost...   I don't understand one aspect of what I am seeing though.
    We have one test file named "camèra.jpg" that is an example of what I am unable to load into an Image.  I decided to examine the character codes at each letter, and this is what Flex has as the string:
    name = cam?ra.jpg
       [0] = c; 0x99
       [1] = a; 0x97
       [2] = m; 0x109
       [3] = ?; 0x232
       [4] = r; 0x114
       [5] = a; 0x97
       [6] = .; 0x46
       [7] = j; 0x106
       [8] = p; 0x112
       [9] = g; 0x103
    Note that the è prints as gibberish in the trace statement, and shows a numeric encoding of 0x232.  According to
         http://docstore.mik.ua/orelly/web2/action/appb_01.htm
    The unicode equivalent of Latin1 for è is 0xE8, which is equivalent to 0x232. That implies that the string is already Latin1, which I would think would mean that Windoze would recognize the file name and open it properly -- but it does not.
    I then tried taking the "camèra.jpg" string, pasting it into NotePad++ in a UTF8 document, then telling NotePad++ to display as ASCII.  The result is "camèra".  I then tried just forcing the file name within Flex to this new mangled string.  The result then is:
    MAGIC name = camèra
       [0] = c; 0x99
       [1] = a; 0x97
       [2] = m; 0x109
       [3] = ?; 0x195
       [4] = ?; 0x168
       [5] = r; 0x114
       [6] = a; 0x97
       [7] = .; 0x46
       [8] = j; 0x106
       [9] = p; 0x112
      [10] = g; 0x103
    Note this time the trace statement looks proper.  More important, the IMAGE DOES LOAD!  (Our display of the name to the user now looks like crap, but that just means I need to modify our class to have a separate 'name' property, rather than extracting it from the 'image.source')
    So... my remaining question -- what encoding did I just do through that NotePad++ incantation?  That site I quoted above said that it was already Latin1, which is what I thought I was trying to get to.  I clearly need to write a method to map from incoming (UTF8 I thought, but maybe Latin1?) to Windows file system (Latin1 I thought, but maybe ASCII).
    In other words, I am not sure what charcter set to come from or go to...  It turns out the code was already in the character set I had been trying to go to (which is why it wasn't working) and the set I seem to need to go to is not the one I thought...

  • Problem loading images - please help

    Hi,
    I have a slight problem loading images. I'm using netbeans 5.0 and have a few packages setup in a project called Maths. In a package called LineConnection theres a class that needs to read an image and display it on screen. To load the image I use:
    URL url = getClass().getResource("fraction/pic1.png");
    Image img1 = Toolkit.getDefaultToolkit().getImage(url);This loads the image and I can display it on screen fine.
    The problem is that the folder fractions with the images in HAS to be located within the Maths/build/class/LineConnection folder otherwise it wont load the image and I get a null pointer exception.
    I want to be able to have the folder containing the images in folder Maths so that it's one folder above the src folder. But if I put it here (or anywhere else) the images can't be found and loaded.
    Could someone tell me why the images can only be found if they're within the build folder because it's causing me some problems when I try to create an executable JAR.
    Cheers

    I've used:
    URL url = ImageHandler.class.getResource("fractions/q0.png");               
    System.out.println("URL = " + url);to determine whether the file is found.
    If I put the file in the folder build/classes/LineConection/fractions/q0.png then it finds the image and prints the file path.
    But, if I put it in another folder such as the src folder it can't find the image and url = null;
    How can I make netbeans search in other folders for the resources so I can store them where I like?

  • IOException: Problem loading image

    Hi foreros
    What could be the reason behind an error like this IOException: Problem loading image except it cannot find the jar path for the images?
    Regards
    Tizha

    Without more information, I'd say there's not enough available RAM to load the image.

  • Problem with loading images dynamically in a pdf document

    dear,
         I am using live cycle designer and i need to load image from a url dynamically in to the document.For this case i placed an imagefield on my document and i wrote javascript to load image in the form:ready event.
    My script for that was
    imagefield.value.image.href="url".Actually i saw an imagefield in my document but it doesnt carry any image.Please help me to rectify this problem......

    If you save your form as Static PDF, it works.
    But most of the time we need the Dynamic XML form. So, I am also stuggling with this issue.
    Nith

  • XML to load images dynamically

    Hi,
    I have an XML file which is programmed to load images into a slide show dynamically. So it must be associated with a button to launch this I'd imagine.
    If I want to add more buttons, do I simply add more script to that one XML file giving the new images different names than what was used with button #1, or do I create an XML file for each button and upload all to the web?
    Thanks.

    xml files can't program anything.  they store data (and are there a from of database).
    it's not clear what adding more buttons has to do with your xml file.   is there data in the xml file that relates to buttons?
    and it's not clear what images and a slide show have to do with anything.
    but commonly, an xml file would store data about what images to display in a slideshow.  and the xml file might even contain text to display for each image and possibly an external link associated with each image and maybe some specifics about how to display the image.

  • Load image dynamically by scripting to dynamic xml pdf, is it possible?

    Hi All,
    I've uploaded static pdf form to http://groups.google.com/group/livecycle/web/logo.pdf.
    The form contains ImageField.
    In the "docReady" event of the form I wrote a script:
    ImageField1.value.image.href="http://www.quicksoft.co.il/images/
    quicksoftlogo2.jpg";
    When the form is loaded the ImageField shows the image from the url
    I've updated in the script.
    Once the form is saved as dynamic xml pdf the script stop working.
    Is that means that it is not possible to load images by scripting to
    dynamic xml pdfs?
    Anyone familiar with workarounds for it?
    Thanks in advance,
    Rbuz

    I got an answer from Adobe:
    Dynamic change of an image href has been disabled due to potential security issues. There are however a few workarounds to choose from:
    1. Embedding the images in the form as hidden objects. They can then be set to visible on initialize or clicking a button. This will affect performance, but if the images are in a compressed format, this can be minimized.
    2. Create a Web service interface to grab the image from wherever they are stored, base64 encode it and return it to the form. You would also have to update the bindings for the image field on the form (a one time operation).

  • Problem loading Image through XML!

    Hi,
      I am Akshay and am beginner in this forum. I am trying to load images using flickr API and having problem.
    I am doing it in following fashion:
    1) I am calling the Httpservice to get the xml through flickr API as
    <s:HTTPService id="photoService" url="http://api.flickr.com/services/feeds/....FullAPI" resultFormat="e4x" result="photoResultHandler(event);" fault="photoFaultHandler(event);"/>
    2) In photoResultHandler I am retrieving the XML
    private function photoResultHandler(re:ResultEvent):void
    photoXml= re.result as XML;
    However, I am struggeling to retireve elements from photoXML and then use it to display image in :
    <mx:Image  id="img0" x="151" y="98" width="520" height="291"/>
    The XML structure is as below:
    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <feed">
    <entry>
         <author>  </author>
         <link rel="enclosure" type="image/jpeg" href="http://farm5.static.flickr.com/4484460580_04bbced2d8_o.jpg"/>
    </entry>
    <entry>
    </entry>
    I need to load the href value of link  which can be found in feed-->entry-->link in the above xml.
    Please help!
    -Akshay

    Hello Dave,
       Thanks for your prompt reply. Here's the mxml code :
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
       xmlns:s="library://ns.adobe.com/flex/spark"
       xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" creationComplete="photoService.send()"  minHeight="600">
    <fx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.events.FlexEvent;
    import mx.events.MoveEvent;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    [Bindable]
    public var photoXml:XML;
    private function photoResultHandler(re:ResultEvent):void
    photoXml= re.result as XML;
    //var src :int =  "{photoXml.feed.entry.updated}" as int;
    img0.source= String(photoXml.entry[0].link[1].@href);
    private function photoFaultHandler(fe:FaultEvent):void
    Alert.show(fe.fault.message);
    ]]>
      </fx:Script>
    <fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
    <s:HTTPService id="photoService" url="http://api.flickr.com/services/feeds/photos_public.gne?id=48951865@N07" resultFormat="e4x" result="photoResultHandler(event);" fault="photoFaultHandler(event);"/>
    </fx:Declarations>
    <mx:Image  id="img0" x="151" y="98" width="520" height="291"/>
    </s:Application>
    Hope it helps you in finding out the problem...DO let me know your thouhgts
    Thanks again for your replies so far......
    -Akshay

  • I have problem loading all items from XML with for each

    Hi all,
    I'm low level as3 programmer and I need help whit this code:
    I have gallery XML file:
    <gallery>
        <item>
            <id>1</id>
            <strana>0</strana>
            <naslov>Lokacije</naslov>
            <aktuelno>1</aktuelno>
            <slika>1.jpg</slika>
        </item>
        <item>
            <id>2</id>
            <strana>2</strana>
            <naslov>Coaching</naslov>
            <aktuelno>1</aktuelno>
            <slika>2.jpg</slika>
        </item>
        <item>
            <id>3</id>
            <strana>0</strana>
            <naslov><![CDATA[O.Å . Bratstvo - panel]]></naslov>
            <aktuelno>0</aktuelno>
            <slika>3.jpg</slika>
        </item>  
    </gallery>
    And:
    var loader: URLLoader = new URLLoader();
         loader.load(new URLRequest("gallery.xml");
    var xml = new XML(evt.target.data);
        for each(var item in xml..item) {
            centralniText.htmlText = item.slika;
    only shows  last item from XML file:
    3.jpg
    I want all. Please help.

    can adding count item in XML help somehow?
    <gallery>
        <item>
            <id>1</id>
            <strana>0</strana>
            <naslov>Lokacije</naslov>
            <aktuelno>1</aktuelno>
            <slika>1.jpg</slika>
        </item>
        <item>
            <id>2</id>
            <strana>2</strana>
            <naslov>Coaching</naslov>
            <aktuelno>1</aktuelno>
            <slika>2.jpg</slika>
        </item>
        <item>
            <id>3</id>
            <strana>0</strana>
            <naslov><![CDATA[O.Å . Bratstvo - panel]]></naslov>
            <aktuelno>0</aktuelno>
            <slika>3.jpg</slika>
        </item>   
        <last>3</last>
    </gallery>

  • Problems loading images in JavaHelp

    Using Helpsetmaker to drop the helpset I have had problems with loading images.
    Helpsetmaker keeps any imported images in a pics/<folder>/<folder> heirachy, where the subfolder heirachy is based upon the 'root directory' used to import images.
    The html docs produced are used OK, but the images are not loaded correctly.
    HTML is fine, so the helpset files in general produced by the utility are OK.
    If I move the images to the root of the helpset i.e. the same
    location as the html, & edit the html <img> tags to reflect the new location they are loaded
    correctly so no problems with image files as such.
    AFAIK JavaHelp does not impose restrictions on locating files in subfolders, am I missing something?

    Having had a spare moment to look at the problem again this was a case of seeing what you want to see.
    HelpSetMaker was actually dropping tags src="pics\folder\folder/image.png"

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

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

  • Problems loading Images

    Hello !
    I'm trying to make a small card game.
    I have 52 small gif files(68x94 pix;500 byts each).
    When I'm loading those cards on a JPanel, it takes to much time (about 15 sec);
    I've enabled double-bufering (no changes);
    Without loading Images, all the stuff (JButtons,JTextFile, some String paintings, etc.) is coming up instantly.
    I'm using a P III 1,1 Ghz, 256 Mo RAM. with WinXP (could be, Bill Gates fault ? -:) )
    I've copyed here an extras of code:
    class pan extends JPanel{
         Color myC=new Color(0,170,85);     
         Toolkit tt=Toolkit.getDefaultToolkit();
         String st="";
         Random rnd=new Random();
         public pan(){setDoubleBuffered(true);}
         public void paintComponent(Graphics g){
         super.paintComponents(g);                    
         g.setColor(myC);
         g.fillRect(0,0,800,500);
         int x=220;int y=10;int m;
         for(int i=0;i<4;i++){
              int c=i;
              for(int j=0;j<13;j++){
              int v=j+2;
              switch(c){
              case 0:m=c+v-1;break;
              case 1:m=13+v-1;break;
              case 2:m=26+v-1;break;
              case 3:m=39+v-1;break;
              default: m=52;}
              g.setColor(Color.white);
              g.fillRoundRect(x,y,72,97,13,13);
              g.setColor(Color.black);
              g.drawRoundRect(x,y,72,97,13,13);
              st="Imagini/Cardsgif/"+"C"+m+".gif";
              g.drawImage(tt.getImage(st),x+2,y+2,this);          
              x=x+20;
              st="";
              if((j>0)&(j%12==0)){
                   y=y+100;
                   x=220;
              

    I just started noticing this problem too. On an order confirmation page on Amazon, many of the button graphics were question marks. But it's random. If I refresh the page, some of the images load but others don't load. All of the images load (so it's not an image format problem), but NEVER all at the same time!
    (On a side note, it's VERY bad that Safari displays the question mark graphic instead of the alternate image tag text. There was no way to know which question marks (which should be buttons to click on) are for submitting, cancelling, veiwing order details, editing shipping address, etc.)
    Even more frustrating is that a friend finally switched to Macs from years of being a PC user. Her brand new Intel iMac is exhibiting the same problem when she views her and her friend's MySpace pages. This was her very first day of Mac ownership, and there was nothing installed on her iMac except what it came with. Everything was still on the default settings. Same thing...refreshing the page would randomly load some images but not others.
    It's all a bit embarassing because the "it just works" arguement was one of the things that convinced her to switch to a Mac. I'd like to offer her a fix to overcome this poor first impression.
    PS: I'm on Tiger with the Tiger version of Safari. She's obviously on Leopard.
    Message was edited by: Bean
    Message was edited by: Bean

  • Problem loading image into texture memory

    Hi there, I am currently porting our new casual PC game over to the iPad using the pfi, the game was written in Flash so the porting process isn't that hard thankfully, it's mainly just optimizing the graphics.
    So far things are going smoothly, I was initially worried about graphical performance, but since we put everything into the GPU that's no longer a concern- it runs super smooth at 60fps at 1024x768, we can have a hundred large bitmaps rotating and alphaing at once with no slowdown.
    However there is one weird problem which is really worrying me at this point- it seems that the speed at which images are loaded into video memory as textures is vastly different depending on what else is being run on the iPad, for example:
    * If I run my game with nothing else in memory, it will run fine at 60fps, and load up large images into texture memory very fast.
    * If I run another App, in this case a Virtual piano app for a while, then close that App via the Home button (so the piano app is still in memory but suspended due to the multitasking), then when I run my game, it will run ok initially, but when I try to load a large (1024x512) image into texture memory it pauses the whole game for several seconds.
    * To make matters worse, if I repeat the same test using the RAGE app from ID software (which is very graphically intense), my game actually slows down to 1 fps and runs extremely slowly as soon as I run it and the frame rate never returns to normal. If I then double-click the home button, shut down RAGE, then go back to my game, it will run fine.
    I have read that sometimes when you load images into texture memory it will have to reclaim that memory from other apps, but that doesnt exaplain why it slows down every time I want to load something, or why the game would slow right down to a crawl.
    So then it seems that having other Apps in memory is slowing down my game, or stopping it from working altogether. Obviously this is not ideal and would stop us from releasing, so is there any way I can stop this, has anyone come across the problem? Please help!
    PS. this problem also happens on an iPhone 4, as I have performed the same tests.

    Hi _mz84
    First thing I noticed, is that you did not close your
    <embed> tag
    <embed src="gallery1.swf" bgcolor="#421628" width="385"
    height="611" wmode="transparent" />
    If that doesn't solve your troubles, try the following
    container.
    <object type="application/x-shockwave-flash" height="611"
    width="385" align="middle" data="gallery1.swf">
    <param name="allowScriptAccess" value="never" />
    <param name="allowNetworking" value="internal" />
    <param name="movie" value="gallery1.swf" />
    <param name="quality" value="high" />
    <param name="scale" value="noscale" />
    <param name="wmode" value="transparent" />
    <param name="bgcolor" value="#421628" />
    </object>
    hope this helps out.

Maybe you are looking for