Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Creating A Non-rectangular Bounding Box



Hey there,

I'm making an RPG game in Flash 5, which involves using the mouse to click in a space, and then a character moves towards it. However, when I do this, the character can move anywhere and therefore ends up walking up the walls. I've tried using If (this._y >= num), but because the border between the floor and the walls is not perfectly horizontal, this doesn't work. I've also tried creating a movieclip with the same shape as the floor, and using a If (this.hitTest(_root.boundBox)) command, but that doesn't work either because it counts the bounds of the MC to be rectangular too.

Any ideas how I can fix this?

Thanks a lot,

Matt



FlashKit > Flash Help > Flash ActionScript
Posted on: 03-27-2005, 11:49 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Creating Movie Clips With Non Rectangular HitTests Help Please
Hey im trying to make a game engine where you can angle up slopes. To do this im trying to do a do collision detection on two points of my object to see if i can rotate the object according to the slope of the ground. But one thing is really screwing me up. My ground is a simple black line with another line running out of it for a jump (as will be shown if i can include the fla). Right now i have it so i can go up the slope, but without rotating to fit the angle. Since the ground has a line coming up from it it makes the movie clip hitTest area into a big square. Is there any way of making the movie clip's hitTest area not in a square but tight to the drawing?

Non Rectangular Hittest
i had this before on my other laptop, but it broke so i need the code again.


how do you make a circle with the instance name of "character" move using the arrow keys?


then how do i make it able to go through a maze that i drew?
i imported the maze onto my computer and deleted the inside so it's only the walls left to be the fill. how do i make it so that the ball cant go through the walls?

any help is very appreciated







:]

Do Symbols Have To Be Rectangular?
im in another corner. i took on this job, and the woman absolutely must have a carousel. ive put this in using classes in pretty much the "standard" way (in other words, coded like you see everywhere). designwise, i have a logo mc with a registration point in the center. this registration point is also the central point for my carousel radius. everything actually works fine, but the problem comes in here: the logo is a circular "pearl", surrounded by six pearls (the carousel part) which are identical to the central pearl. what i believe is that since the circular pearls are actually rectangular in nature (they are png24s, with everything outside the circle having an alpha of 0), and the radius of the carousel must be relatively small, my ROLL_OVER, ROLL_OUT events are being disturbed (because the item symbols overlap. have tried it out with a larger radius and everything works fine. check the image for a visual explanation). ive tried just about everything i can think of, or read about, drawing a Shape as a hit area, using a bitmap fill for the shape, etc etc etc, but i suspect that this is a case where the design just will not work with the code. is anybody here crazy enough to throw out some ideas?gtal.jpg (7.15 KiB) Viewed 128 times

Rectangular Shaped Gradient
serious design flaw in flash? no solution or am i just not seeing the solution (piece of lateral solutioning perhaps?).

i need to make a rectangle with blurred edges. you can create a radial gradient, but the linier is limited to just left to right etc, as opposed to a rectangular shape.

has anywone come across this problem, and did they find a solution to it?

thx
b

MSN Butterfly Animation (non-rectangular Pop-ups)
when MSN redid their page recently i noticed a little butterly would fly around and land on the page and become stationary as part of that page. i'm pretty sure it was flash. i'm quite new to flash so let me describe what i'm trying to do.

I want a pop-up that is NOT rectangular and doesn't have navigation buttons or the maximize/minimize/close in the top right corner (kind of like MSN's butterfly animation-NOT A WINDOW). Eventually i wanna change the opacity (alpha) of this pop-up so you can see any windows/desktop below. I hope im making sense here. any help is GREATLY appreciated.... THANKS!

HitTesting For Non Rectangular Objects
i am doing a hitTest and i need to hit test for a object which is not a circle
, i have done the original testing but the ball hitTests the objects around the recatngulat area:

----------------
| -- |
| - - - |
| - - - - |
|----------------

the dots in the rectangle is my object whihc i want to hittest for and the ractangle is the hitTest area, so if the the object i am hitTesting for hts the ractangle, it hit tes is true, all i want is the hittest to be insode the bits in ractangle

Non-rectangular Movieclip Boundries
Ok so I understand how getBounds works. It gives me the maximum and minimum x coordinates and maximum and minimum y coordinates.

The problem is that I am trying to place an apple movieclip on at tree movieclip. The tree, however, is not a rectangle and has a very organic shape to it. Is there any way to randomly place my apple movieclip inside of the tree shape rather than inside the rectangular bounding box?

I couldn't really find the answer inside the forums, but if this issue has already been addressed please let me know where I can find the thread. Thanks!

Rectangular Collision Detection
Hi,

I'm tryin to do a minigolf game in flash, but i'm having some problems when i use rectangular obstacles. Squares work fine, but i need some rects too. The problem is i need to know the correct side, so the ball should go to the right direction..

tried many things, all of theme were really buggy

any help plz?

Balls In A Non-rectangular Container
As part of my first flash project (a movie in Jib-Jab style), I need balls to bounce around inside of a container (a vector object). Is there anyway to set the balls to bounce around inside of this non-regular shape instead of the standard frame/rectangle?

I found a tutorial on how to program a bunch of balls (with encapsulated code) to bounce around inside of the frame:

http://director-online.com/buildArticle.php?id=974

however, I have been unable to find anything on this form or through google on how to have them bounce off of a container's wall instead.

Thanks so much!
Doug

[AS3]Using A Non Rectangular Drag Boundary.
How would you do it?
To clarify ...
When you call startDrag on a Sprite/MovieClip/whatever, you can specify a rectangle which the object in question will stay within.

Eg... startDrag(false, rect1);
where rect1 is of type :Rectangle

My question is; does anyone have any idea how you would go about constraining the dragging to an arbitrary shape, say a triangle or a circle rather than a rectangle?

I figure I could just have a Timer calling a function to check the whole time but that doesn't seem particularly nice.

Anyway, thanks in advance.

Hittest And Non-rectangular Shapes..
Hi,

First, it is a rectangle. But its a rectangle at an angle. I have a rectangular MC with a hitTest, when its positioned straight it works fine but i have a rotate option on the MC and once the user has rotated the MC (for example 45 degrees) the hitTest fires anywhere within the MCs outer limits and not strictly within its shape.

Is there a way around this??

Thanks,

Steven.

Collision Detection Of Non Rectangular Bodies
Dear Friends,
I would like to get more info on how to detect collisions between non rectangular bodies. {eg.. two balls colliding, or a ball colliding with a U shaped body )

thnx in advance

Pramod

How To Make A Simple Rounded Rectangular Box
Hi,

How can I make a rectangular box with rounded corners in Flash. I drew a box and selected rounded from the properties cap; however, nothing gets changed.

am I missing something?

Any help will be very much appreciated.
E

[F8] Random Movement In A Non-rectangular Boundary
I want a movie clip to randomly appear with a non-rectangular boundary. I've got random position changes within in a rectangular boundary working fine. Ideally i'd like to be able to draw a shape and use that as the boundary for the position changes.

Any ideas

[MX04] Hittesting Non-rectangular Objects?
[Flash MX 2004]
[AS 2.0]
Is there a (hopefully simple) way to do a hitTest on, say a triangle? That is, I want to check the shape itself, not the bounding box.

How To Programmatically Create A Rectangular Mask
Could someone post a simple example of how to programmatically create a
rectangular mask of size x by y? I need this to be 100% ActionScript. Thank
you!!

Morphing Between Rectangular And Polar Coordinates?
I'm a Java developer moving over to Flex/Flash for a new project. I have a crazy idea and I have no idea how to make it work, but this seems to be the forum to ask: I'm designing a custom data visualization component, and I want to be able to tween the data it renders between a polar-coordinate representation (a ring, basically) and a rectangular-coordinate representation (traditional line-graph). It's not enough to render the data two different ways -- I want to actually animate it between modes.

The best approach I can come up with is to generate an object that contains the data-points and maps them to points on a shape via some equation like..

renderX = (multiplier)*rectX + (1-multiplier) * polarToRectX

and so forth, where multiplier is between zero and one and polarToRectX is the rectangular representation of the polar point (with an appropriately-positioned center and radius.. in theory this could work for bezier handles too, I think?

Is there a better way to do this that involves less complexity, by any chance?

How To Programmatically Create A Rectangular Mask
Could someone post a simple example of how to programmatically create a
rectangular mask of size x by y? I need this to be 100% ActionScript. Thank
you!!

Rectangular Inserted Shining Diamonds
Happy New year to ALL MY FAVORITE READERS !!!!


I have a rectangular (50*100) piece of inserted diamonds (no unfortunetly not real, this is real only inside flash...) and I'm trying to find a solution to how to make my diamonds shining randomly ???

Thank you for your time.

Transform A Rectangular Image Into A Trapezoid
Hi i want to transform an image from a regular rectangle to a trapezium (almost like a flat topped triangle). Is that possible with actionscript?

Random Movement In A Non-rectangular Boundary
I want a movie clip to randomly appear with a non-rectangular boundary. I've got random position changes within in a rectangular boundary working fine. Ideally i'd like to be able to draw a shape and use that as the boundary for the position changes.

Any ideas (i'm using flash 8)

Not Rectangular Mouse Sensible Zone With Mask
I have a containerSprite
that contains two other DisplayObjects
- maskedSprite (contains dynamically Loaded Bitmap)
- maskingBitmap (dynamically Loaded)

Masking works fine
but I'd like to have the masked content
to respond to mouse events
only in the actually visible area...
instead
mouse events trigger in all the rectangular area
having the maskingBitmap dimensions...

Am I missing something really simple here?
Shouldn't the mask automagically shield masked zone from mouse events?

- Tried attaching eventsListeners to maskedSprite directly.
- Tried creating a maskedSpriteChild and attached events to it.
- Tried making maskingParentSprite containing dynamically loaded bitmap
cause (as suggested in another message) I was trying to assign false
value to mouseEnabled property to masking object, but this as a bitmap
obviously complains...


Recall having done something similar in old swfs
but don't really remember how it was and don't really get
how to do it now.

Any help and suggestion
greatly appreciated

thanks
Jo

Bringing Images From Photoshop Without Rectangular Outline
I'm trying to do shape tweening with shapes brought in from photoshop. The problem is, even if I erase the area around the shape in photoshop, it still comes into flash with a rectangular outline. I've tried it with jpegs and transparent png's. Perhaps I need to do something with the image once in flash.
any ideas?

Change Rectangular Constraints Dynamically When Dragging?
Hi,
I have a draggable movie clip. It is something being dragged out of a test tube and over to a piece of paper. While it is still being dragged "within" the test tube, I would like for the rectangular constraints to be very narrow so it looks like you can't drag it through the side of the test tube but you have to drag it to the opening at the top of the tube.
Once you drag it beyond the top of the tube, I would like for the user to be able to drag the object around more freely, i.e. I need a bigger constraint rectangle.

Has anybody tried this before?

If I use a variable for each of the four constraints, will it recognize a change in the variables and change the rectangle accordingly, or does it only go by the values the constraints are set to initially, when first calling "startDrag"?

Rectangular Collision Detection On A Tiling System
As the title says I have a grided tiling system where each tile can be assigned a collidable property. If this property is true then objects may not pass through the specified tile. Now as objects move through the environment their collision area is represented as a rectangle of variable size. This rectangle is able to rotate and move forwards and backwards along the rotation axis.

Now what I'm wondering is: Given every tiles position and all points on the rectanglular object how can you find out which tiles are being intersected by the object? (Keep in mind I want as little overhead as possible)

Thanks,
Blank_101

Need To Make A Rectangular Box With Rounded Edges Dynamically...
Now I've trired making a box dynamically using "lineTo" which works, but I've noticed that it makes the outer line look like it has a rounded edge, however the fill color looks like a square. I'm wanting a rectangular box, with a nice thick border that's got rounded edges along with the fill that's rounded also.

Would / Could I used the "curverTo" method to do and if so how/where do I start. I'm kind of at a loss right now...

Passing Variablr Within Keyframes & HITTEST For A Non Rectangular Shape?
i am making a small game in flash.I am facing some probs.(atleast for now).
1. how to move a variable from one key frame to another on main time line.(this is the total score ,which is being generated on the first scene of the main timeline, i want to show this in the second keyframe i.e, the end of the game.)?
2.I have a plane and a enemy fighter.I blast these planes whenever they collide(through hit test).But the ptoblem is the MC is in rectangular shape, but the plane is not exactly in a rectanglur shape and blast even when the plane shape has not actually touched the another enemy plane MC.How do i get the HIT TEST for the exact shape of the plane and not the whole rectangle?

Why Can I Not Animate Rectangular Image To Move Left Side To Right?
Hello
I have a rectangle and i want to animate it so that the left side is moved right until the middle of the rectangle. It seems to only want to animate it so that the left side moves right and the right side moves left, at the same time

even if i drag the white dot in the middle of the rectangle, then it correctly lets me drag the left side into the centre, but when i add the motion tween it just ruins the animated so do a shrinking into itself affect

how can i achieve this?

Bounding Box
Hi Flash Gurus,

When I have put a Flash element on a html page, opening it in a browser brings up the bounding box when you hover over it. Is this due entirely to the browser settings or is there anything one can do about it? (I assume it would go if the whole page were Flash and not just the movie though it will mean the animation can't be centred on all screen sizes as one can on an html page).

Thanks in advance.

AB

Bounding Box?
I am trying to make a math interactive program where students are given a ten by ten array of cubes and they are suppose to click on a certain percent of boxes. Anyway, I am finding it very difficult to write a script that allows the user to click, hold the mouse and drag, and then release to select more than one cube at a time. Any suggestions on how to get a bounding box or a select area?

Also is there a way to draw a thin rectangle as you click and drag to see what you will be selecting?



Sorry to ask, just couldn't find anything similiar online.

Bounding Box...
Hi there ,
I'm trying to print out a form which, but i can't get it working. It prints 140 pages..... I just don't seem to understand the how the bounding box works in the different print functions. Is there anyone that has a FLA in which i can take a peek please?

Thanx in advance.
Erik

Bounding Box Anyone?
Hi guys, i know that this sounds like a bit of a n00bish question but can anyone help?
I am trying to create a bounding box that objects that can be constrained to / in. I have tried using constrainTo(); but that only works in as1.0, does anyone know the as 2.0 equivalent is?

Kind regards

Juan Pablo.

Bounding Rectangle
I don't know how to make a bounding rectangle when I set an object to drag, so that it ... wait I'm being too explicit. You get the drift.
T

Thanks to anyone that reads/responds in advance.

Detecting Bounding Box
Having trouble with the hitTest method, I assume the boolean value in the brackets is to detect the bounding box of a movieclip, but I don't appear to be doing so. Anyone know why and what I can do?

Using this code, i.e. when my movieclip hits the object collide, it effectively bounces back, but it still moves over the bounding box first.

if (_root.collide.hitTest(_x, _y, true)) {
speed *= -.6;
}

How To Print From A Bounding Box
My movie contains only a single frame. I have a print button on stage and wants it to print an area of the stage only. How do i do that? I know i need to draw a bounding box where do i get it?

Thx for helping~

Cliplet Bounding Box
So... if my movie cliplet's center point (the little crosshair thingy?) is some arbitrary point with respect to the general movie cliplet, is there still a way to determine if I've clicked inside that movie cliplet's bounding box?

I can't use onPress (complicated reasoning)... so I have to actually figure this out relative to the x,y coordinate and height/width. Although if there's another variable I don't know about, I'll be glad to use that instead =)

Thanks!
~kirason

Help With A None Bounding Box HitTest...
I am trying to do a hitTest that checks against the object and not the bounding box. I have an object called land, and a character. This is the code on the character that checks for the object

code: if (!_root.land.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed = 0;
}



all this does is stops the character from moving when it hits the "land" but i need it to be able to walk away again...ive tried a number of things but they either have no effect or make it worse.

Can anybody fix this for me or help me out please?"

Cheers,
Var.

Bounding Box? Printing? Uh-uh
Check this coloring page: http://www.vexing.org/color/

When I try to print, it wants to print the whole stage, even an object offstage.

PRINT button code is:
"on (release) {
// send a simple print instruction
print(_root,"bmovie");
}"

A shape is on its own frame that I want as the bounding box. That frame is labeled "#b".

Source file here: ftp://vexing.org/pub/color/

Where did I drive off the bridge?

Thanks,
-P

Bounding Box For Images
Is it possible to alter how Flash sees a particular image's bounding box?

For example, I want to have an image used as a button, but I do not want the entire image to be enabled as a button grab, only the opaque areas (the image has a transparency, and I don't want the transparency to be grabbed).

HitTest() Without Bounding Box
i'm just learning hit tests, but it's driving me crazy. is there anyway to use the actual shape of the movie clip instead of the bounding box?
----
thanks,
jason

How Do I Get A Clip's Bounding Box?
This might be a really lame question, but...

I'm trying to get the bounding box of a movie clip so I can put it, sized and centered, in a box. The catch is that I don't know in advance whether the clip's content is centered.

So for a given clip MC, I have my _width and _height, but I don't see how to get "top" and "left" -- since _x and _y only tell me where the clip's center point is, without any particular relation to the clip's content.

If I know in advance where the clip's center point is relative to its content, this is easy. But I don't know that, since I don't have any control over the creation of the clip itself.

I have a feeling I'm missing something really, really obvious here. Any help in ending my ignorance is appreciated. :-)

Bounding Box Around Swf Elements In IE
Hi!

When using Internet Explorer as a browser and when rolling over .swf contents on the page I need to click the bounding box prior to making my choice: Before I can make my choice it seems I need to first activate the flash element by a mouse press which gives the user an annoying experience.

Check out the menu at;

http://www.vokteren.no/forum/index.php

and you will understand (with Internet Explorer!).

This is a problem only in Internet Explorer (I use v6.0), not in Opera or Firefox.

How can I go around this? I use Flash MX.

Any help appreciated!

Print: Bounding Box?
i'm trying to create a printable area in my movie using the Print Action in conjuction with the "#p" and "#b" labels, and the various options (movie, max, frame) in the actions panel.
there's a graphic on frame 1. - frame label "#p" (w/out quotes), stop action

frame 10 label is "#b" and this frame contains a filled box to define the printable area.

and a button to print (i tried 'max', 'frame' and 'movie')

everything on the stage is printing. am i missing something here? the documentation in Flash (they use a bee image as an example)is very brief and doesn't provide any screen shots.

thanks...

Bounding Box Of MovieClip
Is it possible to display the bounding box of a movie clip. Not the yellow box with _focusrect. But a constant outline.

Thanks

WIK

Bounding Box In Hittest?
Hi, I know this probably has a simple answer but I can't find it. I have a maze type thing, except not all of the walls are perfect rectangles, some may be curved or tilted, and when my dot (the thing you navigate with) goes within the bounding box of the shape the hitTest becomes true and th character "dies". Is there a way to make hitTest work so that it tests the insides, and not the bounding box?

AS 3 StartDrag And Bounding Box
I have noticed when setting a bounding box on a drag object, if you go outside the bounds of the box you have set, the mouse won't let go of the object unless you go back inside the bounds and click on it again. Is there any way to force the stopDrag if you go outside the bounds while dragging? I have tried this bit of code:

Code:
handle.addEventListener(Event.ENTER_FRAME, controlHandle);
function controlHandle(evt:Event):void {
if (handle.x < trackX) {
handle.stopDrag();
handle.x = track.x;
} else if (handle.x > track.x + track.width) {
handle.stopDrag();
handle.x = track.x;
}
}
But once I try to drag it out of the bounds it still hangs on to the mouse unless I click. Any ideas!?

Thanks!

Redefining MC's Bounding Box
Hi,

I am developing a game with flash by using (unfortunately) as 2.0.
I have to detect collisions between two clips, I use therefore the following function :
clipA.hitTest(clipB);

all is working well except that I would like to resize my default bounding box of clipA which has a complex shape.

I used therefore the hitArea property, I create a clip inside clipA which is a little square called square_mc :
clipA.hitArea(square_mc);
=> I though that the bounding box would have been resized but it is not the case, the collision are still detected based on the default bounding box instead of square_mc.

Can anybody help me?

Thanks

Redefining MC's Bounding Box
Hi,

I am developing a game with flash by using (unfortunately) as 2.0.
I have to detect collisions between two clips, I use therefore the following function :
clipA.hitTest(clipB);

all is working well except that I would like to resize my default bounding box of clipA which has a complex shape.

I used therefore the hitArea property, I create a clip inside clipA which is a little square called square_mc :
clipA.hitArea(square_mc);
=> I thought that the bounding box would have been resized but it is not the case, the collision are still detected based on the default bounding box instead of square_mc.

Can anybody help me?

Thanks

Text Bounding Box
Hello,

I am having a problem with founding out the x and y position of dynamic text. I have a flash movie which allows users to type out some text, change font, size, bold, italic etc and then move it around within a restricted area. The users then save their design which saves all the information about there design in a database.

The problem is the x and y position of the text saved in the database is actually the x and y position of the bounding box which is quite a way out from the actual text. This causes a lot of problems when trying to re-create their design using a different system. This also causes problems as the difference between the x and y of the bounding box and the actual x and y differs massively between different fonts and sizes etc.

Basically I have to find out the actual x and y of the text and not the bounding box. I have noticed actionscript 3 has a feature which would solve all my problems but obviously this is no good for me now as I need my movie as accessible as possible.

I have a feeling there is no straight forward answer to this question but I seriously need some sort of solution to this problem.

Thanks in advance
Steven

Copyright © 2005-08 www.BigResource.com, All rights reserved