|
-
file not found
simple question, simple answer
how do you hitTest for a duplicated mc?
I've tried
if (this.hitTest (_root.dupedmc[i])) {
trace("please work this time";
}
am I doing something wrong, or is my flash program just messed up?
-
M.D.
are you storing a reference to every duplicated MC in an array? and/or are you adding them to a specific movieclip, like "enemies"?
-
You forgot a ) to close your trace, maybe that's it? Because if dupedmc[i] is in fact a reference to a valid movieclip (duplicated or not, shouldn't matter), it should work.
Try tracing dupedmc[i] and see what you get.
-
file not found
I use this to duplicate it:
blahblahblah.onEnterFrame =...
...
dupedmc.duplicateMovieClip( "dupedmc"+i, i++ );
fixed the trace, still nothing.
-
Senior Member
-
Senior Member
I though you could only use that when you store the referance of a MC in an array. I Must be wrong?
92.7 Fresh FM for all your South Aussies - Doof Doof music FTW people!
-
DOT-INVADER
code: _root["dupedmc"+i]
^ this means you'll target things like:
_root.dupedmc1
_root.dupedmc2
_root.dupedmc3
_root.dupedmc4
...etc
code: _root.dupedmc[i]
^ this means you'll target things like:
_root.dupedmc.MC1
_root.dupedmc.MC2
_root.dupedmc.MC3
_root.dupedmc.MC4
...etc
ANYWAY, did you specify anything for "i" when you perform your hitTest? a for loop in your case...
-
file not found
nothing continues to work with this. Here is virtually the exact code I'm using to duplicate and check for a hitTest:
bob.onEnterFrame = function() {
if (bob.hitTest (_root["dupedmc"+i])) {
trace("yes");
}
duplicateMovieClip(_root.dupedmc, "dupedmc" + i, i++);
}
at this point, I'm starting to assume there's just something wrong with my program.
btw, I've got other code set up to where it doesn't duplicate on EVERY frame, only on some, I just opted not to show that.
-
Yes we can
 Originally Posted by Captain_404
nothing continues to work with this. Here is virtually the exact code I'm using to duplicate and check for a hitTest:
bob.onEnterFrame = function() {
if (bob.hitTest (_root["dupedmc"+i])) {
trace("yes");
}
duplicateMovieClip(_root.dupedmc, "dupedmc" + i, i++);
}
at this point, I'm starting to assume there's just something wrong with my program.
btw, I've got other code set up to where it doesn't duplicate on EVERY frame, only on some, I just opted not to show that.
it would be helpful if you try to explain what exactly happens. "nothing continues to work with this" is no propper explanation of the problem.
On first glance i see several reasons for it still not working:
1.: Did you initialize the variable i with 0 value ahead?
2.:
duplicateMovieClip(_root.dupedmc, "dupedmc" + i, i++);
where do you count i up? Just for the depth or somewhere else in your enterframe?
3.:To check hittest with several instances you need to iterate through em with a loop,as you do it now:
if (bob.hitTest (_root["dupedmc"+i])) {
you only check for hit with one instance
-
Senior Member
404, did you even check your OUTPUT window when you publish?
Any errors?
-
file not found
@Ray Beez
I check the output box every time, nothing.
@tomsamson
1. yes
2. just for the depth, should I be doing it differently? I tried changing it to: depth = 1+1000 and then i++ on the next line with no affect
3. ?...this is where you lost me, so that's probably my problem...
-
CostomJunky
 Originally Posted by Captain_404
1. yes
2. just for the depth, should I be doing it differently? I tried changing it to: depth = 1+1000 and then i++ on the next line with no affect
3. ?...this is where you lost me, so that's probably my problem...
2. if you increment something within duplicateMovieClip it doesn't do that globaly so change that to outside, see code below...
3. if you do not have a for loop you are checking collision only between bob and a single i value.
I hope this will work for ya:
Code:
bob.onEnterFrame = function() {
for (var n = 0; n<i; n++){
if (bob.hitTest (_root["dupedmc"+n])) {
trace("yes");
}
duplicateMovieClip(_root.dupedmc, "dupedmc" + i, i);
i++;
}
}
PS: I understand that you guys want this guy to stuggle but I think the servers would be thankfull if you cleared questions sooner and not bit by bit. But I guess its a win-lose sitiuation.
Last edited by Xploder; 08-29-2006 at 07:39 PM.
-
guys, you've helped me a lot too!!! sometimes it surprises me-why i can't get it out myself?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|