ActionScript 3.0 :: Different Movieclips Same Instance Name - HitTest
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
Similar Posts:
Jul 7, 2011
I am trying to make the instance 'red' be removed when all 3 objects have hit it here is my code:
var hit = 0;
addEventListener(Event.ENTER_FRAME, hittest);
function hittest(e:Event){
addChild(blue);addChild(green);
addChild(pink);
addChild(red);
[Code] .....
View 2 Replies
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
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
Dec 13, 2009
I have a stage with instances of bauble_mcs on it that are attached by the document class of the main timeline (can someone tell me what the right term is here? I don't know what I call the main time line in AS3).I then have instances of snow_mc attached by the same class. Inside the snow_mc I want to test to see if it is hitting any bauble_mcs but I don't know how!
inside snow_mc I am trying:
PHP Code:
if(this.hitTestObject(this.parent.bauble_mc)){
}
to which flash says:
1119: Access of possibly undefined property bauble_mc through a reference with static type flash.displayisplayObjectContainer.
View 1 Replies
Sep 25, 2005
I've got this code on my frame:
if (_root.count <= 20) {
duplicateMovieClip("_root.clip", "clip"+_root.count, _root.count);
_root["clip"+_root.count]._x = random(500)+50;
_root["clip"+_root.count]._y = random(1)+20;
}
And I need to figure out how to have the hitTest see the randomly generated instances of this duplicated mc.
I can get the hitTest to see the first instance (called "clip"), but then it doesn't see all the rest.
Here's the code I have on the hitTestMC:
onClipEvent (enterFrame) {
if (_root.chime1, hitTest(_root.clip)) {
_root.chime1.gotoAndPlay("play1");
}
}
View 1 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
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
Feb 18, 2010
Is it possible to compile movieclips to swc with the instance name as property name? This happends when I add a dynamic text field, but i would like this also on some UI elements.
View 1 Replies
Jan 27, 2012
I have 2 copys of the same Movieclip on the timeline and I need them both to do the exact same thing, so I figured I'd give them the same instance name.
I have an event listener on the stage that listens for a mouse click and then checks what has been clicked usiing a switch statment, but the switch statment only picks up one instance of the movieclip, the other one comes up as the default.
Mainly what i'm asking is, is it possible to have to movieclips on the timeline with the same instance name?
public function Main() {
stage.addEventListener(MouseEvent.CLICK, doStuff);
}
public function doStuff(e:MouseEvent):void {
[Code]....
View 2 Replies
Aug 28, 2010
I've been working on a game recently. I wanted to know if I can have two movieclips (Tabl1_ON & Table2_ON) have the same instance name, as long as they are in different movieclips. Will it cause an error? or will AS3 be kind to me.
View 1 Replies
Feb 3, 2009
I have one MC on stage with instance name "box". That MC duplicates by using this script:
Code:
duplicateMovieClip (box, newname="box2", this.getNextHighestDepth());
box2._x = xPoz;
box2._y = yPoz;
So the new MC is now called "box2".
Inside original MC "box", I have one button. After click on that button, I need to know on which MC I clicked. box, or box2. I tried to use:
Code:
trace (this._name);
But, that get me only instance name of the button.
View 4 Replies
Apr 27, 2011
I'm following a tower defence tutorial and part of the code is set up so I can build towers on the "grass" movie clip. I wanted to add more patches of "grass" and gave them all the same instance name so I can be able to place towers on them, but I have the problem that I can only place towers on the first item I placed and has the instance name of "grass". I can't seem to place towers on the other patches of grass.I removed the instance name of the first patch of grass and it let me build towers on the second patch, but the second patch only.
[Code]...
View 1 Replies
Feb 21, 2010
I have a movie clip and inside that movie clip there is a button. I will be copying this movie clip 40+ times. When you click the button it must seek out the reference name of the movie clip it is nested in. The point of the script on the button is to make all other boxes but its self vanish. The script needs to know what box it is so it can make all boxes but it's self vanish. I know that _name returns the name of the object the code is on but what about the movie clip the object is in maybe _parent._name?
View 5 Replies
Nov 1, 2010
I've got a movieclip in my library called primaryCommMC.I'm loading these 5 times onto the stage and naming them commMC0-4 using the following:[code]Right now they're all obviously loading on top of each other. I want to stack these movieclips on top of each other so the first movieclip will be at y=0 and the following at y=(the height of the proceeding MC + 5 (a little gap)).
View 1 Replies
Feb 4, 2010
It might sound confusing so let me explain the situation. I made a movieClip. And in that movieClip I have a dynamic textfield set. I called this textfield "AmmoCount".I dragged this movieClip onto the stage several times and each time I called on the AmmoCount varible in each movieclip and gave it a different value. I get the following error TypeError: Error #1009: Cannot access a property or method of a null object reference.[code]
When I trace these objects, weapon1.AmmoCount works, but weapon2.AmmoCount shows as empty. Yet they both contain a value in them. Ive used the weapon1 property and weapon2 property countless times and there is no doubt that it works. so why doesnt it work for weapon2. but for weapon1. Below is some code that I called on earlier that shows they work.[code]these worked! but when I called on the AmmoCount text box within them, I get the error. The following image you can find within the weapon1 movieClip
View 1 Replies
Dec 18, 2009
I have created a number of Movieclips as part of my Navbar such as About Us, Contact etc. I'm using setInterval to send them to a function that springs them open one after another using the tween class. The they are dynamically generated and positioned using the following code, however when I want to use them as buttons by using onRollOver or onRelease they act like I'm not scoping them correctly. In other words the cursor does not change into a hand when over them. This is a setInterval issue as if I have them open just using attachMovie, the scoping works just fine.
The actual code is as follows:
function aboutUs () {
var mcAboutUs:MovieClip = this.attachMovie("mcAboutUs", "aboutUs_mc", 20, {_x:197, _y:520});
var x_elasticTween:Tween = new Tween (aboutUs_mc,"_xscale",Elastic.easeOut,0,100,1,true );
var y_elasticTween:Tween = new Tween (aboutUs_mc,"_yscale",Elastic.easeOut,0,100,1,true );
clearInterval(_global.intervalID1);
} function setIntervals() {
_global.intervalID1 = setInterval(this, "aboutUs", 1000);
There are more in here, each going to its own function to attachMovie and Tween them. This all works fine.
setIntervals();
this.aboutUs_mc.onRelease = function() {
OnRelease is suppose to activate another function that generates the "About Us" page but nothing happens as if the instance is not been scoped.
page_aboutUs();
}
View 2 Replies
Oct 28, 2010
cat 1 and cat2 are the instance names of the movieclips when using the trace command to find out the values of the array this returns both movieclips undefined.Is that correct output window (undefined; undefined)how can trace name of movieclips in the array.[code]
View 5 Replies
Jun 13, 2009
Is it possible to iterate through MV copies with the same instance name? It would be very useful for my project.
View 5 Replies
Jun 1, 2004
getting angles, of two movieclips that are on my stage. With instance names: circle1,circle2. I read that I should use the function Math.atan2 to get the angle, in radians, then I convert it to degrees, but it doesn't make sense, the angles aren't correct.. Here I paste the code I use (its AS not PHP don't know how to add the AS tags):
[Code]...
View 2 Replies
Nov 12, 2004
I have an actionscript that controls the movieclips _alpha through instance names. The problem is: I habe a lot of movieClips and I will use the same action in all of them. The same action, just changing the instance name.
View 4 Replies
Oct 2, 2006
Right check this:
/////////////////////////////////////
/////////////////////////////////////
///////////////FUSE//////////////////
/////////////////////////////////////
import com.mosesSupposes.fuse.*;
[code]....
But the problem is the thumbMov movies will obviously have a uniquely generated instance name i cant target directly due to the "for" loop..How can i modify what ive done to target any of the thumbMovs with the FUSE functions?
View 3 Replies
Mar 3, 2008
I am using attachMovie in a for(var i=1; i<50; i++) loop.Everything loads fine, but I am having difficulty referencing the dynamically created instance names.I don't want to reference individually ie movieclip1, movieclip2 etc.but more by movieclip[i].Basically - if movieclip instance 1 is rolled over I want to display image 1, and so on?
View 2 Replies