Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Flash - ActionScript

drag + drop to swap depth

 
Jump to:  
 
luciewong
PostPosted: Wed Aug 06, 2008 5:52 am    Post subject: drag + drop to swap depth
       
Hi,
I have a list of 10 emptyMovieClips, each representing a "Depth".
So the top EMC is depth 0, the last in the list represents depth 9.

I want to drag and drop now for ex. the EMC number 10 to the top, so he
inherits the depth 0 of the top EMC, while the top EMC with depth 0 should
inherit the depth 9 of the moved and dropped EMC. cool.

How could I achieve this and where could I start??

Thanks
 

 
Shan-Dysigns
PostPosted: Wed Aug 06, 2008 6:30 am    Post subject: Re: drag + drop to swap depth
       
Use swapDepths() with your onPress (or whatever event you are using). Example:

mc1.onPress=function() {
this.swapDepths(_root.getNextHighestDepth);
this.startDrag();
}

That will place the object at the top of the stacking order once you press it.
Or you could have it swapDepths() with another movie clip instance name. This
part really would determine how your stage is set up because I can't visually
understand your purpose.
 

 
luciewong
PostPosted: Wed Aug 06, 2008 7:43 am    Post subject: Re: drag + drop to swap depth
       
Hi, thank you for your reply,
The purpose is:
I have 7 components attached to my root. Each component has its depth (from 0
to 6);
The data comes in from an array like>
theDepth_array = [0,1,2,3,4,5,6];

Also the components names come in from an array like>
sub1_array = [compA,compB,compC,compD,compE,compF,compG];
sub1L = sub1_array.length;

Now with the >sub1_array< I create a list with code below>(code is reduced,
but you can see what I want)


function createDisplay(){

this.createEmptyMovieClip("holderSub_mc",mydepth+2998);//


//create the TFs>THE LIST>
for(a:Number =
0;a<sub1L;a++){ this.holderSub_mc.createEmptyMovieClip(["sub1_mc"+a],
(sub1depth)+a);//
this.holderSub_mc["sub1_mc"+a].avar = a;//<<
this.holderSub_mc["sub1_mc"+a].createTextField(["sub1_txt"],
(sub1depth_txt)+a,sub1X, sub1Y, sub1W, sub1H);
this.holderSub_mc["sub1_mc"+a]["sub1_txt"].type = "dynamic";
this.holderSub_mc["sub1_mc"+a]["sub1_txt"].text = sub1_array[a];//
this.holderSub_mc["sub1_mc"+a]["sub1_txt"].setTextFormat(sformatM);
}
};

//xxx

I have now a list of items + beside a list of depths.
So compA would be on top representing the depth 0
The comG is last in the list representing depth 6

All I want is to be able to change the depth of a component by pressing it and
moving to a desired other position.
I want to be able to change the depth of compG [6] by moving it up to compA,
so compG has the depth 0 and compA has then the depth 6.

If this could be done with RollOver and Press/Relaese actions without
drop/drag then I am happy.
For example, I >press< compG ? hold it down and move to the top over compA and
Quote:
Release</

- if I could achieve a data exchange ( depth + text ) would be perfect.
Then no need for physical drop+drag.
Maybe with a MouseMove action?
The arrays update with splice/onRelease would then be no problem.

Hope I made myself clear.
Thankyou
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

newsy.bober.duu.pl Do Samotności - Mickiewicz Adam free bingo Podczas Świąt - Lipska Ewa spadki