A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: Embedding an image from a URL

Hybrid View

  1. #1
    Member
    Join Date
    Jan 2003
    Posts
    43

    Embedding an image from a URL

    I think I'm close to getting this, but I can't seem to figure it out... here's what I'm trying to do: I've got a movie clip that's basically just a transparent box, 300 px X 200 px. I want to be able to load an image into that box of the same size 300 px X 200 px from a URL.
    From what I can gather in the help files of Flash MX, I can use the loadMovie function, but I can't for the life of me get the picture to load at all.

    Help!?

  2. #2
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    The transparent box has to be given a instance name (usually container ). Then load the image...

    container.loadMovie("www.someSite.com/image.jpg");

    You can only load non progressive jpg images.

    The container will be the size that the image has, no need to size it manually.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  3. #3
    Member
    Join Date
    Jun 2003
    Location
    germany
    Posts
    31
    Additionally the jpg has to be in the same subdomain as the .swf loading the pic.
    When you pic is not located in the same subdomain you can use php to get the file and save it on your server before loading it into flash.

  4. #4
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    This is not true when using load movie, but when loading using loadVariables from another domain..

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  5. #5
    Member
    Join Date
    Jan 2003
    Posts
    43
    Well, that didn't work.

    My transparent box is a movie clip, BTW. Should I just make it an image, or should I even convert it to a symbol?
    Do I want to put the loadMovie function as an action on the box itself, of as an action in the frame that has the box in it?

  6. #6
    Member
    Join Date
    Jan 2003
    Posts
    43
    And, forgive me, but what is a non-progressive JPG (or a progressive JPG for that matter)?


    I guess I should let you know that this SWF is not on a webpage, but is being used as a wallpaper (via a program called SWF Desktop). I want to be able to let people download this wallpaper/desktop and install it on their machines. There's a section in my SWF that shows a picture gallery. Instead of having to try to include all of the pictures in the SWF, I'd rather be able to pull them from a URL.

  7. #7
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    If youre "box" is movieclip it is already a symbol. Tou have to name with a instance name ( not library name ).

    The load action can be anywhere as long as the "box" is present in that timeline.

    If youre image is a jpg and use on the web chances are its is a preogressive jpg ( these will progressively load on a normal html page, revealing what is loaded. Flash dont support that. It is an option when you save a image from PhotoShop for example ).

    Begin by trying to load a jpg from the harddrive or something you have more control of, so youll get a hang of it.

    If the "image" is a normal jpg or a swf file , located on a server, it should be possible to load it into your Flash file.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  8. #8
    Member
    Join Date
    Jan 2003
    Posts
    43
    Maybe that's the problem... I'll bet it's a progressive JPG. I'll trying saving it differently in Photoshop and see how that works. Thanks.

  9. #9
    Member
    Join Date
    Jan 2003
    Posts
    43
    Nope... the JPGs I'm trying to load are not progressive JPG files. Can someone send or show me an example of how you would load an image like I'm trying to do into a 300 X 200 box?

    I can't this to work... it should be a very simple thing to do, as it's done all the time.

  10. #10
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    Heres some general info on loading external file. The code goes for jpg as well.

    There are two ways of loading external files into Flash. Either you can load swf files into _levels or into movieclip targets.

    _levels only exist in the Flash player. They are like layers but for swf files The Flash player is like a overhead projector where the plastic films you put on top of each other are like the swf files in the player. There are 16000 available levels

    //To load a external swf into a _level from a button. The number 1 being the level to load into.

    on(release){
    loadMovieNum("myExternalFile.swf",1);
    }

    Movieclip targets are what it sounds like. A empty movieclip placed on the stage just for the purpose of loading a swf file into it. The advantage is that you can place it anywhere, manually ( as opposed to swf's in _levels) and also can control what othe objects should be on top or beneath.

    Usually you give the movieclip an instance name of container.

    //To load a external swf into a target movieclip from a button ( both being on the main timeline ).

    on(release){
    container.loadMovie("myExternalFile.swf");
    }

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  11. #11
    Member
    Join Date
    Jan 2003
    Posts
    43
    Well, I don't know what to say....

    I have a button in a frame with the following actions:

    on (release) {
    container.loadMovie("http://www.slowburnmusic.net/pics/1.jpg");
    }

    In the same frame, on the same layer is a movie with the instance name of "container". When I click on that button, nothing happens.
    Any help?

  12. #12
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    I uploaded your image to my server for testing and it did not load. It did not work from my hard drive. But for a reason.......
    According to Photoshop youre image is progressive. And when resaving it it loads fine.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  13. #13
    Member
    Join Date
    Jun 2003
    Location
    germany
    Posts
    31
    hold on... you´re telling me it´s possible to load jpg´s from other servers than my own with loadmovie? Then why doesn´t it work when I did the day before yesterday? And why does the Flash MX manual say that you can´t load jpg´s from other domains?

    If that´s true I´m actually pretty sad about it. It would mean that any jerk can link to my images and use them for his pages while stealing my bandwidth

    [edit]
    Just checked it again.
    The reference cleary states that the URL of the image must be in the same subdomain as the .swf file that loads the picture... so no loading images from other domains.
    Or am I still wrong
    [/edit]
    Last edited by Tango2k3; 09-29-2003 at 07:10 AM.

  14. #14
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    I have no problems loading images from other domains. See this example for test purpose...
    www.danny.se/pippi/

    The EYE image is getting loaded from www.pellepiano.com/nana/images/eyes.swf

    The restrictions for other domain concerns loadVariables, but that is easily fixed with a small php script.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  15. #15
    Member
    Join Date
    Jun 2003
    Location
    germany
    Posts
    31
    hmmm...

    Now I´m seriously asking myself why it never worked for me. Was trying to do the exact same thing and stumbled accross this text in the reference after 2 hours and as said the text says that you can´t load stuff from other domains.
    Well I solved the problem with a small php script but anyways... as said this would mean that anyone who likes jpg´s on one of my pages can simply steal them with loadmove That would really really REALLY suck IMO.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center