This content has been marked as final. Show 33 replies
Please give me a solution.
You're going to have to do some math for this particular problem. In particular, you'll need to convert the coordinates of the outer-most corners into a vector (distance and angle), perform the rotation, and convert back into x/y coordinates. Then, find the difference between the x-coordinates of those corners, and there's your width.
Consult your math teacher for details of the conversion; good luck.
you can put the strawberry in side antoher MC and rotate the MC the you can get the properties of the strawberry MC.strawberry._width OR how about use variables get the values you need before the rotation
hope that makes sence
oh i get it now sorry that is not going to work
You can have some pointed mclips inside the main mclip and you could track the distance between those opposite points which have placed and tracked in proper place/mclips such that in opposite horizons. What i try to explain the solutions exactly is as "Bob Robertson " said earlier. :)
Thank you for your All your interest.
Dear "Bob Robertson" How it is possible in flash. if You know any way please Guide me.
Dear Basker. I m not using this one movieClip, I have to use Lot of clips, and they are loading dynamically. if i would like to put some pointed movieclip, i have to put it for entire outline. it is not so good....
There s a solution. Please goto this site.
They did it.(Please click on the Banner will let you to T-Shirt Designer. On that Select and Image will add it to Stage. Now you can rotate and scale it..... With the Exact boundry of the Image.
I hope there s a Common Solution, Better Solution... I need that solution.
Okay, I don't have the time to hash out the actual code, but the requirements are fairly simple:
1. Determine which corners are the outermost.
Picture a box. This is the bounding rectangle of your problematic strawberry. If you rotate it (clockwise) 0 degrees, then the top and bottom-right corners are the farthest right, and the top and bottom-left corners are the farthest left. In this situation, and when rotated 180 degrees, you don't need to do any calculations. Similarly, when the box is rotated between 0 and 90 degrees, or 180 and 270 degrees, the top-right and bottom-left corners are the outermost. When the box is rotated between 270 and 360 degrees, the bottom-right and top-left corners are the outermost. The conditional can be simplified here by using _rotation%180, which returns the remainder of dividing _rotation by 180.
2. Convert the coordinates of the relevant corners into vectors.
This step depends on which point your clips are registered at, as they will rotate around that point (I think? Could someone check me on this?). You'll have to use the pythagorean theorem (squareroot(x*x+y*y)) to get the distance of each corner from the registration point, and then find the angle of each point relative to the global axes before the rotation.
3. Make the appropriate transformations.
Just add the desired rotation factor to the angles calculated in the previous step.
4. Turn the vectors back into x-y coordinates.
cosine(theta)=adjacent/hypotenuse; the hypotenuse is the distance from the registration point in question, and theta is the angle modified in step 3. Your new x-coordinate for that point, then, is hypotenuse*cosine(theta), and the new y-coordinate for that point is hypotenuse*sine(theta).
5. Find the difference between the appropriate x-coordinates.
Subtract the lesser from the greater. You'll probably need a simple If Then Else for this one.
Alternately, if you want uber-1337ness points, you can build a matrix object and use some nifty 2D transforms.
Also, "Problematic Strawberry" would be an awesome band name.
Thank you very much For spending your valuable time to answer my question. Eventhough i am Weak in Maths, i'll try to implement your valid suggestion.
Thank you once again.
Actually, now that I think about it, basker3dartist's idea would probably be a lot easier to implement.
Just put an empty movie clip at each corner of the strawberry clip, and track their _x properties. The only even slightly difficult part then would be finding the greatest and least _x values, and finding the difference between them.
Good call, basker! I applaud your ingenuity.
But When i rotate the Strawberry the Boundry will vary. if i would like to calculate the width using method i have to put movie clips for entire strawberry outline
Dear Friends. I am Blank. I am in urgent to complete this task... Can any one please help me.....
I have completed my Project 90% this is the major one to be handled...... Please Help me
Nice question. Here's a solution. It's limited in that if you have shapes that have any concave curves then it may not catch them. You could account for that using the same principle but I'm supposed to be working not playing, so you'll have to try that for yourself! Oh, and it could be made much neater, but again, work calls...
oh yeah, and any empty spaces in your diagram will need to be filled with alpha 0 else hitTest won't work (I think)
this question was answered in another thread. why is it continuing here?
kglad that completely misses the point. Look at his demonstration image in the first post.
Of course. I am a moron. :-) Sorry kglad.
Except that that code actually works perfectly, and does in two lines what my approach would have done in about twenty-five.
Remember: test, then argue. The other way is admittedly much more fun, but tends to lead to people getting annoyed and questioners not being helped. Good call, kglad.
thank you. it's accurate as long as you can accept the original _width and _height before any transforms are applied.
so, if you want the bounds of the square_mc before it's rotated, use square_mc.getBounds(square_mc).
Mine doesn't even answer the question, now I come to think about it. I am being particularly dosy today. It is however, quite a fun little function. Hey ho. Anyone want a contiguous cross-sectional width through the center point function?
I am not looking to waste your time.
Actually my question is Wrongly understand in the previous forum After testing it i removed it from answerd one.
If i use the getbounds method i'll get unrotated MovieClip width and height always. But the rotated content's width is little bit greater than the unrotated movieClip width. So only i reposted it with a sample image. Please take a look at the reference image.
Thank you verymuch "Alec MCE" I'll Try with your code... If any one having any other answer please post it here
Actually what i am looking is
Please select one of the print image listed in the right side and do scaling and rotation....
Component functionality is done. But i am in position to position the corner movieClips (to show the boundry of the movie) to exactly fit with the content.
hi Devendran ,
Please see the attach code. you need to make "designBorder" inside "designBorder" four movieclip should be exist and put the name via property panel as delete_mc, rotate_mc, scale_mc & designCorner_mc and you need to set the centerPoint of each movieclip with little tactic.
code is wokring on my system. i've used your refrence image.
I just had a brainwave: movieclip.hitTest apparently has a shapeFlag input that determines whether a movieclip is coincident with a given target's bounding box, or the actual, visible content of the target. So, my idea is this: create a pair of invisible movie clips 2 px wide and as tall as your stage, and a third movieclip, which will control their behavior. A custom script for the controller movieclip then moves both movieclips inward, until the find the boundaries of your target movieclip. When the right one hits, stop moving it; when the left one hits, stop moving it. When they're both stopped, return the difference in their x-coordinates.
Or would that work, since an invisible movieclip has no apparent content? Experimentation is required, methinks.
But kglad did in fact answer the question, so all of our babbling is irrelevant.
There is, however an oddity, unless I am being stupid again (which is very possible)
Please don't draw a square but a randomly blobby shape, then try this, to recreate the oddity. Reason?
Oh, the oddity is obvious. I am being stupid... I'll post the fix in a mo
well, no that didn't answer the question. i gave a method for returning the un-transformed movieclip's dimensions and dev wants the transformed movieclip's dimensions.
the following function returns the the data, i believe, dev wants:
Thank you very much KGLAD,
This is what i want... I got the solution... Once again thank you very much for all my dear friends for their extreme support....
there are two issues.
one is the registration point of your empty image holder is not at the top left and the code i gave works for movieclips with their registration point at the top left. that can be remedied.
the second issue i don't have time to track right now.
I'll check it after with TOPLEFT registeration point.....
the only problem caused by your use of center registration point was caused by placing your movieclip's registration point at 0,0 on SCALING_COMPONENT_IMG's timeline. when a bitmap is created, it's always created with it upper left at 0,0. so, 3/4 of your movieclip was out of range of the bitmap.
here's code that compensates for the placement of your movieclip. however, note that if you rotate and/or scale your movieclip off-stage, no flash function can accurately determine the movieclip's bounds.
also, note that i included a function (drawRectangleF) that draws the bounding rectangle. your use of tempObj appears faulty and is unneeded. so, you may want to remove those 3 lines of code in getDimension.
Thank you very much fro your continues Support.
After week end holiday today only i reached the office. I'll Modify the code as you told... If any i'll contact you...Thank you very much.