Monday, February 14, 2005

pop up with image size

If you are making an image viewier and wnt the pop up to resize according to the image size this is wot u have to do.
I hav'nt used the loader component of flashMX 2004 which make things more simple, here am using the old techique of loading image into an empty movie clip.

to make things working open a new flash doc inside the lib'
make three movie clip.

1.boder_mc -- this will have the outer border of you image that you are showing
2.holder_mc -- this will be any empty movie clip to which you will load the image
3.loading_mc -- this movie clip will have the loading animation

once this is done drag all of them into another movie clip called frame_mc
and drag frame_mc to stage.

keep the same instance name and the order


on the one and only frame paste this code and that's it .

------------------------------------------------------------------------------------------------
var id ;
var x_range;
var y_range;
var counter =1;

function loadImage(){
frame_mc.loader_mc._visible=true;
frame_mc.holder_mc.loadMovie("test.jpg");
id = setInterval(traceAmount,100);
}

function traceAmount() {
frame_mc.holder_mc._alpha =0;
if(frame_mc.holder_mc.getBytesLoaded()== frame_mc.holder_mc.getBytesTotal()){
xrange = frame_mc.border_mc._width -( frame_mc.holder_mc._width+10);
yrange = frame_mc.border_mc._height-( frame_mc.holder_mc._height+10);
frame_mc.loader_mc._visible=false;
clearInterval(id);
id = setInterval(popupSizer,100,xrange,yrange);
}
}

function popupSizer(x:Number,y:Number){

var xdiv_val = x/10;
var ydiv_val = y/10;
frame_mc.border_mc._width -= xdiv_val;
frame_mc.border_mc._height -= ydiv_val;

counter ++;

if(counter == 10){

frame_mc.border_mc._width = frame_mc.holder_mc._width+10 ;
frame_mc.border_mc._height= frame_mc.holder_mc._height+10 ;
frame_mc.holder_mc._alpha =100;
clearInterval(id);
}
}

loadImage();
stop();

----------------------------------------------------------------------------------------------
I have used some constants , be ready to change those and improvise the look and feel of the out put.
Happy coding

No comments: