Flex :: Converting Sprite To Bitmapdata With A Different Registration Point And Rotation

May 22, 2011

I'm trying to convert a Sprite that I have into BitmapData so I can perform some collision detection. There are a few things about the way the Sprites are used that is making this more difficult than I expected:

The Sprite itself is a container which holds another Sprite that actually has a box drawn in it. The inner Sprite is positioned negative half its width & height so that it can be rotated from the center via the container. The container may be rotated at any angle at any given time

So my approach thus far has been attempting to draw the outer Sprite onto a new BitmapData object with a Matrix to account for the difference. Whilst I can use a Matrix to make this work for one particular rotation angle, I cannot find a way to make it work for any rotation.

Here's what I'm doing to draw onto the new BitmapData:

var p:Product = getProduct(); // Product is the container with the inner sprite
var bounds:Rectangle = p.getBounds(stage);
var bd:BitmapData = new BitmapData(bounds.width, bounds.height, true, 0x00FFFFFF);

[Code]....

Translating by the same amount as the previous example will no longer work here, and the box will still be cut off. I've looked around at some solutions posted before or suggestions from other people but they don't seem to work for me due to my container Sprite and rotation.

View 1 Replies


Similar Posts:


Flash :: Change 3D Registration Point For Rotation In AS3

Apr 18, 2011

Has anyone got a bit of code I can use to change the center point DisplayObjects rotate around in a 3D space? I need it to work with rotationX, rotationY and rotationZ. I know theres a workaround of wrapping every object in aother sprite and offsetting the x & y positions but I'd much prefer a math solution. As an example of the problem, this code should make a star shape:

[Code]...

View 1 Replies

ActionScript 2.0 :: Rotation Around Simulated Registration Point?

Oct 31, 2003

I want to have arm movement such as the forearm rotating about the arm where the elbow should be the problem is the registration point is at the shoulder for arm. I want the forearms registration to be constantly equal to a simulated registration point where the elbow should be as the arms registration point would be at the shoulder. I need to do it without nesting (a movieclip within another) is it possible. I tried using a constant distant between the two clips but it doesn't work. Don't know I have to use trigonometry or not

I think in brief what I trying to accomplish is
onEnterFrame=function(){
arm._x=shoulder._x
arm._y=shoulder._y
arm._x=simulated_x (where elbow would be)
arm._y=simulated_y (where elbow would be)
}

View 7 Replies

Actionscript 3 :: Change The Registration Point When Using Bitmapdata.draw?

Dec 5, 2011

I have a movieclip on stage that I draw into a bitmap, how do I change the registration point, the code below produces bitmap with half chopped off:

var bitmapData:BitmapData = new BitmapData(mc.width, mc.height, true, 0x00FFFFFF);
var matrix:Matrix = new Matrix();
matrix.translate(0, -mc.height/2);

[Code].....

View 1 Replies

ActionScript 3.0 :: Pan Sprite Which Changes Its Size And Registration Point?

Apr 26, 2009

i am succesfully panning an image so far with this code:

Code:
my_mc.addEventListener(Event.ENTER_FRAME, panMe);
function panMe(e:Event):void {

[code]....

View 10 Replies

Actionscript 3.0 :: Sprite Instance Registration Point At Runtime?

Aug 30, 2009

I've looked over many forums and pages to sadly learn that you can not reset/change the registration point of a movieclip dynamically. Though I am curious if or how I could go about assigning the registration point to a sprite instance I create at runtime. To give you a more concrete example of what I'm doing:

I create an instance contentWindow in my code to be animated (a 300px by 200px rect with registration in the top left corner)I create a Sprite instance imageHolder in my code and add it as a child to contentWindow I then add various images to imageHolder through a Loader object referencing an XML file. imageHolder's top left corner is oriented to contentWindow's registration point. (Leaving me with an oddly oriented imageHolder if the contentWindow's registration is centered, and will only re-size from that origin) Since imageHolder will be switching out various sized images it would be much more aesthetic to have the sprite's registration point centered. So since as3 defaults it to top left shouldn't there be a way to alter it at instantiation of the sprite? Then I could set my contentWindow's registration to center and the empty sprite would center all content loaded into it?

View 1 Replies

ActionScript 3.0 :: Change The Rotation Point Of A Sprite?

Feb 4, 2008

I'm attempting to write a racing game. I've loaded in my image, I brought it to the stage and now, all I want to do is rotate it from its' center and not upper left corner.

The code:

racer.rotation += 5;

rotates from the upper left corner. How do I rotate from the center of the car/sprite? I've tried putting it into a container but I'm unsure on the coordinates of the container because I tried to set the x,y coordinates to half the sprite image but y'know, it's not doing what I expect it to.

ActionScript Code:
if (arrowLeft) {
var container:Sprite = new Sprite();

[Code]....

I will never sneer at another racing game! I didn't think it would be this hard to do a simple rotate of an image!

View 3 Replies

Flash :: Converting A SVG Image Into Bitmapdata In Flex 4

Oct 25, 2011

I am working on a flex project, where I have to load a couple of SVG files and compare their pixels. To compare the pixels, I like to convert them into a byte array (BitMapData). I am able to create a bitmap data for a PNG image, but not for a SVG image.

View 1 Replies

Flex :: Changing Registration Point From Upper Left Corner To Center?

Mar 31, 2011

I want to learn how you can change the registration point for the Canvas.I want to make a zoom of this component, but the point registration in the upper left corner! How do I move to the center?

View 3 Replies

Flex :: Changing Registration Point From Upper Left Corner To Center

Mar 31, 2011

I want to learn how you can change the registration point for the Canvas. I want to make a zoom of this component, but the point registration in the upper left corner! How do I move to the center?

View 3 Replies

Flex :: EOF Error Encountered While Converting Bytearray To Bitmapdata

Mar 18, 2010

I am using [code]...

In the 4th line in the code above i am getting "Error: Error #2030: End of file was encountered." I checked the length of the pixels object which is 4 times the width*height of the rect object. Given that setPixels() functions reads unsigned int from bytearray and sets that value to pixels, I think it should work.

But I have no clue why this wont work. The pixels object is filled after RLE decoding of the data which i get from a server.

Is there any work around or any other method which I could try to use. The loader class wont work as the data that I get from the server is not in any of the recognized format.

View 2 Replies

Flex :: Draw Sprite Into Bitmapdata With A Strange Mask

Apr 14, 2009

I have run into strange behavior drawing a sprite into a BitmapData. This sprite looks fine when drawn directly to the screen. But when this sprite is drawn into a BitmapData, the sprite is being masked... but there is no such mask applied to that sprite! This "bad mask" can be toggled off and on... by applying / not-applying a different mask to the sprite I am drawing. This mask is not the same shape or location as the "bad mask".

[Code]...

View 1 Replies

Flex :: How To Know If Point Belong To Sprite

Mar 8, 2012

How can I know if a point is contained inside of an Sprite in Flex?

For example:
// My example point
var A:Point = new Point(5,5);
// My example sprite
var s:Sprite = new Sprite();
s.graphics.lineStyle(1,0x000000,1);
s.graphics.moveTo(0,0);
s.graphics.lineTo(100,100);

The point A belong to sprite s because its position is inside of it. Is there any function to know it? I want to do it for all kind of sprites, so use math formulas to calculate linear or quadratic equations (line, circle, rectangle, etc) is not valid for me.

View 1 Replies

Flex :: BitmapData - Scaling Always Taking Place On Previous Point

Feb 1, 2010

I am working on an application that will allow a user to scale an image. The issue that I am having with the method below is that the scaling is always taking place on the previous scale point. For example: If I scale the image up one and then scale the image down one. I have to scale down twice to get it back to the point I want it to be.

Here is my current code:
private var sourceBMD:BitmapData = testImage.source as BitmapData
private var matrixScaleX:Number = 1;
private var matrixScaleY:Number = 1;
private var baseScaleX:Number = .05;
private var baseScaleY:Number = .05;
[Code] .....

View 1 Replies

Actionscript 3 :: Moving A Point With Rotation Doesn't Change The Point XY?

Jul 15, 2011

i have the follow issue :

I have a point which is setted at the border on a component, with changed transform point to the center of a component in order to match the component rotation.

the important part is when i try to get the point XY after rotation - they remains the same as before rotation.

how to get XY, after rotation ( changeing point.rotation property to specific degrees of rotaion )

View 2 Replies

ActionScript 3.0 :: Rotation Around Center With Registration In Top Left

Jun 20, 2011

I coded an entire file based on the top left registration point of my movie clip. I want it rotate it to point at the cursor, but since the registration point isn't in the middle.. its not a perfect rotation around the center of the mc. Is there anyway to rotate it around the center of the movie clip without changing the registration point?

ActionScript Code:
stage.addEventListener(Event.ENTER_FRAME, aimBall, false, 0, true);
function aimBall(event:Event):void {
ball_mc.rotation = getAngle(ball_mc.x, ball_mc.y, mouseX, mouseY) -90;
trace(ball_mc.rotation);
} function getAngle(x1:Number, y1:Number, x2:Number, y2:Number):Number {
var radians:Number = Math.atan2(y1-y2, x1-x2);
return rad2deg(radians);
} function rad2deg(rad:Number):Number {
return rad * (180/Math.PI);
}

View 9 Replies

ActionScript 3.0 :: How To Set Registration Point

Feb 8, 2010

There is not setRegistration point method. So, how to set registration poing in AS3. Do any body know about it ??

View 3 Replies

IDE :: Registration Point = X,Y Coordinates?

Jan 1, 2010

Flash uses a movie clip's REGISTRATION POINT to determine the MC's X and Y coordinates, correct? If not, what is used?

View 4 Replies

ActionScript 2.0 :: Set The Registration Point Of A Mc?

Sep 9, 2005

can you set the registration point of a mc with as? I need to do this for a whole bunch of loader components, which are by default set to TL. I need CC.

View 3 Replies

Professional :: Change The Registration Point

Mar 20, 2008

I have a movie clip on my stage with various elements in it. When I edit this movie clip all the coordinates for the various elements have really random values because the registration point is not set to the top left corner of the symbol but I can't find any way to change the registration point - nothing I've found online so far works.

View 3 Replies

ActionScript 1/2 :: Repositioning The Registration Point?

Apr 20, 2009

I want to load a series .jpgs into an existing mcs. The mcs are 75 x 75 pix and the .jpgs are 50 x 50 pix. The problem is that I made the mcs with the registration point at the top left corner. This causes the mcs to load in at that point so that the margine between the .jpg and the mc is uneven. How can I change the registration point of each mc so that the CENTER of the .jpg is positioned the CENTER of the mc?

View 3 Replies

ActionScript 3.0 :: Set The Registration Point Of An Object?

Jul 23, 2009

using action script how can I set the registration point of an object. Also what import would I use.

View 1 Replies

ActionScript 3.0 :: Changing The Registration Point?

Jun 8, 2008

it posseple to change the Registration point via AS3 ?

View 11 Replies

Change Registration Point Of Uiloader?

Feb 3, 2010

How can i change registration point of uiloader?

because that loader loads images which needs to be zoomed for productional purposes, but it does not zoom the center, it zooms through to reg point.

View 5 Replies

Professional :: Change Registration Point XY?

Jul 5, 2011

how?

View 1 Replies

ActionScript 3.0 :: Setting The Registration Point?

Sep 25, 2007

How do you change the registration point of a TextField or MovieClip?Suppose you want to Twin a zoom in, I need it to happen from the middle, but I found no methods or properties that let you set it in the center.

View 9 Replies

ActionScript 3.0 :: Read The Registration Point?

Sep 15, 2009

is it possible to find out where a movieclip registration point is in comparison to the stage?for example its in the bottom left or top right...

View 2 Replies

ActionScript 2.0 :: Manually Set Mc Registration Point

Apr 19, 2006

I'm importing an image that I'll use as my pointer(arrow) in a speedometer. My problem is that I need to manually set the movieClip's registration point so that I'll get the rotation right. If I manually drag the image on stage and use F8 to convert it to a MovieClip, I can set the registration point in the dialog box popping up. The only thing I'm trying to do is just that, but with ActionScript since I create this thingie dynamically

View 3 Replies

ActionScript 2.0 :: MovieClipLoader +registration Point ?

May 9, 2008

I've got quite a few images that are being loaded into my project through the MovieClipLoader function, anyway, when they are loaded to a specific MovieClip, their registration point is set to the top left corner (0, 0).Is there any way of adjusting the registration point for this MovieClip? Or would I have to something like the following:

Code:
var pL:MovieClipLoader = new MovieClipLoader();
// loader[code]......

I don't know if the above is even possible, but thats what I'd guess, if there is no way of setting the registration point in a easier way. I feel that the above is such a waste.

View 2 Replies

IDE :: Registration Point Always Upper Left?

Mar 18, 2009

Do you usually set the registration point in the upper-left corner ?I usually have always troubles with the registration point in the center.. or is maybe useful in any situation ?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved