-
Actionscript to move symbol to front?
Is there a line of actionscript which can be used to make a symbol arrange to the front (of its current layer, at least)?
So for example:
symbol1.onPress = function () {
startDrag (this, false);
//code here to make symbol1 appear on top / at the front of this layer
}
Thanks in advance
-
Flashmatics
As far as flash is concerned once the movie is published , you can imagine everything as being on ONE single layer, with things at varying depths(according to the layer they where on at author time or the depth they have been placed at dynamically)
if you want to change the depth of a movieclip you can use for e.g
Code:
symbol1.swapDepths(_root.getNextHighestDepth());
this will put it above everything else... if you want to swap the depths of symbol1 with symbol2 you can use
Code:
symbol1.swapDepths(symbol2);
you cannot say put this movieclip at the top of the current layer (although you could do calculations based upon knowing the other objects on that layer, determining their depths and swapping the depths accordingly)
-
Thanks, I think the top code is best for me.
In my example i'm using a startDrag code, so my symbol will now be at the top on dragging. For my onRelease code (stopDrag) is there a command to say 'go back to the depth you came from'... I wouldnt know what this depth would actually be however, just no longer the top.
-
Flashmatics
Code:
var originalDepth:Number;
symbol1.onPress = function():Void {
originalDepth = this.getDepth();
this.swapDepths(_root.getNextHighestDepth());
this.startDrag();
};
symbol1.onRelease = function():Void {
this.swapDepths(originalDepth);
this.stopDrag();
};
-
great! thankyou very much.
in reference to this line of code:
symbol1.swapDepths(symbol2);
i'd actually like symbol1 to swap depth with symbol 2 (or at least go one depth higher) but symbol 2 not to inherit the depth of symbol 1, but stay the same.. is this possible?
-
Flashmatics
well two movieclips cannot occupy the same depth at the same time..so you would have to make symbol1 go at least one depth higher than symbol2 ... you could do that like
Code:
symbol1.swapDepths(symbol2.getDepth()+1);
-
thankyou, you are very kind.
-
Flashmatics
no problem everyone helps everyone here
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|