Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: [Request / Listing] Flash MX 2004 Attach MC?  (Read 2870 times)

0 Members and 1 Guest are viewing this topic.
[Request / Listing] Flash MX 2004 Attach MC?
« on: May 14, 2006, 01:13:55 am »
  • Oh.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 579
 :) I can't figure out how to attach a movieclip in Flash MX 2004 with a script!  I've tried everything..  Just give me the way to do it, damnit!  (Actionscript 2.0)
« Last Edit: February 24, 2012, 07:08:22 pm by Niek »
Logged
Hm.
Re: Flash MX 2004 Attach MC?
« Reply #1 on: May 14, 2006, 01:23:30 am »
  • Its the joeshmo!
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 694
Not sure what you mean but look at this:
http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary508.html

I like madness n_n. Great game/cartoon.
Logged
  • Netterra Virtual Pets
Re: Flash MX 2004 Attach MC?
« Reply #2 on: May 14, 2006, 01:17:31 pm »
  • Oh.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 579
Thanks, but what I want to do is "spawn" a MC at a sepcified X/Y.  So bascicly attach it to a background image  :)
Logged
Hm.
Re: Flash MX 2004 Attach MC?
« Reply #3 on: May 14, 2006, 03:23:52 pm »
  • Its the joeshmo!
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 694
Ah, I see. Here we go

the function is:

Code: [Select]
duplicateMovieClip (movieclip to be duplicated,"name of new movieclip", depth of movieclip);
 if you dont know what the depth is, just set it to one.

Here is a frame code to duplicate a movieclip, we will call it circle, and move it somewhere.
Code: [Select]
duplicateMovieClip (_root.circle,"circle2", 1);
circle2._x=15;
circle2._y=60

Important: The name of the new movieclip MUST be in quotes. Also the name of the first movie clip must be the instance name, not the original name.

If you need another example I will write one for you.
Logged
  • Netterra Virtual Pets
Re: Flash MX 2004 Attach MC?
« Reply #4 on: May 15, 2006, 07:49:14 pm »
  • Oh.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 579
Thanks  :) But Can there be collission detection with many objects at once without defining all the names? 
I mean like have a variable that can mean anything :)
Logged
Hm.
Re: Flash MX 2004 Attach MC?
« Reply #5 on: May 15, 2006, 08:28:44 pm »
  • Its the joeshmo!
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 694
Thanks  :) But Can there be collission detection with many objects at once without defining all the names? 
I mean like have a variable that can mean anything :)

There is no wildcard in flash, which is what you need. What you should do is add the colision testing to the movieclip being duplicaticated rather than the thing it should hit. Oh yes, if you want to spawn multiple times its just:
while(i<10) {
//creates a movieclip. If i=1, it will be circle0
duplicateMovieClip (_root.circle,"circle"+i, 1);
i++;
}

This creates 10 movieclips. You would have the set their location from the movieclip, not the duplicate function. All duplicated movieclips contain the same code as the original.

Logged
  • Netterra Virtual Pets
Re: Flash MX 2004 Attach MC?
« Reply #6 on: May 16, 2006, 12:05:02 am »
  • Oh.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 579
Would this work? (Working with MCs not a frame, whussa diff?) I am assuming that just hitTest would sense ANY hit
Quote
onClipEvent (enterFrame) {
if (!hitTest(circle)) {
add anything else you DONT want it to be
if(hitTest) {
than what you want :)
_width = 103;
_height = 100;
}
}
}
Logged
Hm.
Re: Flash MX 2004 Attach MC?
« Reply #7 on: May 16, 2006, 01:25:33 am »
  • Its the joeshmo!
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 694
That should work. Exept hittest must hit an object specified. It doesnt see collision with all objects, just the ones specified. And there is no wildcard function in flash! There is a way to solve this though:

Code: [Select]
onClipEvent (enterFrame) {
while(_root.num>num) {
num++;
if (!hitTest("circle"+num)) {
//add anything else you DONT want it to be
}
if(hitTest("circle"+num) {
//than what you want
_width = 103;
_height = 100;
}
}
}

Also you needed to close your if(!hittest) section, otherwise the part after it wouldnt do anything. Then in your duplicate script needs to have a num variable
Code: [Select]
while(i<10) {
_root.num++;
duplicateMovieClip (_root.circle,"circle"+i, 1);
i++;
}

This lets flash know how many movieclips you duplicated.
Logged
  • Netterra Virtual Pets
Re: Flash MX 2004 Attach MC?
« Reply #8 on: May 16, 2006, 11:16:35 am »
  • Oh.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 579
But than wouldn't that only sense the latest one created?  What if it needs to sense all of them?  :(
Logged
Hm.
Re: Flash MX 2004 Attach MC?
« Reply #9 on: May 16, 2006, 02:17:13 pm »
  • Its the joeshmo!
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 694
No, because we put the while statement. That constantly circles through all the  movieclips you have to see if it hits.
Logged
  • Netterra Virtual Pets
Re: Flash MX 2004 Attach MC?
« Reply #10 on: May 16, 2006, 08:14:01 pm »
  • Oh.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 579
 :o  I get it.  But if there are 90 objects you want to check and its a 30 FPS movie won't it be too long before it senses it passing over it?
Logged
Hm.
Re: Flash MX 2004 Attach MC?
« Reply #11 on: May 16, 2006, 09:17:30 pm »
  • Its the joeshmo!
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 694
No. Doing this simple while statement takes less than a 90th of a second. It should only have a tiny bit lag.
Logged
  • Netterra Virtual Pets
Re: Flash MX 2004 Attach MC?
« Reply #12 on: May 16, 2006, 10:15:11 pm »
  • Oh.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 579
Wow!  I shouldn't talk back  ;D
Logged
Hm.
Re: Flash MX 2004 Attach MC?
« Reply #13 on: May 16, 2006, 10:16:30 pm »
  • Its the joeshmo!
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 694
Its fine. I thought the same thing too the first time I saw the code. Luckily its just a quick while string. Over 200 video clips with this are not recomended though.
Logged
  • Netterra Virtual Pets
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.137 seconds with 62 queries.