Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mikepro44

macrumors member
Original poster
May 18, 2008
86
0
stop();

var total = getBytesTotal();

onEnterFrame = function()
{
var loaded = getBytesLoaded();
var percent = Math.round(loaded/total*100);
preloader.howMuchLoaded.text = percent+"%";
preloader.gotoAndStop(percent);
if (loaded == total)
{
gotoAndPlay(5);
delete onEnterFrame;
}
}


pick.onEnterFrame = function()
{
Mouse.hide();
this._x= _xmouse;
this._y= _ymouse;

}

var shakeRange:Number = 1;

function shake(target:MovieClip):Void
{

var randomAction = random(2);
if(randomAction == 0)
{
target._x += shakeRange
}
else if(randomAction == 1)
{
target._x -= shakeRange
}


var randomAction = random(2);
if(randomAction == 0)
{
target._y += shakeRange
}
else if(randomAction == 1)
{
target._y -= shakeRange
}
}

_root.onEnterFrame = function(){
shake(guitar_mc);
}


Trying to make a preloader and the bottom piece of code makes an object shake.. or it is supposed to. Although when I have it in it shakes, but everything else doesnt work.. loading bar and doesn't go to frame 5..

any thoughts on why its messing up?
 
onEnterFrame = function() is called twice, the second one is overriding your preloading code, if you place the preloading onEnterFrame below the shaking code, you should be able to see it work. Just lump both chunk in a single onEnterFrame. Adding event listeners is a better choice.
 
Figured it out, i just needed to put preloader. in front of the first onEnter..
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.