ActionScript 2.0 :: HitTest / LocalToGlobal Not Working - Traces Out To The Correct Location
Feb 12, 2010So I am able to trace the correct coordinates. However the hitTest fails. Here is my code:
[code]....
So I am able to trace the correct coordinates. However the hitTest fails. Here is my code:
[code]....
I am attempting to build a xml driven drop down menu where everything is taken from xml. now the problem arises with submenues. I have them being created fine, but it's the mouse out that won't work. I want to use a hittest to check if my mouse is over any of the submenues and if not just to trace something so I know it's working.
The problem is when i mouse of one clip onto the next it fails the hittest and traces. There isn't a space between the two MC's so I dunno what would be causing this. I have read sen's guide but I'm not pulling things from the library. Everything is being created at run time so I can't use the attach movie, so I am just positioning them below each other.
[code]...
Ive tried looking in a whole bunch of threads for a solution to this probably common issue but to no avail.I have a bunch of objects of same type on the stage which are generated through code.Inside these objects which are generally at x=300 on the stage.
Code:
this.x+=2.3;
trace(stage1.localToGlobal(new Point(this.x,this.y)), ", ", this.x , " ", this.y);
stage1 is the stage object I pass into my class.The trace output is as follows
(x=2.3, y=0) , 2.3 0
Now im expecting some values in there somewhere to indicate its actual location on the stage, ie, x=300.This isnt happening.Whats the correct syntax i should be using.
Here's what i have:
Code:
for(var i=x; i<y; i++)
{
[code]......
I have a strange issue in an AS3 project I'm building. For some reason I am not receiving any traces from a specific class in my project. I can get traces from any other class though. I have a Main.as that loads several classes, one of which is IphoneScroller.as
ActionScript Code:
Tipper: News Scroller
package org.FlepStudio.Tipper{
import flash.display.*;
import flash.events.*;
import flash.geom.*;
[Code] .....
Any reasons why I might not be getting traces? I'd also like to note that I have a container that has several control components as children. I pass the container to the iphoneScroller for scrolling and it works fine...until I click a numericstepper and the iphonescroller breaks. However, other controls like InputTextfields don't break the scoller. These issues are why I've been trying to do traces in the first place.
I can't seem to get hitTest work on a textField, is that correct? Does this only work on movieclips?
View 3 Repliespackage
{
import flash.display.DisplayObject;[code]....
In actions in my .fla file I create a new object of a class (addChild) which is in an separate .as file. Now, in my .as file I want to call a function in the .fla file. This should be the parent right? So, I try parent.correct(); which does not work. I get the error #1061 (call to a possibly undefined method). However, when I do this:
var par:* = parent;
par.correct();
Everything works. Why is this?
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]...
I'm trying to make a hitTest between to movie clips (Let's call them J and T)[code]But nothing happens when the two movie clips collide.
View 5 Repliesi'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.
I've included:
if (stok.kogel.hitTestObject(this.muur)) { trace("ball hit") }
but I just can't seem to get an trace back.(PS: here's the file as refference (all AS is in the catapult))
Why my hitTest is not working and how to modify the same in Menu1 to make it to work.
View 1 RepliesI have tried hitTest many times.The function works perfect if I run it from an example, but not if I do it myself.I attached the FLA.Also, in this demonstration I tried using the if with the ,s. I have tried with _root.mc.hitTest style.
View 1 Repliesthere is a problem with IE browser it does not recognize object HTMLEmbedElement and not proceed for further execution . i have no choice because there is nothing to be updated in programming code
View 2 Replieswhy the buttons are not working correct?
View 2 Repliesball2 is duplicated every 3 seconds and the gravity code is on the ball2 mc. this code is on frame one of the main timeline.Why when two of the ball2 mc's are on the stage does the hit test not work on one of them?
Code:
checkX = function (dx, oldVal, newVal) {
if (_root.paddle.hitTest(_root["ball2"+i])) {
[code]........
I can't seem to get the hitTest to work for my script shown below. I have tested using movieclips created on stage during design time and made to collide during run-time. hitTest works fine in this situation.
But if I use the attachmovie command and create a movie on stage during run-time, that clip cannot hitTest with other movieclips. The hitTest simply doesn't work.
The script below is basically, to create instances of enemymc, and it will fall vertically, hitting a movieclip target_mc which is placed during design-time.
var enemyTime:Number = 0;
var enemyLimit:Number = 20;
onEnterFrame = function()
{
[Code].....
I am calling this function via onEnterFrame from another function.
ActionScript Code:
function hitCheck():Void{
or(i= 0; i < numTools; i++){
[code]....
1 main flash movie called game.swf 1 external flash movie called maze.swf
The thing is from my main movie game.swf I load the external "maze.swf" true the LoadClip procedure. This works "fine".
The maze.swf as you can guess contains a maze game, and as you all will know this works with the Hittest commando to check if the character doesn't walk up against the wall.
If I start the maze.swf as a stand-a-lone this works fine, but as soon as I load maze.swf in my main movie. The hittest doesn't work anymore, because in some way the hittest is now checking with the coordinates of the entire main movie instead of only the boundaries of the maze.
I checked If I was calling to the right path, with _root and _level0 and etc. This is al correct because I can trace all the properties from maze.swf in my main movie. But the hittest simply won't work.
I have had this problem for a long time and have not been able to fix it. I am using ActionScript 1, although if you can help me using AS2 I should be able to change it. I have a static movie clip with no code referring to it called "ship". Its center point is 275, 324.9. I have a series of planets coming down from the top of the screen and I need to check whether you "died" or not. The planets movie clips are contained inside blank movie clips that are there so thre registration point does not change. I was using the code
Code:
if(this.hitTest(275, 324.9, true)){
gotoAndPlay("gameover");
}
Ive got this piece of script where i place objects on the stage, to hittest eachother.Ive got two seperate addchilds: one child must hittest another child.[code]only one instance of the hitte_mc will hittest with the instances of Ring.
View 5 RepliesI'm trying to set up a very simple drag and drop game where users drag movie clips onto other matching movie clips.If the answer is correct, the mc stays in place; otherwise, it snaps back to original position. So far, only the dragging part works -- the movie clip won't stay in place when dragged to the correct position.I'm using Flash CS3 and Actionscript 2.The Flash movie can be found here: http:[url]..As it's set up now, the mc with the buffalo symbol is draggable,and the correct drop zone is the fish with thetext.Here's the script I'm using:
// Get the movie clip's location and
// store the coordinates as variables
onClipEvent (load) {[code].....
Go to [URL]. My hitTest function only works on the y-axis. This is the code....
onClipEvent (enterFrame) {
// _root.speed = speed;
if (Key.isDown(Key.UP)) {
speed += 3;
} if (Key.isDown(Key.DOWN)) {
I can't seem to get hitTest to work for the plane in my little game. The code I'm using in the plane MC is:
[AS]if (_root.player.hitTest("_root.badguy"))
playerhealth -= 20;
}
[code]....
I want to the badguy plane to hit the player's plane and take a subtraction from the player's heath. I've fiddled around with using "this" instead of the full path of the playerMC - no success. My hitTest is working fine for the bullets!
i have attached an .fla file to show you what i am trying to achieve, i have a line (acting as a playhead) scrolling accross the screen, i am then wanting it to output to the window when it collides with each of the coloured squares, i have used similar things before but it is not working in this instance
View 5 RepliesI was playing around last night trying to learn simple AS to make a movie clip act like a button. I wanted the button movie clip to reduce the alpha value of the other movie clip when you rollover the button and when you roll off the button the alpha of the movie clip goes back up. It works, but if you keep rolling over and out of the button movieclip sometimes the alpha gets stuck at a certain value for a bit, then does what its supposed to. I'm using onEnterFrame () to do the hitTest constantly.
Here's the SWF and FLA files for you to look through:
hitTest SWF
hitTest FLA
Here's the AS code I used in the frame to do this:
Code:
onEnterFrame = function() {
if ( background._alpha > 100 ) {
background._alpha = 100;
[code]....
i am currently making a game, and for some reason the hittest on my duplicated movie clips isnt working i know how to do them , and know it should be working , because it works on one of the movie clips but none of the others so im guessing it something to do with depth? i will give the code if any1 replys
View 2 RepliesI'm trying to get the depths of all the blocks to be at the correct levels at the correct times so that the 3d effect is maintained. I've tried many things, but have had little success. All the instances of the blocks are stored in an array, but since it's adding them in accordance with when they're added to the stage, it doesn't help me locate them to swap depths. Is there a way to arrange them by location on the board?
View 4 RepliesI am trying to make an object tween from its starting location to the location of a mouse click. I have a script, but it has a very annoying ease to it.I would LIKE the object to mantain a certain speed during while traveling from its starting location to the mouse click location.
View 16 RepliesI created a simple button that displays an error messeage: "error opening 'url" when I test the movie, but does play and opens in browser after publishing. However, it won't open in the browser in a different location. I pasted the html code in a web page but it doesn't work there nor opens in the browser in a differnet location from where it was originally published and saved. Why is that?
View 13 Replies