A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Automatically animating box resize

  1. #1
    Member
    Join Date
    Dec 2000
    Posts
    48

    Automatically animating box resize

    Hello,

    As a background to some loaded images, I want the rectangular frame around the pictures to resize to fit the next image being loaded. However, I want to be able to dynamically do this as the images can be called randomly.
    Because each button is called from different buttons, ie a thumbnail - what I am also finding difficult to underatnd is how the resize knows the size of the box before it animates the resize?

    I have been unable to find a tuturial etc for this effect - can anyone help?

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    don't know wht you mean by 'images can be called randomly.' Each thumbnail button can open random pictures? more info on that part could be needed.
    If it's not the case, the size is given by the thumbnail button.
    gparis

  3. #3
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    A neat way is for the rectangular movieclip to constantly check what size the containerMC movieclip has.......

    onClipEvent(enterFrame){
    width_of_image=containerMC._width;
    height_of_image=containerMC._height;
    // Resizing code here
    }


    ( that is if I get you right ).

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

  4. #4
    Member
    Join Date
    Dec 2000
    Posts
    48
    http://www.linaeriksson.com/
    the transition between images in this site is exactly what I want to do.

    The checking MC size code helps - but the for step - I am trying to accomplish is when I click on a thumbnail it loads a new picture (random in that it is not in sequence like a slide show). The new picture will have different dimensions. I therefore want the MC with the image border to change its size to properly frame the new image. I want that transition to animated in that the 'image border' MC to resize itself. Equivalent to a simple tween between a square and rectangle for example, but using scripting to do it.

    Any pointers?

  5. #5
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    This will resize the frame MC to whatever position and size of the movieclip you are loading images into ( here called containerMC )

    ON the mc with borders

    onClipEvent (enterFrame) {
    // Set dimensions and speed and more
    w = _root.containerMC._width;
    h = _root.containerMC._height;
    xpos = _root.containerMC._x;
    ypos =_root.containerMC._y;
    speed = 5;
    // Move the thing
    this._width += (w-this._width)/speed;
    this._height += (h-this._height)/speed;
    this._x += (xpos-this._x)/speed;
    this._y += (ypos-this._y)/speed;
    }

    Note that the frame's top left should be in the middle of the mc.

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

  6. #6
    Member
    Join Date
    Dec 2000
    Posts
    48
    Thanks - I will give it try!

  7. #7
    Member
    Join Date
    Dec 2000
    Posts
    48
    Hello again,

    I tried the script you provided and it worked perfectly, however I also realised that the picture appeared and then the box resized.

    How do I resize the box in the same way but by using dimensions pulled from a XML document - ie the dimensions would correspond to the jpeg.

    So when I press on the button, it first goes to the XML document and uses the dimensions to resize the border and then load the jpeg.

    Any suggestions?

    ps I have looked at different posts but can't work it out!

  8. #8
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    I dont know xml. And if you are reading from a textfile you have to manually put in the dimensions. Cant you just set the loaded image to alpha 0 until the resize is done or something.

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

  9. #9
    Member
    Join Date
    Dec 2000
    Posts
    48
    That makes sense!
    But how would I know that the resize is complete - would I doa size check or something and compare it to the new jpeg size??

  10. #10
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    Yes, when they both have the same size you could start the alpha fade.

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

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