A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Importing Images into Flash using URL

  1. #1
    Junior Member
    Join Date
    Aug 2008
    Posts
    7

    Importing Images into Flash using URL

    Hi all

    Is it possible to have Flash (using Actionscript maybe?) import an image from a URL? I have a 4 image rotating animation that basically shows news items. I'm going to have to change it often, and would like to just be able to automate it a little to prevent having to import the image, resize etc. The CMS i'm having hosts and resizes the image to the correct size. I'd just like to maybe copy/paste the url somewhere and have Flash grab it. Is that possible?

  2. #2
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    yeah you can sue the loadMovie() method to import a jpg into flash.

    hope it helps
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  3. #3
    Junior Member
    Join Date
    Aug 2008
    Posts
    7
    Thanks Paul. Didn't know about this function. Having trouble finding somewhere that explains how I can use it as I want to.

    The syntax is this....

    loadMovie(URL:String, target: Object, [method:String]);

    I created 2 layers. One with a movie clip of just a rectangle, another for actionscript. Am I even on the right track here?

  4. #4
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Come on the flash manual for AS2 is not that hard to understand.
    To load a SWF or image file into a level in Flash Player, use the loadMovieNum() function. To load a SWF or image file into a movie clip target, use the loadMovie() function or method. In either case, the loaded content replaces the content of the specified level or target movie clip.

    When you load a SWF or image file into a movie clip target, the upper-left corner of the SWF file or image is placed on the registration point of the movie clip. Because this registration point is often the center of the movie clip, the loaded content might not appear centered. Also, when you load a SWF file or image to a root timeline, the upper-left corner of the image is placed on the upper-left corner of the Stage. The loaded content inherits rotation and scaling from the movie clip, but the original content of the movie clip is removed.

    You can optionally send ActionScript variables with a loadMovie() or loadMovieNum() call. This is useful, for example, if the URL you're specifying in the method call is a server-side script that returns a SWF or image file according to data passed from the Flash application.

    When you use the global loadMovie() or loadMovieNum() function, specify the target level or clip as a parameter. The following example loads the Flash application contents.swf into the movie clip instance named image_mc:

    loadMovie("contents.swf", image_mc);


    You can use MovieClip.loadMovie() to achieve the same result:

    image_mc.loadMovie("contents.swf");


    The following example loads the image1.jpg JPEG image into the image_mc movie clip instance:

    image_mc.loadMovie("http://www.helpexamples.com/flash/images/image1.jpg");
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  5. #5
    Junior Member
    Join Date
    Aug 2008
    Posts
    7
    Okay! Got it to work.

    Used this code:
    loadMovie("1.jpg", _root.movie1);

    Does anyone know if I can know Tween between two jpegs that are loaded in? I want to fade from one to the other...

  6. #6
    Junior Member
    Join Date
    Aug 2008
    Posts
    7
    All good - figured it out. Sorry guys....I probably should have played around first before bothering you all. I didn't think I'd be able to come up with the answers on my own. Thanks again Paul.

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