ActionScript 2.0 :: Movieclip As Button HitTest Working Intermittent?
Jul 9, 2004
I 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]....
View 12 Replies
Similar Posts:
Jan 15, 2009
i just would like to know how to create an "hitTest" script inside a movieclip that is actually part of that hitTest code?I mean... I have mc A, and mc B. and the current hitTest code im using (that is on the timeline) makes mc A, destroy mc B when collide with it... but there are many mc B on the stage (with the same instance name) so, when mc A collide with one mc B, it destroys ALL mc's B... but i want it to destroy only the mc B that he collides, not all the others... maybe an hitTest script inside a movieclip B would work (somethig like "if MC A hitTest ME = i die" (not all the others)).
View 1 Replies
Sep 15, 2009
I am having a problem where my buttons on main timeline are working fine. When I create a button within a movieclip layer (a page importeded from Photoshop as a movieclip) the button is not working once I leave. It doesn't show as a working button when I select Enable simple buttons, when I preview or publish as HTML. The thing is, it is a button, it has an instance name, is that weird blue color... and it works fine when I am double clicked into that movieclip layer. I also tried common library buttons and they work fine until I leave that layer as well, also tried it within other layers and creating a new file and doing it... all no success!
View 5 Replies
Apr 7, 2010
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]...
View 1 Replies
Aug 12, 2010
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 Replies
Apr 7, 2010
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.
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))
View 7 Replies
Aug 28, 2009
Why my hitTest is not working and how to modify the same in Menu1 to make it to work.
View 1 Replies
Jul 2, 2007
I 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 Replies
Jul 16, 2010
i 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]...
View 7 Replies
Nov 23, 2009
In AS2 you could put a button under a movieclip and it would still work so you had to put a disabled button above it to stop it working. It seems that in AS3, a movie clip will disable button rollovers underneath it but I need it work!I've done a very basic test to make sure my movie clip isn't set to buttonMode=true or anything like that but it still happens.
View 1 Replies
Sep 30, 2009
ball2 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]........
View 4 Replies
Oct 5, 2009
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].....
View 3 Replies
Feb 10, 2010
I am calling this function via onEnterFrame from another function.
ActionScript Code:
function hitCheck():Void{
or(i= 0; i < numTools; i++){
[code]....
View 4 Replies
Oct 14, 2010
I am trying to create a very basic concept for a program that it based around a WIMP style interface. I have created a few moving windows using movie clips and I now want to add a button inside these movieclips that would act as an exit button, but in theory just returning to the frame before these appear. The problem I am having is that anything I create inside the movie clip is not being recognised, as clicking on it just makes the program think you want to move the window. The code I have used in my actions layer to create the moving effect is[code]...
View 6 Replies
Apr 7, 2010
I have four movieclip buttons inside my swf file.I have to add function on each movieclip. I tried it is not working.example code swf_name.butn1_mvc.addEventListener(MouseEvent.Cli ck, functionname);
View 4 Replies
Aug 23, 2005
This is the third thread I've written for my current project (1st was answered perfectly, 2nd failed [but I still figured it out anyways]) but I'm not sure if there is a solution to this problem. I can't really explain my problem, so once again I've included a helpful animation to show you what I mean. Bear in mind that the pale-blue box represents the movie clip's borders, and those borders are usually changed to include the animation (instead of the borders moving with the animation, the borders get bigger).
For the animation problem, I've already got a solution: create an invisible movie clip that has the exact size and shape of the animated movie clip and make it follow the movie clip as it animates, and make the hitTest check the invisible movie clip instead of the animated one. As for the rotation problem, well, I don't know how to fix it. Is there a way to change that?
View 1 Replies
May 30, 2007
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.
View 7 Replies
Oct 9, 2009
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");
}
View 3 Replies
Mar 29, 2011
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 Replies
Mar 26, 2009
I'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].....
View 3 Replies
Oct 14, 2003
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)) {
View 1 Replies
Apr 4, 2003
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!
View 3 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
Mar 2, 2010
I have a simple getURL button within a movieclip within another movieclip. Does anyone have any clue why this isn't working? The button is in the top layer of the child movieclip, and the child movieclip is in the top layer of the parent movieclip, so what am I missing here? I attached a simplified fla to show the issue. In the end, the main red box will be a country on a map and the popup box will contain info about the country and links to pictures and sites.
View 4 Replies
Jul 5, 2010
I am creating a somewhat elaborate (for me at least) navigation for my site. I have created a bunch of animated MC's to use as nav-buttons, and all that works great. The only issue is that when you mouse over the MC-buttons, the cursor stays as an arrow instead of turning into the little hand that always happens with links. The links work, but no little hand. Do I have to have a "hit area" defined in order to get the hand icon to popup or what?
View 7 Replies
Apr 21, 2004
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 Replies
Feb 12, 2010
So I am able to trace the correct coordinates. However the hitTest fails. Here is my code:
[code]....
View 1 Replies
Oct 20, 2010
I have a function that fires when a movieclip is pressed. It determines what animation to play and then calls the appropriate function. When it calls FlipWinCard
"private function FlipWinCard( card:MovieClip ):Void
{
// save card so we can flip it back over.[code].......
Most of the time the animation plays correctly but sometimes the animation fails. This has lead me to place most of the followup code in a function that is called by the animation (so I don't change state without showing an animation to the user). I would like to get some clues as to why gotoAndPlay inconsistently fails.It's not always the first time in a run, so I can't blame loading. It just gives up sometimes.The frame is a constant so it's not like I'm guessing a number that should change, in my opinion.I made a watchdog timer to check for the animation so my question isn't a "how to workaround" kind of question.I think there might be better coding practices I'm overlooking and maybe you've seen this before.
View 0 Replies
Jun 14, 2010
I've just recently tried my hand at actionscript 3 and have come across a road block.How do I go about rendering the cubes (cube1) intermittently, ie. staggered loading. I need the cubes to load a split second from each other.Below is a snippet of what I have so far:
var rows:int = 5;
var cols:int = 3;
var spacery:int = 100;
[code]....
View 1 Replies
Mar 17, 2011
I am building a quiz using XML for the questions and a ButtonTopLevel class to control the behaviour of the buttons tasked with choosing a question. Basically, the docClass imports the XML, makes sure it is fully loaded and then adds these top level buttons as children. I need to maintain the MouseEvent.CLICK in the button class because once the button has been used, it will switch to feedback mode and no longer be available as a button. Once clicked, the button says:
[Code]....
I have a sort of "go back" button in during development, and if I go back to the top level buttons and click any one of them, it works as it should. There is nothing undefined, with the possible exception of a variable or two I've declared and not yet used. Is it something in the way I'm telling the child to talk to its parent? My code is rather lengthy, but I will post if need be - just hoping it might be something I'm missing in this call to the parent.
View 2 Replies