# onClipEvent enterFrame stop loop problem

**URL:** https://forum.kirupa.com/t/onclipevent-enterframe-stop-loop-problem/54604
**Category:** flash
**Created:** [June 16, 2004, 3:52am UTC](https://forum.kirupa.com/t/onclipevent-enterframe-stop-loop-problem/54604 "2004-06-16T03:52:23Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![enriquepr](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/enriquepr/32/459_2.png) [@enriquepr](https://forum.kirupa.com/u/enriquepr)
#### Post date: [June 16, 2004, 3:52am UTC](https://forum.kirupa.com/t/onclipevent-enterframe-stop-loop-problem/54604/1 "2004-06-16T03:52:23Z")

</div>

I wasn’t sure how to name this thread to well. Ah well. Here’s my funk:  
I have made a photo slide show and all works well for browsing and viewing. Where I got stuck was when I tried to write code that would center images that were vertical. This is the entire code on the empty mc that has it preload, display then adjust the x of the image. Now, with this code if the image is vertical it flies off the right of the page. haha. sounds fun eh?

```auto

onClipEvent (enterFrame) {
	total_bytes = this.getBytesTotal();
	loaded_bytes = this.getBytesLoaded();
	remaining_bytes = total_bytes-loaded_bytes;
	percent_done = int((loaded_bytes/total_bytes)*100);
	_root.loaderim.gotoAndStop(percent_done);
	if (total_bytes == loaded_bytes) {
		if (this._width<this._height) {
				this._x = this._x+(this._width/2);
		} else {
			this._x = 149.8;
		}
	}
}

```

I’ve been playing around with a few alternatives to stop the loop once it has changed the \_x position but haven’t figured out the best way. I’ll figure it out sooner or later but i find whenever i post on here someone tends to beat me 😏. Ok, well thanks in advance to anyone who can help out. The race is on! :bad:
