LOADING
Loading
Hi , welcome back.
LogoutLOGOUT
 
  Lost password?  
Hi
 




 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-10-2004, 03:54 PM
Lelboy Lelboy is offline
Registered User
 
Join Date: Apr 2004
Location: edinburgh
Posts: 38
Rep Power: 0
Lelboy is on a distinguished road
randomly selecting from an array

Hi,
The following code randomly selects one of the movieclips and loads it into an itemQueue_mc, but it only loads each mc into the itemQueue_mc once, then deletes it, so as it won't get loaded in again. It repeats the process until the categories array is empty.

My clips are in the library with the linkage id's set.

Is there a way that I could randomly select three clips of the seven to load into the itemQueue_mc??

Actionscript:
var categories = new Array();
categories[0] = 'accessories_mc';
categories[1] = 'work_mc';
categories[2] = 'holiday_mc';
categories[3] = 'gym_mc';
categories[4] = 'partyTime_mc';
categories[5] = 'partyWear_mc';
categories[6] = 'comfyCasual_mc';


//attachRandom();
function attachRandom(){
	var catLength = categories.length;
	if(catLength == 0){
                //sends play headto endgame screen
		_root.gotoAndPlay("endGame");
		//call the gameover function
		gameOver();
		trace("finished")
	}else{
		// let's make a random selection of the category:
		var cat = Math.floor(Math.random()*catLength);
		// attach this item to the queue_mc. by loading always into the same depth
		// (1), the item which was there previously gets obliterated
		_root.itemQueue_mc.attachMovie(categories[cat],'curItem',1);
		// as every category should only appear once, let's remove this category
		// from the array:
		categories.splice(cat,1);
		trace(categories);
		//move diasable button on screen
		_root.disableScreen_mc.moveMe(800, 76, 1);
		_root.queueMarker_mc._x = 190;
		_root.running2 = true;
	}
}

Any help / tips / advice would be great

TAI

Lel
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with a Tough Array Randomization/Shuffle Problem TheMediaBoy Actionscript 2.0 10 07-21-2006 09:05 AM
Trigonometry tricky array challenge? nathanScruggs Flash MX ActionScript 0 04-24-2005 09:04 PM
Help Needed: Stopping last element in array incriment wyclef Flash MX ActionScript 6 03-17-2005 08:35 PM
Randomly selecting a movie Burpee Flash MX 1 02-17-2005 01:13 PM
Resolved: display contents of an array Lelboy Flash MX 2 05-06-2004 03:46 PM




All times are GMT. The time now is 06:16 AM.