Old 18-08-2005, 01:15   #1 (permalink)
seanbot
simplicity
 
seanbot's Avatar
 
Join Date: Apr 2004
Location: Minneapolis
Posts: 11
Send a message via AIM to seanbot
Flash - Add Object.

Well, I *thought* I knew a bit of actionscript . . . oh how I was wrong.

Anyways, I'm looking for some actionscript that will allow be to toss in a movieclip over and over in a random position through a click of a button. Also is there a way to set which set of movie clips will be randomized for that particular button?

I've scoured Flashkit/Actionscript.org, as well a few books to no avail.

Anyone?
  Reply With Quote
Old 18-08-2005, 02:23   #2 (permalink)
gray
i still want paying
 
gray's Avatar
 
Join Date: Oct 2003
Location: newcastle, uk
Posts: 4,728
  Reply With Quote
Old 18-08-2005, 11:03   #3 (permalink)
seanbot
simplicity
 
seanbot's Avatar
 
Join Date: Apr 2004
Location: Minneapolis
Posts: 11
Send a message via AIM to seanbot
Quote:
Originally Posted by gray


Hit it right on the head. Thanks!
  Reply With Quote
Old 18-08-2005, 14:24   #4 (permalink)
y498
Stupid Shit since 1982
 
y498's Avatar
 
Join Date: Feb 2005
Location: Calgary, Alberta, Canada
Posts: 155
kirupa.com too - I use it just a bit more than actionscript.org
  Reply With Quote
Old 18-08-2005, 14:32   #5 (permalink)
seanbot
simplicity
 
seanbot's Avatar
 
Join Date: Apr 2004
Location: Minneapolis
Posts: 11
Send a message via AIM to seanbot
Quote:
Originally Posted by y498
kirupa.com too - I use it just a bit more than actionscript.org


I forgot to mention Kirupa as well, I absolutely adore that site.
  Reply With Quote
Old 19-08-2005, 22:03   #6 (permalink)
seanbot
simplicity
 
seanbot's Avatar
 
Join Date: Apr 2004
Location: Minneapolis
Posts: 11
Send a message via AIM to seanbot
Ok, so I've got this running fine, but I'm running into problems duplicating multiple movie clicks with the same button.

My code is:
Code:
on (release) { count = 1; while (count<20) { _root.box.duplicateMovieClip("boxx"+count, count); _root["boxx"+count]._x = random(550); _root["boxx"+count]._y = random(150); _root["boxx"+count]._xscale = random(150); _root["boxx"+count]._yscale = random(150); _root["boxx"+count]._alpha = random(100); count += 1; } } on (release) { count = 1; while (count<20) { _root.box.duplicateMovieClip("box2x"+count, count); _root["box2x"+count]._x = random(350); _root["box2x"+count]._y = random(250); _root["box2x"+count]._xscale = random(150); _root["box2x"+count]._yscale = random(150); _root["box2x"+count]._alpha = random(100); count += 1; } }
  Reply With Quote
Old 02-09-2005, 16:51   #7 (permalink)
chavez
Registered User
 
Join Date: Sep 2005
Posts: 4
Code:
this.onRelease = function() { for(i = 0; i < 20; i++) { if(i < 10){ _root.box.duplicateMovieClip("boxx"+i, i); _root["boxx"+i]._x = random(550); _root["boxx"+i]._y = random(150); _root["boxx"+i]._xscale = random(150); _root["boxx"+i]._yscale = random(150); _root["boxx"+i]._alpha = random(100); }else{ _root.box2.duplicateMovieClip("box2x"+i, i); _root["box2x"+i]._x = random(350); _root["box2x"+i]._y = random(250); _root["box2x"+i]._xscale = random(150); _root["box2x"+i]._yscale = random(150); _root["box2x"+i]._alpha = random(100); } } }

this code has to go inside the first movie clip, and it'll duplicate each of those movie clips 10 times (for a total of 20). so if you wanted 20 of each you'd change "i < 20" to "i < 40"
  Reply With Quote
Old 09-09-2005, 13:15   #8 (permalink)
ewarwoowar
Registered User
 
Join Date: Apr 2003
Posts: 33
Couple of things though...

1) _root only breeds later scope problems - making it relative like this._parent is much more flexible.

2) You can cut your code down by doing poo=this._parent["boxx"+i] then just using poo, so to speak, and by making the code that creates the MCs into a function that you just pass a variable to (1 or 2), instead of very nearly duplicating that big block of code.

3) Also, duplicateMovieClip's a bit clumsy for this as you need one sitting there on the timeline. Ideally you could just replace it with attachMovie and give the clip an identifier in the library.

  Reply With Quote
Old 12-09-2005, 14:36   #9 (permalink)
chavez
Registered User
 
Join Date: Sep 2005
Posts: 4
thanks.

Nobody else was really posting anything so I figured I'd just throw something out. AS isn't really my strong suit. Your suggestions could be easily incorporated though, hopefully the OP will post back if he decides to use it.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8