<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Simple Flash Snap-To-Grid (Flash AS 2.0)</title>
	<atom:link href="http://waxjelly.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/feed/" rel="self" type="application/rss+xml" />
	<link>http://waxjelly.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=simple-flash-snap-to-grid-flash-as-20</link>
	<description>The Internet is for Users</description>
	<lastBuildDate>Fri, 30 Oct 2009 14:45:45 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Murten Saerbi</title>
		<link>http://waxjelly.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/comment-page-1/#comment-1249</link>
		<dc:creator>Murten Saerbi</dc:creator>
		<pubDate>Fri, 08 Aug 2008 22:21:50 +0000</pubDate>
		<guid isPermaLink="false">https://waxjelly.wordpress.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/#comment-1249</guid>
		<description>Hey,

I thought you might be interested in my post about snapping to grids in actionscript 3. You can check it out here: http://www.murtensaerbi.be/blog/index.php/2008/08/08/actionscript-30-snap-to-grid/</description>
		<content:encoded><![CDATA[<p>Hey,</p>
<p>I thought you might be interested in my post about snapping to grids in actionscript 3. You can check it out here: <a href="http://www.murtensaerbi.be/blog/index.php/2008/08/08/actionscript-30-snap-to-grid/" rel="nofollow">http://www.murtensaerbi.be/blog/index.php/2008/08/08/actionscript-30-snap-to-grid/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jasper</title>
		<link>http://waxjelly.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/comment-page-1/#comment-34</link>
		<dc:creator>Jasper</dc:creator>
		<pubDate>Sat, 19 May 2007 17:36:45 +0000</pubDate>
		<guid isPermaLink="false">https://waxjelly.wordpress.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/#comment-34</guid>
		<description>Its me again.

I was wondering why the ball was shaking when I moved the mouse, but not far enough to make the ball move.
When I looked at this part:

    ball.onPress = function () {
        this.startDrag();
        ball_move = true;
    }

I got it. Why are you using this.startDrag?
You are setting the var &#039;ball_move&#039; to &#039;true&#039;. And in the
ball.onMouseMove you are checking for that var to see if it&#039;s true. If so, the ball is allowed to move.
So why use startDrag?
You can leave that part out

    ball.onPress = function () {
        ball_move = true;
    }

And it will move more fluidly</description>
		<content:encoded><![CDATA[<p>Its me again.</p>
<p>I was wondering why the ball was shaking when I moved the mouse, but not far enough to make the ball move.<br />
When I looked at this part:</p>
<p>    ball.onPress = function () {<br />
        this.startDrag();<br />
        ball_move = true;<br />
    }</p>
<p>I got it. Why are you using this.startDrag?<br />
You are setting the var &#8216;ball_move&#8217; to &#8216;true&#8217;. And in the<br />
ball.onMouseMove you are checking for that var to see if it&#8217;s true. If so, the ball is allowed to move.<br />
So why use startDrag?<br />
You can leave that part out</p>
<p>    ball.onPress = function () {<br />
        ball_move = true;<br />
    }</p>
<p>And it will move more fluidly</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jasper</title>
		<link>http://waxjelly.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/comment-page-1/#comment-33</link>
		<dc:creator>Jasper</dc:creator>
		<pubDate>Sat, 19 May 2007 17:32:10 +0000</pubDate>
		<guid isPermaLink="false">https://waxjelly.wordpress.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/#comment-33</guid>
		<description>Hey, thanks for this code. The _xmouse%size part is real usefull, though I still don&#039;t really get how it works.

By the way; I think this part:

this._x = _xmouse - _xmouse%size;

can be improved by adding half the gridsize to it:

this._x = _xmouse - _xmouse%size + size/2;

This makes the snapping feel a little better. Instead of having to move a hundered pixels to the right and having to move just 1 pixel to the left to make the ball move, you have to move it 50 pixels in either way to make it move if you add half the gridsize.

Same goes for the y ofcourse</description>
		<content:encoded><![CDATA[<p>Hey, thanks for this code. The _xmouse%size part is real usefull, though I still don&#8217;t really get how it works.</p>
<p>By the way; I think this part:</p>
<p>this._x = _xmouse &#8211; _xmouse%size;</p>
<p>can be improved by adding half the gridsize to it:</p>
<p>this._x = _xmouse &#8211; _xmouse%size + size/2;</p>
<p>This makes the snapping feel a little better. Instead of having to move a hundered pixels to the right and having to move just 1 pixel to the left to make the ball move, you have to move it 50 pixels in either way to make it move if you add half the gridsize.</p>
<p>Same goes for the y ofcourse</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benjamin</title>
		<link>http://waxjelly.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/comment-page-1/#comment-32</link>
		<dc:creator>Benjamin</dc:creator>
		<pubDate>Tue, 17 Apr 2007 22:13:27 +0000</pubDate>
		<guid isPermaLink="false">https://waxjelly.wordpress.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/#comment-32</guid>
		<description>Thanks, this was helpful. I think the problem with the copying of the code into Flash stems from the punctuation coming through as actual punctuation and not standard hash marks. I had to do a find replace on all the quotes and semi-colons.

Ben</description>
		<content:encoded><![CDATA[<p>Thanks, this was helpful. I think the problem with the copying of the code into Flash stems from the punctuation coming through as actual punctuation and not standard hash marks. I had to do a find replace on all the quotes and semi-colons.</p>
<p>Ben</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Meshach</title>
		<link>http://waxjelly.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/comment-page-1/#comment-31</link>
		<dc:creator>Meshach</dc:creator>
		<pubDate>Fri, 30 Mar 2007 21:35:22 +0000</pubDate>
		<guid isPermaLink="false">https://waxjelly.wordpress.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/#comment-31</guid>
		<description>faisal, Thanks for the feedback. We&#039;ll try and get the bug fixes in the next version of this post. Thanks for reading.</description>
		<content:encoded><![CDATA[<p>faisal, Thanks for the feedback. We&#8217;ll try and get the bug fixes in the next version of this post. Thanks for reading.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: faisal</title>
		<link>http://waxjelly.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/comment-page-1/#comment-30</link>
		<dc:creator>faisal</dc:creator>
		<pubDate>Wed, 28 Mar 2007 15:04:01 +0000</pubDate>
		<guid isPermaLink="false">https://waxjelly.wordpress.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/#comment-30</guid>
		<description>nice tut, I had couple of errors, but got rid of them works fine now.

 Errors:
 1.lineStyle(1,0x0000ff,100): x in the rgb hexadecimal
 part has to be erased and rewritten.
 2.The double quotes have to be replaced.

 As well, the above code has ball clip created first.
 The
createEmptyMovieClip(&quot;ball&quot;,this.getNextHighestDepth())
along with it&#039;s mouse handlers have to be placed after the for loop that generates the grid.
 Currently your code generates the grid and places circle behind it, this is due to getNextHighestDepth.</description>
		<content:encoded><![CDATA[<p>nice tut, I had couple of errors, but got rid of them works fine now.</p>
<p> Errors:<br />
 1.lineStyle(1,0&#215;0000ff,100): x in the rgb hexadecimal<br />
 part has to be erased and rewritten.<br />
 2.The double quotes have to be replaced.</p>
<p> As well, the above code has ball clip created first.<br />
 The<br />
createEmptyMovieClip(&#8221;ball&#8221;,this.getNextHighestDepth())<br />
along with it&#8217;s mouse handlers have to be placed after the for loop that generates the grid.<br />
 Currently your code generates the grid and places circle behind it, this is due to getNextHighestDepth.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simpsons225</title>
		<link>http://waxjelly.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/comment-page-1/#comment-28</link>
		<dc:creator>Simpsons225</dc:creator>
		<pubDate>Thu, 25 Jan 2007 14:39:40 +0000</pubDate>
		<guid isPermaLink="false">https://waxjelly.wordpress.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/#comment-28</guid>
		<description>GOD DAMNIT!! WORD PRESS CUTS OFF MY COMMENTS!!! HERE IS THE LAST PART!!!!

continues on same line as last piece of code from above:</description>
		<content:encoded><![CDATA[<p>GOD DAMNIT!! WORD PRESS CUTS OFF MY COMMENTS!!! HERE IS THE LAST PART!!!!</p>
<p>continues on same line as last piece of code from above:</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simpsons225</title>
		<link>http://waxjelly.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/comment-page-1/#comment-27</link>
		<dc:creator>Simpsons225</dc:creator>
		<pubDate>Thu, 25 Jan 2007 14:36:56 +0000</pubDate>
		<guid isPermaLink="false">https://waxjelly.wordpress.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/#comment-27</guid>
		<description>Sry the one above was not complete, and remember to erase the doublequotes in flash and re-write them yourself. For some reason wordpress formats the text wrong :(

var size:Number = 100;
var columns:Number = Math.ceil(Stage.width/size);
var rows:Number = Math.ceil(Stage.height/size);
var ball_move:Boolean = false;
var ball:MovieClip = this.createEmptyMovieClip(&quot;ball&quot;, this.getNextHighestDepth());
ball.lineStyle(70, 0x000000, 100);
ball.lineTo(0, 1);
ball._x = 200;
ball._y = 200;
ball.onPress = function() {
	this.startDrag();
	ball_move = true;
};
ball.onMouseUp = function() {
	this.stopDrag();
	ball_move = false;
};
ball.onMouseMove = function() {
	if (!ball_move) {
		return;
	}
	this._x = _xmouse-_xmouse%size;
	this._y = _ymouse-_ymouse%size;
	updateAfterEvent();
};
function drawSquare(who:String, to_x, to_y) {
	this.createEmptyMovieClip(who, this.getNextHighestDepth());
	this[who].lineStyle(1, 0x000000, 100);
	this[who].moveTo(0, 0);
	this[who].lineTo(size, 0);
	this[who].lineTo(size, size);
	this[who].lineTo(0, size);
	this[who]._x = to_x;
	this[who]._y = to_y;
}
for (var c = 0; c</description>
		<content:encoded><![CDATA[<p>Sry the one above was not complete, and remember to erase the doublequotes in flash and re-write them yourself. For some reason wordpress formats the text wrong :(</p>
<p>var size:Number = 100;<br />
var columns:Number = Math.ceil(Stage.width/size);<br />
var rows:Number = Math.ceil(Stage.height/size);<br />
var ball_move:Boolean = false;<br />
var ball:MovieClip = this.createEmptyMovieClip(&#8221;ball&#8221;, this.getNextHighestDepth());<br />
ball.lineStyle(70, 0&#215;000000, 100);<br />
ball.lineTo(0, 1);<br />
ball._x = 200;<br />
ball._y = 200;<br />
ball.onPress = function() {<br />
	this.startDrag();<br />
	ball_move = true;<br />
};<br />
ball.onMouseUp = function() {<br />
	this.stopDrag();<br />
	ball_move = false;<br />
};<br />
ball.onMouseMove = function() {<br />
	if (!ball_move) {<br />
		return;<br />
	}<br />
	this._x = _xmouse-_xmouse%size;<br />
	this._y = _ymouse-_ymouse%size;<br />
	updateAfterEvent();<br />
};<br />
function drawSquare(who:String, to_x, to_y) {<br />
	this.createEmptyMovieClip(who, this.getNextHighestDepth());<br />
	this[who].lineStyle(1, 0&#215;000000, 100);<br />
	this[who].moveTo(0, 0);<br />
	this[who].lineTo(size, 0);<br />
	this[who].lineTo(size, size);<br />
	this[who].lineTo(0, size);<br />
	this[who]._x = to_x;<br />
	this[who]._y = to_y;<br />
}<br />
for (var c = 0; c</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simpsons225</title>
		<link>http://waxjelly.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/comment-page-1/#comment-29</link>
		<dc:creator>Simpsons225</dc:creator>
		<pubDate>Thu, 25 Jan 2007 14:32:20 +0000</pubDate>
		<guid isPermaLink="false">https://waxjelly.wordpress.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/#comment-29</guid>
		<description>Here is the complete script without errors:

var size:Number = 100;
var columns:Number = Math.ceil(Stage.width/size);
var rows:Number = Math.ceil(Stage.height/size);
var ball_move:Boolean = false;
var ball:MovieClip = this.createEmptyMovieClip(&quot;ball&quot;, this.getNextHighestDepth());
ball.lineStyle(70, 0x000000, 100);
ball.lineTo(0, 1);
ball._x = 200;
ball._y = 200;
ball.onPress = function() {
	this.startDrag();
	ball_move = true;
};
ball.onMouseUp = function() {
	this.stopDrag();
	ball_move = false;
};
ball.onMouseMove = function() {
	if (!ball_move) {
		return;
	}
	this._x = _xmouse-_xmouse%size;
	this._y = _ymouse-_ymouse%size;
	updateAfterEvent();
};
function drawSquare(who:String, to_x, to_y) {
	this.createEmptyMovieClip(who, this.getNextHighestDepth());
	this[who].lineStyle(1, 0x000000, 100);
	this[who].moveTo(0, 0);
	this[who].lineTo(size, 0);
	this[who].lineTo(size, size);
	this[who].lineTo(0, size);
	this[who]._x = to_x;
	this[who]._y = to_y;
}
for (var c = 0; c</description>
		<content:encoded><![CDATA[<p>Here is the complete script without errors:</p>
<p>var size:Number = 100;<br />
var columns:Number = Math.ceil(Stage.width/size);<br />
var rows:Number = Math.ceil(Stage.height/size);<br />
var ball_move:Boolean = false;<br />
var ball:MovieClip = this.createEmptyMovieClip(&#8221;ball&#8221;, this.getNextHighestDepth());<br />
ball.lineStyle(70, 0&#215;000000, 100);<br />
ball.lineTo(0, 1);<br />
ball._x = 200;<br />
ball._y = 200;<br />
ball.onPress = function() {<br />
	this.startDrag();<br />
	ball_move = true;<br />
};<br />
ball.onMouseUp = function() {<br />
	this.stopDrag();<br />
	ball_move = false;<br />
};<br />
ball.onMouseMove = function() {<br />
	if (!ball_move) {<br />
		return;<br />
	}<br />
	this._x = _xmouse-_xmouse%size;<br />
	this._y = _ymouse-_ymouse%size;<br />
	updateAfterEvent();<br />
};<br />
function drawSquare(who:String, to_x, to_y) {<br />
	this.createEmptyMovieClip(who, this.getNextHighestDepth());<br />
	this[who].lineStyle(1, 0&#215;000000, 100);<br />
	this[who].moveTo(0, 0);<br />
	this[who].lineTo(size, 0);<br />
	this[who].lineTo(size, size);<br />
	this[who].lineTo(0, size);<br />
	this[who]._x = to_x;<br />
	this[who]._y = to_y;<br />
}<br />
for (var c = 0; c</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ruslan</title>
		<link>http://waxjelly.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/comment-page-1/#comment-26</link>
		<dc:creator>Ruslan</dc:creator>
		<pubDate>Tue, 19 Dec 2006 22:25:03 +0000</pubDate>
		<guid isPermaLink="false">https://waxjelly.wordpress.com/2006/08/21/simple-flash-snap-to-grid-flash-as-20/#comment-26</guid>
		<description>Hi! This what I got , when I tried to run your program:

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 6: This type of quotation mark is not allowed in ActionScript. Please change it to a standard (straight) double quote.
     var ball:MovieClip = this.createEmptyMovieClip(”ball”, this.getNextHighestDepth());

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 7: &#039;)&#039; or &#039;,&#039; expected
     ball.lineStyle(70, 0×0, 100);

Total ActionScript Errors: 2 	 Reported Errors: 2</description>
		<content:encoded><![CDATA[<p>Hi! This what I got , when I tried to run your program:</p>
<p>**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 6: This type of quotation mark is not allowed in ActionScript. Please change it to a standard (straight) double quote.<br />
     var ball:MovieClip = this.createEmptyMovieClip(”ball”, this.getNextHighestDepth());</p>
<p>**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 7: &#8216;)&#8217; or &#8216;,&#8217; expected<br />
     ball.lineStyle(70, 0×0, 100);</p>
<p>Total ActionScript Errors: 2 	 Reported Errors: 2</p>
]]></content:encoded>
	</item>
</channel>
</rss>
 

