-
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?
-
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
-
Senior Member
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 ).
-
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?
-
Senior Member
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.
-
Thanks - I will give it try!
-
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!
-
Senior Member
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.
-
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??
-
Senior Member
Yes, when they both have the same size you could start the alpha fade.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|