ActionScript 2.0 :: Shapeflag HitTesting Not Working In Movieclip?
Mar 19, 2008I thought maybe I had to use localToGlobal, but they are on the same layer, so it can't be that. It works on the root frame, just not in the movieclip.
View 2 RepliesI thought maybe I had to use localToGlobal, but they are on the same layer, so it can't be that. It works on the root frame, just not in the movieclip.
View 2 RepliesI am trying to make a basic game, and have read all about bitmaps, but they have only confused me, so I am trying to succeed with a more flawed, but basic approach. I couldn't find any comprehensible tutorials on this, so I've tried it on my own, but it doesn't work.Basically I have my character in a movie clip connected to a class, and it is spawned when the movie starts, just like the "wall" class here. It populates the stage with a line of boxes, but my problem is that the hittesting only works on the first one.[code]
View 9 RepliesI'm making a game where your character must touch rings (big ovals) that are moving up and down with a motion tween (with easing). I attach these movies and push them into an array. For the hittesting, nothing is accurate. Since a movieclip inside the ring movieclip is moving up and down, the boundary box is much bigger than it should be when hittesting. If I use the x/y method, it triggers the hittest when my character is in line with the reference point. It should trigger when the middle of the character hits around the middle of the ring.
View 2 RepliesWhy isn't this working?I've tried everything.Here's a resume on what's the part with errors:
Code:
var Bl:Object = {x:-18, y:174};
_parent.mwall.globalToLocal(Bl);
[code].....
I'm a newb. I have a problem with a file I'm working on. HitTest with shapeflag works properly in a movie clip, but NOT in the main timeline. When I switch it to a simple HitTest with 2 objects and no shapeflag it still works.
I've attached the .fla. In this example you adjust the sliders to highlight different biomes. Everything works in when I TestScene the movie clip, but when I testMovie the whole thing the only hitTest that seems to be functioning is the one for Tropical Rainforest which DOESN'T have Shapeflag.
ok so if i have an obect called square1 and an object called square2 and inside square2 i have hitArea... i want to use shapeflag to detect an absolute true hitTest on just the area of square1 not the bounding box.... i tried this code and it didnt work...
actionscript 2.0
ActionScript Code:
if (_root.square1.hitTest(square2.hitArea._x, square2.hitArea._y, true)) {
I have a question regarding hittest object in actionscript 3. When using events, you can check what the current target is by using e.target or e.currenttarget. I was wondering how this achievable by hittesting?since hittests are not a function.
I need to retrieve info about the hittested object.Here is an example to make it more clear:
ActionScript Code:
if(movieclip1.hitTestObject(movieclip2)){
textfield.text = "this is information selected by the hittest: " + channel[e.target.name].item;
}
I'm working on a project and using hittest to navigate. So it's pretty important haha.
I have a movieclip named Map linked to a class named Map. Inside of the movieclip I have 3 instances of a movieClip hitbox. they are named block0, block1, block2. What I'm trying to do is add them to an array using a for loop. Then in my player class I use another for loop to hitTest against the array. What I'm getting tho is this error:
Code:
TypeError: Error #1034: Type Coercion failed: cannot convert []@2393159 to flash.display.DisplayObject.
at xxx::Player/loop()[Player.as:54] The code from Player.as that the error refers to is here:
[Code]...
I created a .PNG in Photoshop (see attachment) -- now when I make this into a movieclip the bounding box covers the entire area so the hittest activates as soon as my helicopter flies into the bounding box.I looked at adobe's "help" they recommended this code (by the way, I'm using Flash 8):
my_mc.hitTest(x, y, shapeFlag )
my_mc.hitTest(target)
The way I interpreted the code was like this:
onClipEvent(enterFrame){
heli.hitTest(248.1, -38, shapeFlag)
}
I read somewhere that you only use one of the two, and the shapeFlag one is the one to use.The above code I placed into the helicopter MC (named heli) - I set the x & y to where the PNG is.The PNG moves towards the helicopter, so I'm not sure if that makes a difference.I just want that if the helicopter runs into the ceiling or floor, the level resets.However my current actions activate as soon as it hits the bounding box.This is my code in the PNG:
onClipEvent(enterFrame){
this._x -= _root.levelSpeed;
}[code]....
I've tried a lot of things, and nothing seems to be working.
iv gotten hittest to work on me and my friends sites, but with olny one button for the MC to check for. Very simply, how do i get it to check for 2 or more?
View 6 RepliesI've got a game where I need the enemys to hitTest with each other, I'm going to have copys of 3 types of enemys on the stage, instead of giving them all an instance name is it possible to hittest from the libary because I've given them instance names in the library of "enemya" "enemyb" "enemyc"
The code I have got didn't work which was -
Code:
onClipEvent(enterFrame){
if(this.hitTest(_root.enemyc)){
trace("true")
}
[Code].....
I'm looking to run a trace that targets all TextFields on a mouse over, something like this:
PHP Code:
TextField.prototype.hitTest = MovieClip.prototype.hitTest;
onEnterFrame = function(){
[code].....
are there any special rules regarding hittesting? im using this code here and its jus not working at all:
var speed:Number = 0;
var angle:Number = 0;
var angleFish:Number = 0;[code]....
im starting to get quite irritated
I have a tile-based platformer game under work, and I'm stuck on a problem with hitTesting:
//check all character collisions with levelHolder
for(var i:int = 0; i < levelHolder.numChildren; i++)
{
[Code].....
The problem here is that hitBlock only hitTests one block at a time, and when I test this: If you lean on a wall (press right arrow key) and go downwards you can go through the floor.
I need to make it so that I can test on multiple blocks at a time.
And I did try to replace hitBlock with levelHolder[i], but it gave an error saying:
ReferenceError: Error #1069: Property 0 not found on flash.display.Sprite and there is no default value. at Main/enterFrame()
I'm guessing that comes from the level array where 0 = blank block / empty space.
At first I had all my sprites in an array and cycled through them to detect for collisions but now I am trying to put them in 1 big sprite and testing just that. I don't know if I am doing something wrong or this is to be expected but testing for 1 big sprite creates lag within the engine. Am I correct to assume that it's because I am constantly testing the pixels of the 1 sprite? When cycling through the sprites individually i never noticed this lag.
View 0 RepliesI'm just learning so I'm sure I'm making many stupid errors. How do you hitTest 2 separate arrays of different lengths, all entries against one another . Code below for guidance.
Code:
package{
import flash.display.*;
import flash.events.*;
[Code]....
What I'm trying to do is hittest two irregularly shaped objects using their alphas and not the bounding box.
The code below hittests two objects named target 1 & target 2. This is not my code, but mine looks exactly alike, except target 1 & target 2 are replaced with my MC's. the thing is, I keep getting an error.At every function line, like the "public static function complexHitTestObject I get an error that says: Expecting right paren before left-bracket. I don't know what this error is caused by, because I can't really see why Flash wants another right paren.
[Code]...
im having a really frustrating problem. I have 6 movieclips on the stage, all acting as 'map areas', these are named area1_mc, area2_mc and so on.. I then have a car which i drive around the screen, this instance name is car_mc ... All i want to do is do a HitTest to determine if the car is on one of the 6 areas.. i have the following
[Code]...
The reason it is not working i think is it is expecting the car to be on ALL map areas in order for it to be "on map". For example if the car is in the middle of area1_mc, i get three traces. On map (refferign to it being on area1_mc) then two traces of 'off map', because it obviously isnt on area2_mc or area3_mc.
i'we tried for years to duplicate multiple movie clip and then hittesting them all but i can't this is my last resort
View 2 Repliesit's easy to test collision between two squares. how do I test the collision if they are rotated?
View 1 RepliesI have 4 ball movie clips, a playhead and four target movieclips called mc_1-4, the array, (my_array), has 4 elements, which are each defined as having values of 0: I have a hitTest set up that will trace my_array to the output window each time it hits mc_1, to see what is happening. However the hitTest prints the array 3 times?
Am i right in thinking that this is because the hitTest is being triggered on entry of mc_1 in the center and upon exit?I need to make this hitTest be triggered once when the hitTest passes the center of mc_1. Secondly if any of the balls have been dragged and dropped on to mc_1 i want the array value with an index of 0, to change to 100 from 0 (not in terms of its index position because my array is only 4 elements long, in terms of its actual value) which i have tried to implement but i cannot configure the right code.
1. hit tests that only trigger once when they pass through the center of the object thus tracing one array.
2.use the balls 1-4 to make the array index 0, have a value of 100 if they are in contact with mc_1.
This is sort of a multi-layered question- I have a movie clip that I sectioned off in quadrants:The red dot is the player, the stage is the size of one square. My goal is to, when the player moves to either of the 4 edges, the next section of the quadrant comes up (meaning if the player moves to the right edge, the section that borders the right edge will slide on screen, and the old section will slide off screen).I was wondering if there was a way to hitTest if an object is touching any part of the edges? Is the hitTestPoint method something I should look into? What I have so far is an object off screen (black rectangle), that when the player touches the quadrants slide like I want them to (at least I'm trying to make that work).Here is my code. I know some of it's wrong and/or I'm missing something.
if(leftKeyIsDown && player_mc.x > -15)
//-15 is half the size of the temporary player_mc
{
[code]......
I've created a movieclip of a trashcan, which falls over and 6 items fall out of it. I want each of these items to become a button, which will jump to a different point on the timeline.
The movieclip is all working fine, and the buttons appear to be fine. The problem is when I publish the flash, the movieclip resets each time I hover over one of the buttons, so i get an endless loop of this trashcan falling over and the items falling out.
I've made 2 swf's. One is navigation with a movieclip named "connn" where another swf of content being loaded into it. The second swf is the content consists of a scrollable bar of thumbnails at the bottom, loading particular content on the stage. For the contents swf, I've this script on each of the thumbnail
PHP Code:
on(release){
_root.gotoAndPlay("framename");
}
which framename is marked on the top level of the flash, with a movie clip of a couple of images swaping. And this work perfectly. [URL]
PHP Code:
loadMovie("services_web.swf",this.connn);
which load the content into the movie clip named "connn". It got no problem loading the swf in but I discover that after it is loaded, the thumbnail script of the content failed to work. (please see: http://mr-otto.com/wd/services.html under WEB/INTERACTIVE > websites)
I guess that is the problem of the _root. thing and perhaps changing this I can have it work as perfect as it can be even being called in another swf.
I can place the following code on a movieclip:
PHP Code:
onClipEvent(load) {
gravity = 0.2;
yspeed = 0;
[code]....
And it'll work fine, however if I place it like this on a frame in the movieclip:
PHP Code:
this.onLoad = function() {
gravity = 0.2;
yspeed = 0;
[code]....
It doesn't work
I created a symbol (Movie Clip) for my library, and I can manipulate all of its properties except for one—alpha. Here is a sample of the code:
var range:Range = new Range(); // Range is the symbol in my library, and has been exported for ActionScript
range.alpha = .1; // Doesn't seem to work as the symbol is still at 100% opacity.
_buffer.draw(range, range.transform.matrix); // This is where I draw the symbol to the buffer
Everything draws fine, but it is as if the alpha property is not working.
P.S. - If anyone knows, should I use a Graphic for my symbol instead of a Movie Clip if I only have one frame?
I'd like to get more of the actionscript into class files and off the various time lines. The problem is I can't make it work. I have a class file called dezynworks.aegis.TextPanel Container.I have a MovieClip in my library called TextScrollWinow. Linkage for TextScroll Window: Identifier, TextScrollWindow; class: dezynworks.aegis.TextPanelContainer. Now I read on a web site that dragging the clip to the stage would retain the class association. That is news to me. I thought you had to use attach. Regardless, neither way seems to work.[code]The attach works. The clips appear on the stage, but the class is gone. dummy.init() (a method of the TextPanelContainer class) is never called and the instanceof statement returns false. There are no compiler errors. There are no runtime errors. I've set up test cases in a new Flash file and it all works like I expect.I've tried deliberately gumming up the class name and introducing syntax errors into the class file. It seems Flash is finding the file okay. Something must be failing silently, but I have no clue what and I'm out of ideas.
View 6 RepliesI have four movieclip buttons inside a swf file. (External swf) Different layers.I need to access those buttons separately.
View 6 RepliesI've created a class and then in my library I linkaged my movieclip to the class..Inside the movieclip there are some actions in the frame like gotoAndStop . but it seems they are all ignored.
View 2 Repliesi have 2 movieclips, 1 with buttons and the other with the action.when i click the button nothing happens, why ????
menufilm = the movieclip with the buttons
band = the movieclip with the action
menufilm.contact.addEventListener(MouseEvent.CLICK , contact);[code]...