ActionScript 2.0 :: How To Get Simple HitTest To Work With Two MCs (Lines)
Nov 30, 2009
I am having trouble getting a hitTest to work. My two MCs are lines, one horizontal, one slanted. When the horizontal line gets within the "bounding box" of the slanted line the hitTest is true, but it's not touching the slanted line yet. I saw that the shapeFlag property comes into play here, but only when using coordinates... I'm not sure how to apply it to these two lines. I want the hitTest to be true only when the lines actually touch. I have attached a simple FLA of the problem.
View 1 Replies
Similar Posts:
Mar 19, 2009
I've been trying to write a hittest that will work for rounded walls on my RPG. But I've been epic phailing.
Heres my code:
onClipEvent(load){speed=10;
}onClipEvent(enterFrame){if(Key.isDown(Key.UP)){this._y-=speed;this.gotoAndStop(5);
}if(Key.isDown(Key.DOWN)){this._y+=speed;
this.gotoAndStop(6);}
if(Key.isDo wn(Key.RIGHT)){this._x+=speed;this.gotoAndStop(7);
}if(Key.isDown(Key.LEFT)){this._x-=speed;this.gotoAndStop(8);}
View 2 Replies
Feb 28, 2012
This question was posted in response to the following article: [URL]..
View 6 Replies
Jan 15, 2012
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 Replies
Apr 11, 2012
I'm having a bit of a problem with my script. I currently have a square that moves across the screen. There is another square on the stage as well. I want the other square to call a hitTest with the first square (that moves), which we'll give an instance of "hero". The hitTest should make the "hero" (or first square) rotation a specific degree (in this case 30) and then move him in a specific direction, either up, or down the y-axis or left or right on the x-axis. This is my current code, attached to my second square.
onClipEvent(enterFrame){
if(this.hitTest(_root.hero)){
_root.hero.rotate += 30;
[code]....
View 1 Replies
Jun 30, 2011
I start to work on new web 3d engine. I call it IGood engine.As can be seen from the video, it is already possible to create a simple application of visualization without lines of code.Base on for alternative 3d.I am waiting your opinions.
View 1 Replies
Sep 26, 2011
Non-programmer here, struggling with having to now (finally) work in AS3.I've looked around, but can't find something similar (or as simple) as my old AS2 scoring - hitTest method was.Problem 1: my converted AS3 game does not hitTest or score.[code]I have a Dynamic text box on the stage named "scorecounter" which is now displaying "0" when the game plays. This is correct.When the gun (mouse) is clicked, we then tell the "hittest1" MC to play, which will detect hits. All Correct.[code]The hittest1 MC plays, and checks if the "cursor" MC was touching the "bug1", and tells it to animate (splat) All bug detections are listed in the hitTest frame - "bug1" through "bug30", ie. the code below x 30. This Fails - maybe because the hitTest MC lists all 30, and not all bugs are visibile at once, some are hidden until required later in the game?[code]Then on the last frame of the "bug1" MC (frame 10), it tells the score to add one. Also Fails - maybe because of errors above, nothing is being processed now.[code]
View 5 Replies
Mar 17, 2011
I am trying to create a game. My game is birds eye view game and I am trying to get it so my character (instance name hero_mc )can't pass through the buildings(instance name block_mc). I have been looking at tutorials on the web and most of them cover it so that a text appears if you hit the object whereas I want it so my character can't pass through or well is "push back", the one tutorial I found doesn't want to work for me, but it's not giving me any errors so I really don't know what is wrong with it.
Actionscript Code:
hero_mc.addEventListener(Event.ENTER_FRAME, enter_frame); function enter_frame(event:Event):void{if (hero_mc.hitTestObject(block_mc)) { trace("hero _mc is next to block_mc") } else { hero_mc.y += 10 hero_mc.x += 10 } }
My character still passes through the block objects.
View 1 Replies
Mar 30, 2010
I have this very simple .fla file and you use the keys to move the bus around. As it detects the hittests with the other movie clips on the stage it goes to and plays a frame on that mc's movieclip. It all works fine but i dont want the hittest to repeat after it has done it once(on each movie clip) so that as you drive the bus around you reveal the photo. [URL]
View 1 Replies
Sep 3, 2005
so my game's code is as follows:
Code:
//The Austin Weisgrau (El Nacho)
//Blob Game, to go with the video so it will get like the .3 mor it needs not to be blammed
[Code]....
the character instance is Blob and the background instance is Background. i can't get the hitTest to work with either of those two things in the /* */ and i need to no how i can
View 1 Replies
Oct 14, 2008
For some reason I cannot get my hitTest to work on an mc within an mc within an mc...which is assigned to a variable...
Code:
var miniWin:MovieClip = CAD_mc_mini.zoomControl.miniWin;
trace(miniWin); //returns _level0.CAD_mc_mini.zoomControl.miniWin
var mouseListener: Object = new Object();
[Code].....
View 3 Replies
Sep 22, 2009
I was trying to make it so you had to hold up this ball, and if it touched the block near the bottom of the screen, it would go to the first keyframe. (The menu.) So, I labeled the ball, "ball", and the block, "block". Then, I added this code to the block:
onClipEvent (enterFrame) {
if (ball.hitTest(block)){
gotoAndPlay(1)[code]....
And tested it out. To my dismay, it didn't work at all. I've spent about 30 minutes testing other ways, and I cant seem to make it work.
View 6 Replies
Sep 23, 2009
import flash.display.BitmapData;
import flash.geom.Point;
//
var BitmapA:BitmapData = new BitmapData(550, 400, true, 0x00);
[code]....
This is using the bitmapdata.hittest way to check whether the one bitmap is overlapping the other. Throug pixel-to-pixel detection.But I'm having trouble understanding this line:
Code:
if (BitmapA.hitTest(destPoint, 255, BitmapB, currPoint, 255))
I know that destPoint is the topleft point from which it is determining all opaque pixels. No value is given to destPoint so basically it is checking from 0,0. Having determined all opaque pixels from that bitmap it should compare them with the opaque pixels of the other bitmap. But why does currPoint use the topleft coordinate of its movieclip? Couldn't it just as well use 0,0 too? I mean when determining the opaque pixels of bitmap two it might as well start checking for those from 0,0 as the topleft position as well?
View 2 Replies
Mar 28, 2011
i am making a game where a ninja runs through a course, every thing is running smoothly. EXCEPT hittest will not work, hittest never works on ANY of my projects. I know im doing it right, because ive even tried copying and pasting working ones. Look at the attached fla file to see what im talking about.is it my computer that wont let it work, because the exact codes worked for all of the people on youtube that used it.
View 2 Replies
Feb 18, 2009
I am trying to use the following code to simplify multiple Hittests using an Array, but the code won't work. Can anyone tell me why?
var blockArray:Array = new Array("block1", "block2", "block3");
player.addEventListener(Event.ENTER_FRAME, blockTest);
function blockTest(evt:Event):void {
[Code].....
View 4 Replies
Dec 30, 2008
I have this code so that when a spaceship goes through a blackhole it plays the spaceships moveiclip. This works fine on the first part of the code when the user just clicks the start button.However, i have put in a difficulty setting and when you change the difficulty setting the hittest doesn't work anymoreand there are no error messages. I have tried putting the blackHoles array in the difficulty function but nothing changes and i didn't really think this would make a difference as the easy function is already using the blackHoles array outside the difficulty function.
View 7 Replies
Sep 13, 2009
I have about 100 movieclips that scroll across the stage from out of bounds. They are supposed to hit another movieclip both in bounds and out of bounds, but it seems like Flash only detects the hittest when it happens within the frame.
if(_root.sceneclip.reef1.hitTest(this._x+300, this._y+350, true) ){
View 2 Replies
Aug 20, 2010
So I'm doing this project for school and all, and I'm trying to do a htitest on an object. For some reason, it doesn't work. So I tried writing out my own method... Which halff worked, but wasn't as exact as it should've been.
Heres my code (Though I'm pretty sure somethings wrong with my MC, so i'll upload the main .fla file)
Code:
right = true;
left = false;
itemX;
itemY;
[Code].....
View 1 Replies
Sep 6, 2011
Lets say that I got movieclips A,B,C,D in my scene and E,F which only come into scene when A hitTest B and C hitTest D.I was able to make the A+B and C+D hitTest functioning properly. But when E,F came into the scene, I tried to make E to hitTest F to get something else function but they won't work.# note that there is some short animation before E & F come into scene.I am pretty sure all the instance names are named properly.
View 5 Replies
Oct 29, 2006
I have two pieces of code, that won't work together.First: this makes a hitTest on an mc to make it run on rollover:
Code:
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
if (this._currentframe<this._totalframes) {
nextFrame();
[Code]...
Each work seperately, but they won't together. How do I get around this?
View 7 Replies
Apr 29, 2011
In Flash Pro, I drew a rectangle on the stage.In the first frame, I typed:
ActionScript Code:
addEventListener(MouseEvent.MOUSE_DOWN, method1);
function method1(e:MouseEvent):void
[code]....
View 9 Replies
Oct 29, 2008
I'm wondering, is it possible to access shape data with actionscript. I want to draw simple lines with "line tool"somewhere in my movieclip and then to access information about my lines with actionscript to get startX, startY and endX endY of every line.
View 1 Replies
Jul 3, 2009
Ok, I am new to Flash and I am using CS3. I just learned about creating lines and choosing their end cap styles and joint style. I created 2 lines that were connected, highlighted both with the selection tool and tried to change the join style to miter. It would not work. I also tried round and bevel but they would not work either. I did this over and over with many different sets of lines, and I could not change the join style. What am I doing wrong?
View 2 Replies
Nov 10, 2003
for some reason the hitTest I have setup in the attached file seems to work in relation with the blue box's that surround objects and not with the actually objects. Anyways I'm pretty sure that it has to do with the border.
View 4 Replies
Feb 1, 2011
I have come against a problem whit this tutorial:i cant erase my lines now i have a bit more then just a pencil and a hole menu whit it,now i have even download the tutorial file and in the file it doesnt work eitheri use flash cs4.ow i dont whant to have anything complex like actionscript 3but still an solution and if it isnt to hard can i make a eraser to?
View 3 Replies
Jul 7, 2009
I am just testing out how to place a button to go to a scene.I have 2 scenes named, one and two and 2 buttons...One on each scene to get them back to the other scene.The instance names on the buttons are scen1_btn and scene2_btn.My Functions are just called scene1 and scene 2.The code I have below is what I wrote, and I thought would work, but isn't.[code]
View 5 Replies
Oct 24, 2010
I have this little slideshow, it is for practise for my students. It always worked well in as 2.0, 5 slides, and two buttons: back and next.The script in2.0 has: prevFrame and nextFrame in the code and for the exceptions in frame 1, and frame 5 we made a new frame 1 in the actions layer, and coded the back button, gotoAndStop(5); and a new frame 5, and coded the next button: gotoAndStop(1); Works.
Now I put the thing over tot as 3.0: And I can not get it to work properly....the buttons work, but when I am on frame 5, and go back to 4, it will go no further than 4, evenso when I go back to frame 1 from 5, I can not go further up than frame 1.
import flash.events.MouseEvent;
stop();
next_btn.addEventListener(MouseEvent.CLICK, volgendFrame);//next_btn.addEventListener(MouseEvent.CLICK,[code].....
View 5 Replies
Jan 13, 2012
I'm not familiar with AS3 at all.I'm working on a simple 2 minute presentation. For testing purposes, I have a layer named "label" that I am using to set a label called "test" (currently it's on frame 1445)I'm trying to put an action in the timeline, frame 1, that will cause the play head to automatically jump to the "test" label so as I build the presentation and test it, I don't have to sit through the entire thing just to see if my latest animations are working as expected. I'd like to move this "test" label down the timeline as I continue to build new parts of the presentation. I would expect this code to jump the play-head to where ever I put that "test" label..Instead, it either doesn't work at all, or it jumps to some other random spot around frame 160. NO other labels are being used in this presentation (I'm using the FlashEff component plugin for effects, in case that info is necessary)
View 2 Replies
Jan 14, 2010
I'm an AS2 guy finally being drug into the AS3 world and finding it difficult.I just want to make a simple rollover effect.[code]I noticed the first line in the code, do I have to import something? Either way my text in the button doesn't move when I rollover. It moves upon render but then it stops.URl...
View 2 Replies
Feb 18, 2006
I am using Flash 8, and for some reason, my if statement won't work. I have a scrollbar which scrolls a movieclip (that contains AS loaded material (eg. attachmovie). I want it so that only when the material is longer than the scrollbar do I see the scroll bar.For some reason, it doesn't work. The traces don't even work!
if (scrollbar._height < menu_mc._height) {
scrollbar._alpha = 100;
trace("works");[code].....
View 2 Replies