Hi there!\r\rFollowing problem:\r\rI want e.g. 25 cicles on the screen. Position and size shall come from a .txt-file. Does it work with duplicateMovieClip. I don’t want to draw 25 circles by hand.\rIdeas?\r\rTHX a lot\r\rHartwig

couldn’t you just use the one circle and drag it on to the stage 25 times then manipulate each instance as you’d like?

yes of course i could, but in fact i used 25 as example and i have nearly 500 circles. so i would go crasy dragging and manipulating each circle.\r\rHartwig

so duplicate movie clip then :slight_smile:

OK. Let me re-ask my question:\rHow could the script look like, that duplicates my circle and reads its properties from a textfile. Duplicate does work but the the variables from the textfile are ignored. It only works when I use fix values.\r\rHelp me please!\r\rTHX Hartwig

ok… lobstar is being oblique… :slight_smile: \r\rA) keep in mind that if you do this, you’re going to have 500 movie clips on the stage. If all of these are moving, it’s going to bog down the processor a lot. I have no clue what sort of frame rate you’ll be able to achieve that way… but this is the script that will do it.\r\rlets say you place one circle on the stage and give it an instance name of “myCircle”\r\rnow you could place this in any frame to duplicate the movie clips.\r\rfor (i=0;i<500;i++){\rmyCircle.duplicateMovieClip(“myCircle”+i,i);\r}\r\rthis will place 500 duplicates of the circle on the stage, in the exact same location as the first circle. Each one will be named myCircle0, myCircle1, myCircle2, etc until you reached myCircle499.\r\rif you were going to possition them as you duplicated them, you could add the coordinates into the for loop like so\r\rfor (i=0;i<500;i++){\rmyCircle.duplicateMovieClip(“myCircle”+i,i);\r[“myCircle”+i]._x=myvariable;\r[“myCircle”+i]._y=myvariable;\r}

LoL, remind me never to go on that flash, my computer struggles with 25 randomly moving circles… 500 would destroy it!

Hi!\r\rTHX for the code. I haven’t tried it yet, but when reading it I can’t get rid of the feeling that all the circles will be placed on the same position, because myVaraible doesn’t change. I have more variables myVariable1, myVariable2,…,myVariable500 (just for the x-position).\rDo I have to put them in [], too?\r\rHartwig

as long as your variables are named that way it’s easy\r\rfor (i=0;i<500;i++){\rmyCircle.duplicateMovieClip(“myCircle”+i,i);\r[“myCircle”+i]._x=“myVariable”+i;\r[“myCircle”+i]._y=“myVariable”+i;\r}

Sorry!!! I have just started doing landscape gardening for a living :slight_smile: DARN IT I’M TIRED…\rSorry for not being more helpful :slight_smile:

:slight_smile: it’s ok man… we understand.

Cheers David :slight_smile:

Hi again!\r\rSomething doesn’t work with your code. The instances of the circle are created, but the assignement of the new values of the coordinates from the variables from the .txt-file take no effect: all circles are at the same position. Any alternatives (e.g. setProperty,…)\r\rTHX for any help\r\rHartwig

set property is evil, never use it. It is a depreciated command as far as I know. Make sure that you have the correct path to your TEXT file, and make sure you load the variables from the text file first. the problem is that it is not getting the variables…

you’ll have to evaluate those variables references:

 \r\rfor (i=0;i<500;i++){\r\r  myCircle.duplicateMovieClip("myCircle"+i,i);\r\r  _root["myCircle"+i]._x = _root["myVariable"+i];\r\r  _root["myCircle"+i]._y = _root["myVariable"+i];\r\r}

\rthat will set each circle’s x and y to its corresponding myVariable.\r\rie. _root.myCircle4’s x and y will be set to _root.myVariable4

OK you’re right, as usual. The variables are read and the properties are set correct. Now the next problem: Can I tween these duplicated circles? With start- and endsizes coming from a txt-file, too? Once I heard of this:\r\ronClipEvent (load) {\r&nbsp &nbsp &nbsp &nbsp finalsize = _root.variable2;\r&nbsp &nbsp &nbsp &nbsp size = _width;\r&nbsp &nbsp &nbsp &nbsp diff = finalsize-size;\r&nbsp &nbsp &nbsp &nbsp width = _root.variable1;\r&nbsp &nbsp &nbsp &nbsp height = _root.variable1;\r&nbsp &nbsp &nbsp &nbsp _height = height;\r&nbsp &nbsp &nbsp &nbsp _width = width;\r&nbsp &nbsp &nbsp &nbsp _x = posx;\r&nbsp &nbsp &nbsp &nbsp _y = posy;\r}\r\ronClipEvent (enterFrame) {\r&nbsp &nbsp &nbsp &nbsp if (_width<finalsize) {\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp _xscale += diff/50;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp _yscale += diff/50;\r&nbsp &nbsp &nbsp &nbsp }\r}\r\rIt’s for one specific circle. But how can I use this here???\r\rTHX\r\rHartwig

suprabeener is awesome… listen and learn from everything he says. He’s taught me more than almost any book I’ve read.

upu - thanks for the kudos!\r\rhartwig - \r\rif you’re going to keep this many variables for each movie, how about creating a more organised method of storing them? let’s use an array of custom objects:

   \r\r// create the array of objects\r\r_root.settings = [\r\r   {_x:300,_y:300,_xscale:150,_yscale:150},\r\r   {_x:200,_y:200,_xscale:200,_yscale:200}\r\r];

\ri used shorthand to create both the array and the objects in it, but it’s pretty clear how it works, right? see how each element of settings is an object with various property / value pairs?\r\rwhile poking around in the help files, i discovered that macromedia has built in a way to grab you variables from an object when using duplicateMovieClip! perfect!!\r\rnow we use that array to create our movies, good to encapsulate it in a function:

   \r\rfunction makeDemMovies() {\r\r   // declare local variables\r\r   var j;\r\r   // for each object in settings...\r\r   for(j in _root.settings){\r\r      // the last argument is the object that you grab the values from\r\r      _root.myCircle.duplicateMovieClip("myCircle"+j,j,_root.settings[j]);\r\r   }\r\r}

\rthen call the function to put it into action:


\ret viola! many movies!\r\rthis method involves making an object for each clip you want to duplicate … lots of typing.\r\rbon chance!\r\r* edited because i used i in the for loop (again) and it made everything italic, doh*

Hi suprabeener!\r\rI understand your description to make many movies (I think), but I can’t get how this should help me to tween each of these circles in a different way. duplicateMovieClip makes X circles from one and I don’t know how to treat these X new circles sepperately. Please explain the next step after duplicateMovieClip.\rIt would be very appreciated,\r\rHartwig

ah, i see what you mean.\r\rthe elements in the object don’t have to be properties, they can be anything, and the duplicated clip will inherit them. for instance:

 \r\r_root.settings = [\r\r   {_x:300,_y:300,_xscale:150,_yscale:150,myVariable:"someString"},\r\r   {_x:200,_y:200,_xscale:200,_yscale:200}\r\r];\r\rfor(j in settings){\r\r   myCircle.duplicateMovieClip("myCircle"+j,j,settings[j]);\r\r}\r\rtrace(myCircle0.myVariable); // outputs "someString"\r\r

\rthen you want them to tween to some size right?\r\rlet’s create a tweenSpd and a tweenMax variable to facilitate that, and write a method to make each movie tween.\r\rfirst, the method:

 \r\rMovieClip.prototype.tween = function(){\r\r   if(this._xscale < this.tweenMax){\r\r      this._xscale = this._yscale += this.tweenSpd;\r\r   }else{\r\r      this.onEnterFrame = null;\r\r   }\r\r}

\rso this is a pretty simple method. the clip will check if it’s too big, if not it grows uniformly in along both axis, if it is, it cancels the onEnterFrame event (itself).\r\rnow we need to add those variables to the objects, and have each clip tween when it loads. here’s a version to include those things:

 \r\r_root.settings = [\r\r   {_x:300,_y:300,tweenSpd:5,tweenMax:150},\r\r   {_x:200,_y:200,tweenSpd:10,tweenMax:200}\r\r];\r\rfunction makeDemMovies() {\r\r   var j,mc;\r\r   for(j in _root.settings){\r\r      mc = _root.sqr.duplicateMovieClip("myCircle"+j,j,_root.settings[j]);\r\r      mc.onEnterFrame = mc.tween;\r\r   }\r\r}