473,788 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hit Test

15 New Member
hi friends,

i have a problem with this code. when i run this code, i want that the arrow should not accross the wall movieclip but it is accrossing the wall.

So if anyone have some idea about what we can do for to get the desired result.

thaks



my FLA file code:

var myclass:moveArr ay = new moveArray(arrow _mc);


As files code:


class moveArray extends MovieClip {
var targetMc:MovieC lip;
var mc:MovieClip;
var wall:MovieClip;
//var myListener:addE ventListener;
public function moveArray(targe tMc:MovieClip) {
//trace(targetMc) ;
this.targetMc = targetMc;
checkPosition(t argetMc);
updatePosition( targetMc);
}
//-------------------------------------------------------------------
public function updatePosition( mc:MovieClip) {
var myListener:Obje ct = new Object();
myListener.onKe yDown = function() {
if (Key.isDown(Key .RIGHT)) {
//trace("right key is pressed");
//trace(mc);
mc._rotation = 90;
mc._x += 25;
}
if (Key.isDown(Key .LEFT)) {
//trace("left key is pressed");
mc._rotation = -90;
mc._x -= 25;
}
if (Key.isDown(Key .UP)) {
//trace("up key is pressed");
mc._rotation = 360;
mc._y -= 25;
}
if (Key.isDown(Key .DOWN)) {
//trace("down key is pressed");
mc._rotation = 180;
mc._y += 25;
}
};
Key.addListener (myListener);
}
//------------------------------------------------------------
public function checkPosition(m c:MovieClip) {
mc.onEnterFrame = function() {
if (this._x>=Stage .width) {
//trace("right");
this._x = Stage.width-this._height/2;
}
if (this._x<=0) {
this._x = this._height/2;
}
if (this._y<=0) {
this._y = this._height/2;
}
if (this._y>=Stage .height) {
this._y = Stage.height-this._height/2;
}
};
}
public function chkcoll(mc:Movi eClip, obj:Object) {
if (mc.hitTest(obj )) {
// this._y = 249;

}
}
}
Aug 13 '07 #1
1 1828
crabpot8
40 New Member
hmmm.. i could use some clarification on your exact problem, i didnt really get what you meant. few pointers, however.
1. it looks like you are commenting out your traces for run-time, ect. just fyi, under publish settings, flash tab, you can check not to export traces. this will lower your bandwidth a little, and allow you to put in as many traces as you want without worrying.

2. right here.. "if (this._x>=Stage .width) { this._x = Stage.width-this._height/2;} " it looks likt you are trying to say "if i am off the right side, move me to the middle of the stage(not the middle of the mc, is what i think you are going for). however, you are looking at the height, not the ._x characteristic, the width. try something simpler, like this._x = Stage.width/2;

3. when you are inside a function () { }, using "this" references whatever called the function, so mc_instance.OnR ollover = function () { this.gotoAndPla y(1);} is going to go to and play frame one of our mc_instance. if you want to be in reference to the frame you are on (aka if you want to control a different movie clip), just leave out the "this" and it will be in relation to the current frame

hope that helps

crabpot8



hi friends,

i have a problem with this code. when i run this code, i want that the arrow should not accross the wall movieclip but it is accrossing the wall.

So if anyone have some idea about what we can do for to get the desired result.

thaks



my FLA file code:

var myclass:moveArr ay = new moveArray(arrow _mc);


As files code:


class moveArray extends MovieClip {
var targetMc:MovieC lip;
var mc:MovieClip;
var wall:MovieClip;
//var myListener:addE ventListener;
public function moveArray(targe tMc:MovieClip) {
//trace(targetMc) ;
this.targetMc = targetMc;
checkPosition(t argetMc);
updatePosition( targetMc);
}
//-------------------------------------------------------------------
public function updatePosition( mc:MovieClip) {
var myListener:Obje ct = new Object();
myListener.onKe yDown = function() {
if (Key.isDown(Key .RIGHT)) {
//trace("right key is pressed");
//trace(mc);
mc._rotation = 90;
mc._x += 25;
}
if (Key.isDown(Key .LEFT)) {
//trace("left key is pressed");
mc._rotation = -90;
mc._x -= 25;
}
if (Key.isDown(Key .UP)) {
//trace("up key is pressed");
mc._rotation = 360;
mc._y -= 25;
}
if (Key.isDown(Key .DOWN)) {
//trace("down key is pressed");
mc._rotation = 180;
mc._y += 25;
}
};
Key.addListener (myListener);
}
//------------------------------------------------------------
public function checkPosition(m c:MovieClip) {
mc.onEnterFrame = function() {
if (this._x>=Stage .width) {
//trace("right");
this._x = Stage.width-this._height/2;
}
if (this._x<=0) {
this._x = this._height/2;
}
if (this._y<=0) {
this._y = this._height/2;
}
if (this._y>=Stage .height) {
this._y = Stage.height-this._height/2;
}
};
}
public function chkcoll(mc:Movi eClip, obj:Object) {
if (mc.hitTest(obj )) {
// this._y = 249;

}
}
}
Aug 17 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
3086
by: Berthold Hoellmann | last post by:
Hello, When I use ./configure --with-thread --with-fpectl --with-signal-module \ --with-pymalloc --enable-shared --with-cxx=g++ make test on 2.3.3 I get
0
2055
by: Remy Blank | last post by:
Ok, here we go. I added the possibility for tests using the unittest.py framework to be skipped. Basically, I added two methods to TestCase: TestCase.skip(msg): skips unconditionally TestCase.skipIf(expr, msg): skips if expr is true These can be called either in setUp() or in the test methods. I also added reporting of skipped tests to TestResult, _TextTestResult and
4
3084
by: Edvard Majakari | last post by:
Hi, I just found py.test and converted a large unit test module to py.test format (which is actually almost-no-format-at-all, but I won't get there now). Having 348 test cases in the module and huge test classes, I started to think about splitting classes. Basically you have at least three obvious choises, if you are going for consistency in your test modules: Choise a:
0
1909
by: Andrea M. Segovia | last post by:
I just compiled (but did not install) perl 5.8.0 on an SGI Origin 300 server (IP35) running IRIX 6.5.20m. Make test reported one test error, which I narrowed down to .../lib/ExUtils/t/Constant.t using harness. I ran the test separately, and got the following detailed error report: .../lib/ExtUtils/t/Constant....ok 6/51Confused test output: test 6 answered after test 44
0
2314
by: Tim Haughton | last post by:
I've just released an article on using Test Driven Development with C# and Windows Forms. GUI's are often difficult to test, so I thought it might be of interest. The article along with the example source code can be downloaded here: http://www.blogitek.com/timhaughton/archives/files/User%20Interrogator%20And%20TDD.zip The article text is below. Not sure what it will do to the formatting when
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2897
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.