Bounding Box (or Shape) Hit Area?
Greetings, I am creating a button made from Text.
BUTTON NAME
How do i make a Hit area or bounding box, instead of the letters defining the hit area?
Right now the hit area is constrained to each letter, and rolling over the text looks bad.
thanks
FlashKit > Flash Help > Flash Newbies
Posted on: 09-10-2007, 02:17 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Rollover Detect Bounding Box NOT Shape, How?
Does anyone know how to make the mouse detect the bounding box of a movie clip instead of the actual shape when rolled over?
I have some "buttons" that are really lines and are very hard to click so the mouse needs to detect the bouding box.
Thanks for any help.
HitTest That Works On Shape And Not Bounding Box
Hello all
I am new to actionscript and thought it would be nice to learn it by making a simple game. My problem is with the hitTest method
//code
function moveIt(apple1) {
apple1._y += 8;
if (apple1.hitTest(_root.man1)) {
removeMovieClip(apple1);
}
}
man1 is a mc that catches apples falling from the sky. when the apple hits the man it should disappear. the thing is now the apple does the hit test on the bounding box of the movie clip and not on the actual shape.
i went to macromedia and found out i can use a boolean value to specify if the hitTest will be done on the shape or bounding box but only if the target is an x and y coordinate.
my question is how can i implement this in my mc since i perform the hitTest using the mc's name. i am not sure how i can specify it using x and y since my man mc moves on the x plane
thanks in advance
bsw
Printing Frame, Not Bounding Box Area
This seems to a very popular topic. I have searched far and wide for the following solution:
I want to print an off-stage dynamic text box that mirrors an on-stage dynamic text box. On a layer called "printlayer" I have made a bounding box instance called 'printbounding'. On this single frame I have labeled '#f'. On the layer above called "print2" I have made a dynamic text box instance called 'printbox'. On this frame I labeled '#p'. My printbutton looks like this:
PHP Code:
printbutton.onPress = function() {
print(this.printbox, "bframe");
}
stop();
When I print I get the whole frame and not the bounding box area. The idea is to print a "quote" that shows up in the printbox text.
Here is the *.fla:
http://www.duffelbagboy.com/print_help.zip
Here is the site with some personalized instructions on getting to the print page :
http://www.duffelbagboy.com/print_help.html
I think I have tried every possible combination of script and mc's. If some one has a moment to take a look at my *.fla that would be great. The layers in questions are:
Quote:
Total (contains the button script on frame 17)
printlayer (the bounding box named printbounding, frame 17 marked with #f)
print2 (the dynamic text box named printbox, frame 17 marked with #p)
Thanks,
Cheez
Crop Image Based On Bounding Box Area
I was wondering how one would go about uploading and image and having a gray box that indicates the crop area able to be moved around. Once the user selects the position/crop area it save that as a new image.
I understand the save/upload would require a server side script but couldn't the cropping the image and moving it around and then generating a new image be done with the bitmap data class or something?
Any help would be greatly appreciated? I know this was done may of times in flash 8 with the GD libraries and stuff but i need this done in AS3.
Any idea how to go about it, urls, suggestions, etc?
Height / Width Of Bounding Box Of Visible Area
I have imported a bunch (actually, over 1000!) jigsaw puzzle pieces into FLA files from Illustrator CS3.
In many cases the pieces have artifacts outside of their visible area. For example, a piece can have a picture of a dog's face, but one of the long ears is off to the side, outside the visible region of the piece. The path data is extremely detailed, so our designers didn't crop it off. They used a mask (at least I think it's a mask, I'm not a graphics guy and know little about that stuff) and this makes it invisible in Flash, when we turn them into movie clips. Also, in Flash when I look at the width and height of the piece, it does reflect only the visible area.
However, in ActionScript when I try to get the width and height using, for example
Code:
pieceObject.width
I get the width of the piece including the part that is hidden, i.e. a larger width than the visible area.
Is there a way in AS 3.0 to get the height / width of the bounding box of visible area only?
Thanks.
Reduce Movie Clip Bounding Area
I want to know if there is a way to use a slider to manually adjust the bounding edges of a movie clip. I DO NOT want to scale the movie clip. I want to use this to gradually reduce or increase the area of a bounding rectangle inside the movie clip with bouncing objects. I already have a slider set up I just need to know how to control it.
Height / Width Of Bounding Box Of Visible Area
I have imported a bunch (actually, over 1000!) jigsaw puzzle pieces into FLA files from Illustrator CS3.
In many cases the pieces have artifacts outside of their visible area. For example, a piece can have a picture of a dog's face, but one of the long ears is off to the side, outside the visible region of the piece. The path data is extremely detailed, so our designers didn't crop it off. They used a mask (at least I think it's a mask, I'm not a graphics guy and know little about that stuff) and this makes it invisible in Flash, when we turn them into movie clips. Also, in Flash when I look at the width and height of the piece, it does reflect only the visible area.
However, in ActionScript when I try to get the width and height using, for example
Code:
pieceObject.width
I get the width of the piece including the part that is hidden, i.e. a larger width than the visible area.
Is there a way in AS 3.0 to get the height / width of the bounding box of visible area only?
Thanks.
Extract Bounding Area Of MC With Random Content
I have a main movieclip with a bunch of 'flies'-MCs flying around randomly in it. If the main mc is placed in main timeline, is there a way to retrieve the actually covered area of the main mc at a certain moment... imagine a snapshot bounding box of all flies at that specific moment.
tia
P.
Mouse Hide/show Bounding Area Only
trying to get the mouse to hide in an area, then show when you rollout of that area. However, only when in that area i want a "gunsight" graphic to replace the mouse, then go away and return to the mouse when outside of this area.
here's how i am now (a little frustrated)
Code:
//setup hitArea for game
shootemup_mc.hitArea = shootemup_mc;
//detect hitArea and hide mouse + attach gunsight graphic
shootemup_mc.onRollOver = function() {
Mouse.hide();
this.attachMovie("gun");
gun._x += (this._xmouse-gun._x)/5;
gun._y += (this._ymouse-gun._y)/5;
trace("hide!"+this._name);
};
shootemup_mc.onRollOut = function() {
Mouse.show();
trace("show! "+this._name);
};
By the way, this has to be in a movieclip, no references to _root. I hate _root.
thanks fellers!
Calculating The Area Of A Shape?
Hi everyone...
Is it possible to calculate the area of a shape in Flash?
In short, my movie allows the user to draw a shape on the stage, and I need to determin the area of this shape.
Any ideas?
Calculating The Area Of A Shape
Hi. We are trying to find a way to caluclate the area of a shape which is drawn by the user. And, to make it even more of a challenge, only calculate the area drawn inside a given shape. Eg. if we show an outline of a shape, and they draw over this but go outside the lines, how do we calculate the area inside the lines which they have drawn.
Brain fried!!
Selecting An Area Inside A Shape
Every time I try to use the Selection tool to select an area inside a shape (click and drag), the result is that the whole shape moves. How do you select an area inside a shape without moving the shape?
I appreciate any suggestions.
Confine A Drag Area To A Shape?
I'm trying to confine a drag area to a shape, and I just can't get my head around it...
(Its shaped like a big H)
I started off trying to set bounderies to the drag using coordinates and if statements, but it got insanely complicated, and it wasn't working right.
So, I thought I'd try a hit test method, but this isn't working right either...
This code is worthless, but just so you know where I'm coming from...
Code:
gKnob.onPress = function(){hTest = true;}
gKnob.onRelease = function(){hTest = false;
}
onEnterFrame = function(){
if (gKnob.hitTest(hBox)) {
if(hTest == true){gKnob.startDrag()}
}else{gKnob.stopDrag();}
}
Anyone have at least a direction to send me in?
I'm not utilizing the hit text method right to do what I want...
Draw A Dynamic Shape And Calculate The Area
Hi, if you draw a shape, then fill it can you work out the area?
Through whatever function, flash makes certain pixels a different color.
Surley it must know which ones its changing the color of. I dont really know how it does it, but I really need to measure the area of the shape I'm making.
I have kinda done it it here - but not as acurate as I'm sure flash all ready knows (at it filled a defined area)...
Anyone know anything about this?
Addition info and my wip:
http://www.flashkit.com/board/showth...hreadid=494342
Cheers,
M@)
Draw A Dynamic Shape And Calculate The Area
Hi, if you draw a shape, then fill it can you work out the area?
Through whatever function, flash makes certain pixels a different color.
Surley it must know which ones its changing the color of. I dont really know how it does it, but I really need to measure the area of the shape I'm making.
I have kinda done it it here - but not as acurate as I'm sure flash all ready knows (at it filled a defined area)...
Anyone know anything about this?
Addition info and my wip:
http://www.ultrashock.com/forums/for...?s=&forumid=88
Cheers,
M@)
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.
Is There A Way To Perfectly Compare Overlapping MC's Shape On Shape?
Is there some sord of hitTest tweak or script/code that can tell whether the two movie clips are overlapping each other SHAPE on SHAPE and not bounding box on bounding box? I have experimented that whenever I use the hitTest code like this.hitTest(anotherMovieClip) it does not work as I hoped.
Don't get what I mean? Well...
Is is possible to compare 2 objects shape against shape by doing a hit-test from object A to compare it against the shape of object B and then another hit-test to compare object B against the shape of object A and if both give true then the shapes are overlapping each other?
Shape Hint Makes Shape Dissapear
Sometimes (not always) when I add shape hints to shapes to help shape tweening, the tweened images inbetween two shapes dissapear leaving nothing except for the first image on the first frame and the last image on the last frame that i'm trying to shape tween.
This only happens if i'm using shape hints, and if I take them away, it tweens normally.
How can I fix this and still use the shape hints?
Is It Possible To Get The Dimensions Of An Oblong Shape? Or Can I Replace The Shape?
I am using the loader to load an swf. The swf has movieclips inside that I register to my class using this.clip1 = loadedMov.getChildByName("clip1");
Say clip1 contains only a solid colored, oblong shape. I want to be able to change clip1's color to a gradient fill and retain the oblong shape. What is the best approach to do this? The shape would be a little difficult to draw dynamically. It also would not be practical to redraw it for every possible gradient at design time for my situation.
Seems to me I should be able to replace the shape's color with a gradient like a ColorTransform does for solid colors, or get the vectors of the shape and redraw it with beginGradientFill. Really need help on this one.
Tags: Actionscript 3.0
Drawing Custom Shape, And Filling Shape
Hello Forum members,
I have not yet figured out how to fill a shape (not an oval or a rectangle) that I draw.
for example, I draw a triangle with the pen tool (or the pencil tool). I have a nice triangle now.
Three lines, etc.
How can I fill this new "shape" with a color? Witout using the brush or the pencil and drawing color in.
Thanks,
eholz1
Shape To Text Shape Tween Not Responding
I wanted to know if anyone has encountered this problem or can see that I'm doing something wrong. It really doesn't look too complex and I've also done it before with no issue. I'm only running 2gb of ram, but I've done this plenty of times with no latency and for some reason recently it just won't work. I'm using CS3 Pro, AS 3
Set up:
Draw a square in frame one
create a blank keyframe on say, frame 30
write some text on frame 30
shape tween the square into the text
Results:
If I tween the square to a single character-no problem
If I tween the square to a sentence slow tween on preview and publishing
If I tween 3 paragraphs it will bomb out and go into...not responding and I have to shut down the program
Any thoughts?
Advanced Hittest . Shape/shape Not Rectangle?
Does anybody know a solution
for testing the collision of two shapes
where only the visible shapes
not their border rectangle count.
the point/mc collision is not enough. i need to check the shapes of both mcs.
Load External Swf Into A Specific Area And Confine Interactivity To That Area... ?
Hello again,
I have a problem I've been trying to solve below.
I have a file that loads external swf files onto the screen, but I need these swfs to load into a specific 1024x644 area in the main movie.
I need the external swfs to maintain their interactivity while the mouse is over their area, but not when the mouse is over other parts of the screen (I need other buttons to still be accessible outside the area of the loaded swf.
As it is now, the mouse properties of the loaded swf take over the entire movie and render the buttons useless.
Below is some code I'm using. Can anyone provide examples of code that positions an external swf into a specific area and contains its interactivity?
I'm still very new to AS, so it's difficult for me to understand how to do things without specific code examples to look at. Also, if my code is inefficient or sloppy, please let me know.
Thanks.
var loader:Loader = new Loader();
function buttonPush1(event:MouseEvent):void {
var url:URLRequest = new URLRequest("mousetrail_644.swf");
loader.load(url);
this.addChild(loader);
}
Btn1.addEventListener(MouseEvent.CLICK, buttonPush1);
function buttonPush2(event:MouseEvent):void {
var url:URLRequest = new URLRequest("magnify2.swf");
loader.load(url);
this.addChild(loader);
}
Btn2.addEventListener(MouseEvent.CLICK, buttonPush2);
function buttonPush3(event:MouseEvent):void {
var url:URLRequest = new URLRequest("mapcursor_644_2.swf");
loader.load(url);
this.addChild(loader);
}
Btn3.addEventListener(MouseEvent.CLICK, buttonPush3);
function accessDenied(event:MouseEvent):void {
gotoAndPlay("scanner_denied");
}
Btn4.addEventListener(MouseEvent.CLICK, accessDenied);
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
TransitionManager Bounding Bug
It seems that once you call TransitionManager.start or Transition.startTransition and target an object, it caches some properties about the object size. If you change the size of the object and start a new Transition, it works fine and the Transition considers the entire size of object. If, however, the size of the object is changed because of dynamic content being added inside of it, the Transition fails to pick up the new bounding box. As a result, a simple Wipe, for instance, will wipe to the edge of where the object used to be, failing to reveal the newly created parts, and when the Transition completes it suddenly reveals the whole thing. Example attached.
Has anyone else encountered this? Any workaround?
Attach Code
import fl.transitions.*;
import fl.transitions.easing.*;
// "mc" is an instance on the stage of a graphic
// MC is library symbol set to export as MC so it can be attached at runtime
// first transition -- works okay
TransitionManager.start(mc, {type:Wipe, direction:Transition.IN, duration:1, easing:Bounce.easeOut});
// adding dynamic content that changes the bounding box of mc
var mc2 = new MC();
mc.addChild(mc2);
mc2.x = 50;
// second transition, fails to recognize the change in mc's bounding box
// same result even if this transition starts well after the first is completed
TransitionManager.start(mc, {type:Wipe, direction:Transition.IN, duration:1, easing:Bounce.easeOut});
Add Bounding Box To MovieClip?
I have a large graphic consisting of letters from Illustrator. I paste these into flash, break them up into smaller groups and convert these groups to MovieClips. Because of the enormous amount of MovieClips that I have to convert by hand (pressing F8 and Enter), I simply use the default naming of symbols that Flash suggests Symbol 1, Symbol 2 ... Symbol 3245.
I place all these MovieClips into one parent MovieClip (select them all and press F8). And at runtime I add EventListeners to them all using this:
Code:
for(var i = 0; i < letter_ocean_mc.numChildren; i++)
{
var mc:DisplayObject = letter_ocean_mc.getChildAt(i);
mc.alpha = .1;
mc.addEventListener(MouseEvent.MOUSE_OVER, mOver);
mc.addEventListener(MouseEvent.MOUSE_OUT, mOut);
}
I can now apply the same effect to all these clips at once, which is nice. But ...
My problem is, that because each group consist of letters, I can only get Mouse Over Event when I touch the letters them selves, not the holes in the letters and the space between them.
I thought I could easily add a mask or bounding box to get the whole MovieClip to respond to MouseEvents. I hope I thought right, but I just can't seem to get anything to work. I've tried creating both new Sprites, MovieClips, DisplayObjects, Shapes ... you name it, and add them to the instance like this:
mc.addChild(myMask); (where myMask has been any of the above mentioned types - both with and without drawn shapes).
Does anyone have any idea how to achieve a thing like this? And it has do be done dynamically, as I haven't got the three months or so to do it by hand (not to mention if I had to update the graphic ).
Bounding Box Won't Work?
i have read all of the tutorials and everything for my program. i want to be able to print just a small portion of the area, and for some reason i can't get a bounding box to work and then the "bframe" action is cutting out only half of the stuff it is supposed to. i don't know if anyone has encountered this problem but it is frustrating me becuase it shoudl be really freaking easy.
|