Flash Trek: The Unofficial Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Actionscript for Duplicating

4 posters

Go down

Actionscript for Duplicating Empty Actionscript for Duplicating

Post by Final Frontier 2010-03-23, 09:47

I'm having some problem with Actionscript for Duplicating. I wanted to make a button to duplicate a starship like Broken Mirror where you make a fleet, but when I press the button, it only duplicates one. And if pressed again the duplicated one just keeps moving around.

Help!

The code I typed in:
Code:
on (release){
    //keep track of how many movie clips duplicated
    num_movie_clips = num_movie_clips+1
    //duplicate movie clip
    myMovie.duplicateMovieClip("myMovie"+num_movie_clips,num_movie_clips);
    //position movie clip
    _root["myMovie"+num_movie_clips]._x=Math.random()*550
    _root["myMovie"+num_movie_clips]._y=Math.random()*350
}

The swf file
SWF file
Final Frontier
Final Frontier
Ensign
Ensign

Male Number of posts : 301
Age : 27
Location : Where am I?
Registration date : 2010-01-10

Back to top Go down

Actionscript for Duplicating Empty Re: Actionscript for Duplicating

Post by Final Frontier 2010-03-23, 09:50

Final Frontier
Final Frontier
Ensign
Ensign

Male Number of posts : 301
Age : 27
Location : Where am I?
Registration date : 2010-01-10

Back to top Go down

Actionscript for Duplicating Empty Re: Actionscript for Duplicating

Post by Darkwing 2010-03-23, 11:19

oooh, that's out of my league, never got that far, I was only beginning to touch on activating MCs in the AS when I stopped using flash
Darkwing
Darkwing
Founder
Founder

Male Number of posts : 17810
Age : 34
Location : Everywhere
Registration date : 2007-10-13

http://www.flashtrek-tuf.com

Back to top Go down

Actionscript for Duplicating Empty Re: Actionscript for Duplicating

Post by Silvershadows 2010-03-23, 13:20

i think your gonna want to change "num_movie_clips = num_movie_clips+1" to +2 or ++ or whatever to create more than one
Silvershadows
Silvershadows
Lieutenant
Lieutenant

Male Number of posts : 1385
Age : 31
Location : United Kingdom, Guildford
Registration date : 2009-06-07

http://brokenmirror.forumotion.co.uk/

Back to top Go down

Actionscript for Duplicating Empty Re: Actionscript for Duplicating

Post by Final Frontier 2010-03-24, 11:06

I did num_movie_clip ++, still doesn't work. Maybe I'll try again.
Final Frontier
Final Frontier
Ensign
Ensign

Male Number of posts : 301
Age : 27
Location : Where am I?
Registration date : 2010-01-10

Back to top Go down

Actionscript for Duplicating Empty Re: Actionscript for Duplicating

Post by Silvershadows 2010-03-24, 13:21

try like +2 or sumin then
Silvershadows
Silvershadows
Lieutenant
Lieutenant

Male Number of posts : 1385
Age : 31
Location : United Kingdom, Guildford
Registration date : 2009-06-07

http://brokenmirror.forumotion.co.uk/

Back to top Go down

Actionscript for Duplicating Empty Re: Actionscript for Duplicating

Post by JPB18 2010-03-24, 16:13

That it's similar to java and C... weird...

Ok, lets see... may be you should check if there is any ship existent, and then use a loop cycle to keep adding +1 (until the user closes the program... or script...)
JPB18
JPB18
Commander
Commander

Male Number of posts : 5475
Age : 30
Location : At atlantis searching for the ultimate weapon! Ok.. I'm in Azeitão, Portugal...
Registration date : 2008-05-15

http://joaopedroborrego.wordpress.com/

Back to top Go down

Actionscript for Duplicating Empty Re: Actionscript for Duplicating

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum