7 Replies Latest reply on Mar 29, 2007 2:44 AM by Yann Martel

    A beginner's problem

    Yann Martel
      Hello everybody !

      I'm new to the flex technology and I have a little problem.

      quote:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application
      xmlns:mx=" http://www.adobe.com/2006/mxml"
      horizontalAlign="center" verticalAlign="center"
      >

      <mx:Image id="img1" source="@Embed('images.jpg')" />
      <mx:Image id="img2" source="images.jpg" />

      </mx:Application>


      When I compile this code with the mxmlc and test it, the first image is displayed, but not the second one.
      I don't think there is a problem with the code itself, so I'm probably doing something wrong:

      - maybe I'm not using the good compilation command "mxmlc --strict=true -use-network=false --file-specs testimage.mxml"

      - I'm not testing it properly (I simply use the swf file with opera, maybe I should embed it in a html file before ?)

      I know this is a dumb problem, but if someone could explain to me what I'm doing wrong, that would be nice.
        • 1. Re: A beginner's problem
          ringx007
          make the image in the same folder as your Application
          • 2. Re: A beginner's problem
            Yann Martel Level 1
            That's not the problem, my image is in the right folder and the embedded one is displayed just fine.

            I've downloaded FlexBuilder (trial) and I get the same result when I try the swf that is created. However if I use the .html it works. So I guess the problem comes from my way of testing.

            Anyone knows how to create the .html docs without flex builder ? I couldn't find any information about it.
            • 3. Re: A beginner's problem
              ntsiii Level 3
              I believe that setting -use-network=false is a mistake. It prevents you from having a web app and requires you to install physically to the file system.

              Why are you using it? Relative urls work just fine.

              Tracy
              • 4. Re: A beginner's problem
                ntsiii Level 3
                Running a swf from the file system in the stand-alone Flash Player is different than running it from a server in a browser.
                Tracy
                • 5. Re: A beginner's problem
                  Yann Martel Level 1
                  I've tried with both -use-network true or false and it's the same. For the moment I'm just testing my application in the local file system, with relative location such as "doc/myimage.jpg". I don't think that's the problem anyway since it works with "embed".

                  I think the problem comes from the way I test my swf, it should be embedded in an html file. Do you know how I can create one ?
                  • 6. Re: A beginner's problem
                    mike_morearty Level 1
                    Are you doing this all in Flex Builder? If so, then if you delete the first Image tag, and then clean your project and rebuild, I bet the second line will work. Here is what is happening: After Flex Builder compiles your code, it then copies any images etc. which were NOT embedded over to the "bin" folder. That way, if for example you had <mx:Image source="filename.gif"/>, then filename.gif gets copied over to the 'bin" folder because it was not embedded.

                    However, if an image WAS embedded, then it is not copied to the "bin" folder, on the assumption that you don't want it there. You embedded it in the SWF, so there is no need to copy it.

                    This is almost always the desired semantics. But in your experiment, you wrote code in a way that makes sense while experimenting with the technology, but that someone probably wouldn't do when writing a "real" app, and the result is that Flex Builder thought "oh, that image is embedded, no need to copy it."

                    Take a look in your "bin" folder -- if both Image tags are in your source, and you clean and rebuild, "bin" probably will not have the image. But if you remove the embed line and clean and rebuild, "bin" will have the image.
                    • 7. Re: A beginner's problem
                      Yann Martel Level 1
                      Ok thanks for the explanation. However, the weird thing is that my example actually workss with FlexBuilder. The problem is when I simply use the command line compiler.