<?xml version="1.0" encoding="iso-8859-1"?><rss version="2.0">
<channel><title><![CDATA[ActionScript.org Flash, Flex and ActionScript Resources - Comments for article: Simple Magnetic Menu - A Revisit and Upgrade]]></title><link>http://www.actionscript.org/resources</link><description /><language>en-us</language><copyright><![CDATA[http://www.actionscript.org/resources]]></copyright><generator>N/A</generator><webMaster>general.redirect@gmail.com</webMaster><lastBuildDate>Sun, 22 Nov 2009 14:19:42 CST</lastBuildDate><ttl>20</ttl><item><title><![CDATA[Comment #1]]></title><link>http://www.actionscript.org/resources/articles/546/1/Simple-Magnetic-Menu---A-Revisit-and-Upgrade/Page1.html#Comment1732</link><description><![CDATA[Is this written for Flash 8 only, I get an unexpected file format error?<br/><br/>
(Comment posted by Jenny Lynn at 3:10 pm, Sat 24th Mar 2007)]]></description><author>no@spam.com (Jenny Lynn)</author><pubDate><![CDATA[Sat, 24 Mar 2007 15:10:17 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/546/1/Simple-Magnetic-Menu---A-Revisit-and-Upgrade/Page1.html#Comment1732</guid></item><item><title><![CDATA[Comment #2]]></title><link>http://www.actionscript.org/resources/articles/546/1/Simple-Magnetic-Menu---A-Revisit-and-Upgrade/Page1.html#Comment3775</link><description><![CDATA[Great tutorial, but I just keep getting this error and I have no idea why. Please help?

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 24: 'else' encountered without matching 'if'
     else

Total ActionScript Errors: 1 	 Reported Errors: 1<br/><br/>
(Comment posted by James at 6:12 pm, Wed 6th Jun 2007)]]></description><author>no@spam.com (James)</author><pubDate><![CDATA[Wed, 06 Jun 2007 18:12:20 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/546/1/Simple-Magnetic-Menu---A-Revisit-and-Upgrade/Page1.html#Comment3775</guid></item><item><title><![CDATA[Comment #3]]></title><link>http://www.actionscript.org/resources/articles/546/1/Simple-Magnetic-Menu---A-Revisit-and-Upgrade/Page1.html#Comment8288</link><description><![CDATA[I noted 2 things about this program or animation
  
[quote]
if (currY < 33)
  {
   yChange = currY - 31;
  }
  if (currX < 70)
  {
   xChange = currX - 68;
  }
[/quote]
i think this part is useless no use 


and 

second thing
 yChange = Math.round((mouseY-currY)/5
why we divided by an integer greater than 1 as the distance we have to move is mouseY-currY
actually in flash the mouse event is generated according to fps
1 fps =1 mouse event per second
12 fps= 12 mouse event per second

so if we dont divide by 5 or any integer >1
the button will go to the graphic in 1 frame only and there will be no smooth transition 
if we divide it by any no say 5 the button will travel one fifth of distance in one frame in next frame 1/5th of remaining distance and we will get a cool magnetobutano!!!
<br/><br/>
(Comment posted by Ketav at 11:09 am, Mon 17th Dec 2007)]]></description><author>no@spam.com (Ketav)</author><pubDate><![CDATA[Mon, 17 Dec 2007 11:09:16 CST]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/546/1/Simple-Magnetic-Menu---A-Revisit-and-Upgrade/Page1.html#Comment8288</guid></item><item><title><![CDATA[Comment #4]]></title><link>http://www.actionscript.org/resources/articles/546/1/Simple-Magnetic-Menu---A-Revisit-and-Upgrade/Page1.html#Comment9447</link><description><![CDATA[AS3 code
********

var mouseOnGraphics:Boolean;
menu_mc.mouseEnabled = false;
graphics_mc.addEventListener(MouseEvent.MOUSE_OVER,rollOver_fn);
graphics_mc.addEventListener(MouseEvent.MOUSE_OUT,rollOut_fn);
function rollOver_fn(event:MouseEvent):void {
	mouseOnGraphics= true;
}
function rollOut_fn(event:MouseEvent):void {
	mouseOnGraphics = false;
}
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(event:Event):void {
	var Var_mouseX = mouseX;// x of the mouse position
	var Var_mouseY = mouseY;// y of the mouse position
	var currX = menu_mc.x;// current button x
	var currY = menu_mc.y;// current button y
	var xChange = 0;// how much to add/subtract from x coordinate
	var yChange = 0;// how much to add/subtract from y coordinate
	// move toward mouse if mouse is on the graphics
	if (mouseOnGraphics) {
		// mouseY - currY determines the total distance between the y points
		// the "/5" says take the distance and divide by 5.  This keeps the button from relocating to the mouse positoin without floating there
		// changing the 5 will also affect the speed the button moves.  Try changing it to 20 or to 2 to see what happens!
		yChange = Math.round((Var_mouseY-currY)/5);// determine the distance to move y 
		xChange = Math.round((Var_mouseX-currX)/5);// determine the distance to move x

		// since we're moving towards the mouse, always add :D 
		menu_mc.y += yChange;
		menu_mc.x += xChange;
	} else {
		// the following will help keep the button from bouncing around the point you want it to be at forever.  It says if you're within 2 pixels then just go to the position. 
		if (currY<33) {
			yChange = currY-31;
		}
		if (currX<70) {
			xChange = currX-68;
		}
		// this code is the same as for moving towards the mouse however, 
		// move from it's current position to the desired location (68,31) 
		yChange = Math.round((currY-31)/5);
		xChange = Math.round((currX-68)/5);
		// as we are moving away - subtract the difference!
		menu_mc.y -= yChange;
		menu_mc.x -= xChange;
	}
}<br/><br/>
(Comment posted by Anil at 4:57 am, Tue 12th Feb 2008)]]></description><author>no@spam.com (Anil)</author><pubDate><![CDATA[Tue, 12 Feb 2008 04:57:51 CST]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/546/1/Simple-Magnetic-Menu---A-Revisit-and-Upgrade/Page1.html#Comment9447</guid></item><item><title><![CDATA[Comment #5]]></title><link>http://www.actionscript.org/resources/articles/546/1/Simple-Magnetic-Menu---A-Revisit-and-Upgrade/Page1.html#Comment12974</link><description><![CDATA[It's nice.....<br/><br/>
(Comment posted by arya Gdm at 9:30 am, Wed 6th May 2009)]]></description><author>no@spam.com (arya Gdm)</author><pubDate><![CDATA[Wed, 06 May 2009 09:30:47 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/546/1/Simple-Magnetic-Menu---A-Revisit-and-Upgrade/Page1.html#Comment12974</guid></item></channel></rss>