# I'm loosing my mind

**URL:** <https://forum.kirupa.com/t/im-loosing-my-mind/149636>\
**Category:** Uncategorized\
**Created:** [May 31, 2005, 7:30am UTC](https://forum.kirupa.com/t/im-loosing-my-mind/149636 "2005-05-31T07:30:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pisosse](https://avatars.discourse-cdn.com/v4/letter/p/46a35a/32.png) [@pisosse](https://forum.kirupa.com/u/pisosse)\
**Post date:** [May 31, 2005, 7:30am UTC](https://forum.kirupa.com/t/im-loosing-my-mind/149636/1 "2005-05-31T07:30:00Z")

</div>

I might be in over my head with this but something in this code is messing with me…

On a webpage it’s supposed to work like [THIS](http://www.michaelevensen.com) dudes combined preloadbar and transition(shuffle through his works and see what I mean)

but what I got is [THIS](http://www.mentalindustries.com/pretra)

First time you hit a button you’l get the awfull NaN for percentage text next time you hit the same button it works as intented. When you hit the other buttons only the transition is working…

\*\*\*\*…can anybody see whats going on??

```auto
_root.createEmptyMovieClip("container_mc", 0);
container_mc.depthTrack = 0;
_root.createEmptyMovieClip("Preloader", _root.getNextHighestDepth());
_root.createEmptyMovieClip("percentText_mc", _root.getNextHighestDepth());
_root.percentText_mc.createTextField("percentTextField", _root.getNextHighestDepth(), 0, 0, 150, 20);
newTf = new TextFormat();
newTf.font = "myVerdana";
newTf.size = 12;
newTf.color = 0xff0099;

_root.percentText_mc.percentTextField.embedFonts = true;

Preloader._x = 410;
Preloader.moveTo(0, 0);
Preloader.beginFill(0x006699, 70);
Preloader.lineStyle(1, 0x006699, 0);
Preloader.lineTo(410, 0);
Preloader.lineTo(410, 307);
Preloader.lineTo(0, 307);
Preloader.lineTo(0, 0);
Preloader.endFill();
trace(Preloader._width);
Preloader._xscale = 0;
function Preload(Target) {
        var Percent:Number = 0;
        container_mc.depthTrack++;
        var dT = container_mc.depthTrack;
        loaderMC = container_mc.createEmptyMovieClip("image" + dT, dT);
        loaderMC._alpha = 0;
        loaderMC.loadMovie(Target);
        onEnterFrame = function () {
                Percent -= (Percent - ((loaderMC.getBytesLoaded() / loaderMC.getBytesTotal()) * 100)) * .25;
                _root.percentText_mc._x = Preloader._x - Preloader._width;
                if (loaderMC.getBytesTotal() < 1) {
                        _root.percentText_mc.percentTextField.text = "0 percent loaded";
						
                } else {
                        _root.percentText_mc.percentTextField.text = Math.round(Percent) + "percent loaded.";
						_root.percentText_mc.percentTextField.setTextFormat(newTf);
                }
                Preloader._xscale = -Percent;
                if (Percent > 99) {
                        delete onEnterFrame;
                        var dT = depthTrack;
                        if (dT > 1) {
                                removeMovieClip(container_mc["image" + (dT - 1)]);
                        }
                        percentText_mc.percentTextField._alpha = 0;
                        loaderMC._alpha = 100;
                        scaleToZero = new mx.transitions.Tween(Preloader, "_xscale", mx.transitions.easing.Regular.easeOut, Preloader._xscale, 0, 1, true);
                }
        };
		
}

btn1.onRelease = function() {
	Preload("http://www.mentalindustries.com/pretra/pic01.jpg");
}
btn2.onRelease = function() {
	Preload("http://www.mentalindustries.com/pretra/pic03.jpg");
}
btn3.onRelease = function() {
	Preload("http://www.mentalindustries.com/pretra/pic02.jpg");
}

```
