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








Multiple Conditions With HitTest?


I'm trying to create a script using multiple conditions and the hit test. Essentialy I have 6 hit areas and 6 plops so I need a condition to say if hitTest(1) and hitTest(2) and hitTest(3) and so on are in their hit areas go to and play. So this is the code I've come up with and it's not working.

Code:
if (_parent.step1.hitTest() &&
_parent.step2.hitTest() &&
_parent.step3.hitTest() &&
_parent.step4.hitTest() &&
_parent.step5.hitTest() &&
_parent.step6.hitTest()){
_root.play();
}

I'm sure I'm off on how I have the first part but know that I need to use the && to make the multiple conditions. Thanks




FlashKit > Flash Help > Flash ActionScript
Posted on: 02-24-2005, 01:34 PM


View Complete Forum Thread with Replies

Sponsored Links:

IF (multiple Conditions) Hittest And Placement
Hi
I am trying to make an animation with two MC's going through a loop, and when they are both at the loop at the same time, only one, call it mc_a, is allowed through, and the other stays still, mc_b
so, i thought i could use if/then on theMC to stay still, with the IF being a combo of HitTest on the ring, and having an equal X coordinate with mc_a., preferably with a range +/- some level of precision......
but i cant figure out how to make more than one condition in the IF, or if that is even the smartest way of doing it.....

thanks in advance
andrew

View Replies !    View Related
Multiple Conditions - Is This Possible?
Is it possible to have more than one condition on an if statement?

eg. if something is black and if it is 40cm then do the following....

both conditions must be fulfilled before the action can occur.

Can anyone give me the code for this?

View Replies !    View Related
Multiple Conditions
I'm trying to do something only if the mouse is within a certain rectangle area (100x150 area at x,y of 50, 300). Basically if all of the following conditions are true: -

code:
if (_xmouse<200 AND _xmouse>50 AND _ymouse<400 AND _ymouse>300){
//do this
}


But I am well aware this is mere pseudo code and will not work, can anyone offer me the correct syntax to do this?

Thanks
Dan

View Replies !    View Related
Multiple Conditions (if And If?)
I need to carry out an action upon three things being true. I am unsure of how to write this code.

The closest i have gotten is as follows:

if (var10 == 1, var3 == 4,7){
_root.sketch.gotoAndPlay(6);
}

if var10 is exactly equal to 1 and var3 is exactly equal to either 4 or 7 I need it to play the sixth frame in movie "sketch."

Can anyone help me? I would greatly appreciate your wisdom.

thanks,
Matthew Praetzel
mpraetzel@rcn.com

View Replies !    View Related
Multiple Conditions
what code do i need if i have multiple conditions? i've tried

if (condition1, condition2, condition3)

but if condition3 is met before condition1 or 2, it completes the statement anyway. is there another way?

View Replies !    View Related
[F8] Multiple Conditions?
Is it possible to put more than one condition in a conditional statement? I have tried and failed with an "if" statement, but I need something similar; only with two conditions. Any help would be much appreciated.

View Replies !    View Related
Multiple Conditions
is there anyway that i can check for two multiple conditions, such as a hitTest and a varbile equaling a certain number?

View Replies !    View Related
If Then With Multiple Conditions
I'm making a flash game. This code does not work for me. Does anyone know what is wrong?

onClipEvent (enterFrame) {
if ((key.isdown(key.LEFT)) || (key.isdown(key.RIGHT))) {
this._visible = false;
} else {
this._visible = true;
}
}

View Replies !    View Related
Multiple Conditions
Ok, I am new to Flash and this is my first big project at work:

I am creating a training to test meter readers. As the assessment part, there will be an 4 input boxes where the user puts in the reading they got (1 digit per box). When they hit a button on the bottom (or hit "Enter") it checks to see if they got the right reading. If they did, a text box will show "Correct." If they didn't, the text box will show "Incorrect" and the correct number will appear above the ones they got wrong.

My problem is:

1) I am not sure how to make it so when they hit the button, it will check all the input boxes to see if they are right, thus showing a Correct or Incorrect.

2) I am not sure how to have the correct number appear, if they missed just that particular one.

Suggestions?? No fla for this one, just trying to plan out the AS so when I build it, I do it right.

View Replies !    View Related
If (multiple Conditions?) {
I've got a zoomable map within a frame, and of course I don't want it to be dragged out of view, right?

So, how do I set the startDrag (L,T,R,B) parameters when it's a different size when it's enlarged (zoomed)?

Would it be advisable to somehow set multiple conditions to do something like this? (if so, how would I do it?)


if ( between Size>100 AND Size<200) {
startDrag(this, false,400,150,600,250);
}
if ( between Size>200 AND Size<400) {
startDrag(this, false,500,250,500,150);
}


Would it be advisable to do something like that? If so, how would I code it?
If not, what would be a better idea?

...I swear, adding this zoom feature added a whole level of complexity to this map that I've never imagined. PLEASE HELP!

ThanX!

View Replies !    View Related
Multiple Conditions
Hi,

does anyone know how to do an if statement that will only work if all conditions are met?

for example, I have been using this code

if ((condition1) || (condition2) ){

} else {

}

in this case it only checks to see if one or the other is fulfilled. Is there a way to make it check that both condition1 and condition2 are fulfilled before it does it's stuff?

Any help would be greatly appreciated.

Thanks

View Replies !    View Related
Multiple Conditions
Ok, I am new to Flash and this is my first big project at work:

I am creating a training to test meter readers. As the assessment part, there will be an 4 input boxes where the user puts in the reading they got (1 digit per box). When they hit a button on the bottom (or hit "Enter") it checks to see if they got the right reading. If they did, a text box will show "Correct." If they didn't, the text box will show "Incorrect" and the correct number will appear above the ones they got wrong.

My problem is:

1) I am not sure how to make it so when they hit the button, it will check all the input boxes to see if they are right, thus showing a Correct or Incorrect.

2) I am not sure how to have the correct number appear, if they missed just that particular one.

Suggestions?? No fla for this one, just trying to plan out the AS so when I build it, I do it right.

View Replies !    View Related
If (multiple Conditions?) {
I've got a zoomable map within a frame, and of course I don't want it to be dragged out of view, right?

So, how do I set the startDrag (L,T,R,B) parameters when it's a different size when it's enlarged (zoomed)?

Would it be advisable to somehow set multiple conditions to do something like this? (if so, how would I do it?)


if ( between Size>100 AND Size<200) {
startDrag(this, false,400,150,600,250);
}
if ( between Size>200 AND Size<400) {
startDrag(this, false,500,250,500,150);
}


Would it be advisable to do something like that? If so, how would I code it?
If not, what would be a better idea?

...I swear, adding this zoom feature added a whole level of complexity to this map that I've never imagined. PLEASE HELP!

ThanX!

View Replies !    View Related
Multiple If Conditions
how do you have multiple if conditions without nested if's

View Replies !    View Related
Multiple Conditions For Variables
Hey there,

Hope this is an easy one... Have an input txtbox that I want to test true for multiple inputs - ie. the user can enter
1,000
1000
1000.00
1,000.00

and they will all test true... easy?

Thanks, Josh

View Replies !    View Related
[problem] Multiple Conditions
How I would do multiple conditions.

b, c, d and e are all integer

Old style:

if(b==1){
function();
}
if(c==1){
function();
}
if(d==1){
function();
}
if(e==1){
function();
}

View Replies !    View Related
Multiple Conditions On MC Buttons
Greetings,

I'm building a portfolio web site for my freelance business. Essentially I have five Movie Clip buttons across the top: "About Us," "Portfolio," "Capabilities," "Clients," "Contact."

When the Portfolio MC is clicked, a sub-menu animation drops down with five other Movie Clip buttons leading to various sections of my portfolio, e.g., print ads, design, direct mail, etc.

The other main Nav MC buttons, "About," "Capabilities," "Clients" and "Contact," each have a drop-down panel animation that will contain info/description regarding that topic.

What I'm trying to do is when one of the main Nav buttons is clicked, I want it to be able to check and see if any of the other MC/buttons' panels are open and close those first, then run the panel animation for which the MC/button was clicked.

I sort of have it working, but not really in the way I want. For instance, if the "Capabilities" panel is open and the user clicks on the "About Us" button, the "About Us" panel runs its animation, but the "Capabilities" MC remains open until or unless you click on the "About Us" button a second time. Plus, as it is right now, even if I could figure out how to open/run one animation while closing the other, the animations would run simultaneously, rather than consecutively like I'd prefer.

Heres the code I have so far. I know it's far from efficient or even very well coded. But I'm doing the best my mental capabilities will allow while trying to learn actionscript and get this site working.


//////////////MY FUNCTIONS//////////////

function closeWindows() {
if (_root.portfolioMenu_mc._currentframe == 1) {
this.gotoAndStop("noPortMenu");
} else {
_root.portfolioMenu_mc.gotoAndPlay("closePortMenu" );
}
}


////////////////////////////////////////


/////////MAIN NAV BUTTON FUNCTIONS///////////
aboutUs_mc.onRollOver = function() {
this.gotoAndPlay("StartAni");
};
aboutUs_mc.onRollOut = function() {
this.gotoAndPlay("EndAni");
};



aboutUs_mc.onRelease = function() {
closeWindows();
if (aboutUsInfo_mc._currentframe == 1) {
aboutUsInfo_mc.gotoAndPlay("openInfo");
} else {
if (aboutUsInfo_mc._currentframe == 16) {
aboutUsInfo_mc.gotoAndStop("info");
}
if (capabilitiesInfo_mc._currentframe == 16) {
capabilitiesInfo_mc.gotoAndPlay("closeInfo");
} else {
if (clientListInfo_mc._currentframe == 16) {
clientListInfo_mc.gotoAndPlay("closeInfo");
} else {
if (contactUsInfo_mc._currentframe == 16) {
contactUsInfo_mc.gotoAndPlay("closeInfo");
}
}
}
}
};


/////////

I have one small function to check and see if the sub-menu is open and if so, to close it, "closeWindows()." Otherwise, my thought was to place basically all the code that's checking to see if any of the other main Nav panels are open, but rearrange the code so that it starts off looking at frame 1 of the particular button that was clicked, i.e., "About Us, check if its animation is sitting on frame 1 and if any of the others are sitting on frame 16 ....", "Client List, check if its animation is sitting on frame 1 and if any of the others are sitting on frame 16 ....", etc.

I hope what I've written makes sense. It's taken me about forty minutes write this question out, which for me is a lot of time; It's time I've lost on my paying work, so I'm hoping my post yields help that will increase my skills and justify future billable hours.

I appreciate those of you who take a minute to look this over and give me your thoughts.

Thanks,
bfg

View Replies !    View Related
[F8] Multiple Conditions Go To New Frame HELP
I need for this timeline to go to another frame after all these buttons have been rolled over, but can't figure out the code. I'm new at the trying to use conditional statements.



PHP Code:



stop();coffee_after_mc.setProperty._alpha = 0frame_after_mc.setProperty._alpha = 0monitor_after_mc.setProperty._alpha = 0pencils_after_mc.setProperty._alpha = 0still_smiln_mc.setProperty._alpha = 0nice_try_mc.setProperty._alpha = 0say_cheese_mc.setProperty._alpha = 0lovin_life_mc.setProperty._alpha = 0coffee_before_mc.coffee_btn.onRollOver = function() {        unloadMovie(coffee_before_mc);        setProperty(coffee_after_mc,_alpha,100);        setProperty(still_smiln_mc,_alpha,100);        still_smiln_mc.play();        onClipEvent(load){loaded=false;}}frame_before_mc.frame_btn.onRollOver = function() {        unloadMovie(frame_before_mc);        setProperty(frame_after_mc,_alpha,100);        frame_after_mc.play()        setProperty(nice_try_mc,_alpha,100);        nice_try_mc.play();}monitor_before_mc.monitor_btn.onRollOver = function() {        unloadMovie(monitor_before_mc);        setProperty(monitor_after_mc,_alpha,100);        monitor_after_mc.play()        setProperty(say_cheese_mc,_alpha,100);        say_cheese_mc.play();} pencils_before_mc.pencils_btn.onRollOver = function() {        unloadMovie(pencils_before_mc);        setProperty(pencils_after_mc,_alpha,100);        setProperty(lovin_life_mc,_alpha,100);        lovin_life_mc.play();}if (coffee_before_mc, loaded == false && frame_before_mc,loaded == false && monitor_before_mc,loaded == false && pencils_before_mc,loaded == false) {gotoAndPlay("cta");}




*edit: added php tag to the code.

gparis

View Replies !    View Related
If Thens With Multiple Conditions
I'm making a flash game and I want to make it do something whenever neither the left nor the right arrows are pressed. I said if left is down then leftpressed=true and otherwise leftpressed=false. I did the same for the right button. Now how would i make an if then that says "if leftpressed= false and if rightpressed=false then do something"?

View Replies !    View Related
Multiple Conditions For One If Statement?
hey guys!

I have this movie im working on, and I need to do a conditional statement that has multiple conditions. Something like the following:

ActionScript Code:
if (_root._xmouse>=500 AND _root._ymouse>400) {
    logos_mc.nextFrame();
}
Understand what I mean?

I searched the forums, but couldnt find what I was lookin for.

Thanks a bundle guys.

Scottizzle

View Replies !    View Related
Multiple Conditions On An If Statement
Is it possible to have multiple conditions on an if statement?

I need an If statement to work when two keys are up
For example:

ActionScript Code:
onClipEvent (enterFrame) {
    if (Key.isDown (Key.RIGHT, Key.LEFT) == false) {
    trace ( "bleh" )
    }
}

However, it only stops tracing when the right key is down, but not the left one.

Is there any way to do this?

Thanks,

|/|.|/|.

View Replies !    View Related
If Statement/ Multiple Conditions
on my MC load...

onClipEvent(load){
actionGiraffe = false;
actionHippo = false;
actionZebra = false;
actionElephant = false;
actionLion = false;
}

now I have different MC's that when clicked change the variable to true...

on (release) {
trace("giraffe click");
actionGiraffe = true;
}

I have this script on each of the animals when clicked.
now.... at some point I need to test to see if all the variables have been changed to true so I can execute another script. the "training from the source advanced action script" book says the following...

"some times your if statement needs to analyze multiple conditions before taking a single action or set of actions..

if (moneySaved > 500 && billsPaid == true) {
buyStuff()
}

so... adapating that to my script I should add the following to the end of each click...

on (release) {
actionLion=true;
if(actionHippo = true && actionGiraffe=true && actionZebra=true && actionElephant=true) {
_root.gotoAndPlay(305);
}
}


but this is the error i'm getting:

Left side of assignment operator must be variable or property.
if(actionHippo = true && actionGiraffe=true && actionZebra=true && actionElephant=true) {



any ideas why this wouldn't work? I have also tried

on (release) {
actionLion=true;
if((actionHippo = true) && (actionGiraffe=true) && (actionZebra=true) && (actionElephant=true) ){
_root.gotoAndPlay(305);

This one didn't work either.

Please help

View Replies !    View Related
Most Effient Way To Do Check For Multiple Conditions
I'm trying to make my code as efficient as possible. My general style of programming is to write it as simple as possible and then to come back through and basically re-write code that I know works into a loop, or some more efficient way of programming.

So, enter this page. It works just fine - but I'm POSITIVE that there's a more efficient way to write this section of code. The part I'm trying to clean up is the part that takes the angles of the triangle and figures out what type of angle is formed.

Here's the code:

Code:
// SERIES OF IF STATEMENTS THAT CHECK FOR EACH TYPE OF TRIANGLE
if (obtuseCall == true){
if ((alphaAngleFinal > 90) || (betaAngleFinal > 90) || (gammaAngleFinal > 90)){
trace("This is an obtuse Triangle");
problemSteps_mc.gotoAndPlay("obtuse");
}
} else if (equilateralCall == true){
if ((betaAngleFinal == 60) && (alphaAngleFinal == 60) && (gammaAngleFinal == 60)){
// IF FOR EQUALATERAL (ALL SIDES EQUAL EACH OTHER)
trace("This is an equilateral");
problemSteps_mc.gotoAndPlay("equilateral");
}} else if (isoscelesCall == true){
if ((alphaAngleFinal == betaAngleFinal) || (betaAngleFinal == gammaAngleFinal) || (gammaAngleFinal == alphaAngleFinal)){
if (alphaAngleFinal != 60){
trace("This is an isosceles");
problemSteps_mc.gotoAndPlay("isosceles");
}
}
} else if (rightCall == true){
if ((alphaAngleFinal == 90) || (betaAngleFinal == 90) || (gammaAngleFinal == 90)){
//IF FOR RIGHT TRIANGLE
trace("This is a right Triangle");
problemSteps_mc.gotoAndPlay("win");
}
}


So, what's going on is that when the movie clip on the left calls the variables that end in call. For example, when the movie plays to Equilateral, the last frame calls the variable 'equilateralCall = true' and the rest false. This way it can only look for triangles that fit the description of a equilateral triangle.

Here's a link to the movie playing.
http://www.biscuitcleaver.com/flash/trig.html

What are your thoughts?

View Replies !    View Related
Puzzled If Statement With Multiple Conditions
I want to set multiple conditions for an if statement, but I don't want the conditions to all have to be true, I want to say if (a or b or c or d, etc. is true) then do this. I don't want to say if (a && b && c && d, etc. is true). Is it possible to have an if statement with an "or" in the condition? If so, what's the proper syntax for that?

View Replies !    View Related
Switch/Case Multiple Conditions
hi!

I have this switch here .. which doesn't seem to be working..


Code:
Power = 100;
switch(Power){
case 0<Power and Power<140 :
trace("level1");
play();
//==== level 1 ====//
break;
}
Could someone tell me what it is i'm suppose to do?

Thanks!

View Replies !    View Related
Multiple Conditions For A Single Button
Hey all....

I have a small problem. I don't know how to code this....

I made a trivia game, and there is a final button that will show you the score you got on the quiz.
When the button is clicked, based on the score, it will play a movie clip with "you scored 10%", etc...

There are 5 possible outcomes, 20% 40% 60% 80% 100%..
When the button is pressed, it has to play the movie clip with the corresponding percentage...

Any help is appreciated!

View Replies !    View Related
Puzzled If Statement With Multiple Conditions
I want to set multiple conditions for an if statement, but I don't want the conditions to all have to be true, I want to say if (a or b or c or d, etc. is true) then do this. I don't want to say if (a && b && c && d, etc. is true). Is it possible to have an if statement with an "or" in the condition? If so, what's the proper syntax for that?

View Replies !    View Related
Assigning Multiple Conditions On Movieclip Event Functions
i want to have two calls on a single movieclip event function. like you can on button funtions (like this)


Code:
on(release,releaseOutside)// note multiple calls (release and release outside)
{
// my actions
}
how would i get two calls on a function constructed like the below


Code:
myMovieClip.onRelease = function()
{
// my actions
}
do i seperate them by commas or "[" or ....

thanks!

View Replies !    View Related
Multiple Conditions, Multiple MC's
Hello,

Im stuck here. I am trying to create a code that checks 5 different MC's to see if they're true. If they are, gotoAndPlay (3) if not gotoAndPlay (2).

I can't get it to work. The MC's just send you to frame 3, not checking if the other statements are true.

Script (in the MC)

this._parent.snowplayed = "true";
if ((this._parent.treeplayed="true") && (this._parent.snowplayed="true")) {
_parent.gotoAndPlay('3');
} else {
_parent.gotoAndStop('2');
}
stop();



Script (setting variables)

var treeplayed:Boolean = false;
var snowplayed:Boolean = false;
var birdplayed:Boolean = false;
var earthplayed:Boolean = false;
var siloplayed:Boolean = false;


Help!


Am I targeting the path's wrong?

View Replies !    View Related
"If" With Multiple Conditions
I have 8 items, and when they are all moved to _x = 800, I want the timeline to move to frame 12.
Below I have the script I wrote so far, that isn't working. Please tell me how to write this script correctly.

stop();

if ((_root.l01._x == 800)
(_root.l02._x == 800)
(_root.l03._x == 800)
(_root.l04._x == 800)
(_root.l05._x == 800)
(_root.l06._x == 800)
(_root.l07._x == 800)
(_root.l08._x == 800));

{

gotoAndPlay(12);

}

View Replies !    View Related
HitTest For Multiple MCs
hi All,
this is for a multiple MCs hitTest.
part of my code is:
if{!this.hitTest(_root.bu1) && Key.isDown(key.DOWN)} etc.

This works fine with MC bu1. Now i have quite a lot of these 'bu' MCs. bu1, bu2, bu3, bu4 etc, How can i check them all at once? i tried a 'for' loop but i don't exactly know what i'm doing. I guess i want to be able to say if{this.!hitTest("_root.bu" + count) but i have no clue on how to get there. Any help appreciated!
gparis

View Replies !    View Related
Multiple Hittest
I want to perform multiple hittesting on the following code.
This code works properly for the first section of hittests.

onClipEvent(keyDown) {
k = Key.getcode();
face2y=getProperty(_root.face2,_y);
face2x=getProperty(_root.face2,_x);

if (k == Key.LEFT)
{_root.pt1l=this.hitTest(_root.game2.part1l);
if (_root.pt1l==false)
{setProperty(_root.face2,_x,face2x-11);}
else{}
}
if (k == Key.UP)
{_root.pt1u=this.hitTest(_root.game2.part1u);
if (_root.pt1u ==false)
{setProperty(_root.face2,_y,face2y-11);}
else{}
}
if (k == Key.RIGHT)
{_root.pt1r=this.hitTest(_root.game2.part1r);
if (_root.pt1r ==false)
{setProperty(_root.face2,_x,face2x+11);}
else{}
}
if (k == Key.DOWN)
{_root.pt1d=this.hitTest(_root.game2.part1d);
if (_root.pt1d ==false)
{setProperty (_root.face2,_y,face2y+11);}
else{}
}
}

Now I want to add hittests for other sections so a keypress would look something like:

if (k == Key.DOWN)
{_root.pt1d=this.hitTest(_root.game2.part1d);

//add this hittest
_root.pt2d=this.hitTest(_root.game2.part2d);

if (_root.pt1d ==false)
{setProperty (_root.face2,_y,face2y+11);}
else

//add this part for second hittest
if (_root.pt2d ==false)
{setProperty (_root.face2,_y,face2y+11);}

else{}


With various manipulations, I can get the first one or the second one to work, but I can't get both to work. I've searched the forum and can't find anything on multiples. Can anyone help me with the proper structure for multiple hittests/if statements? It's probably some stupid little thing that I'm missing, but I've wasted a whole day with different configurations, so help please!

pkw

View Replies !    View Related
Hittest Multiple MC's
Hi

I think I'm doing something wrong here and hopefully somebody can help me.

I have a movieclip called "roller" in that movieclip I created another movieclip called "dup". I duplicated that "dup" mc 7 times. On the parent movieclip i put the script

onClipEvent (enterframe){
for (i=1; i<=7; i++){
if (this.hittest(_root.roller["dup" add i])){
_root.dragmovie = this;
_roothitmovie = _root.roller["dup" add i];
}
}
}

So now I can check in the dynamic textfields with the variables _root.dragmovie and _root.hitmovie which movieclip I drag and which one I hit.

this works all fine with the first movieclip.
_root.dragmovie is then _root.roller.dup1
_root.hitmovie is then f.ex _root.roller.dup3 (depending on which one I hit.

Now when I take _root.roller.dup2 as the one to drag
_root.dragmovie stays _root.roller.dup1 (no matter if I first took that one to drag) and _root.hitmovie remains also the same and doesn't change if i hit others.

Help me here please. I know it's something little to change but I can't just find the stupid mistake.

Thx

Tom

View Replies !    View Related
HitTest With Multiple MC's
I'm working on a little game. I have a little player that moves around. Then I put in mc's (that represent solid objects) and gave the MC's a hitTest to the player that moves around. Only problem is, that the hitTest only works in one of the MC's that represent solid objects.
Thnx

View Replies !    View Related
Multiple HitTest........
Hi all,

There r 3 movieclips..... moving, the condition is only if all the 3 moving movieclips pass hittest to each other the clips should stop.

If the following script is used for detecting hittest with other clip. How can i detect hittest for the 3rd clip at the same time

onClipEvent (enterFrame) {
if (this.hitTest(_root.a)) {
}
}

Pls help me...

Kaustubh

View Replies !    View Related
Hittest, Multiple Mc's On Top Of Each Other
okay,

here's a tough one for me

i'm doing a hittest on several movieclips. problem is, many of the movieclips are on top of each other. so it's affecting more movieclips that i'd like it to.

suggestions?

code:

if(crayon.mc_hit.hittest(wetlands["mc_"+t])){
brandNewColor = new Color(wetlands["mc_"+t]);
brandNewColor.setRGB(theColorPerm);
}

View Replies !    View Related
Multiple HitTest
Can someone help me?

I can't quite sus out how to do multiple hit tests - I would like to have right answers and wrong answers.

Do I need another testObjectArray? I have tried writing another "if this.hitTest" section for the same MC but it does not work...

Have attached the .fla file

Cheers

View Replies !    View Related
[F8] Multiple HitTest
Hi, I have a need to detect whether the mouse is hitting multiple movieclips. For the sake of this thread, I am just showing two movie clips.

Eventually, I will write an array to allow the code to be condensed and applied to each instance, but for the moment, I cannot get my head around why this simplistic test isn't working.

My test code is as follows

myMC1.onEnterFrame = function() {
if (myMC1.hitTest(_root._xmouse, _root._ymouse, true)) {
message.text = "hit";
} else {
message.text = "";
}
};

myMC2.onEnterFrame = function() {
if (myMC2.hitTest(_root._xmouse, _root._ymouse, true)) {
message.text = "hit2";
} else {
message.text = "";
}
};

Why can I not have multiple hit tests, all that happens is that myMC1 works but myMC2 doesn't .....

Cannot get my head around why not. Any ideas are more than welcome and any help is v.appreciated.

Regards,

motorpilot

View Replies !    View Related
[F8] Multiple HitTest Help
I am tiring to create a simple game for a class assignment. In it a character searches for an object, kinda like a maze. My problem is that when I use hitTest it will only works for one instance of a movie clip (In this case a free standing wall). I've tried many different things with no luck. I will attach a simplified version of my problem - flash8. Thanks for any help.

code placed in hero mc, wall is a1

onClipEvent (enterFrame) {
if (this.hitTest(_root.a1)) {
this.speed = 1;
} else {
this.speed =10;
}
}

View Replies !    View Related
[F8] Hittest On Multiple Mc's
Morning all!

Need some help with a problem that I am having with the hittest function.

What I have is a stage with multiple mc's with instance names tile1/tile2/tile3 etc... at present when any of these mc's get hit by another mc with the instance name ball - what I hope do is add a hittest function to the tiles that will tell another group of mc's - instance names shad1/shad2/shad3 etc... to goto and stop on frame 2 when the ball hits the tile mc.

So if tile1 is hit by the mc ball - the tile1 mc disappears and the mc shad1 goes to and stop on frame 2. Does that make sense?!

on all of the tile mc's I have this code to centre the mc's to the stage. This is the AS on the clips;

PHP Code:




onClipEvent(load){startX = this._x;startY = this._y;}








and this is what it looks like when I add what I thought was the right hittest script


PHP Code:




onClipEvent(load){startX = this._x;startY = this._y;}onClipEvent (load) {    if (this.hitTest(ball)) {        shad1.gotoAndPlay(2);    }}







...that code doesn't seem to work though - in fact it doesn't even seem to recognise it!

All of the mc's (ball/tiles/shads) are placed on the main timeline so it shouldn't need any ref to _root. or to _parent. should it?

Anyone put me right???

...please?

View Replies !    View Related
Hittest On Multiple MCs
If I have multiple copies of the same MC, each named wellHole1_mc, wellHole2_mc, etc. and then I have another MC called driller_mc, how do I run a hittest on all of those wellHole_mc's? I want the wellHole_mc to react when the driller is moved over it, but I need to know which of the wellHole_mc the driller is over.

Should I be using the hittest function? Or is there some other way to do this?
Attached is the .fla file I have so far.

thanks
david

View Replies !    View Related
Multiple HitTest
When you hittest something it returns true if the two objects are connected, right? but when I want to have say 3 of the same instances (Y), and i want hittest to tell me if X touching one of those three Ys, is it possible? When I tried it it only worked for one of them...

View Replies !    View Related
Multiple HitTest
I have a scenario where the user drags an item and places it on the corresponding answer in the movie.

What I want to happen is that when the user drops the dragged object, it snaps to the position of the object over which they dropped it. This may not be the correct position. I then want the user to click a button which will check the answers and return to their original position, any answers which are incorrect, leaving behind those items that are in the correct position.

My problem is how to get the object to stick to the item that it is dropped on.

All the target items are called "target" followed by a number.

Any help would be great.


Thanks

Phil

View Replies !    View Related
HitTest() With Multiple Objects
If I have a say, 50 boxes and I want them to explode when they hit eachother, what would be the best way to script it? Is there a way for me to name them something like box01, box02, box03 etc.. and then have the hitTest work with every object containing the word "box" in the name?

View Replies !    View Related
HitTest() With Multiple Objects
I posted this in the General Help forum, but I think I might have better luck here...

If I have a say, 50 boxes and I want them to explode when they hit eachother, what would be the best way to script it? Is there a way for me to name them something like box01, box02, box03 etc.. and then have the hitTest() work with every object containing the word "box" in the name?

View Replies !    View Related
HitTest Playing Multiple Mc
Hi, I've searched through the forum and found this script by oldnewbie which is just what i wanted :

code: onClipEvent (enterFrame) {
// if the mouse IS over the button ...
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
// play the appropriate clip...
if (_root.menu2._currentframe<_root.menu2._totalframe s) {
// go to the next frame of the menu opening sequence
_root.menu2.nextFrame();
}
// if the mouse is NOT over the button
} else {
// reverse play the clip...
if (_root.menu2._currentframe>1) {
// play the previous frame of the clip
_root.menu2.prevFrame();
}
}
}


but what if I wanted to trigger 2 clip at once? Please help.

View Replies !    View Related
HitTest On Multiple Targets
Hey Guys,
I’m trying to setup a MC that has a hitTest that is triggered by multiple targets. Like how do you game developers do this. Like in a shooting game, the bullet will not hit only one target every time. It’s different all the time. So how would you know on a wide range of targets?
Thanks,


Najam D.


UPDATE++++++++++++++++++++++++++++++++++++++++++++ ++++++++
Best Work Around

Quote:




Originally Posted by HeraldofWoe
I think that this will get you on the right track.

(And it specifically addresses your problem Pitchdog)





++++++++++++++++++++++++++++++++++++++++++++++++++ ++

View Replies !    View Related
HitTest Multiple Objects
Hi,

I am currently creating a small game, and I want to do the following:
There is one main character. Whenever the character hits a mc (for instance: block001 or block002 or block003 etc.) then it must gotoAndPlay("dead");
My current script is:

Code:
onClipEvent(enterFrame) {
if(this.hitTest(_root.block001)) {
this.gotoAndPlay("dead");
}
if(this.hitTest(_root.block002)) {
this.gotoAndPlay("dead");
}
if(this.hitTest(_root.block003)) {
this.gotoAndPlay("dead");
}
}
And I could go on for some time (because there are many blocks)...
Isn't there an easier way to do this. I thought of something using the var i. and then with something like i++.

But then it only checks one block (either block001 or block002, etc.) per frame. I want it to check all the hits for every frame. Is this possible with a shorter script then writing out every hitTest for every block?

Thanks,
Death

View Replies !    View Related
[MX] Multiple Objects HitTest
Hi,

I'm trying to break bubbles by shooting bullets, both generated by duplicateMovieClip(). Everytime I create a bubble, I push it into an array, then on my bullets level, I go through the array, see if I hit anything in there. Here's what I have now:


Code:
onClipEvent (enterFrame) {
var b = _root.bubbles.length;
for (i = 0; i < b; i++)
{
var bubble = _root.bubbles[i];

// We've hit the bubble
if (_root.bubble.hitTest(this))
{
trace("touched: " + bubble);
_root.score_txt.text += _root.scoreplus;
}
}
}


bubbles[] is my array containing the name of all my bubbles (bubbles0, bubbles1, bubbles2..) but for some reason my if condition is never true. On my 'actions' layer, frame 1, I have the following:


Code:
bubbles.push("circle0");
for (i = 1; i < tmi; i++)
{
circle0.duplicateMovieClip("circle" + i, i);
bubbles.push("circle" + i);
}


'tmi' is a variable that changes depending on how many bubbles I want for this level.

Anyone sees what's wrong with this? Other than the fact that it's probably not the best wat of doing it? time is a bit limited and I'm far from being a pro, and this is all I could come up with.

Thanks a lot!

EDIT: Might as well post it here. I have another little problem. When a bubble hits the character, I want to go to the scene called 'Dead', so on my main circle I have the following code:


Code:
onEnterFrame = function () {
if (_root.char_mc.hitTest(this)) {
trace("You die.");
gotoAndStop("Dead", 1);
}
};


The trace works, but the gotoAndStop() doesn't. I'm sure the scene exists, and I have the exact same code on my first scene (Intro -> Game -> Dead)

View Replies !    View Related
[CS3] Multiple Hittest Using Arrays
Hello,

I am creating a game where a shopper moves horizontally in a store and runs into different items. When the shopper "hits' an item, he/she displays a speech bubble identifying the item (produce, milk, shopping bag, etc..). I realize that I need to utilize a multiple hittest between the shopper (shopper_mc) and the many items in the store (shopping_bag_mc, produce_mc, milk_mc, etc..).

Here is my current code which resides on a layer in a movie clip called background_mc. The current code does not work.

/////// code begins //////
function hit(){
if (_root.shopper_mc.keyFlag==false){
if (_root.shopper_mc.hitTest(info_desk_mc)){
_root.shopper_mc.attachMovie("speech_produce_mc" , "instance1", 1, {_x:-28, _y:-235});
}
if (_root.shopper_mc.hitTest(shopping_bag_mc)){
//_root.shopper_mc.attachMovie("speech_shopping_bag_ mc", "instance1", 1, {_x:-28, _y:-235});
}
if (_root.shopper_mc.hitTest(milk_mc)){
//_root.shopper_mc.attachMovie("speech_milk_mc", "instance1", 1, {_x:-28, _y:-235});
}
} else {
_root.shopper_mc.createEmptyMovieClip("empty_mc", 1);
}
}
setInterval(hit,4);
///////// code ends ////////

The shopper_mc is at the root level of the movie and all of the product movie clips reside in the movie clip background_mc. I hope this is clear.

Thank you for your time

View Replies !    View Related
HitTest With Multiple Objects
heres my fla, I want the hitTest to detect a collision with each wall, but it only works on the first wall, the one below the ball, Is this possible? I know its possible with a for loop and naming each wall wall1, wall2... but Is it possible with just one name?

BTW why doesn't an actionscript based forum allow you to upload .fla files???

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved