A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: This works in Player 6 but not 8???

  1. #1
    Junior Member
    Join Date
    Feb 2001
    Posts
    22

    This works in Player 6 but not 8???

    This Actionscript has been added to a basic movie clip -- the script was created so the MC will avoid the mouse. It works great when I publish in Player 6, but not 8. Please help. Thanks in advance.


    Code:
    onClipEvent(load){
    	homeX = this._x;
    	homeY = this._y;
    	magnet = 1000;
    }
    
    onClipEvent(enterFrame){
    	x0 = this._x;
    	y0 = this._y;
    	x1 = _root._xmouse;
    	y1 = _root._ymouse;
    		
    	distancex = x1-x0;
    	distancey = y1-y0;
    
    	distance = Math.sqrt((distancex * distancex) + (distancey * distancey))
    	
    	powerx = this._x - (distancex / distance) * magnet / distance;
    	powery = this._y - (distancey / distance) * magnet / distance;
    
    	forcex = (forcex + (homex - x0) / 2) / 1.66;
    	forcey = (forcey + (homey - y0) / 2) / 1.66;
    
    	this._x = powerx + forcex;
    	this._y = powery + forcey;
    }
    Last edited by alec1241; 05-18-2007 at 09:31 PM.
    Scott

  2. #2
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    Do this As2 case sensitive and you have to intial some of the variables:

    onClipEvent(load){
    homeX = this._x;
    homeY = this._y;
    magnet = 1000;
    forcex = 0
    forcey = 0

    }

    onClipEvent(enterFrame){
    x0 = this._x;
    y0 = this._y;
    x1 = _root._xmouse;
    y1 = _root._ymouse;

    distancex = x1-x0;
    distancey = y1-y0;

    distance = Math.sqrt((distancex * distancex) + (distancey * distancey))

    powerx = this._x - (distancex / distance) * magnet / distance;
    powery = this._y - (distancey / distance) * magnet / distance;

    forcex = (forcex + (homeX - x0) / 2) / 1.66;
    forcey = (forcey + (homeY - y0) / 2) / 1.66;
    this._x = powerx + forcex;
    this._y = powery + forcey;
    }
    }
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  3. #3
    Junior Member
    Join Date
    Feb 2001
    Posts
    22
    Thank you very much. It works perfectly.
    Scott

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center