# Adding randomly loaded variables together and more

**URL:** <https://forum.kirupa.com/t/adding-randomly-loaded-variables-together-and-more/100754>\
**Category:** Uncategorized\
**Created:** [February 2, 2004, 2:59am UTC](https://forum.kirupa.com/t/adding-randomly-loaded-variables-together-and-more/100754 "2004-02-02T02:59:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![oldgreymare](https://avatars.discourse-cdn.com/v4/letter/o/838e76/32.png) [@oldgreymare](https://forum.kirupa.com/u/oldgreymare)\
**Post date:** [February 2, 2004, 2:59am UTC](https://forum.kirupa.com/t/adding-randomly-loaded-variables-together-and-more/100754/1 "2004-02-02T02:59:11Z")

</div>

Hello

I’m struggling with a project. I’ll try and describe it. 10 mc are loaded randomly with one of two ext.swf’s. Each time you click/drag on one, 1 of 6 questions are randomly loaded from an array into a text box on the main timeline. I need to count and add up how many of each of the 2 ext.swf’s have loaded and whether they have an x pos \< or \> 300. My first problem is: The question shows up in the text box when the mc is clicked/dragged but when I trace it, the question that shows in the output doesn’t match the one that’s loaded into the text box?  
The second problem is a big one. I need to be steered in the right direction as to keep track of what is where on stage. I only have a vague sense of how to go about it, and combining all the bits is too much.

1. I need to trace the question
2. I need to say if the question is ‘blah’ do this
3. The ‘do this’ is pretty complicated. I need to add up the #1 movies that have an x pos of \<300 and the #1 movies that have an x pos of \>300 and then do the same for the #0 movies. Then I need to compare a users input answer to the correct one!!!  
The question AS is in the external swf. [AS]stop();  
// Questions Array  
question = new Array(); {  
question[0] = “How many hedgehogs are in the bed?”;  
question[1] = “How many hedgehogs have rolled out of the bed?”;  
question[2] = “How many hedgehogs with curly hair are in the bed?”;  
question[3] = “How many hedgehogs with straight hair are in the bed?”;  
question[4] = “How many hedgehogs with straight hair have rolled out of the bed?”;  
question[5] = “How many hedgehogs with curly hair have rolled out of the bed?”;  
}  
out\_btn.onPress = function() {  
\_parent.startDrag();  
r = 0  
hog.eyeball\_mc.gotoAndPlay(‘open’);  
gotoAndPlay(‘rotateStart’);   
}

out\_btn.onRelease = out\_btn.onReleaseOutside = function() {  
\_parent.stopDrag();  
hog.farBottomLeg\_mc.gotoAndPlay(‘wiggle’);  
hog.farTopLeg\_mc.gotoAndPlay(‘wiggle’);  
hog.nearBottomLeg\_mc.gotoAndPlay(‘wiggle’);  
hog.nearTopLeg\_mc.gotoAndPlay(‘wiggle’);   
\_global.whichQuestion = trace(question[Math.round(Math.random()\*4)]);  
}  
[/AS]

I think it would be simpler if I removed the first two questions.  
The movie clip trace AS is on the maintimeline. I know I should have made them load from an array or something more effiecient than this mass of code but I knew I could make it work doing it the long way.  
[AS]stop();  
//Create movie clip for 1 curly hh  
//there always needs to be at least one of each  
\_root.createEmptyMovieClip(“hedgehog1\_mc”,2);  
loadMovie(“1.swf”, “hedgehog1\_mc”);  
movNum1 = trace(1);   
hedgehog1\_mc.\_x = 35 ;  
hedgehog1\_mc.\_y = 240 ;  
//create movie clip for one straight hh  
\_root.createEmptyMovieClip(“hedgehog2\_mc”,3);  
movNum2 = trace(0);  
loadMovie(“0.swf”, “hedgehog2\_mc”);  
hedgehog2\_mc.\_x = 75 ;  
hedgehog2\_mc.\_y = 245 ;

//create movie clip for the random 3rd, position  
//trace which mc loads and give it a name to keep track of it  
\_root.createEmptyMovieClip(“hedgehog3\_mc”,4);  
hh = Math.round(Math.random()\*1);  
movNum3 = trace(hh);  
loadMovie(hh+".swf", “hedgehog3\_mc”);  
hedgehog3\_mc.\_x = 115 ;  
hedgehog3\_mc.\_y = 240 ;

//create movie clip for the random 4th, position  
\_root.createEmptyMovieClip(“hedgehog4\_mc”,5);  
hh = Math.round(Math.random()\*1);  
movNum4 = trace(hh);  
loadMovie(hh+".swf", “hedgehog4\_mc”);  
hedgehog4\_mc.\_x = 155 ;  
hedgehog4\_mc.\_y = 245 ;

//create movie clip for the random 5th, position  
\_root.createEmptyMovieClip(“hedgehog5\_mc”,6);  
hh = Math.round(Math.random()\*1);  
movNum5 = trace(hh);  
loadMovie(hh+".swf", “hedgehog5\_mc”);  
hedgehog5\_mc.\_x = 195 ;  
hedgehog5\_mc.\_y = 240 ;

//create movie clip for the random 6th, position  
\_root.createEmptyMovieClip(“hedgehog6\_mc”,7);  
hh = Math.round(Math.random()\*1);  
movNum6 = trace(hh);  
loadMovie(hh+".swf", “hedgehog6\_mc”);  
hedgehog6\_mc.\_x = 55 ;  
hedgehog6\_mc.\_y = 265 ;

//create movie clip for the random 7th, position  
\_root.createEmptyMovieClip(“hedgehog7\_mc”,8);  
hh = Math.round(Math.random()\*1);  
movNum7 = trace(hh);  
loadMovie(hh+".swf", “hedgehog7\_mc”);  
hedgehog7\_mc.\_x = 95 ;  
hedgehog7\_mc.\_y = 255 ;

//create movie clip for the random 8th, position  
\_root.createEmptyMovieClip(“hedgehog8\_mc”,9);  
hh = Math.round(Math.random()\*1);  
movNum8 = trace(hh);  
loadMovie(hh+".swf", “hedgehog8\_mc”);  
hedgehog8\_mc.\_x = 135 ;  
hedgehog8\_mc.\_y = 265 ;

//create movie clip for the random 9th, position  
\_root.createEmptyMovieClip(“hedgehog9\_mc”,10);  
hh = Math.round(Math.random()\*1);  
movNum9 = trace(hh);  
loadMovie(hh+".swf", “hedgehog9\_mc”);  
hedgehog9\_mc.\_x = 175 ;  
hedgehog9\_mc.\_y = 255 ;

//create movie clip for the random 10th, position  
\_root.createEmptyMovieClip(“hedgehog10\_mc”,11);  
hh = Math.round(Math.random()\*1);  
movNum10 = trace(hh);  
loadMovie(hh+".swf", “hedgehog10\_mc”);  
hedgehog10\_mc.\_x = 215 ;  
hedgehog10\_mc.\_y = 260 ;

//bellpull button to check answers  
\_root.bellPull.checkAnswer\_btn.onRollOver = function(){  
\_root.bellPull.gotoAndStop(‘over’);  
}  
\_root.bellPull.checkAnswer\_btn.onRollOut = function(){  
\_root.bellPull.gotoAndStop(‘still’);  
}  
\_root.bellPull.checkAnswer\_btn.onRelease = function(){  
\_root.bellPull.gotoAndPlay(‘dangle’);  
}[/AS]

If someone could make some suggestions about where I should start it would be so incredible. This project is overwhelming me. I can post the FLA’s too.  
Thank you to any one who can take the time.
