# Stick

**URL:** <https://forum.kirupa.com/t/stick/261815>\
**Category:** Uncategorized\
**Created:** [May 31, 2008, 6:11am UTC](https://forum.kirupa.com/t/stick/261815 "2008-05-31T06:11:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahul\_7star](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@rahul\_7star](https://forum.kirupa.com/u/rahul_7star)\
**Post date:** [May 31, 2008, 6:11am UTC](https://forum.kirupa.com/t/stick/261815/1 "2008-05-31T06:11:39Z")

</div>

Hi see this game  
[http://www.tallhat.com/matches/](http://www.tallhat.com/matches/)

Now what they have used to check the ans is they had store the x(say x=200)and y(say y= 300) value of solutions to a variable and whenever it matches you win , the problem is that if you drag all these stick to some other places(then x and y values changes), and then chk you wont be havng right ans , now i want to have other logic to do this … any help

HI guys , i got stuck with the ans checking logic to this type of game…help me …

---

<div class="post-metadata">

**Author:** ![rahul\_7star](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@rahul\_7star](https://forum.kirupa.com/u/rahul_7star)\
**Post date:** [June 2, 2008, 11:52am UTC](https://forum.kirupa.com/t/stick/261815/2 "2008-06-02T11:52:52Z")

</div>

HI  
i am having 8_8 grid and i am having a move clip, whenevr you release that movie clip it should attached itself to its nearby Grid(8_8)…any help

---

<div class="post-metadata">

**Author:** ![neilmmm](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@neilmmm](https://forum.kirupa.com/u/neilmmm)\
**Post date:** [June 2, 2008, 5:17pm UTC](https://forum.kirupa.com/t/stick/261815/3 "2008-06-02T17:17:20Z")

</div>

try

```auto
var g_gridSpacing:Number = 40;
_mc.onRelease = _mc.onReleaseOutside=function () {
 this.stopDrag();
 // Stop Dragging
 X = this._x;
 // Reference X Pos
 Y = this._y;
 // Reference Y Pos
 if (X<320 && Y<320) {
  this._x = Math.round(X/g_gridSpacing)*g_gridSpacing;
  // Round to nearest GridSpace 
  this._y = Math.round(Y/g_gridSpacing)*g_gridSpacing;
  // Round to nearest GridSpace 
 }
};

```

---

<div class="post-metadata">

**Author:** ![rahul\_7star](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@rahul\_7star](https://forum.kirupa.com/u/rahul_7star)\
**Post date:** [June 3, 2008, 7:35am UTC](https://forum.kirupa.com/t/stick/261815/4 "2008-06-03T07:35:50Z")

</div>

Thanks but i want something like this …see the fla…

[quote=neilmmm;2334908]try

```auto
var g_gridSpacing:Number = 40;
_mc.onRelease = _mc.onReleaseOutside=function () {
 this.stopDrag();
 // Stop Dragging
 X = this._x;
 // Reference X Pos
 Y = this._y;
 // Reference Y Pos
 if (X<320 && Y<320) {
  this._x = Math.round(X/g_gridSpacing)*g_gridSpacing;
  // Round to nearest GridSpace 
  this._y = Math.round(Y/g_gridSpacing)*g_gridSpacing;
  // Round to nearest GridSpace 
 }
};

```

[/quote]

---

<div class="post-metadata">

**Author:** ![neilmmm](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@neilmmm](https://forum.kirupa.com/u/neilmmm)\
**Post date:** [June 3, 2008, 3:31pm UTC](https://forum.kirupa.com/t/stick/261815/5 "2008-06-03T15:31:59Z")

</div>

you need to use hitTest

draw a copy of your grid

make each mtach stick position an mc and put a reference to each stick position in an array

then alpha copy grid to 0

when moving a matchstick, on release just do a hitTest to array of alpha out matchsticks in a for loop

the sticks do not have to snap to \_x and \_y but if you want them to they can match the \_x and \_y of the match with alpha O

this will also easily give you a match to see if the game is finished

hope this helps

---

<div class="post-metadata">

**Author:** ![rahul\_7star](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@rahul\_7star](https://forum.kirupa.com/u/rahul_7star)\
**Post date:** [June 3, 2008, 3:47pm UTC](https://forum.kirupa.com/t/stick/261815/6 "2008-06-03T15:47:56Z")

</div>

[quote=neilmmm;2335609]you need to use hitTest

draw a copy of your grid

make each mtach stick position an mc and put a reference to each stick position in an array

then alpha copy grid to 0

when moving a matchstick, on release just do a hitTest to array of alpha out matchsticks in a for loop

the sticks do not have to snap to \_x and \_y but if you want them to they can match the \_x and \_y of the match with alpha O

this will also easily give you a match to see if the game is finished

hope this helps[/quote]

well if you can post a fla then i can have some idea…right now i am not able to make it
