13 Replies Latest reply on Feb 28, 2009 1:01 PM by Francisc

    Image not changing after source is reassigned

    Francisc Level 3
      Hello!

      Have an <mx:Image id="myImage"/> with no source at start.
      After the data loads from a RemoteObject, I set the source to the path of the image I need load:
      myImage.source=event.result.picture. The path is correct, if I do a navigateToURL(new URLRequest(event.result.picture),"_blank") the browser goes to the image. So... why doesn't it load, please? I get that classic 'no picture' icon.
        • 1. Re: Image not changing after source is reassigned
          Level 7

          "M*A*S*H 4077" <webforumsuser@macromedia.com> wrote in message
          news:goafgh$ks4$1@forums.macromedia.com...
          > Hello!
          >
          > Have an <mx:Image id="myImage"/> with no source at start.
          > After the data loads from a RemoteObject, I set the source to the path of
          > the
          > image I need load:
          > myImage.source=event.result.picture. The path is correct, if I do a
          > navigateToURL(new URLRequest(event.result.picture),"_blank") the browser
          > goes
          > to the image. So... why doesn't it load, please? I get that classic 'no
          > picture' icon.

          More code, please.


          • 2. Re: Image not changing after source is reassigned
            Gregory Lafrance Level 6
            You might try forward slashes if you were using back slashes and visa versa.

            Sample could would help, to be sure.
            • 3. Image not changing after source is reassigned
              Francisc Level 3
              I'll just put the part of code that is relevant. The text inputs work as they should, however the image does not refresh. I remember doing this with images from XML files and they updated when I changed their source, but that was AIR and the pictures were in the project files. In this case they are in a different folder, but on the same server/domain.
              • 4. Re: Image not changing after source is reassigned
                Francisc Level 3
                event.data.picture will look like: "media/pictures/12345678.jpg" for example. And as I said, navigating to that URL from Flex will 'get me' the picture. So I suppose the path is correct. I will try with the other type of slash '\\'.
                • 5. Re: Image not changing after source is reassigned
                  injpix Level 3
                  I am not sure if you changed your code prior to this post, but Image has an id of 'pozaFormatieImage'. And in your Script tags you seem to be expecting a "pictureImage".
                  • 6. Re: Image not changing after source is reassigned
                    Francisc Level 3
                    Ups, sorry! I changed it so that it's in English and more easily understandable! :) Missed that.
                    Thanks! I will Edit it now.
                    • 7. Re: Image not changing after source is reassigned
                      Level 7

                      "M*A*S*H 4077" <webforumsuser@macromedia.com> wrote in message
                      news:gob821$jov$1@forums.macromedia.com...
                      > I'll just put the part of code that is relevant. The text inputs work as
                      > they
                      > should, however the image does not refresh. I remember doing this with
                      > images
                      > from XML files and they updated when I changed their source, but that was
                      > AIR
                      > and the pictures were in the project files. In this case they are in a
                      > different folder, but on the same server/domain.
                      >
                      > <mx:Script>
                      > ...
                      > private function getDateFormatieResultHandler(event:ResultEvent):void
                      > {
                      > nameText.text=event.result.nume;
                      >
                      > pictureImage.source=event.result.poza;
                      > descriptionText.text=event.result.des
                      > criere;
                      > }
                      > ...
                      > </mx:Script>
                      > ...
                      > <mx:Canvas right="0">
                      > <mx:Image id="pozaFormatieImage" horizontalCenter="0"
                      > verticalCenter="0"/>
                      > </mx:Canvas>
                      > ...

                      At what point in the application life cycle are you calling
                      getDateFormatieResultHandler?


                      • 8. Re: Image not changing after source is reassigned
                        Francisc Level 3
                        Damn I forgot another name to change into English...

                        I call that after some IFs in init() which is called at creationComplete.
                        I take it that's too late?
                        • 9. Re: Image not changing after source is reassigned
                          Level 7

                          "M*A*S*H 4077" <webforumsuser@macromedia.com> wrote in message
                          news:goboje$97l$1@forums.macromedia.com...
                          > Damn I forgot another name to change into English...
                          >
                          > I call that after some IFs in init() which is called at creationComplete.
                          > I take it that's too late?

                          No, that should work. Try stepping through the code to make sure

                          (a) it's getting called
                          (b) event.result.poza contains what you think it does


                          • 10. Re: Image not changing after source is reassigned
                            Francisc Level 3
                            I already tried that... this wasn't suppoed to be a Forum issue es it seems easy...

                            I added Alert.show(event.result.picture) before pictureImage.source=event.result.picture and the result is as it should be: "media/pictures/needToLoad.jpg".

                            It's strange that even if I write: pictureImage.source="media/test,jpg", still nothing. Do I need to have the string with the file path as URLRequest or something? Pictures I need are outside project files, but on the same server.

                            PHP page with embeded SWF is here: "./"
                            Pictures I need load are here: "./media/pictures/"
                            • 11. Re: Image not changing after source is reassigned
                              Level 7

                              "M*A*S*H 4077" <webforumsuser@macromedia.com> wrote in message
                              news:gobt9j$enk$1@forums.macromedia.com...
                              >I already tried that... this wasn't suppoed to be a Forum issue es it seems
                              > easy...
                              >
                              > I added Alert.show(event.result.picture) before
                              > pictureImage.source=event.result.picture and the result is as it should
                              > be:
                              > "media/pictures/needToLoad.jpg".
                              >
                              > It's strange that even if I write: pictureImage.source="media/test,jpg",
                              > still
                              > nothing. Do I need to have the string with the file path as URLRequest or
                              > something? Pictures I need are outside project files, but on the same
                              > server.
                              >
                              > PHP page with embeded SWF is here: "./"
                              > Pictures I need load are here: "./media/pictures/"

                              I haven't had any of the issues you're finding. You might want to try
                              looking at this example:
                              http://examples.adobe.com/flex2/inproduct/sdk/photoviewer/PhotoViewer.html

                              And see if it shows you anything.


                              • 12. Re: Image not changing after source is reassigned
                                injpix Level 3
                                Have you tried:

                                /../media/pictures/needToLoad.jpg
                                • 13. Re: Image not changing after source is reassigned
                                  Francisc Level 3
                                  I managed to make it work but I don't get...

                                  It needed an extra "../" in front of the addess, thought I give this a go before finding an alternate route...
                                  While it is true the SWF is 'a folder away' from the pictures folder, the navigateToURL went where it was supposed to from the same app as the Image component. Also, the file that embeds the SWF is located in the root.

                                  AMFPHP gateway.php is called from the root with a relative address even if used inside the SWF which is not in the root file... don't get why, but it works.

                                  Sorry to have bothered you with this and thanks for all your hints and advice everyone!