Pedro, Your loop goes from 0 to 1, and you are constructing the names of your movie clips as "code"+I; therefore, your movie clip names are "code0" and "code1". There is no such clip as "code2".
-Jim -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Pedro Kostelec Sent: Wednesday, January 16, 2008 7:21 PM To: Flash Coders List Subject: Re: [Flashcoders] placing mc on the stage Thanks for the reply. but it still doesn't work for me. I can only see code1 moving randomly overthe stage, but thereis no sign of code2 movie clip. Here is a bigger peace of the code: this.createEmptyMovieClip("canvas",this.getNextHighestDepth());//creates an empty MC in which i attach 2 textMCs mouseInterval = setInterval(cahngeAlpha, 1);//set interval for bg and hello world reload attachMovieInterval = setInterval(attachMovies, 200);//set interval for green text mc reload function attachMovies() { for (var i = 0; i<2; i++) { canvas.attachMovie("code","code"+i,this.getNextHighestDepth()); canvas.code1._x = random500; canvas.code1._y = random100; canvas.code2._x = Stage.width/2; canvas.code2._y = Stage.height/2; } } function cahngeAlpha() { a._alpha = (Math.round(_root._xmouse/550*100)); a._xscale = (Math.round(_root._xmouse+250)-1)/0.9998; a._yscale = (Math.floor(_root._xmouse/550*20+100)); black._alpha = Math.round((550-(_root._xmouse))/550*100); white._alpha = Math.round(_root._xmouse/550*100); random500 = Math.random()*100; random100 = Math.random()*100; updateAfterEvent(); } attachMovies();//ou said ihave to put this. but for the other function(cahngeAlpha) i didnt and it works perfectly!! have i done a mistake? On 16/01/2008, Bob Leisle <[EMAIL PROTECTED]> wrote: > > Hi Pedro, > > A couple of things: > Are you trying to place the MovieClips once in random places, or make > them move to random places? Your code suggests one-time placement. What > you say below suggests movement on the stage. > Also, have you checked your random calculations? If you divide (/) > Math.random, you will always get a number less than 1. Math.random() > returns a number between 0 and 1 which can then be multiplied to get > numbers usable for the stage coordinates. > > If you are trying to place the clips one time on attachment, here is a > function, based on the code you sent, that works: > random100=Math.random()*100; > random500=Math.random()*500; > // Assumes you've already created the MovieClip, "canvas". > function attachMovies() { > for (var i = 0; i<2; i++) { > canvas.attachMovie("code","code"+i,this.getNextHighestDepth()); > } > canvas.code1._x = random500; > canvas.code1._y = random100; > canvas.code2._x = Stage.width/2; > canvas.code2._y = Stage.height /2; > } > attachMovies(); > > This will place code1 at the some random point between (0,0) and (500, > 100), and place code2 at center stage, offset by it's own registration > point > > hth, > Bob. > > Pedro Kostelec wrote: > > sorry. I forgot to copy this. > > > > random100=Math.random()/100; > > random500=Math.random()/500; > > - how do i do to define the x and y position of each mc separately? > > > > I don't get it.. what do you want to do here? > > > > what i want is to make one ofthose mcs moveup and downand the other > > right-left. Theproblem is tht i just can not do it > > > > function attachMovies() { > > for (var i = 0; i<2; i++) {//iwantto place each of those mc-s into a > > different placeon the stage. I am not sure this is the right way. > > canvas.attachMovie ("code","code"+i,this.getNextHighestDepth()); > > //didn't it created on mc named code1 and another code2???? > > canvas.code1._x = random500;//i triyed something like > > canvas.code1._x=500; instead of this but it didn't work. what i am > doing > > wrong?? > > canvas.code1._y = random100; > > canvas.code2._x = Stage.width/2; > > canvas.code2._x = Stage.height /2; > > } > > }On 16/01/2008, Leandro Ferreira <[EMAIL PROTECTED]> wrote: > > > >> You could also use random(500), but is deprecated - > >> > http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/ac tionscript_dictionary630.html > >> > >> > >> > >> > >> - how do i do to define the x and y position of each mc separately? > >> > >> I don't get it.. what do you want to do here? > >> > >> > >> Leandro Ferreira > >> > >> On 1/16/08, Bob Leisle < [EMAIL PROTECTED]> wrote: > >> > >>> Hi Pedro, > >>> > >>> Try this instead: > >>> > >>> Math.random()*500; > >>> > >>> Here's a simplistic but clear tutorial on the subject: > >>> > http://animation.about.com/od/flashanimationtutorials/ss/mathrandom.htm > >>> > >>> hth, > >>> Bob > >>> > >>> Pedro Kostelec wrote: > >>> > >>>> Hello > >>>> i got this code: > >>>> > >>>> this.createEmptyMovieClip("canvas",this.getNextHighestDepth()); > >>>> > >>> //creates an > >>> > >>>> empty MC in which i attach 2 textMCs > >>>> canvas._x = random500;//should place the MCs to a random position > when > >>>> > >>> they > >>> > >>>> load but it doesn't work?!?-----------------------------What is wrong > >>>> > >>> here? > >>> > >>>> canvas._y = random100; > >>>> > >>>> attachMovieInterval = setInterval(attachMovies, 200);//set interval > >>>> > >> for > >> > >>>> green mc reload > >>>> > >>>> function attachMovies() { > >>>> for (var i = 0; i<2; i++) { > >>>> canvas.attachMovie("code","code"+i,this.getNextHighestDepth > ()); > >>>> canvas.code1._x = random500; > >>>> canvas.code1._y = random100; > >>>> canvas.code2._x = Stage.width/2; > >>>> canvas.code2._x = Stage.height/2;//how do i do to define the > x > >>>> > >>> and y > >>> > >>>> position of each mc separately? > >>>> } > >>>> } > >>>> > >>>> sorry for writing it so briefly. My keyboard doesn't work well and i > >>>> > >>> cannot > >>> > >>>> type a lot > >>>> --------------------------------------------------------- > >>>> > >>>> > >>>> > >>> -- > >>> Thanks, > >>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > >>> Bob Leisle > >>> Headsprout Software & Engineering > >>> http://www.headsprout.com > >>> Where kids learn to read! > >>> > >>> _______________________________________________ > >>> Flashcoders mailing list > >>> Flashcoders@chattyfig.figleaf.com > >>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > >>> > >>> > >> _______________________________________________ > >> Flashcoders mailing list > >> Flashcoders@chattyfig.figleaf.com > >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > >> > >> > > > > > > > > > > -- > Thanks, > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Bob Leisle > Headsprout Software & Engineering > http://www.headsprout.com > Where kids learn to read! > > _______________________________________________ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- Pedro D.K. _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders