Actionscript 3 :: Applying Rotation Of Sprite To StartDrag()'s Rectangle Bounds

Apr 13, 2010

from my main class i call to create a sprite and add it to the stage

private function addSwatch(evt:MouseEvent):void
{
if (stage.getObjectsUnderPoint(mousePoint()).length == 0)
{

[Code]....

View 1 Replies


Similar Posts:


ActionScript 3.0 :: Get "on Stage" Bounds Rectangle Of Xyz Rotated Sprite

Dec 28, 2011

i cant get "on stage" bounds of sprite that rotated in 3d space

Code:
var draggableContent:Sprite=new Sprite();
var _3dContent:Sprite=new Sprite();
var _child3D:Sprite=new Sprite();

[Code]....

View 0 Replies

ActionScript 3.0 :: Question Regarding Startdrag() Bounds?

Nov 16, 2010

I am trying to make this an kinda interactive map in flash. I will try to explain it for better explanation. Here is an image of the output I have a jpg image(converted to movieclip) which is way larger than the stage.

[code]...

Then I have a mask in the center of the stage and user sees a portion of the map and is allowed to scroll to move mouse around to see areas around the focused city.

[code]...

I put this numbers in by playing around but where are these values exactly coming from. I have tried everything(every possible way) but cant figure out what are these values. I need to numbers to be dynamic so I can change the focus to different cities(for example when a user click A city A should be seen inside the mask and so on).How can I make these values dynamic instead of hard coding them.

View 4 Replies

ActionScript 3.0 :: Using Bounds In StartDrag If RotationX Property Is Changed?

Sep 26, 2010

I've created a flash card class in ActionScript that uses a tween to flip the card over the y-axis (i.e., by using rotationX). I also use the bounds property of startDrag so that, when you drag it, its movement is locked on the x-axis. (There's also a method for switching between dragging and flipping, but since that's not broken, there's no need to discuss it further).

Here's my problem. If I haven't yet flipped the flash card over, the card drags fine. If I flip the card over and don't use bounds in startDrag, it works fine. But if the bounds property is set and then I try and drag the flash card after it's been flipped, the movement goes all haywire. It basically jumps back and forth between the two ends of the bounds' rectangle.

Is there any way you can think of to solve this problem? Alternatively, is there any way to use sprites to limit movement? For example, would it be possible to place a pair of one-pixel-thick horizontal lines on the top and bottom side of the flash card, set their alpha to zero, and somehow stop the flash card from moving past the lines?

View 4 Replies

ActionScript 3.0 :: Flash StartDrag Setting Negative Bounds?

Dec 17, 2010

I have a large movieclip (2336 x 1752) and a stage of 800 x 600. I want to be able to drag the movieclip around the stage so no white is visible:

minimum x before I get whitespace: -1536
minimum y before I get whitespace: -1152
maximum x before I get whitespace: 0
maximum y before I get whitespace: 0

I have tried this:

Code:
var mcBounds = new Rectangle(-1536, -1152, 0, 0);
mc.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
mc.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);

[code]...

But it doesn't drag at all...when I try it just moves it to it's maximum position and stays there.Is it because the rectangle can't have negative values?

View 2 Replies

Actionscript 3 :: Scrollbar With Sprite And Rectangle Won't Move Text, Just The Rectangle It's Painted On?

Mar 8, 2010

For those of you still with me, I am tasked with making some scrollable content in Flash. Load in a TextFile using LoadURL(), then display it. To get the text, we've written our own class TextFieldExtended, which is basically just there to give the textfile location to the constructor and then have the class do the various steps of getting it and loading it for you.So I needed to get a Scrollbar, which I got hereThe thing is, it works with Sprites.After trying to get it to accept TextFieldExtended, I bumped into a block, since the scrollbar relied heavily on a Sprite property that TextFieldExtended didn't have or could have.

So I tried adding the TextFieldExtended instance to a Sprite instance using addchild.A problem occurs here that I do not know how to handle. It seems that a Rectangle is drawn and the Text is drawn on that. I say this because the scrollbar moves the Rectangle up and down a bit, but the text doesn't scroll, just the Rectangle it is positioned in and the text then moves along with it.My question: can this be fixed, or is does this implementation of scrollbars need a lot of adaptations before this is possible?

View 1 Replies

Actionscript 3.0 :: Get Bounds Of A Rectangle On Stage

Apr 30, 2009

I have a simple MC on the stage. I want to create a simple conditional statement that would check if the mouse is on the rectangle using get bounds. something like [code]Basicaly...how do I properly use the getBounds in a situation like this?

View 3 Replies

ActionScript 3.0 :: Dynamically Calculating Bounds Of A Rectangle?

Dec 15, 2010

I am creating an app that has to load a image or swf on to the stage and dynamically place and position it on either sides of the stage i.e. (top, left, bottom or right).how can I dynamically calculate the remaining bounds of the stage using the bounds of the dynamically placed loaded image/swf. ?e.g if the bounds of the loaded clip isRectangle(x=10, y=10, w=250, h=800);What is the remaining Rectangle() to use ofRectangle(0,0,1024,800); ?

e.g if the bounds of the loaded clip is
Rectangle(x=0, y=0, w=800, h=50);
What is the remaining Rectangle() to use of

[code].....

View 3 Replies

ActionScript 3.0 :: StartDrag() Constrain To Rectangle?

Oct 19, 2009

I am trying to created a constraint to a rectangle. I have the startDrag working and I am trying to constrain a square to the movie size of 600x400.I have been searching online help files but I can not for the life of me get it to work, would someone beable to put me out of my misery. I have attached the demo file I am working with but I will also post my script here for thoughs who prefer that...

Code:

("animation", false, 0, 0, 300, 300);

but know joy...

my code:

////Button Listeners/////////////

Code:

// BtnNav listeners
btnNav.addEventListener(MouseEvent.ROLL_OVER, btnNavOver);
btnNav.addEventListener(MouseEvent.ROLL_OUT, btnNavOut);
btnNav.addEventListener(MouseEvent.CLICK, btnNavDown);

[code]....

View 2 Replies

ActionScript 3.0 :: StartDrag Method With Rectangle Parameter

Jul 29, 2010

I want to drag one movie clip within specific region. For that I have created one rectangle with following
var rectangle:Rectangle = new Rectangle(52.75, 5, 100.25, 0);
Though I have given x position 52.75 ; i can drag movieclip to x position - 52.

View 9 Replies

ActionScript 3.0 :: Keeping Mouse In The Same Rectangle As The StartDrag?

Mar 25, 2009

I am noticing that if you let the mouse wonder away from the movie clip while dragging, it doesn't drop when you let go of the button. You have to click in the defined rectangle for the drag for the movie clip to drop appropriately.

How can I define my mouse movement to the same rectangle as the drag while the movie is clicked on and being dragged?

View 8 Replies

ActionScript 2.0 :: StartDrag - Constrain To A Rectangle (or Coordinates)

Jan 24, 2006

I have 9 images that are draggable on my screen - and when pressed become the top image- using the script below. I'd also like to constrain to a rectangle (or coordinates) - ideally adapting the exisiting script and movie clip set-up.

[Code]...

View 6 Replies

ActionScript 3.0 :: Using Rectangle In StartDrag Makes StopDrag Not Work

Nov 9, 2009

I have a pretty simple function here where I want to start dragging a video scrubber along the x axis within bounds, and drop it when they let go. The code works perfectly if I don't specify a bounding rectangle (except it doesn't restrict to x-axis). What's up with that? Here's my non-working code:

Code:
videoConsole.scrubber.addEventListener(MouseEvent.MOUSE_DOWN, dragScrubber);
videoConsole.scrubber.addEventListener(MouseEvent.MOUSE_UP, releaseScrubber);
private function dragScrubber(e:MouseEvent):void{

[code]....

View 1 Replies

ActionScript 3.0 :: StartDrag Breaks When Rotation Applied?

Jun 14, 2009

I have narrowed my issue to this. If you create a sprite add a square and a startDrag on press to that sprite. then add that sprite as a child to a container sprite. Create a button on the same level as the container sprite and add a mouse click listener that causes container sprite to rotate using rotationY or X. Now run it, first you will notice you can drag the square no prob. Once you hit the button and rotate your container using rotationY or X the drag does not work. Other properties such as x, y , alpha can still be set but startDrag or stopDrag. I think this is a bug as I have found several people reporting on this but not solution.

View 2 Replies

ActionScript 3.0 :: StartDrag And Bounds - User Will Be Able To Drag The Image, As Long As The Edges Of The Image Doesn't Show?

Jan 19, 2011

I have an image on the stage which is bigger than the stage itself:

The stage is 700x550

The image is 2100x1650, and it's registration point is at its center, if I remember correctly.The initial location of the image on the stage is 350,75.I want to make sure that the user will be able to drag the image, as long as the edges of the image doesn't show.here's what I did:

mapRect = new Rectangle(0-mapMC.width/2, 0-mapMC.height/2, mapMC.width, mapMC.height);

and later on:

mapMC.startDrag(false,mapRect);

The the top and the left of the image are bounded well, but as far as the bottom and the right side of the image.

View 1 Replies

Flash :: Draw A Rectangle Is Automatically Applying A Corner Radius?

Apr 23, 2010

Im probably overlooking something simple, but when I try to draw a rectangle Flash is automatically applying a corner radius.  I've tried resetting the options in the Properties Inspector, which resets to the default, but soon as a draw a shape it goes right back to a random radius. 

View 4 Replies

ActionScript 2.0 :: GetBounds() - Get A Movie Clips Coordinate Bounds And Use The Minimum And Maximum Values Of X And Y To Draw Rectangle Around The Object

Apr 11, 2007

I'm having a little difficulty getting to grips with the getBounds() Movie Clip function. I assumed the getbounds() method simply got the boundary coordinates for the movie Clip, that one could use to draw a rectangle. This is what I'm trying to do;I'm trying to get a movie clips coordinate bounds, and use the min and max values of x and y to draw rectangle around the object. Simple right? But in my case, I'm getting some unexpected results. I wonder does ther registration point of the object determine the coordinate values? Also are the coordinate values local to the clip instance or global to the stage?

[Code]...

View 5 Replies

ActionScript 3.0 :: Applying A GradientFill To An Animated Sprite?

Jul 8, 2009

I was working through some animation tutorials with plain round sprites using the following code...

Code:
package {
import flash.display.Sprite {

[code]......

View 1 Replies

Flash - Drawing Rectangle Or Resizing Sprite?

May 13, 2011

I have two options and I want to know whats faster. I have a pool of 1000 sprites objects in as3 on screen. When its needed each sprite has to resize itself. I can
1- Make each sprite a simple container to use graphics to draw a rectangle, that is, call a 'spriteInstance.graphics.' ,draw the rectangle and on each 'refresh', I do graphics.clear and redraw the rectangle but with the new size, this for each sprite.
or
2- Create each sprite with a border and on each refresh, resize it
Whats better?

View 1 Replies

ActionScript 3.0 :: Draw API - One Pixel Width Rectangle In A Sprite

Mar 21, 2011

I try draw one pixel width rectangle in a sprite. And add some tween on it to make some effect. But I find use the code below can't create exactly one pixel white rect. I created I want to create

[Code]....

View 1 Replies

Actionscript 3 :: Passing A Rectangle To Sprite.graphics.drawRect( )

Mar 5, 2011

Is there a neat minimal way of doing this? (this produces an error):

var freeSpace = shape.freeSpace() // returns Rectangle
var s:Sprite = new Sprite();
s.graphics.drawRect(freeSpace);

Just looking for a more cleaner way other than something like .drawRect(freeSpace.x, freeSpace.y, freeSpace.w, freeSpace.h) I know you can do it with bitmapData.fillRect(rectangle), but need sprites in this case.

View 1 Replies

ActionScript 3.0 :: Off-center Rotation Of A Sprite?

Aug 19, 2010

As is well demonstrated by a Google search, the rotationX, rotationY, and rotationZ properties turn a display object around the center.

That's all well and good, but I want to rotate a display object about a different point.

I can't believe there isn't a way to do this, but I don't see anything that addresses this question specifically.

View 3 Replies

Flash :: Narrow A Rectangle Within A Sprite To Exclude Transparent Pixels?

Oct 2, 2011

I have a Sprite that contains opaque objects surrounded by transparent pixels. I also have a Rectangle that represents a part of the Sprite that I want to render using BitmapData.draw(). The problem is that the Rectangle that I obtained also contains transparent parts. How can I narrow the Rectangle to only include the opaque parts and ignore the transparent surroundings?

kapep's answer is just what I want to do, but the problem is that the source is a Sprite, not a BitmapData object, and I don't have getColorBoundsRect() on a Sprite.

View 2 Replies

Actionscript 3 :: Sprite Scale - Rectangle Is Clearly Larger Than 100x100 Pixels?

Nov 4, 2011

Here's a very simple AS3 project consisting of one class which draws a rectangle. When I run it, the rectangle is clearly larger than 100x100 pixels.

Edit: I know that it isn't correct because, though I have my screen resolution set to 1280x800, if I set the width to 500 it takes up almost all of my screen.

package
{
import flash.display.Sprite;
import flash.events.Event;[code]....

View 1 Replies

ActionScript 3.0 :: Change Thickness And Color Of A Rectangle Sprite On Mouse Over

Feb 8, 2009

I am a new user. How do I can add more thickness and change color of a rectange Sprite object on mouse over and on mouse out I want to make it normal again.

View 2 Replies

Actionscript 3 :: Sprite Rotation Around Center Error

Jul 6, 2011

I found this actionscript online to rotate a sprite around its center point but I get two errors when I use it. 1084: Syntax error: expecting identifier before leftparen. 1084: Syntax error: expecting rightparen before leftbrace. Also, in place of angleDegrees do I put in the angle I want the sprite to rotate by?

var point:Point=new Point(spr_box.x+spr_box.width/2, spr_box.y+spr_box.height/2);
rotateAroundCenter(spr_box,45);
function rotateAroundCenter (ob:*, angleDegrees) {
var m:Matrix=ob.transform.matrix;
m.tx -= point.x;

[Code]...

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

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

ActionScript 3.0 :: FP9/10 Enforces A Minimum Increment Or Resolution For The Sprite Rotation Property?

Aug 18, 2009

Does anyone know if AS3 or FP9/10 enforces a minimum increment or resolution for the Sprite rotation property?It seems to only allow rotations in multiples of 0.25 degrees.For example:

var lines:Array = new Array();
for (i=0; i<2000; i++){
lines[i] = new Shape();
lines[i].graphics.lineStyle(.1, 0x000000);

[code]...

This draws the lines in groups at 0.25 degree spacing with gaps between them.

View 2 Replies

Actionscript 3 :: Finding An Original Rectangle's Dimensions From Rotation And Bounding Box Dimensions?

Jan 25, 2010

In AS3, I have a Sprite that has a Z axis rotation applied.How do I calculate that Sprite's dimensions (it's original size) from Sprite.rotationZ and Sprite.getRect(...)?

View 2 Replies







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