Using Hit Detection
Hello
I was wanting to know if there was a way to use hit detection rather than stage width to keep an object(character mc) from leaving the screen.
I'd imagine you'd create a movieclip at both sides of the screen and then use code.
I imagine the code for it would go something ike this...
onClipEvent (enterFrame) {
if(this.hitTest(_root.character)){_root.character. _x-1; } So far I havent got this to work
Any pointers?
FlashKit > Flash Help > Flash ActionScript
Posted on: 03-05-2006, 03:20 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Detection Inside Detection
To serve as a collision detection I've made a stage-size movieclip.
Code:
onClipEvent (enterFrame) {
_root.vlak.onRollOver = function() {
trace(1);
};
}
Inside this movieclip is a button with a move over frame changing its color when the mouse is over the button.
But when the original movieclip is detected with an Rollover, the button stops working. It keeps focussing on the entire movieclip "vlak" and doesn't notice anymore when the mouse is over the button insice the movieclip. Is there any way to fix that?
Hit Detection
Is it possible to detect if one movieclip hits another one?. What's the code?.
Thanks.
URL Detection
hey guys, can you help me. I want a flash NAV that I'm working on to goto a certain place in the timeline if it's opened in a certain page. Can this be done? Is there any way to have flash ask the browser for the current URL?
Detection
is there a way to detect whether a viewer has flash before the site opens up? i was thinking of having a blank white page that detects if the viewer has flash player or not and if it does, then it will open up a site with flash and if it doesn't it will open up the html site.
anyone kno how to do this? and if so can you tell me the coding or point me in a direction of where i can find it?
URL Detection
How with Action Script detect current url and depending on this url goandplay
necessary movie clip?
URL Detection
How with Action Script detect current url and depending on this url goandplay
necessary movie clip?
Hit Detection
Sup folks,
I'm coding a totally cool game, however, my hit detection sucks right now.
I understand that Flash allows for hit detection between two bounding boxes or a point with a shapeflag. I need hit detection between the shapeflags of two movieclips.
I currently use the two bounding boxes method, and I was going to "brute force" a number of collision points. However, one of the movieclips rotates dynamically, and as such, if I say "_x + 30", it's wrong when the thing's been rotated, and hit detection goes to hell.
Any Ideas?
-Loydog
Detection
hello,
Question... i have a index page where a simple swf file is. when the index page will called up then the file will go to a frame with the right url.... if the visitor has no flash plugin then in the meta tag (head) is a code which realod the browser window after 2 sec. with a page what actl. tell that "you don't have a flash plugin in, please go to ..."
ok everything is working but a friend told me that it don't work on a mac. ok what's up with that? and does somebody have a better idea with the flash plugin?
chek it out on the page www.55-studio.com .... it's the same there
On Key Up Detection
Hello,
I am trying to detect when a certain key is 'unpressed', using a listener:
-----------------------------------------------------------------------------------------
myListener = new Object();
myListener.onKeyDown = function() {
if (Key.isDown(Key.RIGHT)) {
trace("right");
Rkeypressed = true;
}
if (Key.isDown(Key.LEFT)) {
trace("left");
Lkeypressed = true;
}
if (Key.isDown(Key.DOWN)) {
trace("down");
Dkeypressed = true;
}
if (Key.isDown(Key.UP)) {
trace("up");
Ukeypressed = true;
}
};
// --------------------------------------------
myListener.onKeyUp = function() {
if (!Key.isDown(Key.RIGHT)) {
trace("right up");
UkeyUP = true;
}
if (!Key.isDown(Key.LEFT)) {
trace("left up");
UkeyUP = true;
}
if (!Key.isDown(Key.DOWN)) {
trace("down up");
UkeyUP = true;
}
if (!Key.isDown(Key.UP)) {
trace("up up");
UkeyUP = true;
}
};
-----------------------------------------------------------------------------------------
Problem is, the onKeyUp listener activates when ANY button is unpressed. I want to just detect a specific key, like when the RIGHT key is unpressed for example.
any help greatly appreciated!
Thanks,
Darren[size=1]
Is URL Detection Possible?
I'm doing a flash navigation bar that acts differently depending on the web page it is in.
How can the flash movie find out what web page it is in? Is there an actionscript for that or do I have to use javascript?
Thanks a lot!
matti
MX Detection
I've looked through the tutorials and movies section and can't find a good, but simple detection for MX. I found a few things that have loading bars with detection, but I just need detection...that's it. I remember when version 5 came out someone came up with a detector that had AS in it that only version 5 understood. If your player understood this AS it would advance to a frame that said you had the correct plugin. If it didn't, obviously, it stayed in the same frame that informed you that you didn't have the correct one. Is there a way to do this simple, but effective, detector for MX? Any help is much appreciated. Thanks in advance!
Laters,
lithium
MX Detection
I've looked through the tutorials and movies section and can't find a good, but simple detection for MX. I found a few things that have loading bars with detection, but I just need detection...that's it. I remember when version 5 came out someone came up with a detector that had AS in it that only version 5 understood. If your player understood this AS it would advance to a frame that said you had the correct plugin. If it didn't, obviously, it stayed in the same frame that informed you that you didn't have the correct one. Is there a way to do this simple, but effective, detector for MX? Any help is much appreciated. Thanks in advance!
Laters,
lithium
MX Detection
I've looked through the tutorials and movies section and can't find a good, but simple detection for MX. I found a few things that have loading bars with detection, but I just need detection...that's it. I remember when version 5 came out someone came up with a detector that had AS in it that only version 5 understood. If your player understood this AS it would advance to a frame that said you had the correct plugin. If it didn't, obviously, it stayed in the same frame that informed you that you didn't have the correct one. Is there a way to do this simple, but effective, detector for MX? Any help is much appreciated. Thanks in advance!
I've posted this in other forums and got back one response...I was told to publish the movie with compression turned on and only Flash 6 Players would play it. If I do this will the Flash movie appear blank if they have a previous Flash Player version?
Key Detection
How can I tell a movie clip to go to frame 2 when the 'Print Screen' key is held down, and then frame 1 when it is released?
Hit Detection Help
I'm making a breakout-style game (arkanoid-style).
I'm having problems with hit detection. I can get hit detection to work, but the problem that I'm having is that when the ball intersects a wall or the paddle, it passes half way through them before it starts in the next direction. Is there any way to make it so that the whole shape of the objects are used?
I've included the .fla. Just play the game and watch how the ball passes half-way through stuff. I don't like that.
Also, I'd like to stop the paddle from passing half-way through the walls, as well.
Key Detection
if(key.isDown(key.SPACE)) {
//play gunshot sound effect
reload.start(0, 1);
//reset bullets
}
Is there anyway I can alter this so that the sound effect only plays when the space key is released?
Hit Detection
I need help with hit detection. Does anyone know how to script hit dection with out having to type a 400 word code into action script box? Thank you people with huge Iqs!
Key Detection
how do you have a game see if a keyboard ke is pressed? do stuff while it is pressed, and exacute an action after it is released? It would really help me out to know
Hit Detection
hey.. ive never done anything with hit detection before.. but im making a game and i need it. i want it so that when your character touches the ground he dies. so you could maybe make something like a frame that you go to when you die or something, and then wen you touch the ground it goes to that frame.. but i dont know how i would do that any help anyone?
Detection Kit
I have asked this in the flash 8 forum but have not gotten an answer.
I have installed the flash detection kit.(not the express as I couldn't figure it out.) The site is http://www.diversioncentral.com. (The site is unfinished and mostly experimental). Then I unistalled the flash player on a different computer to test it and it does work. But the swfs still appear in large squares with the small little square in the upper lefthand corner. (hope that makes sense.) How could I make it go to a different page altogether with the links to install flash player? I tried the pic.jpg as the suggested alternative but it does not replace the swf when no player is found. it posts the pic and the broken swf at the same time. I ask this because I seem to have seen it done this way on other web sites.--Thank you
I am using flash 8 from studio 8. I published the index swf as flash 8. I used the video instruction at
http://www.macromedia.com/devnet/fl..._detection.html
[F8] URL Detection From Swf?
I have a swf that needs to be uploaded to a webpage. I want it to animate if its loaded on the homepage, but have it go to the last frame (animation ends and it's static) if its uploaded anywhere else (ex: the contact us page or about page). So it basically needs to detect the homepage URL and play, otherwise go to the last frame.
I can't do a PHP script called from the server because the client wants the actionscript in the Flash file itself. Is this even possible??!
I've been searching on forums and tutorials for the past 2 days and spent hours trying to figure it out! I'm new to actionscripting so I have no idea what code to use. I keep seeing references to:
trace(_root._url)
and
if (_url == yourURLHere) {
theRightClip.gotoAndPlay(theRightFrame);
}
and FlashVars
but I have no idea how to incorporate those codes to my Flash file or if they even relate to what I'm trying to do.
Any help would be greatly appreciated.
Thanks!
Detection
for some reason, no matter how many times i update the player, i keep getting the "you must upgrade to the latest player" message for some, but not all sites... what is the deal with that?
Url Detection. There's A Way?
I'm trying to write a code for using the url of the HTML document as content for a variable, but when I use:
_root._url
All I get is the url for the .SWF document. Obviously there's something wrong with my code but I don't understand what can it be...
Please help me...
IP Detection
well maybe a odd question but is there a way to get the IP address of the viewer of the flash movie and return it to them. i know that you can return and display things such as time but can it be done with and IP address.
thanks in advance
yettti
Detection Kit Help
Hello,
I having a tough time figuring out the implementation process with
Robert Hoekman's flash detection tutorial...here http://www.adobe.com/devnet/flash/articles/fp8_detection_04.html
I'm trying the Flash Player Express install....
1. I have published HTML and Flash files out of flash and know I'm confused as the next step says "move the Java Script code found within the Template's <head> tag to the same location in your page along with the JavaScript include, AC_OETags.js"
I'm wondering what template he he using.. and where the information goes? Does it go onto the html I just published from flash or the html on the playerProductioninstall.html example out of the detection kit download.
An example of how he used all the files that came with the kit and how to place them into the HTML that was published from flash would be awesome.
He did give a few brief examples, they didn't seem to make sense...
It would be great to get a few examples !
Hit Detection
i have included my code below for bullets in my game. the bullets are added to the stage when the mouse is clicked anywhere. easy enough... now the question i have is at the bottom of my shooter function. i am trying to detect when a bullet (boxr) hits my target.
it could have something to do with the bullets being generated inside that function and the target being just a movie clip on the stage with the instance name "target". im not sure. any help would be greatly appreciated.
Attach Code
stage.addEventListener(MouseEvent.MOUSE_DOWN, shooter);
function shooter (e:Event) {
var angle = p.spaceShip.rotation;
angle = angle*Math.PI/180;
var boxr:MovieClip = new projectile();
stage.addChild(boxr);
boxr.x = p.x+nose*Math.cos(angle);
boxr.y = p.y+nose*Math.sin(angle);
boxr.xmov = speed*Math.cos(angle);
boxr.ymov = speed*Math.sin(angle);
boxr.addEventListener(Event.ENTER_FRAME, movein);
function movein(e:Event) {
//trace(boxr.x);
boxr.x += boxr.xmov;
boxr.y += boxr.ymov;
}
//NO IDEA WHY THIS WONT WORK <<<<<<<<<<<<<<<
if (boxr.hitTestObject(target)) {
trace("HIT");
}
}
Detection
has anyone got a flash detedction script so if you have flash it will goto say www.kirupa.com but if you aint got the plugin you goto www.macromedia.com ????
Detection Help Please.
Hi, I have 2 swf's in my Web page
The first one main.swf plays automatically and ends at frame 166
The second one nav.swf stops at frame 1
One frame 166 of main.swf I would like to somehow tell nav.swf to goto frame 2
Can anyone help me with this one?
Thanks in advance.
OS Detection
I'm creating a promotional CD that will be handed out to lots of people - which means mostly pc and macs. I know in flash mx you can publish both a windows projector and a mac projector. First, how do I detect if someone is on a mac or pc and second, how do I then play that type of executable off the CD? I do not want to run this through as an html file. Please help!
Thanx
Flv Detection
How can I tell when an FLV file is done playing to then perform some kind of action on my main timeline? I have a skin for the FLV file that is playing - I'm not sure if that makes a difference.
For example:
mymovie.onEnterFrame = function () {
if (movie is done playing){
_root.gotoAndPlay("partII");
}
}
Thanx in advance!
Key Detection
How would I make it so the letters I press on the keyboard are traced and can help trigger variables and such? Like after you type in "Hello" the "greeting" variable is true? (random example)
Key Detection
Hi, I'm working on a dynamically resized photo gallery like everyone else and their mother. Everything works ok so far, until I try to add key detection to complement the previous and next buttons already in place.
When I hit the left or right key it registers, but the picture doesn't resize the same as if I just press the prev or next buttons. It actually loads the next picture, and then resizes on the follow key hit.
PHP Code:
listen = new Object();listen.onKeyDown = function() { if (Key.getCode() == Key.LEFT) { prevImage(); } else if (Key.getCode() == Key.RIGHT) { nextImage(); }};Key.addListener(listen);prevb.onRelease = function() { prevImage();};nextb.onRelease = function() { nextImage();};function nextImage() { //curr = current image count, containerMC = picture mc cur++; if (cur>pArray.length-1) { containerMC.loadPic(0); } else { containerMC.loadPic(cur); }}function prevImage() { cur--; if (cur<0) { containerMC.loadPic(pArray.length-1); } else { containerMC.loadPic(cur); }}
Any ideas? Need to see more code?
Thanks
Key Detection
I'm new to AS3, and I'm going to make a simple game and I need to learn some things.
The most important thing I need to know is Key Detection.
I've read this post but I didn't understand it at all. I also think there must be a simpler way to do that.
So, I would be pleased if someone could post a code to make something happen when a key is pressed, and explain it a bit.
Thanks
Detection
has anyone got a flash detedction script so if you have flash it will goto say www.kirupa.com but if you aint got the plugin you goto www.macromedia.com ????
Detection
This isnt really a flash question, but can you detect what screen resolution people are set at in order to give them a particular version of your site?
Detection Help Please.
Hi, I have 2 swf's in my Web page
The first one main.swf plays automatically and ends at frame 166
The second one nav.swf stops at frame 1
One frame 166 of main.swf I would like to somehow tell nav.swf to goto frame 2
Can anyone help me with this one?
Thanks in advance.
Detection
What happens if a user has flash5 and tries to view a flash 6 movie?
Does it ask them to download the current version or does it do it automaticaly?
Help With Hit Detection
Im making a isometric shoot em up game and Im trying to figure out how to apply hit detection for the players ship and the enemies.. I have no idea at all of how to do this, this is what I´ve done:
clip1x = "getProperty (clip1, _x)";
clip1y = "getProperty (clip1, _y)";
clip2x = "getProperty (clip2, _x)";
clip2y = "getProperty (clip2,_x)";
if (clip1x=clip2x) {
tellTarget ("clip1") {
gotoAndPlay (5);
}
} else {
tellTarget ("clip1") {
gotoAndStop (1);
}
}
Whats wrong in it? is there a better way to do this?
help is much appreiciated!
heres a link to the game so you know what Im trying to do:
exhaust
ICQ Detection On Flash ?
Hello guys,
I just wonder if anybody knows how to implement an ICQ status in java. From java I know how to give the status information to Flash via variable. For the moment I just open on my site a small window with the default ICQ status button. But the ICQ default status buttons are ugly and I would like to manage it all from Flash. If anyone has already met the same problem this would help me.
Thanks a lot.
LaShampoo.
Odd And Even Numbers Detection
hi all! I need to tell a variable if a number is odd or even. I know that the main difference between odd and even is that any "odd" number divided by 2 will be "anyNumber.5" when "even" numbers divided by 2 will be "anyNumber.0" i don't know how to script that "anynumber" part. This is the way the script could look:
Code:
on (press) {
count = new Number(count+1);
if (count/2 == ANYNUMBER.0) {
_root.num = "even";
} else {
_root.num = "odd"; }}
Of course ANYNUMBER doesn't exist. What could i say instead?
thanks in advance
gparis
Function Key Detection
how can i detect the following keypresses without it's getting in action to the browser.
the F4 F6 F7 and F11 key.
when using on keypress its starts messing up my browser
plz ... is there a work around to get it still working
(needed to make an software simulation)
or is this Question to hard?
Collision Detection
I have many instances of a movie clip (by using duplicateMovieClip) on my stage, each with a name of "clip1", "clip2", "clip3" etc.
I have many instances of another movie clip, like the one above, but all derived from a different original movie clip. They're named "something1", "something2" etc.
I want to put an "if" statement that performs a "hitTest" between one of the "something" movie clip instances and ANY of the "clip" instances.
This is the code I have inside the onClipEvent (enterFrame) of the "something" instance:
onClipEvent (enterFrame) {
if (this, hitTest(_root.varClip)) {
this.removeMovieClip();
}
}
and I have this code in a frame on the _root level
for (var i = 1; i<=3; i++) {
_root.varClip = ["clip"+i];
}
Nothing is working this way. Is there some other way that I can check the collision using arrays?
Am I mixing up the paths?
I'd really appreciat some help with this. I feel like I'm so close already.
Thanks
Kevin
Collision Detection
Alright troops?
I wonder if any kind (and talented) souls could give me a hand? I'm trying to build a pac-man type maze game and I'm not sure about how to produce collision detection to stop my character goin' through the walls. I'm really not sure where best to begin on this one, so any advice at all is greatly appreciated.
Cheers
Random Swf W/F5 Detection
I am trying to implement a flash 5 detection that will test if the user has F5. Then upon determining if the user has it, it proceeds to send them to a random intro swf.
This is what I have and I seem to be coming up empty... I can see the outline of the swf loading... but all I get is a blank screen. My frame 2 is where the user is told that they do not have the plugin and will be redirected.
Frame 1:
Actions for frame 1
with (_root) {
gotoAndPlay (3);
}
Actions for frame 3:
intronum = Number(random(20))+1;
intro = "intro" add intronum add ".swf";
loadMovieNum ("http:/ /www.whatever.com/" add intro, 1);
Actions for frame 4:
stop();
Can anyone help me?
Flash Detection: JS Vs AS
Friends:
What is the best way to detect Flash plugin? Through Javascript or ActionScript?
Where do I get such a script?
Thanks,
FK
Internet Detection Anyone?
I need to know how to make flash detect an internet connection. Anyone know? also, if no connection can be found, I'd like it to go advance to the next action.
Flash 5 Detection.
Anyone knows of a good way to detect for Flash 5 in the preloader assuming the user has Flash 4 or later?
Thanks,
z27
|