Sorting a new array from an existing array

This is a discussion on "Sorting a new array from an existing array" within the Flash & Multimedia Forum section. This forum, and the thread "Sorting a new array from an existing array are both part of the Design Your Website category.



 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Design Your Website > Flash & Multimedia Forum

Notices


Reply
 
LinkBack Thread Tools
  #1  
Old Sep 20th, 2005, 02:06
Junior Member
Join Date: Jul 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Sorting a new array from an existing array

Hi

i got an existing array, main[y], which after an equation, will come out with another array.

Code: Select all
 if (main[y] === topicList.getValue()){
        subTopic = [];
        subTopic = fTitle[y]
        trace(subTopic)
}
However, i could not sort the subTopic, as it keep giving me undefined. Is there any way to sort this subTopic, such that they are in alphabetical orders?

Appreciate any help.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Sep 20th, 2005, 06:19
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
You're not actually properly defining your arrays, from the code I can see.

You're also not using arrays properly.

You define an array like this:
myArray = new Array();

then add elements:
myArray[0] = "hello";
etc, etc.

So here's your code, with some defined variables which works...

Code: Select all
main = new Array();
main[0] = "one";
main[1] = "two";
main[2] = "three";

topicList = "two";
y = 1;

if (main[y] == topicList)
{ 
        subTopic = new Array(); 
        subTopic[0] = main[y];
        trace(subTopic) 
}
I'm not entirely sure what you're trying to accomplish so my code doesn't really do much, but it should point you in the right direction.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Sep 20th, 2005, 08:43
Junior Member
Join Date: Jul 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
sorry abt the hasty codes. Actually it is a dynamic array( taken from xml) therefore i could not define it as indicated.

im trying to get the first label's content of the sub list box(featureList) out using the top listbox (topicList)

these are some of the main codes that are related to this issue.. Hope these codes can be understood

Code: Select all
 ////////////////////////////////////////////////////input items in topic listbox 
function setupTopicList() {
	topicList.setAutoHideScrollBar(true);
	f_Topic.reverse();
	sampleList._visible = false;

 for(var item in f_Topic){
	topicList.addItem(f_Topic[item]);
}
topicList.sortItems(upperCaseFunc);
function upperCaseFunc(a,b){
return a.label.toUpperCase() > b.label.toUpperCase();
}
}

////////////////////////////////////////////////////////// input items in feature listbox
function setupFeatureList(p) {
featureList.setAutoHideScrollBar(true);
all = counting.length
featureList.removeAll();
featureList._visible = false;
featureList.setStyle("backgroundColor", "0xC0DFF1");
for(m=0; m<all; m++) {
	if(f_TopicR[p] === fTopic[m]) {  
		featureList._visible = true;
		featureList.addItem(fTitle[m]);
//trace("m of featureList = " + m)
}
}

featureList.sortItems(upperCaseFunc);
function upperCaseFunc(a,b){
return a.label.toUpperCase() > b.label.toUpperCase();
}
}


/////////////////////////// trying to use the topiclist to show 1st of features

function goToFirst(t) {
	if (loaded == filesize) {
		countingall = counting.length
	for( y =0; y < countingall; y++) {
	if (t == fTopic[y]){
		
trace(fTitle[y])
x = y

picture.loadMovie = image[y]; 
titleText.text = description[y];

}}
}

////////////////////////////////////////////////////////////topic list listener
myTopicBoxListener = new Object();
myTopicBoxListener.change = function ( eventObj ){
	var eventSource = eventObj.target;
	var selectedObj = eventSource.selectedItem;
	var q = eventSource.selectedIndex;
	var selectedObjLabel = selectedObj.label;
	var t = eventSource.selectedItem.label;
setupFeatureList(q);
goToFirst(t);


}

topicList.addEventListener ("change", myTopicBoxListener);


///////////////////////////////listens to the feature listbox for command

myListBoxListener = new Object();
myListBoxListener.change = function ( eventObj ){
	var eventSource = eventObj.target;
	var selectedObj = eventSource.selectedItem;
	var p = eventSource.selectedIndex;
	var selectedObjLabel = selectedObj.label;
	var r = eventSource.selectedItem.label;
clickChange(r);
setupsampleList(r);
rojak(r)
}
	
featureList.addEventListener ("change", myListBoxListener);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
sorting, array, existing

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help sorting an array djeyewater PHP Forum 6 Apr 18th, 2008 15:16
[SOLVED] Array sorting welshstew Classic ASP 6 Nov 28th, 2007 16:45
Sorting a PHP array fallen_angel PHP Forum 3 Apr 20th, 2007 22:18
array unable to check another array so as to be displayed Ozeona Flash & Multimedia Forum 1 Aug 5th, 2005 10:26
Sorting the array - reversing the sequence codes? Ozeona Flash & Multimedia Forum 1 Aug 3rd, 2005 01:52


All times are GMT. The time now is 08:03.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42