Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




MovieClip HitTest



Hi,

I've created a moving MC (responding on Up,Left,....).
But I want I to NOT move if it's underneath something like a wall.
I've named the wall "muur". Any suggestions to stop the MC moving if it's right underneath/above/ left to/right to the wall, so you'll have to go around the wall. I tried some hitTest stuff, but it didn't work. Though I think it's related with hitTest.
Anyone?



Luster,



KirupaForum > Flash > Flash 8 (and earlier) > Flash MX
Posted on: 10-25-2003, 07:13 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Checking HitTest With Movieclip Inside Movieclip
I have a game where different movieclips are loaded randomly from an array in to a movieclip call flavors and move across the stage. Flavors is then loaded into the main timeline. I'm trying to test if a movieclip called "butterscotch" is loaded into the flavors movieclip and hits another movieclip called "butterscotch_tube". If it hits the right tube, the it adds one point, if it hits the wrong tube, all points are erased.

Here is the code inside Flavors:

Code:
var flavors:Array;

var thisFlavor:MovieClip;

flavors = [new creamSoda_mc(), new rootBeer_mc, new strawberry_mc, new cherry_mc, new watermelon_mc, new grape_mc, new bubblegum_mc, new butterscotch_mc, new cottonCandy_mc, new raspberry_mc, new sourApple_mc, new chocolate_mc, new mystery_mc];
thisFlavor = flavors[Math.floor(Math.random() *flavors.length)];
addChild(thisFlavor);
Here's the checking in the main timeline:

Code:
if(flavor.thisFlavor.hitTestObject(tubes.butterscotch_tube))
{
if(flavor.thisFlavor == thisFlavor[7])
{
butterscotchScore ++;
trace("butterscotch = " + butterscotchScore);
flavor.removeEventListener(Event.ENTER_FRAME, hitTube);
}

else
{
butterscotchScore = 0;
trace("butterscotch reset");
flavor.removeEventListener(Event.ENTER_FRAME, hitTube);
}
}
The problem, I believe, is in (flavor.thisFlavor == thisFlavor[7]).
thisFlavor is giving me an error, and I don't know what to put in the parenthases to get this working.

Thanks so much for your help in advance!

On HitTest To A Movieclip(a) By Movieclip(b)i Want To Attach Another Movieclip(c) To
on hitTest to a movieclip(a) by movieclip(b)i want to attach another movieclip(c) to movieclip(b)which is in the stage,so how to do it??
can anybody help on this???

HitTest Within A Movieclip
i've been stuck on this one for hours now and its driving me nuts, it seems so simple. I have a movieclip called 'ball' and a movieclip called 'targetClip', they are both nested within a main movieclip. i need to do a hit test to see if ball is inside targetClip, but i need to have the shapeflag set to true as targetClip is an iregular shape. i just can't get it to work?

i'm trying this but it's just saying "miss" all the time:
code: onClipEvent(load){
startDrag(this, true);
}
onClipEvent(enterFrame){
if(_parent.targetClip.hitTest(_x,_y,true)){
trace("hit");
}else{
trace("miss");
}
}

any ideas?

MovieClip.hitTest()
Thanks for to look in this thread.

Can any one explain me properly and priciously about hitTest() of MovieClip.
I am making a game and this hit test problem has been much sticky for me.

See my problem is :
(1) one object is droping form the top of the stage towards down side (consider as water level) to sink.
- with random speed of folling objects.
- so I am initialising a random no to random objets (e.g. randomRange(1,7))
- now, what happens that I have a one level consider (e.g. waterLevel) at some size of (_x = 400 and _y = 430)
and my stage size is ( width=400 and height = 460)
- now condition is that every object folling form top should be die if his parachoots is not opened before it touches to waterLevel.

- I increament the _y property of every fallingObject by this randomly generated Num. cotinuously ( onEnterFrame event )

- so problem is, when I increamet _y by randomly generated Num for some falling objects hit test does not occur and for some it occurs.

- for my waterLevel I have taken a MovieClip of water color and its shape is ( e.g.ractangular with curve shape like water is shaking/moving ) and in that movie clip I hava taken a dummy movie clip (e.g. emptyWaterMC of ractangular shape) and keep it as _hitArea of its _parent MovieClip

!!! ???? can any one explain me what should I do to get hitTest, always, by incrementing with randomly generated Num. ?????

***snippet some thing like****

var fallingObj_MC : MovieClip;
fallingObj_MC = target.attachMovie("abc","xyz",target.getNextHighe stDepth ());
// randomRange(lowNum,hiNum) generates random numers of given range
var randNum : Number = randomRang(1,7);

fallingObj_.onEnterFrame = function()
{
this._y += rndNum;
}
// now for water Level
var waterLevel : MovieClip;
var emptyWater : MovieClip;
waterLevel.hitArea = emptyWater;

watchOnWaterLevel.onEnterFrame = fucniton()
{
//I am checking hit test here
if(this.hitTest(fallingObj))
{
trace("hit done");
callObjectSink();
}
}

****** snippet end*************

Thanking you in advance

HitTest Any MovieClip?
I'm trying to make a Movieclip hitTest for any object in a particular timeline.
I can't seem to find a way to do this.

HitTest On Movieclip
Hi, Beginner and trying to get a feel for flash. I’m extremely competent Lingo programmer but finding Flash extremely frustrating.

I have an external .as script that imports successfully. I put a mouseListerner inside this .as and I want to detect the mouseDown within a movieClip I’ve placed on the stage that has an Instance name of pageA.

I've attached code so can someone explain where I’m going wrong please.

Thanks in advance for any help.Simon.








Attach Code

_MouseClickListen.onMouseDown = function(){
var beenHit = (_root.pageA.hitTest(_xmouse, _ymouse, true);
if (beenHit ) {
trace("Been Hit");
}
updateAfterEvent();
}
Mouse.addListener(_MouseClickListen);

MovieClip HitTest
Hi,

I've created a moving MC (responding on Up,Left,....).
But I want I to NOT move if it's underneath something like a wall.
I've named the wall "muur". Any suggestions to stop the MC moving if it's right underneath/above/ left to/right to the wall, so you'll have to go around the wall. I tried some hitTest stuff, but it didn't work. Though I think it's related with hitTest.
Anyone?



Luster,

Movieclip With Hittest?
hey guys,

i have a problem


i have a hittest area, i have a character you can use to walkaround, once you hit the hittest area, a movieclip will show, i also have a button that can also play the movieclip
now i got both work both the button and hittest. problem is when you walk over the hittest area the movieclip will show, once you leave the area the movieclip its still there, i want to be able to walk over(show movieclip), walk away, (movieclip dissapear), over and over

here is my code for the button

on (release) {
_root.gameup.gotoAndPlay(1)
}

and then on the hittest movieclip (for the guy to walk over) i have:


onClipEvent (enterFrame) {
if (this.hitTest(_root.Guy) && _root.gameup._currentframe==1) {
_root.gameup.gotoAndPlay(1);

}
}


to give you guys a better idea, here is my fla, pleazzz help

http://www.student.cofa.unsw.edu.au/...45/helpplz.fla




cheers

HitTest Within A Movieclip
I am having some trouble using hitTest within a movieclip.

If I create a movieclip on the main timeline, called for instance: world

Then I create a movieclip within that movieclip called: player

And another movielcip within the world movieclip called: walls

The player is a simple circle, and the walls clip contains 4 separated squares, spread around the stage. (Therefore it's separate parts inside the clip that need to be detected, and I can't use the bounding box).

Now, if I attach to the player:


Code:
onClipEvent(enterFrame) {
if (_parent.walls.hitTest(_x,_y,true)) {
trace("Ow.. I walked into a wall!");
}
}
If I used the same code on the player when he is on the main timeline, and the walls clip is also on the main timeline. I shouldn't have any problems and the player can detect when he bumps into an individual 'piece' of wall.

However, when I run the code on the player within the world clip, He appears to be hitting seperate wall pieces, in the same shape as the one's drawn in the wall movieclip, but they are offset from where they are supposed to be. And if you walk up to the walls that you can see, he doesn't notice a collision with them.

I hope that made sense. I'm sure the problem is something to do with the world moveclip's offset from 0,0 on the main timeline or something.

But is there anyway to easily solve this problem?

Also, the game I am making is also a scroller game, so the world movieclip will be constantly moving. Therefore the solution can't be just to keep the world movieclip at certain co-ordinates.

I have attached the simple example to the thread incase you didn't understand what I was saying. (I saved it as MX 2004, in case you don't have flash 8 or 9).

Thanks

Problems With MovieClip.HitTest
Hello!
Is there something wrong with this function?
In my program HitTest sometimes returns true, although there is
no collision with the other clip at all...
Is this a known problem? Or am I too silly?

Mfg
FlashNiete

MovieClip.hitTest(target)
I have movieclips named: target0, target1, target2, target3...
and a movieclip named: ball

i would like to test if the ball hits one of the targets.
How can i do this without having to right:


Code:
if(ball.hitTest(target0)){
... //this code is the same for every target
}
if(ball.hitTest(target1)){
...
}
...
I tried:

Code:
amount = 10;
for(i = 0; i < amount; i++){
if(ball.hitTest("target"+i))
setProperty("target"+i, _visible, false);
...
}
the ' "target"+i ' works fine with setProperty but not with hitTest

does anybody know why ?

Movieclip Duplicate HitTest
Here is my problem:

Say I have 5 duplications of one object.

* * * * *

Then, I have 5 duplications of another object.

! ! ! ! !

I need to run a hitest on each one of the first objectstee see if they hit any of the second objects.

*
! ! ! ! !


The problem is, they are all duplicates so how would I have flash run hittests on the first objects and have them check for duplicates?

HitTest Two Duplicated Movieclip
ok i have to duplicated movie clips (a bullet and enemy) i want the bullet to hitTest when any bullet hits any enemy

i tried many things so plz help

Loadmovie In A Movieclip With Hittest
hi all..
its very weird, loadmovie is a queit simple function i have just a small piece of code in my movie

// This is planted on a moveclip


PHP Code:



onClipEvent (enterFrame) {
    
        if (this, hitTest(_root.area)) {
        this.loadMovie("banner1.jpg");  // This dont works :(
        // _root.stat.text =  "Hit";
        } else {
        // _root.stat.text =  "Not Hit";
        }
        
    }




the load movie doesnt work it doesnt load banner1.jpg?!!

i need the script to be on the movieclip so not on the frame cuz i know
this DOES work, but i don't want to do so



PHP Code:



test.onEnterFrame=function(){
this.loadMovie("banner1.jpg");
}




and the hittest is working fine, cuz the when i set the value for
_root.stat.text = "Hit";

so the hittest DOES work.. but dunno the loadmovie don't.
also i wanted to say

in the frontpage i have 2 movieclip

1 called area
and 1 called tiles --> i've added a drag and drop fuunction for it

inside the tiles there are some other movieclip (3 mc's)
the one i have this code on is the mc called r01..

This is the source of it

Flash file

HitTest - Tell An Outside MovieClip To Go To NextFrame()
I am trying to have a animated rollout sub-menu for a menu, and figured using the onClipEvent / hitTest code would work well. My dilemna is that I want the menu rollout to include a fading in of a full screen photo, so I added the animation of the photo to the menu's movieclip. However, once the photo fades in, it is then part of the MovieClip hitTest area, so it won't let the mouse "rollout" of the movieclip (as the mouse is always over the photo, which takes up the whole flash area).

I came up with two possible solutions to solve the problem, but I need help with the coding:

1. Is there a way to define the hit area specifically to be just the menu part of the MovieClip (and disregard the space area that the photo occupies)?

or

2. Move the Photo animation into it's own MovieClip and then use the hitTest code to call the photo's MovieClip and tell it to do the same thing. Is this possible? This seems the better solution if doable.

Here's my attempt at coding this second option - but it doesn't work when I test it. Any ideas on how to make it work? The MovieClip of the photo animation has an instance name of "DiningRoom".

Here is the (nonworking) code:

onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.nextFrame();
} else {
this.prevFrame();
}
}

onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.DiningRoom.nextFrame();
} else {
this.DiningRoom.prevFrame();
}
}



Thanks for any help!

Defined HitTest Within Movieclip
hey i was just wondering if i can specify the shapeflag of a movieclip that is within another movieclip like,

if (_root.hero.hitTest(this._x, this._y, true)) {
//whatever
}

i tried it and it didnt work, i was thinking maybe it was because since the "this" clip was inside another movieclip, the _x and _y detection of "this" would be off.

HitTest And 'remove' Movieclip?
Hi guys,

To illustrate, lets say I have 2 objects (A and B).
I did a hitTest with A and B BUT what I want is, the B to disappear as it hits. Is it possible? I couldn't find an answer to this.

[F8] HitTest Between Two Instances Of The Same Movieclip
Hi, I'm having trouble with getting two instances of the same movieclip to hitTest with each other.

LINK TO SWF

(skip to the part with the zombies)

Heres the script for the zombies


Code:
stop();
if (_root.scenery._currentframe) {
for (i=1; i<3; i++) {
_root.scenery.attachMovie("zombie", "zombie_"+i, _root.scenery.getNextHighestDepth());
_root.scenery["zombie_"+i]._x = _root.guy._x+180*i*randomzombie;
_root.scenery["zombie_"+i]._y = 0;
randomzombie = Math.floor(Math.random()*(2-1))+1;
}
}
for (i=1; i<3; i++) {
_root.scenery["zombie_"+i].onEnterFrame = function() {
////(all the stuff about their speed and what they do in here)
}
};
}
What I would want to do is have a hitTest in there where when one instance of a zombie(a) touches another instance(b), zombie a would move over 10px;

I would (think I would) say this:


Code:
for (i=1; i<3; i++) {
_root.scenery["zombie_"+i].onEnterFrame = function() {
if (this.hitTest(_root.scenery["zombie_"+i])){
this._x += 10px;
}
}
But it doesn't react to that.

Anyone know how to do hitTests between two instances of the same movieclip?

Movieclip HitTest Problem
I was making a game with a hittest code, and found I can't seem to get it to work. Heres what I have:
Code:
onClipEvent (enterFrame) {
if (_root.boxes.box2.hitTest(_x, _y, true)) {
_root.hitest1 = "box 1 worked!!";
} else {
(_root.hitest1 = "still no hittest");
}
}
This is a movieclip inside another movieclip with that code in it, and whatever I try, it won't work.

HitTest - Using To Control A Different MovieClip
I am trying to have a animated rollout sub-menu for a menu, and figured using the onClipEvent / hitTest code would work well. My dilemna is that I want the menu rollout to include a fading in of a full screen photo, so I added the animation of the photo to the menu's movieclip. However, once the photo fades in, it is then part of the MovieClip hitTest area, so it won't let the mouse "rollout" of the movieclip (as the mouse is always over the photo, which takes up the whole flash area).

I came up with two possible solutions to solve the problem, but I need help with the coding:

1. Is there a way to define the hit area specifically to be just the menu part of the MovieClip (and disregard the space area that the photo occupies)?

or

2. Move the Photo animation into it's own MovieClip and then use the hitTest code to call the photo's MovieClip and tell it to do the same thing. Is this possible? This seems the better solution if doable.

Here's my attempt at coding this second option - but it doesn't work when I test it. Any ideas on how to make it work? The MovieClip of the photo animation has an instance name of "DiningRoom".

Here is the (nonworking) code:

onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.nextFrame();
} else {
this.prevFrame();
}
}

onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.DiningRoom.nextFrame();
} else {
this.DiningRoom.prevFrame();
}
}



Thanks for any help!

HitTest Within A Movieclip. Problem With X, Y Cordinates
Hi,

I am making this game where you are walking around in a house. You can only see the room you are currently in. I want each room to be a separate MC. It seems like hittest makes the x and y coordinates go funny when using hittest within a movie clip. I have a room(MC) and within that two MC, floor(MC) and player(MC) which I want to check for collision. Have played with localToGlobal but can¡¯t get it to work properly. Could anyone post some comments on this please?

Cheers

Jonas Eliasson

Movieclip & Array With HitTest, Not Working
Ok, my problem is that I have a grassfield named: "grass1". I put it an array named:"grass" with the index of 0. I want to use the array in a hitTest to make the guy stop. I know how to do the stop functions, but I don't think I am doing the array right. Here is all of my code so far:
Code:
movespeed = 10;
bg = new Array(_root.bg0);
objects = new Array(_root.bg0.grass0, _root.bg0.grass1);//My grass array
_root.guy.onEnterFrame = function() {
if (Key.isDown(37)) {
this._x -= movespeed;
}
if (Key.isDown(39)) {
this._x += movespeed;
}
if (Key.isDown(38)) {
this._y -= movespeed;
}
if (Key.isDown(40)) {
this._y += movespeed;
}
if (grass[0].hitTest(this)) {//This is the hitTest I am having troubles with
this._x -= movespeed;
}
};
Now, how can I get the hitTest to work properly with the array?

[F8] HitTest To Skip A Frame On Movieclip
I'm trying to use a hit test so that when two items collide, the movieclip which is moused over skips to the next frame of its animated timeline. Have tried various scripts and haven't found one that works properly, however here's the stage where I'm up to at present:

onClipEvent (enterFrame) {
if (_root.reddot.hitTest("_root.kick1")) {
kick1.gotoAndPlay(nextFrame);
}
}

Have also tried swapping kick1.gotoAndPlay.. for:
tellTarget (kick1) {
this.nextFrame()

Which worked on my original version of the movie when the movieclip was moused over.

HitTest Errors Between Attached Movieclip
i've checked this serveral times, there is nothing wrong with my actionscript, but still hitTest returns undefined between movieclips put onto the stage using attachMovie();

here's my code:

ActionScript Code:
thingOne = function() {};thingTwo = function() {    this._x = 100;    this._y = 100;};//Object.registerClass("one", thingOne);Object.registerClass("two", thingTwo);//thingOne.prototype.onEnterFrame = function() {    //make sure that both movieclips are valid movieclips    trace(this);    trace(_root.two);    //    trace(this.hitTest(_root.two));}//_root.attachMovie("one", "one", 1);_root.attachMovie("two", "two", 2);


is this is a bug? was it left out on purpose? am i wrong?
why is this?

Remove MovieClip Hittest Not Working.
Hey peoples,

I'm working on this top down game where some guy has to collect coins.
Thing is, for example I got 2 frames, and they both got coins in em, when you walk to the 2nd room and grab all the coins, and go back to the first room the coins respawned in both rooms.


Code:
onClipEvent (enterFrame) {
if (_root.survivor.hitTest(this)) {
_root.money++;
this.removeMovieClip();

}
}
That line of code is attached to a coin which is outside the Frame.


Code:
duplicatemovieclip("money2_mc", "money3_mc", 1);
setProperty ("money3_mc", _x, "200");
And that line of code is attached to the frame actionscript.
I can't seem to use that script twice, any idea of how I could pull this off?

Thanks in advance!

-Santa

HitTest Errors Between Attached Movieclip
i've checked this serveral times, there is nothing wrong with my actionscript, but still hitTest returns undefined between movieclips put onto the stage using attachMovie();

here's my code:

ActionScript Code:
thingOne = function() {};thingTwo = function() {    this._x = 100;    this._y = 100;};//Object.registerClass("one", thingOne);Object.registerClass("two", thingTwo);//thingOne.prototype.onEnterFrame = function() {    //make sure that both movieclips are valid movieclips    trace(this);    trace(_root.two);    //    trace(this.hitTest(_root.two));}//_root.attachMovie("one", "one", 1);_root.attachMovie("two", "two", 2);


is this is a bug? was it left out on purpose? am i wrong?
why is this?

[as1] Dynamic MovieClip HitTest Troubles
I am working on a project where I have 24 Movie Clips that will be dragged around to create a design layout. Each Movie Clip can be used as many times as necessary for the user to achieve their design. So what I'm doing is duplicating the Movie Clips upon the initial drag.

Since all of my MC's will be dynamically named and I need to be able to snap the ends of the pieces together, I have decided to try and use an array to store the active MovieClips so that I can run a HitTest against the array to determine if the dragged object is overlapping another object. The problem is, it appears to only be working correctly for the first and most recent duplicates. All of the duplicates in between these two do not seem to function properly from what I can gather with my reporting.

What happens is I have a dynamic textbox (txtTest) that is suppose to display the name of the hitTest Target that's in the array. As I mentioned before, the first and last items in the array always report themselves correctly. The ones in between don't, eventhough when I step-through the code in debug mode it seems to be running the line of code that sets the txtTest value. I'm new to operating the debug in Flash MX but the order in which it runs is odd also. It seems to keep going over the area of code more times then it's suppose to.

Anyways, here's the code:

ActionScript Code:
onClipEvent (load) {
    if (getProperty(this, _name) == "testDrag") {
        _root.mcArray = new Array();
        _root.mcArraySize = 0;
    }
}
on (press) {
    if (getProperty(this, _name) == "testDrag") {
        _root.i++;
        nextMC = "testDrag"+_root.i;
        clone = _root.testDrag.duplicateMovieClip(nextMC, _root.i);
        _root.mcArray.push(nextMC);
        _root.mcArraySize++;
        clone._alpha = random(100);
        clone.startDrag();
        clone.onMouseUp = function() {
            stopDrag();
        };
        _root.bringToFront(this);
    } else {
        this.startDrag();
        _root.bringToFront(this);
        this.onMouseUp = function() {
            stopDrag();
            for (i=0; i<_root.mcArraySize; i++) {
                if (this.hitTest(_root[_root.mcArray[i]])) {
                    _root.txtTest = _root.mcArray[i]+" Hit!";
                }
            }
        };
    }
}


Any help would be greatly appreciated. I've looked and looked and haven't seen implementations of this nature to look at for ideas on how to implement this.

HitTest Only The Content Of Movieclip And Not From 0,0 To _width, _height?
Hey guys

This is probably just a brainfart but when I publish the code below, my hitTest is triggered by the entire movieclip from 0,0 to _width, _height and not by it’s content.

The “fwa” movieclip contains some txt that I broke apart, and I only want the hitTest to run when the “mc” hits the txt within the “fwa” movieclip!




ActionScript Code:
var i:Number = 0;var count:Number = 0;var colorArr = ["0x99cc33", "0xff0066", "0xffcc00", "0x33ccff"];this.onEnterFrame = function(){        mc = this.createEmptyMovieClip("mc"+i, this.getNextHighestDepth());    mc.attachMovie("circle", "circle", mc.getNextHighestDepth());    mc._x = Math.random()*Stage.width;    mc._y = Math.random()*Stage.height;    mc._xscale = mc._yscale = Math.random()*150;    mc._alpha = 20+Math.random()*80;        var my_color:Color = new Color(mc);        if(mc.hitTest(fwa))    {        my_color.setRGB(0xFFFFFF);    }    else    {        my_color.setRGB(colorArr[count]);    }    count++;    i++        if(count == colorArr.length){ count = 0 }    }




Hope somebody can give me a hint here

Hittest In A Movieclip Which Is In A Movieclip
Hey

I'm creating a gta style driving game, its top down.

The way it moves is the backround moves and the car rotates, so it gives the viewer the feeling that the car is moving along the road.

Now the map is in a seperate movie clip so its easier to upload/edit and create new maps, also so i can give the map layout to friends so the can help create the maps.

The only problem is the map transition.

Now so we dont have lots of hittests in the car's code, for the map transitions, i want to have the code for each transition in the hittest area on the map.

So the code is in _root.track.city1 movie clip
and we detect the collisition between the _root.car movie clip
and set a variable to be received by a movie clip called _root.mapchange

I'm thinking in the movie clip _root.track.city1 the code

code: if (_root.track.city1.hittest("_root.car")) {
_root.changemap = "newmap.swf";
}

But the movie clip _root.mapchange cant pick it up

i have worked out that the clip _root.mapchange is picking the variable up, the hittest is not see that the two objects are colliding

Hope Someone Can Help
Steve

Movieclip As Button HitTest Working Intermitent, Need Advice.
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. Any ideas why? I'm using onEnterFrame () to do the hitTest constantly.

Thanks

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;
}
if ( background._alpha < 0 ) {
background._alpha = 0;
}
if (hitTest( _root._xmouse, _root._ymouse, true)) {
background._alpha -=25;
}
else if (hitTest( _root._xmouse, _root._ymouse, false)) {
background._alpha +=25;
}
}

Movieclip As Button HitTest Working Intermitent, Need Advice.
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. Any ideas why? I'm using onEnterFrame () to do the hitTest constantly.

Thanks

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;
}
if ( background._alpha < 0 ) {
background._alpha = 0;
}
if (hitTest( _root._xmouse, _root._ymouse, true)) {
background._alpha -=25;
}
else if (hitTest( _root._xmouse, _root._ymouse, false)) {
background._alpha +=25;
}
}

How To Take Time From HitTest True To HitTest False?
hi
i have 2 MCs one is going through the other
and i want to take the time from the beginning
to the end.my code is this:
onClipEvent(load) {
this._visible = 0;
}
onClipEvent(enterFrame) {

first = new Date;
second = new Date;
indicator = 0;
if(!indicator && this.hitTest(_root.rocket)) {
indicator = 1;
sec = erst.getSeconds;
mil = erst.getMilliseconds;
begining = sec add ":" add mil;
}

if(indicator && !this.hitTest(_root.rocket)) {
indicator = 0;
seco = zweit.getSeconds;
mill = zweit.getMilliseconds;
end = seco add ":" add mill;
xposi = getProperty(_root.rocket, _x);
yposi = getProperty(_root.rocket, _y);
position = xposi add yposi;
}
}

further i want to show begining, end and position in 3 different textfields, but nothing works at all !!!
can it be, that it doesn`t work, because "this" is a symbol
in a symbol?!?

thx
bo

Hittest=false, Trying To Do The Opposite Of Hittest.
This question may have such an easy solution it might be worth for the newbies section...
I need an mc to do an action (go to a certain x point) whenever the mouse ISN'T over a particular box. So basically I would need to revert the typical
if (hitTest( _root._xmouse, _root._ymouse));
Anyone knows how to do this?
Thank you soooo much!

HitTest...creating The Opposite Of A HitTest
When I roll over a mc an enter frame triggers a function that is designed to evaluate when the mouse moves off the mc...how do you test for the opposite of a hitTest? I though in an "!", but didn't work.


PHP Code:



var buttonTarget:String = "targetMarkets_mc";

root[buttonTarget].addEventListener(MouseEvent.MOUSE_OVER, overHandler);

function overHandler (event:MouseEvent){
            
    root[buttonTarget].gotoAndStop ("active");
    
    root[buttonTarget].addEventListener(MouseEvent.MOUSE_MOVE, mouseEval);
};

function mouseEval (event:MouseEvent) {
    
    if (!root[buttonTarget].hitTestPoint (mouseX, mouseY, true)) {
        root[buttonTarget].gotoAndStop ("inactive");
        root[targetMC].removeEventListener (MouseEvent.MOUSE_MOVE, mouseEval);
    }
};




Also, how do you remove the event listener? Is there a need?

[hitTest/Mask] Can A Mask Hide A HitTest Area?
Hi, the subject pretty much says it all. I have the following code:


ActionScript Code:
volume.onEnterFrame = function() {
    if (volume.hitTest(_xmouse, _ymouse, true)) {
        _root.nextFrame();
    } else {
        _root.prevFrame();
    }
};


...and here is the link. Move your mouse under the bar and move it up slowly under the the speaker next to the number. See what happens? Keep in mind that the look is still being perfected, I was just wanting to know if there were a way I could fix the problem or do I just have to start thinking of a new look for it? Thanks in advance.

(PS: let me know what you think of the look and layout please)

? Resize Stage To Dynamically Match External Movieclip Loaded Into Empty Movieclip
Hi all,
Does anyone know how I can resize the stage to match the size of an external graphic/movieclip which is loaded into an empty movieclip,
thanks

? Resize Stage To Dynamically Match External Movieclip Loaded Into Empty Movieclip
Hi all,
Does anyone know how I can resize the stage to match the size of an external graphic/movieclip which is loaded into an empty movieclip,
thanks

? Resize Stage To Dynamically Match External Movieclip Loaded Into Empty Movieclip
Hi all,
Does anyone know how I can resize the stage to match the size of an external graphic/movieclip which is loaded into an empty movieclip,
thanks

#1009 Error Movieclip Inside Movieclip Changing The Alpha Property
Problem:
I'm getting this "TypeError: Error #1009: Cannot access a property or method of a null object reference."
What's happening in the flash file is that I've got a movieclip inside a movieclip and when you roll over one of the movieclips the alpha setting for the movieclip inside the initial movieclip is set to 1, then it transitions out back to 0 over a period of time.

var myTween:Tween = new Tween(event.target.parent.ripple_mc, "alpha", Strong.easeOut, 0, 100, 24, false);

It seems to be random but eventually after rolling over the several movieclips on the stage the error comes up. Sometimes the alpha setting stops working and will continue to be visible even though it should have stopped and be invisible after 24 frames.

Would love some help on this.

Cheers

#1009 Error Movieclip Inside Movieclip Changing The Alpha Property
Problem:
I'm getting this "TypeError: Error #1009: Cannot access a property or method of a null object reference."
What's happening in the flash file is that I've got a movieclip inside a movieclip and when you roll over one of the movieclips the alpha setting for the movieclip inside the initial movieclip is set to 1, then it transitions out back to 0 over a period of time.

var myTween:Tween = new Tween(event.target.parent.ripple_mc, "alpha", Strong.easeOut, 0, 100, 24, false);

It seems to be random but eventually after rolling over the several movieclips on the stage the error comes up. Sometimes the alpha setting stops working and will continue to be visible even though it should have stopped and be invisible after 24 frames.

Would love some help on this.

Cheers,

Sarge

Control A Nested MovieClip From A Button Component Inside A Seperate MovieClip.
I am a beginner in using Flash and Action Scripting.

This is the Scenerio:

I want to control a movieclip that is inside of another movie clip.
I control it from a button component that is inside of a seperate movie clip.

test = button component instance name
test1 = function
test2 = Movieclip instance name
test3 = Movieclip instance name
testbutton = movieclip name where button component is located

I am able to control a movieclip on the main timeline with the following AS 3.0:

test.addEventListener (MouseEvent.CLICK, test1);
function test1(event:MouseEvent):void
{
event.target.root.test2.gotoAndPlay(2);
}

I want to control a movieclip inside MovieClip1.

I tried this:

test.addEventListener (MouseEvent.CLICK, test1);
function test1(event:MouseEvent):void
{
event.target.root.test2.test3.gotoAndPlay(2);
}

The movie loaded fine when I tested but got this error when I pressed the button:

TypeError: Error #1010: A term is undefined and has no properties.
at Untitled_fla::testbutton_26/test1().

Please help!!!!!!!!!

MovieClip.onRelease = MovieCLip.Protoype Function Fails To Execute Properly
Dear all,

I created a simpe function:

MovieClip.prototype.hiMe = function(me, theRest)
{
//declare the format colors white and grey
formatMe = new TextFormat();
formatMe.color = Colors[0];
formatMe.font = "Adventure Subtitles";

formatTheRest = new TextFormat();
formatTheRest.color = Colors[1];
formatTheRest.font = "Adventure Subtitles";

// assign grey to theRest
for (i =0 ; i < theRest.length; i++)
{
theRest[i].tfield.setTextFormat(formatTheRest);
}
// make the me white
me.tfield.setTextFormat(formatMe);

}

when I call it (bar[0] is an array of objects)
bar[0].invar.onRelease = hiMe(bar[0],bar);

it executes on load regardless of the onRelease eventHandler and the ownards it does not execute when exciting the event.

does somebody know why this may be?

Cheers

DDT

MovieClip.onRelease = MovieCLip.Protoype Function Fails To Execute Properly
Dear all,

I created a simpe function:

MovieClip.prototype.hiMe = function(me, theRest)
{
//declare the format colors white and grey
formatMe = new TextFormat();
formatMe.color = Colors[0];
formatMe.font = "Adventure Subtitles";

formatTheRest = new TextFormat();
formatTheRest.color = Colors[1];
formatTheRest.font = "Adventure Subtitles";

// assign grey to theRest
for (i =0 ; i < theRest.length; i++)
{
theRest[i].tfield.setTextFormat(formatTheRest);
}
// make the me white
me.tfield.setTextFormat(formatMe);

}

when I call it (bar[0] is an array of objects)
bar[0].invar.onRelease = hiMe(bar[0],bar);

it executes on load regardless of the onRelease eventHandler and the ownards it does not execute when exciting the event.

does somebody know why this may be?

Cheers

DDT

#1009 Error Movieclip Inside Movieclip Changing The Alpha Property
Problem:
I'm getting this "TypeError: Error #1009: Cannot access a property or method of a null object reference."
What's happening in the flash file is that I've got a movieclip inside a movieclip and when you roll over one of the movieclips the alpha setting for the movieclip inside the initial movieclip is set to 1, then it transitions out back to 0 over a period of time.

var myTween:Tween = new Tween(event.target.parent.ripple_mc, "alpha", Strong.easeOut, 0, 100, 24, false);

It seems to be random but eventually after rolling over the several movieclips on the stage the error comes up. Sometimes the alpha setting stops working and will continue to be visible even though it should have stopped and be invisible after 24 frames.

Would love some help on this.

Cheers,

User Input Creates MovieClip Made Of MovieClip Symbols
Hello. I need some help either with my situation or with the search terms I'm using to try to find an answer.

I am using Flash MX Pro 2004.
I have drawn letters A-Z in Flash in two different styles (for example one that is furry and another that looks like metal). I would like users to select a text style (furry or metal) and enter text via text input field. When they have pressed an Enter button I would like the word to appear made up of the drawn symbols that I created.

I don't want to make an actual font. Any ideas on search terms to find the sort of thing I am looking for? Here's some that I've tried already:

convert text to symbols -- I get tons of results talking about putting textfields in symbols.

user input to symbols -- almost same results as above

custom fonts using symbols -- I get results talking about how to embed fonts and making text bold, italic, etc. Also not what I'm after.

All help is appreciated. Thanks in advance.

Scott

Receive Full Path To A MovieClip, Return A MovieClip Reference.
Hi, I got this function...

Code:
Function getMCPath(path:String)
{
var MC:MovieClip;
MC = eval(path)
return MC;
}

If I send "_level0" this will return _level0, but if I send "_level0.myMC" this will return undefined.

what should I do in order to get full path to _level0.myMC

Thanks in Advance,
DMZ

How To Hide My Current Movieclip And Display 2nd Dynamically Created Movieclip?
I have a movieclip in which there is an image create this movieclip dynamically by reading the oath of the image from file and play an effect. its working fine, now i want to hide this MC after its effect is ended and then dynamically want to create the other MC and similarly so on. how to do that. my code is as below:

var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);

lv.load("data.txt");
var my_lv:LoadVars = new LoadVars();
my_lv.load("data.txt");
my_lv.onLoad = function(success)
{
if (success)
{
if(this.pic1!=undefined)
{
var ImgMc:MovieClip = createEmptyMovieClip("ImgMc", getNextHighestDepth());
_root.mcLoader.loadClip(this.pic1,_root.ImgMc);
//Some effect on ImgMc

//how to hide the ImgMc whe nits effect is played and then load another image in a movieclip and so on
}
}
}

Load Movieclip From Libary Into Another Blank Movieclip On Stage (URGENT PLEASE)
hi all i just need to know how to load a movieclip into a blank movie clip all in the same movie?! please help many regards peter thanks in advance!

Movieclip Rollover Effect Disables Internal Movieclip Buttons
Is it possible to have a movieclip rollover effect with another movieclip inside of it that is able to be clicked and do what it's scripted to do?

Let me try to get specific...


Movieclip 1 -- Has www.kirupa.com/developer/mx2004/button_effect.htm applied

Inside of Movieclip 1 --> Buttons that appear visible when you rollover the menu (it comes out of eases into view)

These buttons inside are not being allowed to be pushed because from what I can gather, the complex rollover is not allowing anything to be activated except the rollover effect.

So here's a diagram:

Rollover Movieclip 1 --> Eases it's bottom part up revealing 4 buttons --> These buttons when clicked are supposed to do an action --> Buttons cannot be activated for some unknown reason.

Can anyone help me out? I'm out of ideas after working on this for the past hour or so. If you need any extra info or materials, let me know; I'm sitting right here working on this problem haha.

-Indecisive

Copyright © 2005-08 www.BigResource.com, All rights reserved