•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Graphics and Multimedia section within the Web Development category of DaniWeb, a massive community of 427,935 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,924 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Graphics and Multimedia advertiser: Programming Forums
Views: 462 | Replies: 1
![]() |
•
•
Join Date: Aug 2007
Posts: 179
Reputation:
Rep Power: 0
Solved Threads: 0
Hello
I have a quick question. I will have to learn syntax for action script. Before I research my objective. Can someone enlighten me with a yes or no (example code would be awesome).
Question: Can I create a Array of symbols and then manipulate them by making them apear and disapear from a lower layer. (Bring forward & move back)?
Or is there another way?
Thanks
Steve
I have a quick question. I will have to learn syntax for action script. Before I research my objective. Can someone enlighten me with a yes or no (example code would be awesome).
Question: Can I create a Array of symbols and then manipulate them by making them apear and disapear from a lower layer. (Bring forward & move back)?
Or is there another way?
Thanks
Steve
•
•
Join Date: Apr 2008
Posts: 14
Reputation:
Rep Power: 1
Solved Threads: 3
It's definitely possible to switch the stacking order of symbols. The manner in which you do it differs in ActionScript 2 and ActionScript 3, though.
IN AS2:
You will use the method "swapDepths" and "getNextHighestDepth()" in order to move a symbol to the top.
In AS2, it's important to keep an eye on the target. You'll notice in the first two examples, I use "this" to indicate the movie clip that flash should determine the "getNextHighestDepth" value for, but in the last one I use "this._parent". That's because in a mouse function like onRelease, "this" refers to the movie clip that called the function.
IN AS3:
It's similar to AS2, except now you're using setChildIndex instead of swapDepths and numChildren instead of getNextHighestDepth().
Again, note that you need to be careful in your targeting. For example, in the button click you need to use "e.target.parent" in order to indicate the parent of the clicking movie clip.
Have fun!
--eric
IN AS2:
You will use the method "swapDepths" and "getNextHighestDepth()" in order to move a symbol to the top.
// First, create an array:
var myArray:Array = new Array(mySymbol1, mySymbol2, mySymbol3);
// This code will move mySymbol1 to the very front
mySymbol1.swapDepths(this.getNextHighestDepth());
// This code will move the second item in the array to the very front
myArray[1].swapDepths(this.getNextHighestDepth());
// This code will move the third item in the array to the very front when the user clicks on mySymbol1
mySymbol1.onRelease = function() {
myArray[2].swapDepths(this._parent.getNextHighestDepth());
}In AS2, it's important to keep an eye on the target. You'll notice in the first two examples, I use "this" to indicate the movie clip that flash should determine the "getNextHighestDepth" value for, but in the last one I use "this._parent". That's because in a mouse function like onRelease, "this" refers to the movie clip that called the function.
IN AS3:
It's similar to AS2, except now you're using setChildIndex instead of swapDepths and numChildren instead of getNextHighestDepth().
// First, create an array:
var myArray:Array = new Array(mySymbol1, mySymbol2, mySymbol3);
// This code will move mySymbol1 to the very front
this.setChildIndex(mySymbol1, this.numChildren - 1);
// This code will move the second item in the array to the very front
this.setChildIndex(myArray[1], this.numChildren - 1);
// This code will move the third item in the array to the very front when the user clicks on mySymbol1
mySymbol1.addEventListener(MouseEvent.CLICK,swapDepths);
function swapDepths(e:Event):void {
this.setChildIndex(myArray[2], e.target.parent.numChildren - 1);
}Again, note that you need to be careful in your targeting. For example, in the button click you need to use "e.target.parent" in order to indicate the parent of the clicking movie clip.
Have fun!
--eric
Eric Oliver
www.thecosmonaut.com
www.thecosmonaut.com
![]() |
•
•
•
•
•
•
•
•
DaniWeb Graphics and Multimedia Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the Graphics and Multimedia Forum
- Previous Thread: uploading image folder
- Next Thread: Programming against design, who is the best?


Linear Mode