ActionScript 2.0 :: HitTest With Many Of Same Movieclips?
Jan 26, 2005
Im making a game in which you controll a turret and it spews out bullets like mad..Usually i know you would name each dupicalted movieclip sumthing like"movieclipname"+nextnumberBut i was in this case hoping i could name em all "bullet" for the simplicity of hittesting
using
bullet1.duplicateMovieClip("bullet1", this.getNextHighestDepth(), {_x:bx, _y:by, xs:Xmov, ys:Ymov});to duplicate
and
[code].....
View 9 Replies
Similar Posts:
Jan 26, 2005
Usually i know you would name each dupicalted movieclip sumthing like "movieclipname"+nextnumber But i was in this case hoping i could name em all "bullet" for the simplicity of hittesting using bullet1.duplicateMovieClip("bullet1", this.getNextHighestDepth(), {_x:bx, _y:by, xs:Xmov, ys:Ymov});
to duplicate
and
if(this.hitTest(_parent.bullet1)){ // is an onEnterFrame
trace("wuuuuuuuuuu");
to c if anything is happening
nothing however happens, i am not ceeing the trace message.. Can i not have many movieclips named the same, or is there somethign else i need to consider
View 9 Replies
Jan 15, 2009
I am designing a flash game and I am having a bit of trouble with the Actionscripting, I wondered if you might be able to help me? I will try and explain how the game should function and I attach a JPG that shows the rough layout as well, hopefully from that you may be kind enough to point me in the right direction.
How it should function The idea is you have a glass that you control, left and right keyboard arrows control left and right movements and it only moves on the _x axis and the _y axis always stays at it's current value, this works fine and I have managed to add actionscript to the glass movieclip to do this, the movement also has gravity and friction which means the glass slides on a little even when you move to go the other way.
Using the Glass you need to collect falling object movieclips, there are two types, good and bad. When you catch the good it adds to your score and when you catch the bad it deducts from your score.
The falling objects need to be random and I have successfully managed to get 1 movieclip to fall by using actionscript code and also I have managed to set the _x position as random each time , the actionscript to do this has been applied to the falling object.
[Code]...
View 3 Replies
Mar 15, 2009
I'm trying to hitTest two duplicate movies clips. One is a bullet and the other is an enemy. I have them properly duplicating, but I cannot figure out how to detect a collision between the two. I've trying everything I can think of, and so far I've only been able to get the hitTest working between the original enemy and the bullet duplicates.Here is the code for duplicating the enemy:
Code:
bb++;
duplicateMovieClip(_root.target, "t"+bb, bb);
[code].....
View 2 Replies
Jan 3, 2011
I'm creating a platform game, and I have those boxes which needs hitTests on all sides - including the bottom.I want my hit areas to have the same instance names. With that I mean, that I want only one instance name for all the bottom hits, one instance name for alle right hits - and so on. If it's possible. 'Cause else there will be so much actionScript code to write.I've been trying to simply make a normal hitTest on for example hitGround, and then place two movieclips with the instance name hitGround, but the hitTest function only works on the last added movieclip with that instance name.I have also been trying to look up some for each in-arrays, but I don't really get the meaning of how to use them.
View 2 Replies
May 3, 2010
Code:
if(_root.selmovie.hitTest(this._parent)){
_root.hit.text="it worked";
}
Why doesnt this work? I want to avoid naming all of the movieclips that this hittest is to apply to but this._parent isnt working...
View 4 Replies
May 3, 2009
I have a character, he stays in the center whilst the surroundings move instead (scrolling). There is a block and when you walk into it, I need it so you cannot walk through it or get stuck in it. Here is my code below but, its very buggy, this is obviously been done before and may be simple, once I learn it I wont need to ask again. Iv tried other things but they dont work.[code]
View 6 Replies
Jul 31, 2009
I've got some flash 2.0 code that is supposed to add 100 points after a hitTest.
Code:
function onEnterFrame(){
connectA();
var strandID:Number
function connectA(){
for (var i = 0; i < 100; i++) {
if (this.hitTest(_root["A_" + i])) {
this.strandID = i;
_root.total = _root.total + 100;
}}
The problem is that it adds 100 points 70 times per second (the frame rate). It's supposed to add 100 points and stop. Here's a little more info: the hitTest makes two movie clips move across the screen together. Maybe because they're constantly hitting as they move, I don't know.
View 6 Replies
Jun 8, 2006
i searched everywhere, i was not able to find a solutionmy xml menu implementation use a "main" Menu class. This class parse the xml file and create an aeeay of MenuItem class.MenuItem costructor is (stripped down version) something like this:Code:function MenuItem(name: String, url: String, parent_mc: MovieClip)parent_mc is a reference to the "container" MovieClip for Items (generally an emptymovieclip made by Menu class)
View 3 Replies
Dec 12, 2002
Does anyone know how to use hitTest with two movieclips so that it would detectthe collision of the visible part of the MC, not the **** bounding box???
View 2 Replies
Nov 23, 2003
I have 2 Movieclips, box and car, and I want them to bounce backwards 10 pixels when they hit. I have a little understanding of hit test but do not know how to make something happen when hit test occurs. And it would be great if you could make the movieclips "move" back 10 pixels instead of automatically jumping 10 pixels back.
View 1 Replies
Apr 28, 2007
[Code]...
NOTE: The following text is my problem and observations, if you afraid to read it all, my problem is easily guessable within the code go ahead and crack at it without my explanation :-p I'm having some trouble with using hitTest(); with movieclips within arrays. I wanted to build a function that checks the hitTest of Movieclips in arrays because the array is dynamic and it would run more efficient and faster this way.
As you may notice it doesn't check just the movieClip in the array, but a movieclip 2 scopes within it. I feel that this is my problem. I noticed in my debugger that that mc doesn't show up, but i put an onLoad event on it to trace its existence when loaded and it shows up fine. I wonder what I'm doing wrong.
View 2 Replies
Jan 15, 2009
i just would like to know how to create an "hitTest" script inside a movieclip that is actually part of that hitTest code?I mean... I have mc A, and mc B. and the current hitTest code im using (that is on the timeline) makes mc A, destroy mc B when collide with it... but there are many mc B on the stage (with the same instance name) so, when mc A collide with one mc B, it destroys ALL mc's B... but i want it to destroy only the mc B that he collides, not all the others... maybe an hitTest script inside a movieclip B would work (somethig like "if MC A hitTest ME = i die" (not all the others)).
View 1 Replies
Feb 8, 2010
i am controlling a tractor mc with right and left keyboard keys and let the user move the tractor till it reach a certain point where it touch a mc i want to go to a certain frame and stop the keyboard event listener and also the hit test listenerso finally the tractor is moved by user till it touches the mc then we will jump to a certain framethis certain frame will not have both of the tractor and the mcPHP Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.display.MovieClip;
[code].....
View 1 Replies
Aug 6, 2010
I m trying to make sense of how to load a swf into a parent MovieClip and allow them to communicate.I ve attached two zip files � one which works fine and the other doesn�t. Unfortunately (for me), the one which doesn�t work is closer to my current project.I need to load movieclips into the parent movieclip. The parent movieclip has controls which rely on values parsed from the child movieclip.In the parent movieclips I wait until the loading is complete and so the values should be passed. However, the values aren�t passed unless I use a button (or timer), to pass the values (see the working exampes).The code which doesn�t work is:
Parent movieclip:
ActionScript Code:
stop();
var myLoader:Loader = new Loader();[code].............
View 5 Replies
Dec 19, 2009
I have two SWF-Movies. One is exported into eht other as Child.Can I instance the Objects of the two libraries in all places, where ActionScript is possible? (In Keyframes of the MovieClips and in external class definitions.)
View 3 Replies
Sep 9, 2011
Looking for a way to stop all movieclips both are the stage and that are children of the ones on the stage.
I toyed with looping thru stage's children so I can first target clips on the stage. But I am getting error.
for (var i:int = 0; i < this.numChildren; i++) if (this.getChildAt(i) is MovieClip)
{
this.getChildAt(i).stop
}}
View 5 Replies
Feb 5, 2009
I have created 25 MovieClips on the stage in 5 X 5 matrix.How can I treat 5 movieclips in each row as a group of movieclips so that I can apply same set action to them?(Similar to RadioButton functionality. )
View 6 Replies
Sep 15, 2010
Printing an MC is easy enough. But I am having trouble printing an MC which has multiple MCs inside of it. They just don't get printed.
I am trying to avoid printAsBitmap.
View 5 Replies
Oct 21, 2010
I want to test mc animations without having to hit F12 to see if they work correctly. For instance, if I have an animation movieclip and then I make another movieclip and drop that aforementioned movieclip within, and animate [via the timeline or library preview] I'm unable to see on-the-fly what my animation looks like... it only shows the top most nest, unless I F12 it.
So if I have a character blinking eyes (one movieclip) and then I create another movie clip of the face, and put that aforementioned movieclip within, the preview animation within the library does not show how it'll be viewed when F12'n it.,,,, it'd be great to see your animations on the fly.
View 1 Replies
Oct 30, 2007
why does a MC inside another MC have different _x and _y values than the main timeline?What I am trying to do right now is animate a MC inside another MC then get the main MC holding everything to move where that new MC ended animating at (it's part of a game I'm making.)
I know it's confusing but Flash shows the cursors current X and Y in the info panel, which is the same as the main timeline. Yet inside the movieclip, an x of 76 and a y of 277 on the timeline is -195 and -30.9 (respectively) inside the MC.How do I fix it so I can get the _x and _y values to match up so I can tell the main MC to reposition itself to the new X and Y (of the inside MC)
View 1 Replies
Mar 27, 2008
I have a movieclip called mapWindow, inside mapWindow are dynamically created movieclips of various sizes. The movieclips inside the mapWindow don't take up the entire space of the mapWindow and thus I use a startDrag on the mapWindow upon detection of a mouse press. The problem is, I don't want the start drag to start if the mouse is detected over any of the child movieclips inside mapWindow.
I have a few ideas of how to proceed, but I'm not sure how to reference all child movieclips of a particular movieclip - or something along those lines.
It would be easy to use the hittest function if I knew how to reference all the movieclips I need to, but alas...
View 1 Replies
May 14, 2009
I have a movie clip called frog who moves along the screen, I want him to jump when he hits any other movie clips. I can make him do so with the code below, the problem is that if I write the same function for the other movie clips it doesnt work, it still works on the first one but none others. I have tried attaching an onCilpEvent on both the frog and on all the other movie cilps so no avail.
function hitBaby(){
if(_root.babyWord.hitTest(_root.frog)){
_root.frog.gotoAndPlay("frogB");}else{ _root.frog.gotoAndPlay("frogA");}
[code]....
View 3 Replies
Nov 20, 2009
Using Flash CS4 - AS 3.0
how to control a movie clip using a separate movie clip.
on scene 1 (2 frames long), i have 2 movie clips.
-bFind (24 frames long)
-textEffects (14 frames long)
i want to jump to frame 7 of the textEffect movieClip when i hover over bFind
i have my AS code in the first frame of the movieClip called "Bfind"
Code:
stop();
addEventListener(
MouseEvent.MOUSE_OVER,
[Code].....
View 5 Replies
May 5, 2010
I'm using flash MX 2004 Professional. What im trying to is the following: I have 9 movie clips, each has a "closed" and "open" state. Basically, when I click no.1 I want it to animate open, and then, when I click no.2, it must first check if any of the other clips are in their "open" state and if so, close them. I've worked with the following, but it doesnt seem to be working:
[Code]...
View 4 Replies
Oct 5, 2008
I am still transfering from AS2 to AS3 and right now i am having a very annoying problem. THE STRUCTURE:
Maintimeline contains 2 buttons that i want to use to access children in a bunch of movieclips. rectangle_mc has circle_mc circle_mc contains xx_mc xx_mc contains wtf_mc placed on frame 1 on maintimeline Why can't flash see my nested movieclips? I remember in AS2 you could go down the line:
[Code]...
View 15 Replies
Jul 30, 2010
I am starting with AS3 programming icm with Flash Builder 4.I have created a "Main" class which is the initial stage.On this stage there is a movieclip called mcMain.In this mcMain is 4 other movieclips: mcStats1 mcStats2 mcStats3 mcStats4 .How can I access these mcStats1-4 from the code to make them go to another frame?I tried:
var t:MovieClip = MovieClip(getChildByName("mcMain"));
t.getChildByName("mcStats1").gotoAndPlay(3);
But that just keeps giving me null reference errors:TypeError: Error #1009: Cannot access a property or method of a null object reference.
View 4 Replies
Nov 17, 2010
I used to work in AS2 and something like this worked:
mc1.mc2.onRelease = function () {
mc3.gotoAndStop(2);
}
But converting it to AS3, it doesn't work anymore.
function goMC (e:MouseEvent):void {
mc3.gotoAndStop(2);
}
mc1.mc2.addEventListener(MouseEvent.CLICK, goMC);
What am I doing wrong? I can't seem to control movieclips within movieclips.
View 2 Replies
Feb 25, 2009
i have this drag and drop thing basically when i drop the item on top of its slot i want it to do a hittest to set the depth to a number assigned to it. so lets say I drag an item called Item to a spot called slot i want it to do like item on hit test to slot set depth(2) lets say.
View 1 Replies
Apr 7, 2010
i'm trying to build this simple game for school: you've got a catapult which launches a "bullet" and you will have to aim it to hit a certain point. Now the whole catapult part and shooting the "bullet" works, but now it has to respond when it hits something, and that's where i'm stuck.
[Code]...
View 1 Replies