A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: Dynamically image loading

  1. #1
    Senior Member
    Join Date
    Jan 2001
    Posts
    122
    Hi, is there a way where i can put a url inside flash and on run time the swf goes to that url and loads into it self the image (jpg or gif) ?

    Thanks in advance,

    Maya.

  2. #2
    Member
    Join Date
    Apr 2002
    Location
    Nevada
    Posts
    57
    just use:
    Code:
    movieClip.loadMovie("picture.jpg");
    
    // OR
    
    loadMovie("picture.jpg",target);
    Only jpg's can be dynamically imported.

  3. #3
    Senior Member
    Join Date
    Jan 2001
    Posts
    122
    10'x

    i'll try it !!!

    :-)

  4. #4
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    Hi Maya (I love your name! - it must be because I'm a fan of the leading software from Alias|Wavefront...called Maya).

    Anyway, yes, you can load images into flash at runtime (only with FlashMX).
    There are some limits though...:
    1) you can only load .jpg images (and not .gif or .png);
    2) you can only load simple jpeg images (in Adobe Photoshop, you should deselect "progressive"; in Corel Photopaint you should deselect "progressive", "optimize", and choose the 2:2:2 compression standard).

    To dynamically load images into flash you must behave just as if you were loading a movie.
    The best way is to use the loadMovie command as follows:

    loadMovie("myImage.jpg", targetMC);

    remember to put a movieclip on the stage and label it "targetMC".

    If you'd appreciate a sample file with a script that dynamically adapts the loaded image to a constraining rectangle, i would be happy to send it to you.

    hope this helps!

  5. #5
    Senior Member
    Join Date
    Jan 2001
    Posts
    122
    HEY, thanks a million - this is fantastic - the help i'm recieving through this form !!!

    As for 3D, i worked for couple years on carrara, built a village in it, i love the 3D.

    Maya

  6. #6
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    well if you want to push your 3D up to a new level, give a try at Maya Personal Learning Edition (which is just as a full Maya Complete pack...without some features, included only in the Unlimited pack..)

    Maya4.5 is on the way..hoping that finally they give a good change to the renderer engine, as many of the cheapy crappy softwares are kind of getting at the same level (like 3DstudioMAX, Lightwave, Cinema4D, Lightscape).

    Maya is the best!

  7. #7
    Member of the Flashist Party
    Join Date
    Nov 2001
    Posts
    146
    I would love a sample script.

    In fact, here's what I am trying to do. I would like to dynamially load three different kinds of thumbnail sliders, depending on what category the user picks, and when a user clicks on a pic, have the real one open up in the main area ofthe stage.

    I want to name all the pics in the first category picA1, picA2, picA3, and the ones in the second category picB1, picB2, picB3, etc...for all three categories.

    Any help would be appreciated. And I definitely will be using a restraining rectangle.

    Thanks.

  8. #8
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    to do such a thing you have two ways:

    1) you install a software on your server, that returns the number of files in the directory, for dynamic list compilation.....

    2) you manually populate a list that refers to the image arrays...

    in the second case it's simple...you just have to create a text file with a series of variables, like this:
    Code:
    picA1=rosmary.jpg&picA2=piccadilly.jpg&picB1=hello.jpg&picC1=goodbye
    in the flash movie you have to create a script that creates a series of arrays, constructed using the variables in the text fileplace this in the frame actions)
    Code:
    this.loadVariables("news/news.txt?x=" + random(9999));
    // the random number is to prevent users to view offline content;
    myAarray = new Array();
    myBarray = new Array();
    myCarray = new Array();
    this.onData = function() {
    	if(!done) {
            for(var i=0; i<30; i++) {
    	        var Atemp = eval("picA" + i);
    		var Btemp = eval("picB" + i);
    		var Ctemp = eval("picC" + i);
    	        if(Atemp.length) {
    		        myAArray.push(Atemp);
    	        }
                    if(Btemp.length) {
    		        myBArray.push(Btemp);
    	        }
                    if(Ctemp.length) {
    		        myCArray.push(Ctemp);
    	        }
            }
            if(myAArray.length) {
    	    createAMenu();
            }
            if(myBArray.length) {
    	    createBMenu();
            }
            if(myCArray.length) {
    	    createCMenu();
            }
        }
    };
    ok this is just enough to create image refer arrays in flash....
    you should do the rest ...come on..where's the fun?!
    you should create 3 createMenu functions (if you need to create different thumbnail menus...)

    if you need more help let me know.. but unfortunatelly this evening I'm not going to have too much time!
    I'll do what I can..

    hope this helps!

  9. #9
    Member of the Flashist Party
    Join Date
    Nov 2001
    Posts
    146
    Awesome!

    I knew it had something to do with arrays. I'll work on it for a while see how it comes out.

    Thanks a lot for your input.

  10. #10
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    It's all matter of simple programming skills, what matters is to be able to find the logical solutions to your problem. (That is where the real creativity comes out - just like in the math's class at highschool)

    lol!
    for any further help: webmaster@key-one.it
    (it's always better to ask for help on the FK boards so that other people can look at the discussion, but as I'm offen not logged in I could miss your thread, it's better you warn me directly if you need more help!)

  11. #11
    Member
    Join Date
    Apr 2002
    Posts
    76
    Could you post your example about loading pictures and scale them to a square..... I'm trying to do it and I'm not able.... I'm more than 2 days fighting with it... :-(

    Thank you

  12. #12
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    Ok guys, I don't have the time to compile a sample that dynamically loads a series of images, so I will address you directly on a real-life job I just made a month ago.

    here I will put da source files:

    http://devlab.key-one.it/flashkit/sa...l_two_NEWS.fla

    http://devlab.key-one.it/flashkit/samples/news/news.txt

    http://devlab.key-one.it/flashkit/sa...ttivazione.txt

    http://devlab.key-one.it/flashkit/sa...ttivazione.jpg

    (the news.txt, attivazione.txt and attivazione.jpg files must go in a folder named "news" as the flash file refers to them as "news/news.txt" ecc...)

    here there is the thing working:

    http://www.montelvini.it/new/main.html

    ...the sample is under "notizie" in the main menu.

    In this source you will get both, a dynamic script that generates an index of news, and a dynamic script that loops until the size of the loaded image is near enough to the size of a certain movieclip. - there are other ways to achieve this function, probably with less cpu usage...)

    please use those source files only for personal use.
    This is uncensored stuff I did for work!

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