# Refresh ClipEvent

**URL:** <https://forum.kirupa.com/t/refresh-clipevent/199384>\
**Category:** flash\
**Created:** [September 1, 2006, 8:00pm UTC](https://forum.kirupa.com/t/refresh-clipevent/199384 "2006-09-01T20:00:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thalamus](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@thalamus](https://forum.kirupa.com/u/thalamus)\
**Post date:** [September 1, 2006, 8:00pm UTC](https://forum.kirupa.com/t/refresh-clipevent/199384/1 "2006-09-01T20:00:34Z")

</div>

[LEFT][SIZE=1][COLOR=#808080]Hello:[/COLOR][/SIZE][/LEFT]

[LEFT][SIZE=1][COLOR=#808080]I have a blank container mc into which I am loading JPGs after you click on a button. [/COLOR][/SIZE]  
[SIZE=1][COLOR=#808080]There are 10 buttons in the movie, each associated with a different JPG.[/COLOR][/SIZE]  
[SIZE=1][COLOR=#808080]This container\_mc is part of a function called on the main Timeline.[/COLOR][/SIZE]  
[SIZE=1][COLOR=#808080]The Flash movie is 1 frame on the main Timeline.[/COLOR][/SIZE][/LEFT]

[LEFT][SIZE=1][COLOR=#808080]This code works correctly on the first JPG when I click on a button for the first time), but then when you click on a different button I believe it just uses the dimensions and coordinates of the first JPG.[/COLOR][/SIZE][/LEFT]

[LEFT][SIZE=1][COLOR=#808080]How can I reset or refresh (unload, reload?) this function so it works correctly every time I load a new JPG?[/COLOR][/SIZE]  
[SIZE=1][COLOR=#808080]updateAfterEvent, maybe?[/COLOR][/SIZE][/LEFT]

[LEFT][SIZE=1][COLOR=#808080]thanks.[/COLOR][/SIZE][/LEFT]  
[SIZE=1]  
//after full size image loads into detailthumb\_mc,  
//resize image so that neither width nor height is \> 150, tben recenter  
onClipEvent(load) {  
var maxWidth = 150;  
var maxHeight = 150;  
if (this.\_width \> maxWidth || this.\_height \> maxHeight) {  
var scaleFactor = this.\_width \> this.\_height ? maxWidth / this.\_width : maxHeight / this.\_height;  
this.\_width = Math.floor (this.\_width \* scaleFactor);  
this.\_height = Math.floor (this.\_height \* scaleFactor);  
this.\_x = 85 - (this.\_width/2);  
this.\_y = 90 - (this.\_height/2);  
//display gallerywm\_mc at bottom of resized image  
var gallerywm = \_parent.gallerywm\_mc;  
gallerywm.\_x = this.\_x;  
gallerywm.\_y = this.\_y + this.\_height - 20;  
gallerywm.\_width = this.\_width;  
gallerywm.\_height = Math.floor (gallerywm.\_height \* this.\_width /150);  
//hide boundingbox\_mc if image is portrait orientation  
if (this.\_height == 150) {  
\_parent.boundingbox\_mc.\_visible= false;  
}  
//hide imagepreloader\_mc  
\_parent.imagepreload\_mc.\_visible= false;  
}  
}  
[/SIZE]
