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




Movie Clip Boundry Detection



if you got to http://www.btinternet.com/~lfl_powell/ you will see what i am trying to do.

the red dot is controlled by the up, down, left, right keys but what i want to happen is when the edge of the dot touches anypart of the black it cant go any further out, so the movement is only contained within the white area.

can anyone help please.



FlashKit > Flash Help > Flash ActionScript
Posted on: 11-27-2001, 04:38 AM


View Complete Forum Thread with Replies

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

Giving A Movie Clip A Boundry
What's happening is that I am moving a movie clip around the screen on button click (left,right,up & down).

What I am having difficulty with is stopping the movie clip from going over the boundry i have drawn around the stage.

I want it to not go over these boundries, is there a way of doing this?

cheers

lee

MouseX , MouseY Detection Beyond Stage Boundry?
Hi there,

I've just started dabbling with AS3 coming from Director. Is there a way to
detect the mouse x , y values beyond the edge of the stage? When tracing
mouseX, mouseY on enterframe event the values stick at the last position
within the stage when the mouse roams beyond the stage boundry.

An vague example of usage would be if you had a big movie clip as a custom
cursor, and wanted it to smoothly disappear beyond the stage edge.

Thanks for your help :)

Richard Smith

Sound Done Detection & Movie Clip Detection
Is there any way in Actionscript to detect if a sound has finished playing?
What about detecting a movie clip has come to the last frame?

Movie Clip Detection
i want to detect how many of a spacific movieclip is crrently been used... i have no clue how though

Keyframe Detection Via A Movie Clip
While working in Flash MX, I came across a problem. So I decided to come to the best place for help. I was wondering if you could check to see if Movie clips were on specific frames whether or not it can be done somewhat the same way as this _root.Movieclip==(frame number or label).
If it can be done but not by that way I am still all ears and open to any suggestions. Also just want to say that you people at Flashkit rock, and thanks for all the help.

Wattsman

Movie Clip Collision Detection
i have a lighter which i created and for an interface i would have 5 ropes, one for each of my menu options.

what i need is when the lighter is on and the flame movie clip is visible i need a collision detection for when the flame touches one of the ropes, then my movie will go to the frame where that option lies.

Movie Clip Angle Detection?
I have the following code which detects the mouse angle, relative to a holder movie clip, and then makes the rotation of a "turret" movie clip follow the mouse. How can I adapt it for use with another movie clip in place of the mouse?


Code:
onClipEvent (mouseMove) {
x = this._xmouse;
y = this._ymouse*-1;
angle = Math.atan(y/x)/(Math.PI/180);
if (x<0) {
angle += 180;
}
if (x>=0 && y<0) {
angle += 360;
}
_root.turret._rotation = (angle*-1) + 90
}

Multiple Movie Clip Collision Detection
I have many instances of a movie clip (by using duplicateMovieClip) on my stage, each with a name of "clip1", "clip2", "clip3" etc.
I have many instances of another movie clip, like the one above, but all derived from a different original movie clip. They're named "something1", "something2" etc.
I want to put an "if" statement that performs a "hitTest" between one of the "something" movie clip instances and ANY of the "clip" instances.
This is the code I have inside the onClipEvent (enterFrame) of the "something" instance:
onClipEvent (enterFrame) {
if (this, hitTest(_root.varClip)) {
this.removeMovieClip();
}
}
and I have this code in a frame on the _root level
for (var i = 1; i<=3; i++) {
_root.varClip = ["clip"+i];
}
Nothing is working this way. Is there some other way that I can check the collision using arrays?
Am I mixing up the paths?
I'd really appreciat some help with this. I feel like I'm so close already.
Thanks
Kevin

Mouse Detection Out Of Movie Clip Boundries
What kind of code do i need so that even if the mouse goes off the side of the Flash Movie, it will still give _x and _y coordinates?

for example I have a box following the position of the mouse. how do i get the box to follow the mouse even if the mouse goes off stage?

thanks..

Mouse Detection Out Of Movie Clip Boundries
What kind of code do i need so that even if the mouse goes off the side of the Flash Movie, it will still give _x and _y coordinates?

for example I have a box following the position of the mouse. how do i get the box to follow the mouse even if the mouse goes off stage?

thanks..

Boundry Within The Movie Heights N Width?
is there a code for this? like if the movieclip hits the height and width of the movie (ex 550 x 400) it wouldn't be allowed to go?

[AS2 On CS3] HitTest For Movie Clip Mouse Click Detection
When I want to detect a mouseclick over a movie clip I use
clipname_mc.onMouseDown

if there are more than one clip onstage, they all respond to that one click!

In AS MX I used hitTest to test if the mouse was over that movie clip while clicking. What do I do in AS2?

Adding Collision Detection To A Custom Movie Clip
Hey, guys. I've created a custom movie clip object (by extending the movieclip class) and instantiated a number of them for a game I'm making. From what I've read, you can add collision detection to the custom object. Before hand, with each frame I'd loop through every single object and see if something hit it. As a matter of fact, I did that for one game I just made and everything worked beautifully. However, can't I do something like


Code:


class Something extends MovieClip {
var someVar;
function Something (x,y,someVar) {
this._x = x;
this._y = y;
this.someVar = someVar;
}
function hitTest(someOtherObject) {
this.removeMovieClip();
}
}



If I can do this, the question becomes, how do I pass in the object to do the test? Do I pass it in as a member variable when I attach the movie clip? For example, I pass in values for the constructor with

_root.attachMovie("instance1","Something",this.getNextHighestDepth,{x:100,y:100,someVar:12});

where the final parameter is the initial values. Should I pass in all objects that could possible hit the attached movie clip then check within hitTest? Any help would be greatly appreciated.

[F8] Set Boundry Help/with Map PLEASE
Hey,

I'm making a map that is dragable and you can zoom in and out. I'd like to be able to stop the map from going past the masked section when it's zoomed in or out. I think I need to use the getBounds() Method but I don't understand how to use it. Any suggestions would be great!!!!
Thanks

Help How Do I Set A Boundry For An MC
Hey,

I have a map that I have made dragable and you can zoom in and out. The map sits under a mask. I would like when a user zooms out(or in) and drags the MC that it not break the area of the mask (I don't want to see behind the map). Any suggestions? I am on a deadline so any help would be helpful.
thank you : )

Boundry
In Flash how do I make it so that wken a charcter walk's into a wall from any side the wall stops him.

Boundry
In Flash how do I make it so that wken a charcter walk's into a wall from any side the wall stops him.

Boundry
I'm building & testing a system where you can zoom In / Out / Drag an image around the screen. It's to go live on a site I'm currently building.

What I need is a way of placing a boundry on the image. The image in the movie is 1074 x 1360, but you can drag the image off screen which I don't want. Also, when you've zoomed in/out, you can still drag the image totally off the stage. Does anyone know how I can put a boundry around the image so that it stays within certain limits (its size).

Here's the URL for the movie:

http://www.buyfromtheband.com/highart/TEST_3.html

Clip Event Detection
how can i tell whether a on(release) has been used on a movie clip. i'm writing a script and i don't know how to detect this.

Next Boundry To Overcome
Hi again today...

It seems my Actionscript skills have become a bit rusty duringthe latest project... but thats not why i started this thread.

Ok' here we go,
In My SWF i have a 1clip that loads some XML into button labels (Not verry complicated) When a buttom is pressed a clip which loads a Content fields starts .. (not the problem also, (Now its getting interresting)somewhere in the 1clip a close button can be pressed to go back to the root of the SWF (this is done by tweening the clip background border)
The same close button should make shure the content clip is finished ... (tweened into invisseble)

Then the 1Clip has to close itself....

-------------------CODE
on (release) {
if (_root.Forumlist.Forums._currentframe = 34) {
tellTarget ("_root.Forumlist.Forums") {
gotoAndPlay(35);
}
} else if (_root.Forumlist.Forums._currentframe = 1) {
tellTarget ("_root.Forumlist") {
gotoAndStop(1);
}
}
}
---------------------CODE


Please help me out here
Thanx....

Help - Boundry For Mousetrail
hey there!

i've made a header (width=780px height= 211px) that's fully flash.
in the header i've got a rectangular menu (width=185px height=18px) with a small arrow horizontically following the movement of your mouse.

the problem is that it keeps on follow you even when i move out of the menu-area. how can i prevent this from happening?

this is the script for my mouse-movement:
code:
pijl_mc.onEnterFrame = function() {
if(this.hitTest(_root._xmouse,_root._ymouse,true)) {
var xMouse = _root._xmouse;

if(Math.abs(xMouse - this._x) < 1) {

this._x = xMouse;

} else {

this._x -= (this._x-xMouse) / 6;

}

}
}


if also attached the fla if you don't really understand my story.
hope someone can help me out with this!
thanks in advance!

Game Boundry
Hey, I have been following a tutorial for the last few days to get boundries working within games and managed to create the 1st file called Get boundries, i am trying to impliment it into my game where the circle still reamains the hit test but is linked with to work around the feet of my little man (see the second file).

So i need to some how get the code checking if i the red circle has hit the black boxs and if it has it needs to stop the man from being able to work over them.

Hopefully someone out there will be able to help me >_<

Thanks in advance

Both files are in there getbounds.fla is the working file and getbounds 2 is kinda how i need it to be working hope i made enought sense to get help.
Download

Easing With A Boundry
i looked at some of the easing tuts which were quality but how can u box in a easing animation and also change its start co-ordinates.. because when easing a animation it always starts on the top left corner.. as for boxing in a animation i mean for example making a easing animtion is only aloud to move up and down the side of a scene..

(eg)
up
and
down
this
side
only
and


.................................................. ... not over here



?

Ball And Boundry
I would like the Ball to move in a random direction 0-360,
Then i would like the Ball to richoche off of the BallBoundry in its reflected direction.
Thank you


I have updated the fla to the one with the new code

here is my post with the work i did to get the AS

Easing With A Boundry
i looked at some of the easing tuts which were quality but how can u box in a easing animation and also change its start co-ordinates.. because when easing a animation it always starts on the top left corner.. as for boxing in a animation i mean for example making a easing animtion is only aloud to move up and down the side of a scene..

(eg)
up
and
down
this
side
only
and


.................................................. ... not over here



?

Unresolved - Clip Detection Logic
The code below seems absolutely watertight to me, but for the life of me I can’t see why it doesn’t work as intended:

Basically I have a ball that travels across 2 movie clips & should start reversing once it senses it is over clip 2.

I’ll set out the code as it currently appears in the movie & then a commented version that shows my logic with it & possibly where I’m going wrong.

An fla is also attached.

Actual Code:


ActionScript Code:
_root.hold_mc.trackOne_mc.num = 1;
_root.hold_mc.trackTwo_mc.num = 2;
done = 0;
_root.ball_mc.onEnterFrame = function() {
    this._x += 2;
    for (i in _root.hold_mc) {
        if (_root.ball_mc.hitTest(_root.hold_mc[i]) && done == 0) {
            numHit = _root.hold_mc[i].num;
            done = 1;
            trace(_root.hold_mc[i].num);
            if (numHit != _root.hold_mc[i].num) {
                _root.ball_mc.onEnterFrame = null;
                _root.ball_mc.onEnterFrame = function() {
                    _root.ball_mc._x -= 2;
                };
            }
        }
    }
};


Commented code:



ActionScript Code:
// I have assigned variables to each of the clips that the ball travels over so as to differentiate them:                                                 
_root.hold_mc.trackOne_mc.num = 1
_root.hold_mc.trackTwo_mc.num = 2;

done = 0;// A flag variable to get the .num value of the first clip

// An onEnterFrame function to move the ball

_root.ball_mc.onEnterFrame = function() {
    this._x += 2;

// A for(in) loop to capture the .num value of the first clip to then check against it.
   
for (i in _root.hold_mc) {
        if (_root.ball_mc.hitTest(_root.hold_mc[i]) && done == 0) {
            numHit = _root.hold_mc[i].num;
            done = 1;

/*Ok this is where I think it is breaking down. To my mind this section will check the ball as it moves along – if whatever number “_root.hold_mc[i].num” throws up is different to the “numHit” variable designated above the ball goes into reverse*/
          
            if (numHit != _root.hold_mc[i].num) {
                _root.ball_mc.onEnterFrame = null;
                _root.ball_mc.onEnterFrame = function() {
                    _root.ball_mc._x -= 2;
                };
            }
        }
    }
};

Using Small Loader Clip For Detection.
I've been using SWFObject for a long time, but lately I've become worried about these IE7 bugs that are causing issues with SWF's using javascript based detection. My current workaround is going to be to just push the content to IE7 users, and use a second detection script in my loader SWF (which loads my main SWF).

Can I use express install with this method? I'd assume I can simply load the express install swf into my loader SWF if they fail detection. Does it work OK like that? Does anyone have experience with this.

Checking To See If A Cursor Is Within A Boundry
does anybody know how to check to see if the cursor is within a rectangular boundy besides droptarget, Im looking for doing it with x and y coordinates

thanks
JH

Target Flow Boundry
I have an image that has a taget in the top layer. the target follows the mouse with this code.

onClipEvent(enterFrame){
_x+=(_parent._xmouse-_x)/8;



What I want todo Is have the target only follow (active) when the mouse is over a certain part of the image ( so its contrained within a box)

can any one help

thanks.

Bouncing Ball + Boundry
I'm looking to create a small movie clip in which I have a small red ball bouncing continuously inside a boundry, I.E. starts off on the left, bounces to the right, hits the right boundry and bounces back to the left, hits left boundry, goes right ... and so it goes on.

I know this is done using AS but am not to sure where to start. If theres a tutorial I could look at or someone who has done this cna help that would be great.

Regards,

Putting A Boundry To My Scrollingmenu
hey everyone!

i made a menu that has a point following the mousemovement horizontically.
my question is:

how can i make it stop moving when you get OUTSIDE the menu area, so it won't follow you wherever the mouse is on the swf???

this is my script:
code:
pijl_mc.onEnterFrame = function() {
var xMouse = _root._xmouse;
if(Math.abs(xMouse - this._x) < 1) {
this._x = xMouse;
} else {
this._x -= (this._x-xMouse) / 6;
}
}


i've included the fla if that can help you (and me) out

greetz and thanks a million, billion, kazzillion!!

How Do You Make A Boundry For A Circle?
I have a ball that gets duplicated when you press a button, the ball acts with gravity so it bounces and whatnot but when the balls hit they just go through eachother, I want them to have boundrys so when they touch sit on eachother or bounce off whatever my gravity allows it to do. I'm gonna do some experimenting but if you could help thatd be great.

I'm using Flash 8 as well

Creating A Boundry In The Script...
I'm new here and I'm taking a class on Director. Unfortunately, my teacher does not know how to do much himself which is leaving me to come here and seek advice. Please forgive me in advance for any stupid questions and the like since I have not learned much.

I am creating a video game similar to Arakanoid but with a small amount of moving objects instead of stationary objects. I am not trying to make an exact recreation but at least something that is playable and fun that can be made in Di.

I am just taking it one step at a time so my question is, am I able to create a border around this portion of my picture? The black border is also part of the same PNG. Is it possible to create a border in the code so nothing passes that section or does my picture have to be separate from the black border? Basically, I want all actions constrained within that picture frame.

I hope this question makes enough sense. Thank you for any help. ^_^

Code To Set Boundry In Game
This may sound noob-ish, but I can't figure out a good way to do this. All I've gotten so far are dumb answers.
I need code that sets boundaries (such as the ground or a wall) that will stop my character when he hits them. The code needs to work for curved surfaces as well as flat ones. I know how to do a hittest, but I can't figure out what to do from there. Stopping gravity doesn't do enough. Keep in mind my character has inertia, so he will keep moving for a little while after you release the arrow key.
Any help would be much appreciated.

Creating A Boundry In The Script...
'm new here and I'm taking a class on Director. Unfortunately, my teacher does not know how to do much himself which is leaving me to come here and seek advice. Flash is a better option for what I'm looking for and Director is moving out anyway. Please forgive me in advance for any stupid questions and the like since I have not learned much.

I am creating a video game similar to Arakanoid but with a small amount of moving objects instead of stationary objects. I am not trying to make an exact recreation but at least something that is playable and fun that can be made in Di.

I am just taking it one step at a time so my question is, am I able to create a border around this portion of my picture? The black border is also part of the same PNG. Is it possible to create a border in the code so nothing passes that section or does my picture have to be separate from the black border? Basically, I want all actions constrained within that picture frame.

I hope this question makes enough sense. Thank you for any help. ^_^

(flash Mx)draggable Mc With Boundry?
Hello everyone, I'd just like to say thank you for every person that has helped me in the past; i hope that you all can help me out once more. I have a menu that i need to be able to drag, but the menu is only allowed to be dragged to a certain constraint. (i.e. before the menu can no longer be visible within the .swf) I have the basic drag ac:

on (press) {
startDrag ("");
}
on (release) {
stopDrag ();
}

How would i go about adding constraints to this mc? Thanks in way advance everyone. Take care

Victor.

Boundry For Infinite Menu- - -
Hi all!

I've searched around for an answer to this on the forums' archives, but to no avail

All i need to do is put a boundry for the infinite menu to stop at for the left and right.
This is my code from the tut:

ActionScript Code:
onClipEvent (load) {    xcenter=150;    speed=1/10; }  onClipEvent (enterFrame) {    var distance=_root._xmouse-xcenter;    _x+=(distance*speed);    if (_x > 0) _x=-300;    if (_x < -300) _x=0; }


And if there is already a thread about boundries for the infinite menu...can you just direct me there? Thanks so, so much!

Johnny

(flash Mx)draggable Mc With Boundry?
Hello everyone, I'd just like to say thank you for every person that has helped me in the past; i hope that you all can help me out once more. I have a menu that i need to be able to drag, but the menu is only allowed to be dragged to a certain constraint. (i.e. before the menu can no longer be visible within the .swf) I have the basic drag ac:

on (press) {
startDrag ("");
}
on (release) {
stopDrag ();
}

How would i go about adding constraints to this mc? Thanks in way advance everyone. Take care

Victor.

Boundry For Infinite Menu- - -
Hi all!

I've searched around for an answer to this on the forums' archives, but to no avail

All i need to do is put a boundry for the infinite menu to stop at for the left and right.
This is my code from the tut:

ActionScript Code:
onClipEvent (load) {    xcenter=150;    speed=1/10; }  onClipEvent (enterFrame) {    var distance=_root._xmouse-xcenter;    _x+=(distance*speed);    if (_x > 0) _x=-300;    if (_x < -300) _x=0; }


And if there is already a thread about boundries for the infinite menu...can you just direct me there? Thanks so, so much!

Johnny

How Do I Have A Hittest That Isn't A Square Boundry?
I've been using Flashes hittest to test if 'paintballs' or their splat hit an object after flight animation...but I'd like it to detect if the object itself hit it, not just a square area.  because in the corners I dont have pieces of the object...looks kinda funny when I didn't hit a button and it goes anyhow.

Regards,
Anthny

Mouse Boundry Control
I need to put a boundry on the cursor in a project I'm working on. e.g.- I don't want the mouse to go below a certain y value. I'm sure the code is simple but so are my Flash skills, so any help would be appreciated.

Mouse Boundry Control
I need to put a boundry on the cursor in a project I'm working on. e.g.- I don't want the mouse to go below a certain y value. I'm sure the code is simple but so are my Flash skills, so any help would be appreciated.

Making A Movie Clip In A Movie Clip Go To The Next Frame Of The Original Movie Clip
I have a movie clip (for simplicity I'll call it movie_a) in movie_a I have another movie clip movie_b.

in movie_a i have a button that when pressed makes movie_b play (it has a stop frame every once in a while so the button acts as a "next" button)

I want it so that when i get to the last frame of movie_b and press the button, it will go to the next frame of movie_a

I hope that doesn't confuse u and u can help me solve this problem, as i am stumped and I've tried everything I could think of (which isn't that much as I'm not too good with actionscript)

thnx

HELP -Printing Current View Within Boundry Box
I have a movie with many different layers and movie clips to allow the user to 'create a character' ( http://alexdesforges.tripod.com/ ).
and basically want it so that when user clicks the button "Print Me"
it prints the character as you see (current frames of all different movieClips)
and within a boundry rectangle.
Is there a simple way to do this? (I have searched forums but cannot find a solution

Hope there is
thanks for any help, much appreciated!

Drag Class: Set Boundry For Movieclip
I want to restrict the movement of my movieclip. For example, I only want it to move 100 pixels to the right and left. Can anyone offer suggestions?


Code:
class Drag extends MovieClip {
var ease;
var dx:Number;

private function Drag() {
this.ease = 0.3;
};

private function onEnterFrame():Void{
this.dx = _xmouse - this._x - 500;
this._x += (this.dx * this.ease);
}
}
The source files:

http://www.0-style.com/files/drag.zip

Targeting A Frame Label In A Movie Clip From A Button In A Separate Movie Clip.
I have two separate movie clips placed on a timeline-MovieclipA and MovieclipB. I have a button in MovieclipB clip that wants to target a frame label located in the MovieclipA timeline. Can someone help me?

Movie Clip Buttons Nested Inside Movie Clip Dont Work
Hi people!
im having a problem here.

in my first frame i have a movie clip named "menu_mc".
i have this AS for this movie:

Code:
this.menu_mc.onRollOver = function() {
menu_mc.gotoAndPlay(8);
}
this.menu_mc.onRollOut = function() {
menu_mc.gotoAndStop(7);
}

thats working ok, the menu_mc plays on rollover from frame 8 till frame 12 where stops.
On frame 12 (this is inside the menu_mc movie clip) i have another movie clip, named button1_mc.
and also i have AS controling that MC:

Code:
this.button1_mc.onRelease = function() {
getURL("index.htm", "_self");
}


The problem is that when i rollOver on menu_mc it work fine and the button1 appears, the problem is when i try to click button1...
doesnt work.

the swf you can see it on www.wt.com.mx/menu.swf
can anybody help me please?
what im doing wrong?
or what other ideas can you give me so i can make that work.

thanks!

Mouse Rollover On One Movie Clip Increase Decrease Alpha Of Another Movie Clip..
So I really haven't messed with Actionscript much for a couple years and here is my issue.

I have several movieclips I put together that will eventually be a menu for my website. When you roll over a menu option (movieclip) I am trying to get another movie clip to fade in giving the description of the menu item.

For example - when you roll your mouse over the 'Live Chat' option a brief text description would appear telling you what the live chat is about. This description is a seperate movie clip appearing away from the original menu.

I have made the movieclips for the menu and the movie clips for the descriptions. I tried this action on the menu option to get the description to fade in:


Code:
onClipEvent (load) {
this._parent.mc_text_discussionBoard._alpha = 0;
}
onClipEvent (enterFrame) {
this.onRollOver = function() {
if (this._parent.mc_text_discussionBoard._alpha<100) {
this._parent.mc_text_discussionBoard._alpha += 5;
}
};
}
But the alpha only increases on the description (mc_text_discussionBoard) by 5 when I keep rolling my move over and out and over again. It makes sense why it does that, but I'm not exaclty sure how to get it to continually increase the alpha by 5.

any help would be great and I am anxiously waiting to get this solved!
Kevin

Code 4 MovieClip Button To Load A Movie Clip Into A Placeholder Movie Clip.
Yeah that title sounds a little confusing...so i will explain:

Is there a way to tell a "movie clip button" that once it is clicked on to load a "movie clip" into a "movie clip placeholder". So instead of loading an external swf into the placeholder, it will be a movie clip from within the same library. Putting every single custom clip on the timeline would take a while, so that is why I thought it would be easier like this, and the other movie clips are not that large that I want to load into it so there is no need for external swfs, trying to keep it clean. Here is the code along the lines I am trying to go for.

__________________________________________

this.profile_mc.onRelease = function() {
placeholder_mc.loadMovie("profileSection_mc","plac eholder_mc","_root.content");
}
__________________________________________

- "profile_mc is the button I am trying to activate to load the
"profileSection_mc" into the "placeholder_mc". but so far no good.

- the movie clips are within the same library, not on the timeline or external library.

- Is this possible?

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