I have a blog post that has this mechanic although set up for arrays -
Also this post by
will help you understand the concept behind bitwise numbers for tiling.
I also made some really heavy changes to you capx to show you how it can be done in your example. Using this method though might cause problems when there are lot's of tiles on screen. Either changing to the array method or only checking tiles near to the newly added tile would help. But It'll give you a starting point.