Flash-Action Script problem

Discussion in 'Web Design and Development' started by mikepro44, Feb 3, 2009.

  1. mikepro44 macrumors member

    Joined:
    May 18, 2008
    #1
    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?
     
  2. angelneo macrumors 68000

    Joined:
    Jun 13, 2004
    Location:
    afk
    #2
    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.
     
  3. mikepro44 thread starter macrumors member

    Joined:
    May 18, 2008
  4. mikepro44 thread starter macrumors member

    Joined:
    May 18, 2008
    #4
    Figured it out, i just needed to put preloader. in front of the first onEnter..
     

Share This Page