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.
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?
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?
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?
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?
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
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...
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.
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?
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.
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{
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.
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.
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.
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?
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?
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
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.
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.
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.
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.
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;
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!
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.
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.
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(...)?