Solved

AS2 moving a datagrid row up or down

Posted on 2011-03-12
9
543 Views
Last Modified: 2012-05-11
I have attached a file as a sample, basically I want to select a row in a datagrid and move it up or down in the order using buttons outside the datagrid. I'm sure this is simple - but some how I'm not making it work.
move.fla
0
Comment
Question by:twall73
  • 5
  • 4
9 Comments
 
LVL 39

Expert Comment

by:blue-genie
ID: 35151099
hi i've uploaded a sample for you.


move-Bgi.fla
0
 

Author Comment

by:twall73
ID: 35179766
Sorry I guess I did not explain it very well. What I am trying to do is move the items in the row up or down, so that the datagrids row items are in a new order. ie if you select a row at index 1 and move it up the itemss in row index 1 becomes the items in row index 0 and the items in row index 0 becomes the items in row index 1.
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 35181856
ah ok. what you need to do then is swap the order in your dataprovider,whether it's an array or xml or whatever, and then just refresh your data provider
0
 

Author Comment

by:twall73
ID: 35203701
so if I create an array from the data in the datagrid, how would I swop the order in the array?
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 39

Expert Comment

by:blue-genie
ID: 35206083
i did a quick google search and came across this

http://stackoverflow.com/questions/2461582/what-is-the-easiest-way-to-swap-items-inside-an-array-actionscript-2-0


you basically need to swap the indexes around.
0
 
LVL 39

Accepted Solution

by:
blue-genie earned 250 total points
ID: 35206095
0
 

Author Closing Comment

by:twall73
ID: 35220271
Provided a link to a solution on the internet over explaining it - still solved the problem but at Expert Exchange as a paying member I thought I would get an Expert answer!!!
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 35222666
I don't believe in re-inventing the wheel - remember the "experts" are all volunteers - for me it's about knowledge sharing - if there's a solution out there why should we re-type it here when the answer is already out there.
Also I could fake it and pretend that it's all me, but I believe in giving credit where credit is due i.e other people who've worked on something.
Not sure what you would consider an "Expert answer" - sorry to have let everyone down. Promise to try harder.
0
 

Author Comment

by:twall73
ID: 35223454
After doing a lot a trial and error I actually figured out how to achieve this:

function swapLines(a,b){
	var a_obj:Object = subs_dg.getItemAt(a);
	var b_obj:Object = subs_dg.getItemAt(b);
	
	subs_dg.removeItemAt(a); 
                     subs_dg.addItemAt(a, b_obj);
	
	subs_dg.removeItemAt(b); 
                     subs_dg.addItemAt(b, a_obj);	
};

Open in new window


I knew there must be a simple solution and there it is....
move.fla
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now