Home Tutorials Forums Articles Blogs Movies Library Employment Press

 ActionScript.org Forums How to check For Identical MovieClips
 Register FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

 11-14-2009, 09:12 AM #1 nikhiljoshi122 मैं एक भारतीय हूँ     Join Date: May 2007 Location: delhi Posts: 111 How to check For Identical MovieClips hey All, I am working on a game in which i need to compare two movieclips for being identical. What i am doing is creating a complex shape out of some primitive shapes and then I allow the user to drag and drop some primitive shapes to recreate a similar shape. My problem is how can I calculate that the user created shape is similar to the original complex shape or not. I have already posted this once before but dun get any replies. Hope to get some help this time. nik
 11-14-2009, 07:00 PM #2 henke37 Senior Member     Join Date: Mar 2009 Location: Sweden Posts: 10,821 Check for position and angle similarities.
 11-15-2009, 03:57 AM #3 nikhiljoshi122 मैं एक भारतीय हूँ     Join Date: May 2007 Location: delhi Posts: 111 Thanks for replying But my complex shape is made of primitive shapes like circle ,square etc by randomly rotating and scaling them. Its kind of an organic shape How could I check another movieclip with my complex shape if it is identical or not.
 11-15-2009, 09:36 AM #4 henke37 Senior Member     Join Date: Mar 2009 Location: Sweden Posts: 10,821 You check each part seperatly.
 11-16-2009, 12:00 PM #5 nikhiljoshi122 मैं एक भारतीय हूँ     Join Date: May 2007 Location: delhi Posts: 111 I think I am not able to clarify my doubt Actually My complex shape is similar to underlying image now if i allow a user to draw a similar shape with pencil tool with high thickness. How can I measure is the two shapes are similar and if not then ant way of calculating the percentage similarity between two of them.
 11-16-2009, 12:20 PM #6 box86rowh FLEX AND FLASH ARE COOL   Join Date: Oct 2005 Posts: 794 you could flop one on top of the other and then go through pixel by picel to see how many share the same surface area, then return them back to position
11-16-2009, 12:41 PM   #7
magicTuscan
Registered User

Join Date: Nov 2009
Posts: 46

Quote:
 Originally Posted by nikhiljoshi122 I think I am not able to clarify my doubt Actually My complex shape is similar to underlying image now if i allow a user to draw a similar shape with pencil tool with high thickness. How can I measure is the two shapes are similar and if not then ant way of calculating the percentage similarity between two of them.
Easy:
Just store for every individual obj (movieClip) properties into an object array.
For example that blob you have.

ActionScript Code:
```private var _objectProps : Object = [];

var userBlobProps:Object = {
"_width":userBlobs.width,
"_height":userBlobs.height,
"_color":userBlobs.color,
"_rotation":userBlobs.rotation,
"_scaleX":userBlobs.scaleX,
"_scaleY":userBlobs.scaleY
}
_objectProps.push(userBlobProps );
}```

So imagine am a user and i provided my name as magicTuscan, and I have created a new blob...via below

ActionScript Code:
```private function newBlob() : void {
var thisBlobCreatedByUser: MovieClip = new UserBlob() as MovieClip;
//code to draw and add blob to stage here

//after all is done- now attach blob props to array & then you can compare later on!!!

}

private function compareBlobs() : void {
}```

 11-16-2009, 02:36 PM #8 -Ev- Senior Member   Join Date: Aug 2008 Location: Boston, MA Posts: 241 When you're ready to compare the two drawings, you can use the BitmapData class to compare them. 1. Use BitmapData.draw() to draw both clips into BitmapData objects with the same dimensions. 2. Use the BitmapData.compare() method, which will return a NEW BitmapData object, in which the pixel RRGGBB values are the DIFFERENCE between the compared bitmaps. If two pixels in the compared bitmaps were identical, the resulting BitmapData will have a black pixel at that (x, y) coordinate. 3. Use the BitmapData.threshold() method to check if every pixel is greater than 0x00000000. It doesn't matter what color you change the pixels to, since this is a disposable BitmapData object. The key to this step is that the method returns the number of pixels that were changed. 4. Divide the number of changed pixels by the total pixels of your bitmap objects (width x height), and that will give you the exact percentage difference between the two drawings. __________________ Tweet Tweet
 11-17-2009, 01:44 AM #9 nikhiljoshi122 मैं एक भारतीय हूँ     Join Date: May 2007 Location: delhi Posts: 111 Hey Ev thanx a ton I was was looking for a solution like this only. great. nik

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home ActionScript Forums Group     ActionScript 3.0     ActionScript 2.0     ActionScript 1.0 (and below)     Simple Stuff (Newbies) Flash General Questions     Flash 10 General Questions     Flash 9 General Questions     Flash 8 General Questions     Other Flash General Questions Flex     Flex 2, 3 & 4     Flex 1 Extensions and Plugins     Components     JSFL - Extending Flash Desktop, Mobile and non-browser Environments     AIR (Apollo)     FlashLite / Portable Devices Development     Projectors and CDs Supporting Technologies     HTML and JavaScript     haXe     Server-Side Scripting     Flash Remoting     Flash Media Server General     Best Practices     Gaming and Game Development     Animation and Effects     Flashants Support Forum Community Boards     General Chat     Just for Kicks Challenges     Detention Flash In Action     Site Check     Cool Sites     Widgets Decommissioned     Projects and Positions CMS Forums     Announcements Board     Content Postings / Updates     Product Review Requests     CMS Technical Questions     Process Questions     Collaboration & Suggested Articles

All times are GMT. The time now is 10:05 AM.

///