A Flash Developer Resource Site

Results 1 to 17 of 17

Thread: dynamically diplaying image

  1. #1
    Senior Member
    Join Date
    May 2001
    Posts
    485

    dynamically diplaying image

    hello,
    I have a flash page that is being driven by an access db, I am successfully getting all the text to display in dynamic text boxes... I need to load an image as well... how do i do this, can i load a swf or jpg file into a dynamic text box.... i dont think so, but what can i do... this is my code for displaying the text, as well as the name of the image...


    Code:
    // depth
    depth = -1;
    // hide the origional clips
    Name._visible = 0;
    Age._visible = 0;
    Image._visible = 0;
    // split up the array by looking for the commas
    Name_array = output.split(",");
    Age_array = eoutput.split(",");
    Image_array = eoutput2.split(",");
    // get the length of the array
    Name_length = Name_array.length;
    Age_length = Age_array.length;
    Image_length = Image_array.length;
    // set the start y position (x position depends on where you put it on the screen)
    yposition = 235;
    // looping everything
    for (i=0; i<Name_length; i++) {
    	// Name
    	duplicateMovieClip(Name, "Name" add i, depth);
    	setProperty("Name" add i, _y, yposition);
    	Name.Name = Name_array[1];
    	set("Name" add i add ".info", Name_array[i]);
    	depth--;
    	// Age
    	duplicateMovieClip(Age, "Age" add i, depth);
    	setProperty("Age" add i, _y, yposition);
    	Age.Age = Age_array[1];
    	set("Age" add i add ".info", Age_array[i]);
    	depth--;
    		// Image
    	duplicateMovieClip(Image, "Image" add i, depth);
    	setProperty("Image" add i, _y, yposition);
    	Image.Image = Image_array[1];
    	set("Image" add i add ".info", Image_array[i]);
    	depth--;	
    	// Set the y position plus 30
    	yposition = yposition+100;
    }

  2. #2
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    No.

    Heres some info on loading external files. It applies to jpg images as well ( jpg's works in MX only).

    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 shoeld 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

  3. #3
    Senior Member
    Join Date
    May 2001
    Posts
    485
    tx,
    I just noticed that half of my actionscript was cut out...

    I can load jpg and swf externally, but I need it to come from the db

    depth = -1;
    Name._visible = 0;
    Age._visible = 0;
    Image._visible = 0;
    Name_array = output.split(",");
    Age_array = eoutput.split(",");
    Image_array = eoutput2.split(",");
    Name_length = Name_array.length;
    Age_length = Age_array.length;
    Image_length = Image_array.length;
    yposition = 235;
    for (i=0; i<Name_length; i++) {
    duplicateMovieClip(Name, "Name" add i, depth);
    setProperty("Name" add i, _y, yposition);
    Name.Name = Name_array[1];
    set("Name" add i add ".info", Name_array[i]);
    depth--;
    duplicateMovieClip(Age, "Age" add i, depth);
    setProperty("Age" add i, _y, yposition);
    Age.Age = Age_array[1];
    set("Age" add i add ".info", Age_array[i]);
    depth--;
    duplicateMovieClip(Image, "Image" add i, depth);
    setProperty("Image" add i, _y, yposition);
    Image.Image = Image_array[1];
    set("Image" add i add ".info", Image_array[i]);
    depth--;
    yposition = yposition+100;
    }
    Last edited by jbalyney; 07-15-2003 at 07:33 PM.

  4. #4
    Senior Member
    Join Date
    May 2001
    Posts
    485
    sorry about that, but it wont let me display the whole amount pf code... as code..

    So what i have above gets the info from the db, and loads it into dynamically text box MC's

    The last bit there
    Code:
    duplicateMovieClip(Image, "Image" add i, depth);
    setProperty("Image" add i, _y, yposition);
    Image.Image = Image_array[1];
    set("Image" add i add ".info", Image_array[i]);
    is now displaying the image name (eg...big.swf) in a dynamic text box.. I need to figure out how to put them into a dynaically created MC.

    i have created an empty MC called container, I do know how to import an external image, I just dont know how to merge that with my database output...

    this code
    Code:
    _root.createEmptyMovieClip("logo", 5);
    _root.logo.loadMovie("images/acaBig.swf");
    _root.logo._xscale = 100;
    _root.Iogo._yscale = 100;
    has to somehow integrated with my loop, so instead of it outputting text, it creates a MC

  5. #5
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    As the dynamically created mc is holding a loaded swf file it can not have anything else in it, unless the external swf itself has atextfield you can display it in. Or you can have the textbox mc have the same coordinate as the other mc so it appears to be inside it.

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

  6. #6
    Senior Member
    Join Date
    May 2001
    Posts
    485
    i dont undertand what u r saying... r u saying that what i want to do is not possible?

    I have seen a database driven website featured on macromedias website, so it has to be possible

  7. #7
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    My impression was that you wanted your text to display inside the same mc ( container ) as where the image displays. I may have got you wrong.

    Ive built many sites myself loading both images and texts from external sources without any problems so that was not the issue in my reply.

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

  8. #8
    Senior Member
    Join Date
    May 2001
    Posts
    485
    sorry,
    let me explain it better...

    my sql in my asp page is grabbing 3 things
    name
    profile
    image

    So far my flash file is looping through the sql results and displaying
    name as text (eg... My name)
    profile as text (eg.... I am 18 feet tall, I have a blue nose)
    image as text (eg.... myPicture.swf)

    BUT......
    I want it to display the image as an image,

    So... my code now is displaying

    name in a dynamic text field
    profile in a dynamic text field
    image in a dynamic text field... I want this to display an image instead..

    The reason that i have the image in a test field at the moment, is for testing purposes

  9. #9
    Senior Member
    Join Date
    May 2001
    Posts
    485
    just to make sure i am clear...

    In flash kit, some of us have footers under all our posts, these images are not in the database...but the names of the images are in the database.... SO. i want my flash file to display the images dynamically, just like flash kit is displaying our footers as images, and not image names

  10. #10
    Senior Member
    Join Date
    May 2001
    Posts
    485
    this is the page and what it is outputting now

    http://www.justinblayney.com/newSite/data.html

  11. #11
    Senior Member
    Join Date
    May 2001
    Posts
    485
    i wrote this, can someone tell me if i am on the right track (it doesnt work).. I created an empty MC and gave it an instance name of container


    depth = -1;
    // hide the origional clips
    Name._visible = 0;
    Age._visible = 0;
    container._visible = 0;

    // split up the array by looking for the commas
    Name_array = output.split(",");
    Age_array = eoutput.split(",");
    container_array = eoutput2.split(",");

    // get the length of the array
    Name_length = Name_array.length;
    Age_length = Age_array.length;
    container_length = container_array.length;

    // set the start y position (x position depends on where you put it on the screen)
    yposition = 235;

    // looping everything
    for (i=0; i<Name_length; i++) {
    // Name
    duplicateMovieClip(Name, "Name" add i, depth);
    setProperty("Name" add i, _y, yposition);
    Name.Name = Name_array[1];
    set("Name" add i add ".info", Name_array[i]);
    depth--;

    // Age
    duplicateMovieClip(Age, "Age" add i, depth);
    setProperty("Age" add i, _y, yposition);
    Age.Age = Age_array[1];
    set("Age" add i add ".info", Age_array[i]);
    depth--;

    // Image
    _root.container.loadMovie("images/container_array");
    _root.container._xscale = 100;
    _root.container._yscale = 100;

    yposition = yposition+100;
    }

  12. #12
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    So you want a loading action.

    container.loadMovie(image);

    As you have only one container you can only show one image at the time.

    If you can make the database return a number for the images too
    (image1 image 2 ) you can have

    container.loadMovie("image"+i);
    i++;

    .....to load the sequentially.

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

  13. #13
    Senior Member
    Join Date
    May 2001
    Posts
    485
    tx.
    The image PLUS 1
    PLUS PLUS,

    it is in the first line, but flashkit will not allow it to display, I have posted my file


    for (i=0; i<Name_length; i++) {
    duplicateMovieClip.loadMovie(container, "container" add i, depth);
    setProperty("container" add i, _y, yposition);
    container.container = container_array[1];
    set("container" add i add ".info", container_array[i]);
    depth--;


    my code works for duplociting the text boxes, i think i am close, I will post my file agin
    Attached Files Attached Files
    Last edited by jbalyney; 07-16-2003 at 06:41 AM.

  14. #14
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    I think your code is wrong. DuplicateMovievlip and loadMovie are separate actions.

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

  15. #15
    Senior Member
    Join Date
    May 2001
    Posts
    485
    i know my code is wrong, LOL,
    thats why i am posting it here, i am trying to figure it out myself, but i really have no idea what to do.. I am trying to follow the pattern that is allready there for displaying text, I just dont know how to convert it to display a image, I did try exactly what u posted, but it didnt work either....


    This is the code below, that is being used to display text in the dynamic text boxes, it also duplicates the text box for the amount of recordset returns from the db,.. that is sent to flash in the array.. Did u d/l my latest .fla file ??/ In it, you will see how it is set up.

    For some reason, I dont think u understand what I am trying to do. i do not know how to explain it better....

    // Age
    duplicateMovieClip(Age, "Age" add i, depth);
    setProperty("Age" add i, _y, yposition);
    Age.Age = Age_array[1];
    set("Age" add i add ".info", Age_array[i]);
    depth--;

  16. #16
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    Im not into arrays, I only work with loops and dynamic variables ( which is almost the same thing).
    I would suggest yo try the loadMovie thing on a separate file to get the hang of it and then implement it in your current code. To many things may go wrong as it is and its better to get a understanding to get the separate elements to work by themselves first.

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

  17. #17
    Senior Member
    Join Date
    May 2001
    Posts
    485
    i know how to do the load movie, i have used it before..So, i dont know what to say... i am a designer not a programmer LOL

    i have posted this elswhere, hopefully i explained it better, and can get some feedback

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