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








HitTest On Multiple Targets


Hey Guys,
I’m trying to setup a MC that has a hitTest that is triggered by multiple targets. Like how do you game developers do this. Like in a shooting game, the bullet will not hit only one target every time. It’s different all the time. So how would you know on a wide range of targets?
Thanks,


Najam D.


UPDATE++++++++++++++++++++++++++++++++++++++++++++ ++++++++
Best Work Around

Quote:




Originally Posted by HeraldofWoe
I think that this will get you on the right track.

(And it specifically addresses your problem Pitchdog)





++++++++++++++++++++++++++++++++++++++++++++++++++ ++




FlashKit > Flash Help > Flash ActionScript
Posted on: 02-07-2006, 05:55 PM


View Complete Forum Thread with Replies

Sponsored Links:

Detecting Hittest On Multiple Targets
okay here's another bummer, a question about a game application:

so i have this 1 player character, who holds a machine gun. and of course, there are dozens upon dozens of enemies. now i want a bullet to damage anyone of these enemies when it hits them (duh), so what do i do? here's how i tackled the problem...

i create an array of enemy movieclips, let's call it enemyArray.

each bullet is a movieclip unto itself, and has a script that runs every enterFrame that detects if it is intersecting anyone of the enemies in the enemyArray. if it detects that it is within an enemy movie clip, it destroys itself and calls a hit() function that is standard in every enemy MC (which in turn removes a hitpoint from said enemy).

now, i've got a feeling that i've been doing this the hard way, since having to traverse an array over and over and over again for EACH bullet is kind of... overdone. is there some function within Flash that can tell me that if a bullet is intersecting something, and return a reference of that said something? so i can do something like:

Code:
bullet.enterFrame = function(){
var victim = this.getIntersectingMC();//this of course is fictitous
victim.hit();
}


thanks to anyone who can help!

J.

View Replies !    View Related
HitTest On 3 Targets
I'm trying to use hitTest to detect if a dragged clip is over any one of 3 different targets - when it is I want that target to blink. And then when I drag off I'd like the blinking to stop. Make sense? I'm struggling a bit with the following code:


Code:
square_mc.onPress = function() {
this.startDrag();
for (z=1; z<4; z++) {
circle = _root["circle"+z+"_mc"];
this.onEnterFrame = function() {
if (this.hitTest(eval(circle))) {
//trace(eval(circle));
trace("You are over a circle");
eval(circle).gotoAndPlay("loop");
delete this.onEnterFrame;
}
};
}
};
square_mc.onRelease = function() {
this.stopDrag();
trace("You released over the circle");
eval(circle).gotoAndPlay("off");
};
The "eval(circle)" part isn't really working. What's a better way to express the name of current target clip? Thanks for the help.

View Replies !    View Related
HitTest Several Objects Two Targets
Hi,

I have a movie clip called redcube_mc on the stage that can be duplicated when pressed. The number of duplicates that can be made is limited by a variable. The cubes can then be dragged to one of two targets. After the cubes are positioned by the user, a "check answer" button should call a function that checks to see how many cubes are on each target. I know how to use hitTest to check for one object on one target but what would the code look like for this situation?

This is what I have so far:

//this function is called when redcube_mc is pressed
function makeCube():Void {

if (nLevel <= nMultiplier) {
var mcDuplicatedCube:MovieClip = this.Figure1.redcube_mc.duplicateMovieClip("redcub e_mc" + nLevel, nLevel++);
}
mcDuplicatedCube.focusEnabled = true;
mcDuplicatedCube._focusrect = false;
Selection.setFocus(mcDuplicatedCube);

mcDuplicatedCube.startDrag(true, 15, 15, nlimit1, 192);
mcDuplicatedCube.onRelease = function() {

stopDrag();
}
//I had to add this bit of code in order to move the cubes again after they are first placed. Is there a better way?
mcDuplicatedCube.onPress = function(){
var x:Number = _root._xmouse;
var y:Number = _root._ymouse;
if (mcDuplicatedCube.hitTest(x,y,true)) {
mcDuplicatedCube.startDrag(true);
}
}
mcDuplicatedCube.onRelease = function(){
mcDuplicatedCube.stopDrag();

}
}

What sort of function should my check answer button call?

Thanks a lot!

View Replies !    View Related
Single Button, Multiple Action/Multiple Targets
I originally posted this on the MX board but I think it should be here. It's a difficult one to describe.

I want to assign two separate events to a single action, but I want one event to follow the other. Both targets are MovieClips nested within the same external swf, which has been imported into the main timeline. Follow me?

on (release) {
_root.loadMovieMC.FallMan.gotoAndPlay("end");
}
on (release) {
_root.loadMovieMC.gotoAndPlay("FishGirl");
}


Problem is that once the button is clicked it runs straight to "FishGirl" without playing FallMan("end"). If I take out the second expression, it will play FallMan okay, but not the two together.

I'm in over my head here, Can anyone please help?

View Replies !    View Related
[MX] Drag And Drop Multiple Targets Multiple Drags
I have a drag and drop that has six dragable items to six potential targets. Only three of the targets are correct. Any of the six dragable items can hit a correct target. What I am having issues with is let's say after target 1 is hit, I don't want it to be able to get hit again. My code looks like this. But trying to do the enabled false does not work. Any idea how I can disable target 1 below assuming that it was just hit for the first time so it can't be hit again? Thanks.

but1_mc.onRelease = function() {
stopDrag();
if (this.hitTest(target1_mc) || this.hitTest(target2_mc) || this.hitTest(target3_mc)) {
if (this.hitTest(eval("target1_mc"))) {
target1_mc.enabled = false;
}

correct = correct+1;
}

View Replies !    View Related
HitTest Based On Diff Targets
I'm trying to make a seating chart generator. I have all the desks laid out and the names at the bottom. A teacher would drag the names to the desk and then that desk would be populated with information about the student.

I can do all the loops and hitTests, but I don't know how to change the text of a MC based on which other MC has a hitTest with it.

Any help would be appreciated.

View Replies !    View Related
Multiple Targets
is it possible to have multiple targets in the same set property script?

View Replies !    View Related
Multiple Targets
Hi there,

I have alot of targets called a,b,c....
I would like to apply a SetProperty to those targets:

setProperty ("a;b;c", _rotation, 90);

What is correct code to have multiple targets in one setProperty?

"a;b;c" dosen't work in my example above, and I can't find the right syntax.

Thank you for any help,
Francois.

View Replies !    View Related
How To Have Multiple Targets
i want to change the color of multiple movie clips all in one big whoop.so here's what i have:

------------code:
gray = new Color(_root["mc1"],root["mc2"].....);
gray.setRBG(0x7D8287);
------------



but it's not working any suggestions?
thanks

View Replies !    View Related
Multiple Targets?
can a button have multiple targets?

if not than how can i make it so my button still has an animation on it and also tell a MC to go to a certain frame?

View Replies !    View Related
Multiple Tell Targets?
Can I have multiple telltargets? I want 5 different movie instances to goto 1 and stop.....do I have to make 5 different telltarget commands or can I do them all in one? Seperated by commas or something?

This is how it looks now (buttton action, release):

}
on (release) {
tellTarget ("_root.comp") {
gotoAndStop(1);
}
}
on (release) {
tellTarget ("_root.solu") {
gotoAndStop(1);
}
}
on (release) {
tellTarget ("_root.case") {
gotoAndStop(1);
}
}
on (release) {
tellTarget ("_root.contact") {
gotoAndStop(1);
}
}


Thanks,


Mik

View Replies !    View Related
Multiple Targets
I'm just starting out in AS3 and need some help with a drag and drop word scramble game.

Basically I need to be able to match two movieclips in the same target. So in the example below I have the word SANDALS, there are two S's and A's and I want the user to be able to put the duplicate letters in either slot. As it is right now the s_mc can only go in the first target slot and the s2_mc can only go in the last target slot. Same goes for the a_mc and a2_mc.

I'm sure there's a simple fix for this

s_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
s_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
a_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
a_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt1);
n_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
n_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt2);
d_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
d_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt3);
a2_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
a2_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt4);
l_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
l_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt5);
s2_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
s2_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt6);

function pickUp(event:MouseEvent):void {
event.target.startDrag(true);
event.target.parent.addChild(event.target);
startX = event.target.x;
startY = event.target.y;
}
function dropIt(event:MouseEvent):void {
event.target.stopDrag();
var myTargetName:String = "target" + event.target.name;
var myTargetisplayObject = getChildByName(myTargetName);
if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
event.target.removeEventListener(MouseEvent.MOUSE_ DOWN, pickUp);
event.target.removeEventListener(MouseEvent.MOUSE_ UP, dropIt);
event.target.buttonMode = false;
event.target.x = myTarget.x;
event.target.y = myTarget.y;
counter++;
s_mc.filters = null;
targets_mc.gotoAndPlay(2);
success.play();
}

if(counter == 7){
this.gotoAndStop(2);

}
}


function dropIt1(event:MouseEvent):void {
event.target.stopDrag();
var myTargetName:String = "target" + event.target.name;
var myTargetisplayObject = getChildByName(myTargetName);
if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
event.target.removeEventListener(MouseEvent.MOUSE_ DOWN, pickUp);
event.target.removeEventListener(MouseEvent.MOUSE_ UP, dropIt);
event.target.buttonMode = false;
event.target.x = myTarget.x;
event.target.y = myTarget.y;
counter++;
a_mc.filters = null;
targeta_mc.gotoAndPlay(2);
success.play();
}

if(counter == 7){
this.gotoAndStop(2);
}
}
function dropIt2(event:MouseEvent):void {
event.target.stopDrag();
var myTargetName:String = "target" + event.target.name;
var myTargetisplayObject = getChildByName(myTargetName);
if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
event.target.removeEventListener(MouseEvent.MOUSE_ DOWN, pickUp);
event.target.removeEventListener(MouseEvent.MOUSE_ UP, dropIt);
event.target.buttonMode = false;
event.target.x = myTarget.x;
event.target.y = myTarget.y;
counter++;
n_mc.filters = null;
targetn_mc.gotoAndPlay(2);
success.play();
}

if(counter == 7){
this.gotoAndStop(2);
}
}
function dropIt3(event:MouseEvent):void {
event.target.stopDrag();
var myTargetName:String = "target" + event.target.name;
var myTargetisplayObject = getChildByName(myTargetName);
if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
event.target.removeEventListener(MouseEvent.MOUSE_ DOWN, pickUp);
event.target.removeEventListener(MouseEvent.MOUSE_ UP, dropIt);
event.target.buttonMode = false;
event.target.x = myTarget.x;
event.target.y = myTarget.y;
counter++;
d_mc.filters = null;
targetd_mc.gotoAndPlay(2);
success.play();
}

if(counter == 7){
this.gotoAndStop(2);
//completed.play();
}
}
function dropIt4(event:MouseEvent):void {
event.target.stopDrag();
var myTargetName:String = "target" + event.target.name;
var myTargetisplayObject = getChildByName(myTargetName);
if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
//reply_txt.text = "Good Job!";
event.target.removeEventListener(MouseEvent.MOUSE_ DOWN, pickUp);
event.target.removeEventListener(MouseEvent.MOUSE_ UP, dropIt);
event.target.buttonMode = false;
event.target.x = myTarget.x;
event.target.y = myTarget.y;
counter++;
a2_mc.filters = null;
targeta2_mc.gotoAndPlay(2);
success.play();
}

if(counter == 7){
//reply_txt.text = "Congrats, you're finished!";
this.gotoAndStop(2);
//completed.play();
}
}
function dropIt5(event:MouseEvent):void {
event.target.stopDrag();
var myTargetName:String = "target" + event.target.name;
var myTargetisplayObject = getChildByName(myTargetName);
if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
//reply_txt.text = "Good Job!";
event.target.removeEventListener(MouseEvent.MOUSE_ DOWN, pickUp);
event.target.removeEventListener(MouseEvent.MOUSE_ UP, dropIt);
event.target.buttonMode = false;
event.target.x = myTarget.x;
event.target.y = myTarget.y;
counter++;
l_mc.filters = null;
targetl_mc.gotoAndPlay(2);
success.play();
}

if(counter == 7){
//reply_txt.text = "Congrats, you're finished!";
this.gotoAndStop(2);
//completed.play();
}
}

function dropIt6(event:MouseEvent):void {
event.target.stopDrag();
var myTargetName:String = "target" + event.target.name;
var myTargetisplayObject = getChildByName(myTargetName);
if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
//reply_txt.text = "Good Job!";
event.target.removeEventListener(MouseEvent.MOUSE_ DOWN, pickUp);
event.target.removeEventListener(MouseEvent.MOUSE_ UP, dropIt);
event.target.buttonMode = false;
event.target.x = myTarget.x;
event.target.y = myTarget.y;
counter++;
s2_mc.filters = null;
targets2_mc.gotoAndPlay(2);
success.play();
}

if(counter == 7){
//reply_txt.text = "Congrats, you're finished!";
this.gotoAndStop(2);
//completed.play();
}
}


s_mc.buttonMode = true;
a_mc.buttonMode = true;
n_mc.buttonMode = true;
d_mc.buttonMode = true;
a2_mc.buttonMode = true;
l_mc.buttonMode = true;
s2_mc.buttonMode = true;

View Replies !    View Related
Tell Multiple Targets?
Gee, this doesn't work:

tellTarget ("Config/BCon1","Config/BCon2","Config/BCon3","Config/BCon4") {
gotoAndStop(1);

}

The only instance that responds is BCon4... Is it the string? There has got to be a simple way... Thanks in advance!

View Replies !    View Related
Tell Multiple Targets
Hi, I was trying to do a button that tells a target to go to frame 5 if the answer is correct, and to frame 10 if it's incorrect, so I put this code

on (release) {if (A == 2) {tellTarget ("A2") {gotoAndStop(5);}}
else {tellTarget ("A2") {gotoAndStop(10);}}}

But, I want to do it so it also verifies and tells other targets to do the same thing, where B==7, C==3, D==6, E==1, F==5 and G=4.

I know i can put multiple Targets in the if statement, but telltarget doesn't allow that, Can anyone tell me how to do this?

I included the file also, just in case... I think my explication wasn't that clear

Thanks

View Replies !    View Related
Hmmm... Multiple Targets?
Is it possible to assign an action to multiple tagets?

ex. I need movie 1 to tell movie 2, 3, 4...12 all to go to frame 1 of their respective timelines

I know that I can write a 'with'/'goto' script for each one but I forsee that getting a little tedious.

I need a function like:

with (movie1, movie2, movie3, ... movie12) {
gotoAndPlay (1);
}

I know the above doesn't work but is there anyway to acheive what I'm describing?

cheers

motiv

View Replies !    View Related
Multiple Tell Target Targets
Is there any way that i can have one tell target action, but have the tell target affect multiple symobls?

View Replies !    View Related
Stating Multiple Targets
is there a way to state more than one target in the TellTarget thing? or do we have do state each target individually?

View Replies !    View Related
Button With Multiple Tell Targets
hello ...can someone show me a sample code for a button that has more than one tell target command when "on release" it doesn't seem to work for me.
thank you in advance for your help

View Replies !    View Related
Multiple Targets For SetScrollTarget....possible?
Hi Wise people...

Does anyone know if there is a way to have 1 scrollbar scroll more than one textfield? (I'm trying to create a shadow in my textfield thisway, but the scrolling seems to cause some problems here..)

Thnx alot!

Greets,

Tony

View Replies !    View Related
Multiple Buttons With Tell Targets
I have looked through the forum....my question is I have multiple buttons on a layer and wish to attach tell targets to each of them. I am creating a portfolio, the first button(1st pic)works fine and the larger image appears in the preview box. When I roll over the second button the telltarget cannot be found. Does each telltarget have to be on a different layer. How do I make all the buttons perform corectly using the roll over/ roll out method.

Desperate and Dying for help...School Project is Eminent

View Replies !    View Related
Load Jpg Within Multiple Targets
hi,
i would like to load an swf with 2 targets.

my code:

this.imagesLoader.container.loadMovie("myImage.jpg ");
this.imagesLoader.container1.loadMovie("myImage.jp g");

but in this way i loaded two times the same jpg.

i thought to load one jpg and duplicate it with duplicateMovieClip method but it works only with levels. I need to load my pictures within targets because i have to mask one.

Any ideas?
thank you,
Noir

View Replies !    View Related
[CS3] AS 2.0 Setproperty And Multiple Targets
Hi,

wel I have 6 buttons named _1 _2 _3 _4 _5 _6

When I rollover on one button the other must became invisible, so for ex the action for the button _1 will be:


PHP Code:



on (rollOver) {
    setProperty("_2", _alpha, 0);
    setProperty("_3", _alpha, 0);
    setProperty("_4", _alpha, 0);
    setProperty("_5", _alpha, 0);
    setProperty("_6", _alpha, 0);
}
on (rollOut) {
    setProperty("_2", _alpha, 100);
    setProperty("_3", _alpha, 100);
    setProperty("_4", _alpha, 100);
    setProperty("_5", _alpha, 100);
    setProperty("_6", _alpha, 100);
}




There is a way to submit multiple targets in the same setproperty line?

Something like

setProperty("_2 _3 _4 _5 _6", _alpha, 100);

Thanks!

View Replies !    View Related
Multiple Drop Targets
I'm just starting out in AS3 and need some help with a drag and drop word scramble game.

Basically I need to be able to match two movieclips in the same target. So in the example below I have the word SANDALS, there are two S's and A's and I want the user to be able to put the duplicate letters in either slot. As it is right now the s_mc can only go in the first target slot and the s2_mc can only go in the last target slot. Same goes for the a_mc and a2_mc.

I'm sure there's a simple fix for this


ActionScript Code:
s_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
s_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
a_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
a_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt1);
n_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
n_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt2);
d_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
d_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt3);
a2_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
a2_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt4);
l_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
l_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt5);
s2_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
s2_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt6);

function pickUp(event:MouseEvent):void {
    event.target.startDrag(true);
    event.target.parent.addChild(event.target);
    startX = event.target.x;
    startY = event.target.y;
}
function dropIt(event:MouseEvent):void {
    event.target.stopDrag();
    var myTargetName:String = "target" + event.target.name;
    var myTarget:DisplayObject = getChildByName(myTargetName);
    if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
        event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
        event.target.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
        event.target.buttonMode = false;
        event.target.x = myTarget.x;
        event.target.y = myTarget.y;
        counter++;
        s_mc.filters = null;
        targets_mc.gotoAndPlay(2);
        success.play();
    }
   
    if(counter == 7){
        this.gotoAndStop(2);
       
    }
}


function dropIt1(event:MouseEvent):void {
    event.target.stopDrag();
    var myTargetName:String = "target" + event.target.name;
    var myTarget:DisplayObject = getChildByName(myTargetName);
    if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
        event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
        event.target.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
        event.target.buttonMode = false;
        event.target.x = myTarget.x;
        event.target.y = myTarget.y;
        counter++;
        a_mc.filters = null;
        targeta_mc.gotoAndPlay(2);
        success.play();
    }
   
    if(counter == 7){
        this.gotoAndStop(2);
    }
}
function dropIt2(event:MouseEvent):void {
    event.target.stopDrag();
    var myTargetName:String = "target" + event.target.name;
    var myTarget:DisplayObject = getChildByName(myTargetName);
    if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
        event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
        event.target.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
        event.target.buttonMode = false;
        event.target.x = myTarget.x;
        event.target.y = myTarget.y;
        counter++;
        n_mc.filters = null;
        targetn_mc.gotoAndPlay(2);
        success.play();
    }
   
    if(counter == 7){
        this.gotoAndStop(2);
    }
}
function dropIt3(event:MouseEvent):void {
    event.target.stopDrag();
    var myTargetName:String = "target" + event.target.name;
    var myTarget:DisplayObject = getChildByName(myTargetName);
    if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
        event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
        event.target.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
        event.target.buttonMode = false;
        event.target.x = myTarget.x;
        event.target.y = myTarget.y;
        counter++;
        d_mc.filters = null;
        targetd_mc.gotoAndPlay(2);
        success.play();
    }
   
    if(counter == 7){
        this.gotoAndStop(2);
        //completed.play();
    }
}
function dropIt4(event:MouseEvent):void {
    event.target.stopDrag();
    var myTargetName:String = "target" + event.target.name;
    var myTarget:DisplayObject = getChildByName(myTargetName);
    if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
        //reply_txt.text = "Good Job!";
        event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
        event.target.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
        event.target.buttonMode = false;
        event.target.x = myTarget.x;
        event.target.y = myTarget.y;
        counter++;
        a2_mc.filters = null;
        targeta2_mc.gotoAndPlay(2);
        success.play();
    }
   
    if(counter == 7){
        //reply_txt.text = "Congrats, you're finished!";
        this.gotoAndStop(2);
        //completed.play();
    }
}
function dropIt5(event:MouseEvent):void {
    event.target.stopDrag();
    var myTargetName:String = "target" + event.target.name;
    var myTarget:DisplayObject = getChildByName(myTargetName);
    if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
        //reply_txt.text = "Good Job!";
        event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
        event.target.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
        event.target.buttonMode = false;
        event.target.x = myTarget.x;
        event.target.y = myTarget.y;
        counter++;
        l_mc.filters = null;
        targetl_mc.gotoAndPlay(2);
        success.play();
    }
   
    if(counter == 7){
        //reply_txt.text = "Congrats, you're finished!";
        this.gotoAndStop(2);
        //completed.play();
    }
}

function dropIt6(event:MouseEvent):void {
    event.target.stopDrag();
    var myTargetName:String = "target" + event.target.name;
    var myTarget:DisplayObject = getChildByName(myTargetName);
    if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
        //reply_txt.text = "Good Job!";
        event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
        event.target.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
        event.target.buttonMode = false;
        event.target.x = myTarget.x;
        event.target.y = myTarget.y;
        counter++;
        s2_mc.filters = null;
        targets2_mc.gotoAndPlay(2);
        success.play();
    }
   
    if(counter == 7){
        //reply_txt.text = "Congrats, you're finished!";
        this.gotoAndStop(2);
        //completed.play();
    }
}


s_mc.buttonMode = true;
a_mc.buttonMode = true;
n_mc.buttonMode = true;
d_mc.buttonMode = true;
a2_mc.buttonMode = true;
l_mc.buttonMode = true;
s2_mc.buttonMode = true;

Thanks to anyone with advice or a quick solution to this problem!

View Replies !    View Related
Hitting Multiple Targets...
Hey all!

So, here's my current situation...

I've created a movie that has numerous drop targets and actions that take place when they are hit. Everything is working beautifully! I would like to take it a step further however.

I was wondering if it's possible to have an action take place after a certain amount of targets have been hit?

For example:

- I have 5 targets called T1, T2, T3, T4, T5
- I have 3 objects that get dropped onto those targets called O1, O2, O3
- only T1, T2, T3 are active targets, meaning, if O1 gets dragged onto T1 then that is correct...same with O2 onto T2 and O3 onto T3
- if O1, O2, O3 get dragged and dropped onto any other target(s), the object justs returns back to where it started from, if the drag and drop is correct, the objects stays on that target
- once T1, T2, and T3 have been hit, I want an action to happen (for example, a button shows up saying 'CORRECT! Click here to go to next level.')

Is it possible? Only when all the correct targets have been hit will this action take place.

Anybody up to the challenge?

Thanks for your time,

Mr. Wallace

View Replies !    View Related
Springing With Multiple Targets.
Sorry, worked it out.
Thanks for anyone who read the thread before.

EDIT: The problem was that I had a general Ball class with functions for velocity and acceleration. However, I had forgotten to define an initial acceleration and velocity value in the class. So, vx was undefined, but it was trying to add this value to the x value of the Ball on every frame. I'm unsure why, but this resulted in the x (and y) values defaulting to -107374182.4, and the Ball disappearing from stage.

So if you're making a class like that, be sure to define the velocity and the acceleration at the start

Ball.as:


Code:
package
{
import flash.display.Sprite;
import flash.events.Event;
public class Ball extends Sprite
{
public var vx:Number;
public var vy:Number;
public var ay:Number;
public var ax:Number;
private var _color:uint;
public var radius:Number;
public function Ball(color:uint = 0xFFFFFF00, radius:Number = 40):void
{
this.radius = radius;
this.color = color;
init();
}
private function init():void
{
with (graphics)
{
beginFill(_color, 0.6);
drawCircle(0, 0, radius);
endFill();
}
ax = 0;
ay = 0;
vy = 0;
vx = 0; //It was this piece of code that I'd forgotten to include.
addEventListener(Event.ENTER_FRAME, moveBall, false, 0, true);
addEventListener(Event.REMOVED_FROM_STAGE, removeBall, false, 0, true);
}
public function moveBall(evt:Event):void
{
vy += ay;
vx += ax;
vx *= 0.95;
vy *= 0.95;
x += vx;
y += vy;
}
private function removeBall(evt:Event):void
{
removeEventListener(Event.ENTER_FRAME, moveBall);
removeEventListener(Event.REMOVED_FROM_STAGE, removeBall);
}
public function set color(c:uint):void
{
if (c <= 0xFFFFFF)
{
_color = c;
} else
{
_color = Math.random() * 0xFFFFFF;
}
}
}
}

View Replies !    View Related
On Mouse Event + Multiple Tell Targets?
Is it possible to target more than one movie clip with a tell target action? I've been messing around witht the action scripting but i cant get it right... can someone please help

This is what I've got so far .. it might give you an idea of what im doing>>>>>
on (press) {
tellTarget ("_parent.pictop") {
tellTarget ("_parent.bottom") {
gotoAndPlay (2);
}
}
}

I'm trying to get 2 seperate mc's to play with one push....it has to be on press also

View Replies !    View Related
Multiple Drag Drop Targets
i'm using this action script to do a drag and drop target set up.


Code:
fscommand("fullscreen", "false");
fscommand("allowscale", "false");
stop();

// don't use the hand icon
drag_mc.useHandCursor = false;

// handle press event
drag_mc.onPress = function() {
this.startDrag(false, 26, 25, 613, 170);
this.onMouseMove = function() {
updateAfterEvent();
};
};

// handle release event
drag_mc.onRelease = drag_mc.onReleaseOutside = function() {
stopDrag();
this.onMouseMove = undefined;
if (this.hitTest(_root.dropTarget_mc)) {
this._x = _root.dropTarget_mc._x+(_root.dropTarget_mc._width/2)-(this._width/2);
this._y = _root.dropTarget_mc._y+(_root.dropTarget_mc._height/2)-(this._height/2);
this.gotoAndStop(2);
} else {
this.gotoAndStop(1);
}
};


how can i make it work with multiple mc's? I appreciate the help.

View Replies !    View Related
Hit Testing Multiple Dynamic Targets ?
I created a grip of little squares on a grid, and gave them names, hit_me_1 through hit_me_600... easy enough..

but now i want to drag an object onto one of these little squares and know which square it was dragged on to.. the code I have now, of course doesn't work. the trace doesn't pop up the right square number.. i know because I gave them temporary text fields with their square numbers in them..

this is the bit thats doing the hit-test..

onClipEvent(mouseUp){

for(h=0;h<=599;h++){
if (this.hitTest(_root.map_mc_1.fresh_hit["hit_me_"+h])) {
trace("hitdatmotherf*ck number "+h);
}
}
}

the oddest part is my trace results:

hitdatmotherf*ck number 428
hitdatmotherf*ck number 429
hitdatmotherf*ck number 458
hitdatmotherf*ck number 459

no matter where i drag my drag mc, i get this same set.. and none of them are near the place where I finally mouseupped..

interestingly these numbers are all around the vicinity where I do the mouse down and start dragging the square..

can anybody see what i'm missing??

thanks!

View Replies !    View Related
Drag And Drop Multiple Targets
I have a movie with ten tokens to be dropped onto about 34 items.
I want the get the destination code when the tokens are dropped on the item. (named item1 - item34)

With the code below, the tokens only go back to their original position, but if i substitute the "i" for a 9 ,to test it for example, it works fine. The token stays on item9 and gives me dest1=9 . If i drop it on item4 it goes back to the original position.

how do i get this to work for all 34 items?

on (press) {
startX = this._x;
startY = this._y;
startDrag(this, false, 30, 15, 720, 435);
}
on (release) {
stopDrag();
}
on (release) {
for (i=1; i<=_root.maxitems; i++) {
if (this.hitTest(_root["item"+i])) {
_root.dest1=_root["item"+i].dest;
} else {
this._x = startX;
this._y = startY;
_root.dest1="";
}
}
}

View Replies !    View Related
Drag And Drop On Multiple Targets
I have been following this tutorial:
http://www.hed.swin.edu.au/design/tu..._tut/index.php

Everything works out fine. Except I can only define the movie clip to be assigned to one target. I created five separate targets, and five separate drag objects. I would like to be able to drag any of the five objects to any of the five targets. As of now, I don't have a problem assigning the objects to all work on the same target, or have them each assigned to one of the five targets.

Is there a simple way to change the script to allow the objects to drop on any of the five targets?

Here is the script I have:
onMouseMove = function(){
updateAfterEvent();
}

function dragSetup(clip, targ) {
clip.onPress = function() {
startDrag(this,true,63,85,530,465);
this.beingDragged=true;
};
clip.onRelease = clip.onReleaseOutside=function () {
stopDrag();
this.beingDragged=false;
if (eval(this._droptarget) == targ) {
this.onTarget = true;
_root.targ.gotoAndStop(2);
} else {
this.onTarget = false;
_root.targ.gotoAndStop(2);
}
};
//the variables below will store the clips starting position
clip.myHomeX = clip._x;
clip.myHomeY = clip._y;
//the variables below will store the clips end position
clip.myFinalX = targ._x;
clip.myFinalY = targ._y;
clip.onEnterFrame = function() {
//all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged)
// then move the MC back to its original starting point (with a smooth motion)"
if (!this.beingDragged && !this.onTarget) {
this._x -= (this._x-this.myHomeX)/3;
this._y -= (this._y-this.myHomeY)/3;
//if the circle is dropped on any part of the target it slides to the center of the target
} else if (!this.beingDragged && this.onTarget) {
this._x -= (this._x-this.myFinalX)/3;
this._y -= (this._y-this.myFinalY)/3;
}
};
}

//this is where the object is assigned to the target
dragSetup(ruff_mc,target1);
dragSetup(chee_mc,target2);

I've tried everything I can think of from copying the dragSetup like this:
dragSetup(ruff_mc,target1);
dragSetup(ruff_mc,target2);
dragSetup(ruff_mc,target3);
But when I do that, it ignores the first two, and only will go to target3.

Any help would be WONDERFUL!!!!

View Replies !    View Related
Help With Collision Detection With Multiple Targets
Hello all you nice people and happy holidays.
I'm trying to make make a drag&drop where the idea is to drag a scanner over various images. Only some of the images are detectable and when the scanner is over the correct image, a text appears on the display I found this script that seems to do what I want, but I can't figure out how to make it register more than one target.


Code:
function dragStarter():Void {
this.startDrag("");
}
function dragStopper():Void {
this.stopDrag();
}
function detectCollision():Void {
this.message_txt.text = "";
if (this.hitTest(this._parent.hitArea_mc) ) {
this.message_txt.text = "hit";
}
}
function attachHitterScripts():Void {
this.onPress = dragStarter;
this.onRelease = dragStopper;
this.onReleaseOutside = dragStopper;
this.onEnterFrame = detectCollision;

}
attachHitterScripts.apply(circle01_mc);

View Replies !    View Related
Multiple Targets With Color Transform....
I am using color transform to change the color of movie clips on my stage. i have a variety of items on my stage at various levels that i would like to change with the same code. i am wondering, is it possible to set multiple target mc's with color transform? if so, how do i do that? i've tried using commas to separate them, with only the first one showing. i have attached the code that pertains tot he color transform....


if (lessonNumber == "1") {
//set the dark color for lesson 1 screen items
darkColor = new Color (moduleBarDark_mc);
darkColorTransform = new Object ();
darkColorTransform = {ra: '0', rb: '128', ga: '0', gb: '0',ba: '0', bb: '0', aa:'100', ab: '100'};
darkColor.setTransform(darkColorTransform);
//set the light color for lesson 1 screen items
lightColor = new Color (moduleBarLight_mc);
lightColorTransform = new Object ();
lightColorTransform = {ra: '0', rb: '255', ga: '0', gb: '0', ba: '0', bb: '0', aa: '100', ab: '100'};
lightColor.setTransform(lightColorTransform);
}
}

View Replies !    View Related
Drag N Drop With Multiple Targets
Hi actionscripters ;)

Does anyone have a good example of drag and drop with multiple targets? I am working on a smart way to code an interface where the objects in the menu can be dropped on a variety of places and then be moved somewhere else if necessary until the user is finished.

Thanks for your time, all replies are very much appreciated ;)

regards
Michael

View Replies !    View Related
Drag And Drop Multiple Targets
i am creating a flash project in which there is a drag and drop feature at the moment only one oblect can drop onto one target. i would like all the objects to be able to be dragged onto all the targets.

the project files can be downloaded here: CLICK HERE

if you have any questions just ask!
thanks in advance

View Replies !    View Related
Drag And Drop Into Multiple Targets
i am creating a flash project in which there is a drag and drop feature at the moment only one oblect can drop onto one target. i would like all the objects to be able to be dragged onto all the targets.

the project files can be downloaded here: CLICK HERE

if you have any questions just ask!
thanks in advance

View Replies !    View Related
SetProperty (multiple Targets, _property, Value)
got stuck with this...
I've 2 mc in timeline
instance names are:
form1
form2

in first frame I wrote the following code

setProperty(form1, _alpha, 50);
setProperty(form2, _alpha, 50);

this works ok
but the question is... multiple targets, how could I do something like this:

setProperty((form1; form2), _alpha, 50);

although I know this doesn't work... how could I setProperty of more than one instance?

View Replies !    View Related
Color Change, Multiple Targets
ActionScript Code:
resetColor = function () {    var my_color:Color = new Color();    my_color.setRGB(0x999999);    subMenu01_btn.Color = my_color;    subMenu02_btn.Color = my_color;    subMenu03_btn.Color = my_color;};


why isn't this workin?...
just need to change color to 3 mc's, when i call the function it wont work...but if i write like so it does:


ActionScript Code:
resetColor = function () {    var my_color:Color = new Color(subMenu01_btn);    my_color.setRGB(0x999999);};


but this way i change only one mc

. am

View Replies !    View Related
Drag And Drop With Multiple Targets
Hey all,

I've been scouring the innernets for the solution to this. I'm sure it's there, it's just hiding.

I've made a drag and drop quiz where you have to drag the labels to the right place, otherwise they just go back to where they were. That was easy enough. But now the bosses decided that they want it so you can get it wrong as well, which means multiple targets. My poor little brain cannot handle it!

I've been looking at changing a variable with the target x and y on mouseover, but that just seems to stop the onRelease function. I'm going to be playing with that today, but if anyone can just wave their magic wand and provide some brain-cooling relief, I'd be much obliged.

Thanks!

View Replies !    View Related
SetProperty (multiple Targets, _property, Value)
got stuck with this...
I've 2 mc in timeline
instance names are:
form1
form2

in first frame I wrote the following code

setProperty(form1, _alpha, 50);
setProperty(form2, _alpha, 50);

this works ok
but the question is... multiple targets, how could I do something like this:

setProperty((form1; form2), _alpha, 50);

although I know this doesn't work... how could I setProperty of more than one instance?

View Replies !    View Related
Multiple Targets From Single Mouse Event
This is a difficult one to describe.

I want to assign two separate events to a single action, but I want one event to follow the other. Both targets are MovieClips nested within the same external swf, which has been imported into the main timeline. Follow me?

on (release) {
_root.loadMovieMC.FallMan.gotoAndPlay("end");
}
on (release) {
_root.loadMovieMC.gotoAndPlay("FishGirl");
}


Problem is that once the button is clicked it runs straight to "FishGirl" without playing FallMan("end"). If I take out the second expression, it will play FallMan okay.

I'm in over my head here, Can anyone please help?

View Replies !    View Related
Drag, Drop, Multiple Targets And Duplicate.
Hello,

I have the folowing problem. I want to create something like this: On the scene you have a square lets call it squareMC and also two square holes in whic you can place the squareMC. Now I want the folowing. When the user klicks on squareMC it becomes dragable and it can be placed on either of the two holes. if you place it outside one of the holes it returns to the starting position. But when you place it on one of the holes it stays there and at the starting position will apear a duplicta of SquareMC wich also will be dragable to the two holes.

So I hope you can help me to achieve this because I am really stuck haha. I understand how I can make something dragable and make it drop but I don't know how to drop it to an target and than duplicate it and to make it return to its starting position.

Thank you in advance,

Andre
The netherlands

View Replies !    View Related
Multiple Targets In A Movie Clip Instance
My problem is I have a long list of call functions that control the follow of an on release event in a scene that I am creating. They control the follow of a movie clip that is loaded into a level in this scene. I have one instance of a movie clip in this loaded movie that has many stop positions within it, that have labels for action script to go to within this movie clip five times. I am trying to get action script to play multiple stop frames within this time line, but because the movies main address is already referenced once using call functions in the script I can't get action script to recognize where it is in reference to the time line. Currently the script just passes by all other call functions that are related to this target address and just plays the last script related to this target address. All other movie clip instances that have a call function in this particular script function as they should and the action script works just fine for them.

HOW CAN I TARGET A MOVIE CLIP INSTANCE USING MULTIPLE CALL FUNCTIONS TO ACT UPON ONE PARTICULAR MOVIE CLIP INSTANCE THAT HAVE A SIMILAR ADDRESS TARGETS?


I WOULD LIKE TO CONTINUE TO USE CALL FUNCTIONS TO SCRIPT THE ACTION BUT I AM NOT SURE HOW TO DO THIS. I HAVE TRIED EXACT ADDRESSES, TARGETING INVISIBLE OBJECTS WITH INSTANCE NAMES WITHIN THE TIME LINE, VARIABLES, AND MANY COMBINATIONS OF THE THE ABOVE, BUT NOTHING WORKS. CAN ANY ONE HELP?

SAMPLE SCRIPT:


on (release) {

set(contact, 12);

_level10.portfolioMC.prophecyMC.gotoAndPlay("endEx itStageProphecy");

_level10.portfolioMC.islandMC.gotoAndPlay("endExit StageIslands");

_level10.portfolioMC.cdcaseMC.cdcaseRotatingMed1_m ov.gotoAndPlay("cdcaseExitStageStart1");

_level10.portfolioMC.roamingeye.gotoAndPlay("endEx itStageRoaming");


//BELOW THIS COMENT IS THE FIVE LINES OF SCRIPT THAT I AM HAVING A PROBLEM WITH. TO TARGET MULTIPLE STOP POSITIONS WITHIN A MOVIE CLIP THAT HAS MULTIPLE LABELS FOR ACTION SCRIPT TO RECOGNIZE, THAT HAVE THE SAME TARGET ADDRESSES WHEN USING CALL FUNCTIONS IN A LONG SCRIPT TOGETHER.

_level10.portfolioMC.bugvadersMC.bvchoiceMC.gotoAn dPlay("pressedStartFrameBugvadersFinish");

_level10.portfolioMC.bugvadersMC.bugvadersbut1.got oAndPlay("bugvadersPanelBackExitStageStart");

_level10.portfolioMC.bugvadersMC.bugvadersbut2.got oAndPlay("bugvadersPanelFrontExitStageStart");

_level10.portfolioMC.bugvadersMC.bugvadersbut3.got oAndPlay("bugvadersPanelLeftExitStageStart");

_level10.portfolioMC.bugvadersMC.bugvadersbut4.got oAndPlay("bugvadersPanelRightExitStageStart");

_level10.portfolioMC.hq120MC.hq120RotatingMed3_mov .gotoAndPlay("hq120MedRotateExitStageStart");

}

View Replies !    View Related
Multiple Targets For Drag And Drop Object?
I followed this tutorial:
http://www.hed.swin.edu.au/design/tu..._tut/index.php

And everything works out fine, until I added more targets and objects. I have a total of 5 objects and 5 targets. I would like to allow any of the objects to be dropped on any of the 5 targets. Right now, the object is assigned to one target. How do I make it so that it can go on any of the targets?

Here is the code:
onMouseMove = function(){
updateAfterEvent();
}

function dragSetup(clip, targ) {
clip.onPress = function() {
startDrag(this,true,63,85,530,465);
this.beingDragged=true;
};
clip.onRelease = clip.onReleaseOutside=function () {
stopDrag();
this.beingDragged=false;
if (eval(this._droptarget) == targ) {
this.onTarget = true;
_root.targ.gotoAndStop(2);
} else {
this.onTarget = false;
_root.targ.gotoAndStop(2);
}
};
//the variables below will store the clips starting position
clip.myHomeX = clip._x;
clip.myHomeY = clip._y;
//the variables below will store the clips end position
clip.myFinalX = targ._x;
clip.myFinalY = targ._y;
clip.onEnterFrame = function() {
//all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged)
// then move the MC back to its original starting point (with a smooth motion)"
if (!this.beingDragged && !this.onTarget) {
this._x -= (this._x-this.myHomeX)/3;
this._y -= (this._y-this.myHomeY)/3;
//if the circle is dropped on any part of the target it slides to the center of the target
} else if (!this.beingDragged && this.onTarget) {
this._x -= (this._x-this.myFinalX)/3;
this._y -= (this._y-this.myFinalY)/3;
}
};
}

//here are two of the objects each corresponding to their own target.
dragSetup(ruff_mc,target1);
dragSetup(chee_mc,target2);






------------------------------------
I've tried everything I can think of, even copying the dragSetup like this:
dragSetup(ruff_mc,target1);
dragSetup(ruff_mc,target2);
dragSetup(ruff_mc,target3);
dragSetup(ruff_mc,target4);
dragSetup(ruff_mc,target5);

But, in this case, it ignores the previous targets and will only go to target 5.

How do I make the object go to any of the 5 targets?

Any help will be wonderful!

View Replies !    View Related
Multiple Movieclips, 3 Functions With Unique Targets
(cs3,as2)
I was wondering if there's an easier way of getting these functions to work for about 150 different buttons? I just put three of the blocks of code in here to show you what it looks like across more than one. On the gotoAndStop actions, the name is a frame label on a seperate swf file. the name used everywhere else is an instance name on a dynamic textbox located inside a movieclip. All this script is located in an external .as file. Thanks so much for reading.








Attach Code

aaronkotowski.fade.person.text = "Aaron Kotowski";
aaronkotowski.onRollOver = function() {
gotoAndStop("aaronkotowski");
aaronkotowski.fade.person.textColor = 0x666666;
};
aaronkotowski.onRelease = function() {
getURL("http://www.aaronkotowski.com", "_blank");
};
aaronkotowski.onRollOut = function() {
aaronkotowski.fade.person.textColor = 0xffffff;
};

albertnormandin.fade.person.text = "Albert Normandin";
albertnormandin.onRollOver = function() {
gotoAndStop("albertnormandin");
albertnormandin.fade.person.textColor = 0x666666;
};
albertnormandin.onRelease = function() {
getURL("http://www.albertnormandin.com", "_blank");
};
albertnormandin.onRollOut = function() {
albertnormandin.fade.person.textColor = 0xffffff;
};

aliciarose.fade.person.text = "Alicia Rose";
aliciarose.onRollOver = function() {
gotoAndStop("aliciarose");
aaronkotowski.fade.person.textColor = 0x666666;
};
aliciarose.onRelease = function() {
getURL("http://www.aliciajrosephotography.com/", "_blank");
};
aliciarose.onRollOut = function() {
aliciarose.fade.person.textColor = 0xffffff;
};

Someone gave me this code below to try but it makes the button have the same name over and over? What am I doing wrong?

myArray_array=[{mcName:"aaronkotowski", url:"http://www.aaronkotowski.com"},{mcName:"albertnormandin", url:"http://www.albertnormandin.com"},{mcName:"aliciarose", url:"http://www.aliciajrosephotography.com"}];
for(var i=0; i<myArray_array.length; i++){
var myMc = this[myArray_array[i].mcName];
myMc.fade.person.text = "Alicia Rose";
myMc.myRoot = this;
myMc .index= i;
myMc.onRollOver = function() {
gotoAndStop(this.myRoot.myArray_array[this.index].mcName);
this.fade.person.textColor = 0x666666;
};
myMc.onRelease = function() {
getURL(this.myRoot.myArray_array[this.index].url, "_blank");
};
myMc.onRollOut = function() {
this.fade.person.textColor = 0xffffff;
};
}

View Replies !    View Related
Drag And Drop With Multiple Targets Problem
Hey this is my first post!!, thanks to everybody for this great forum, your help and knowledge makes Flash not so hard.

Well I'm trying to do some kind of quiz (like the one's included in Flash templates), the basic functionality is drag one item and put it in the correct place (or drop place). I take some code of the kirupa's collision tutorials, but I can't apply that to my particular situation.

The current situation is: i have 3 drag rectangles and 3 drop rectangles, I can drag and drop all the drag rectangles, but just the last one (the third drag rectangle), seems to sense the collision with all the 3 drop rectangles.

My code is:

drag_mc = ["drag0", "drag1", "drag2"];
drop_mc = ["drop0", "drop1", "drop2"];

function init() {
numDrags = drag_mc.length;
for(i=0; i<numDrags; i++) {
var rect1:MovieClip = drag_mc[i];
temp1 = eval(rect1);
temp1.onPress = function() {
this.startDrag();
drop = false;
};
temp1.onRelease = function() {
this.stopDrag();
drop = true;
};
} // fin del for principal
this.onMouseMove = function() {
collision_detect("temp1");
};
};

init();

function collision_detect(rect) {
numDrops = drop_mc.length;
for(j=0; j<numDrops; j++) {
var rect2:MovieClip = drop_mc[j];
temp2 = eval(rect2);
temp1 = eval(rect);

if(temp1.hitTest(temp2)) {
trace("collision");
temp2._alpha = 40;
}
else {
temp2._alpha = 100;
}
updateAfterEvent();
}
}

Thanks in advance

View Replies !    View Related
Multiple Movieclips, 3 Functions With Unique Targets
(cs3,as2)
I was wondering if there's an easier way of getting these functions to work for about 150 different buttons? I just put three of the blocks of code in here to show you what it looks like across more than one. On the gotoAndStop actions, the name is a frame label on a seperate swf file. the name used everywhere else is an instance name on a dynamic textbox located inside a movieclip. All this script is located in an external .as file. Thanks so much for reading.

aaronkotowski.fade.person.text = "Aaron Kotowski";
aaronkotowski.onRollOver = function() {
gotoAndStop("aaronkotowski");
aaronkotowski.fade.person.textColor = 0x666666;
};
aaronkotowski.onRelease = function() {
getURL("http://www.aaronkotowski.com", "_blank");
};
aaronkotowski.onRollOut = function() {
aaronkotowski.fade.person.textColor = 0xffffff;
};

albertnormandin.fade.person.text = "Albert Normandin";
albertnormandin.onRollOver = function() {
gotoAndStop("albertnormandin");
albertnormandin.fade.person.textColor = 0x666666;
};
albertnormandin.onRelease = function() {
getURL("http://www.albertnormandin.com", "_blank");
};
albertnormandin.onRollOut = function() {
albertnormandin.fade.person.textColor = 0xffffff;
};

aliciarose.fade.person.text = "Alicia Rose";
aliciarose.onRollOver = function() {
gotoAndStop("aliciarose");
aaronkotowski.fade.person.textColor = 0x666666;
};
aliciarose.onRelease = function() {
getURL("http://www.aliciajrosephotography.com/", "_blank");
};
aliciarose.onRollOut = function() {
aliciarose.fade.person.textColor = 0xffffff;
};

View Replies !    View Related
Help: Applying A Single Action To Multiple Targets
Hi I'm trying to apply a single action to multiple targets. I am currently using the following code, but to no avail... Everything works properly when I try the script with one object. It only stops functioning when trying to target more than one object.


on (release) {
gotoAndPlay('hit');
with ((_root.button01),(_root.button02),(_root.button03)) {
if (_currentframe >= 75)
gotoAndPlay('off');
}


thank you for any help.

View Replies !    View Related
Multiple Drag Objects To One Target (36 Drags, 12 Targets)
Hi,

I am new and have been struggling try to find a solution somewhere. I need to create a piece that has 36 draggables with only 12 targets. I have done many drag and drop pieces in the past which have 1 draggable per target, but I am having a problem finding anyone info for coding multiple drags per target. Users will drag all the objects to the targets of their choice and then click a 'check' button. At this point, the draggables which are on the correct target will stick and those that are incorrect will snap back to their original position. I have tried messing with the following code which has a 1:1 correlation (1 drag/1 target), but not had much luck.

var tar_num = 36;
var cover = new Array();
var target_ar = new Array();
var object_ar = new Array();
var my_hit = new Array();



function x_y(my_x, my_y) {
this.my_x = my_x;
this.my_y = my_y;
}
for (var i = 0; i<tar_num; i++) {
target_ar[i] = new x_y(getProperty("t"+i, _x), getProperty("t"+i, _y));
object_ar[i] = new x_y(getProperty("o"+i, _x), getProperty("o"+i, _y));
cover[i] = 0;
my_hit[i] = 0;
}
function checkAnsw() {
var dunrite = 0;
for (var i = 0; i<tar_num; i++) {
if (my_hit[i] == 1) {
dunrite = dunrite+1;
this["o"+i].gotoAndStop("stat");
trace(dunrite);
} else {
cover[i] = 0;
this["o"+i]._x = _root.object_ar[i].my_x;
this["o"+i]._y = _root.object_ar[i].my_y;
}
}
// Change your feedback here:
if (dunrite == tar_num) {
feedback = "Well done";
// All correct
} else {
feedback = "Not quite, keep going.";
// Not all correct
}
}
stop();

When I finally solve this, I'll also need to be able to make it so that the correctly dragged items don't stack on top of each other (i.e. they line up on vertically instead on the target).

Has anyone seen code I might look at to do this or do you have ideas on how I can change the above code to work with multiple draggables?

Thanks for any help you can provide.

View Replies !    View Related
Multiple Targets For "new Color (Target)"
Here is the code changing the color of a movieClip called "bg". This works fine.


Code:
InfoColourObject = new Color(bg);
Colour = parseInt(_root.c1, 16);
InfoColourObject.setRGB(Colour);
I was just wondering if there was some way to target multiple movie clips since they will be the same color?

Like this, (only this doesn't work)


Code:
InfoColourObject = new Color(bg, cylinder);
Colour = parseInt(_root.c1, 16);
InfoColourObject.setRGB(Colour);

View Replies !    View Related
HitTest For Multiple MCs
hi All,
this is for a multiple MCs hitTest.
part of my code is:
if{!this.hitTest(_root.bu1) && Key.isDown(key.DOWN)} etc.

This works fine with MC bu1. Now i have quite a lot of these 'bu' MCs. bu1, bu2, bu3, bu4 etc, How can i check them all at once? i tried a 'for' loop but i don't exactly know what i'm doing. I guess i want to be able to say if{this.!hitTest("_root.bu" + count) but i have no clue on how to get there. Any help appreciated!
gparis

View Replies !    View Related
Multiple Hittest
I want to perform multiple hittesting on the following code.
This code works properly for the first section of hittests.

onClipEvent(keyDown) {
k = Key.getcode();
face2y=getProperty(_root.face2,_y);
face2x=getProperty(_root.face2,_x);

if (k == Key.LEFT)
{_root.pt1l=this.hitTest(_root.game2.part1l);
if (_root.pt1l==false)
{setProperty(_root.face2,_x,face2x-11);}
else{}
}
if (k == Key.UP)
{_root.pt1u=this.hitTest(_root.game2.part1u);
if (_root.pt1u ==false)
{setProperty(_root.face2,_y,face2y-11);}
else{}
}
if (k == Key.RIGHT)
{_root.pt1r=this.hitTest(_root.game2.part1r);
if (_root.pt1r ==false)
{setProperty(_root.face2,_x,face2x+11);}
else{}
}
if (k == Key.DOWN)
{_root.pt1d=this.hitTest(_root.game2.part1d);
if (_root.pt1d ==false)
{setProperty (_root.face2,_y,face2y+11);}
else{}
}
}

Now I want to add hittests for other sections so a keypress would look something like:

if (k == Key.DOWN)
{_root.pt1d=this.hitTest(_root.game2.part1d);

//add this hittest
_root.pt2d=this.hitTest(_root.game2.part2d);

if (_root.pt1d ==false)
{setProperty (_root.face2,_y,face2y+11);}
else

//add this part for second hittest
if (_root.pt2d ==false)
{setProperty (_root.face2,_y,face2y+11);}

else{}


With various manipulations, I can get the first one or the second one to work, but I can't get both to work. I've searched the forum and can't find anything on multiples. Can anyone help me with the proper structure for multiple hittests/if statements? It's probably some stupid little thing that I'm missing, but I've wasted a whole day with different configurations, so help please!

pkw

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved