Ill be honest, 10 minutes ago, I sat amongst the thousands of young Actionscripters who long to understand the way the well-known, but not so well understood getBounds function truly works. Some may disagree, but the function in itself isnt as clear as it seems, and unfortunately, there are little if any good tutorials out there that fully explain it. That is why I am writing this tutorial. Hopefully I can finally clear up the confusion for hundreds of Actionscripters. To begin, lets try and understand what getBounds means. Normally, this function is used with the function hitTest, which detects whether 2 objects or 1 object and a point collide. Now supposing you had a rectangular wall, and a square. Now you wanted to make sure that when the square hit the left end of the wall, it would stop moving, and the same would work on every side of the wall. The problem with this is that hitTest only checks for the entire space the movieclip occupies, and not the coordinates of each edge. On the contrary, using getBounds will do this for you. You may not understand this yet, but you will soon.
|» Level Intermediate|
Rating: 9 Votes: 13
|I have a passion for Actionscript.|
|Download the files used in this tutorial.|
|Download (0 kb)|
|More help? Search our boards for quick answers!|