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
ceyesuma -4 Posting Pro
Dani AI
Generated
Short answer: yes — an array of symbol instances can be used to control visibility and stacking. As pointed out, the exact API differs by ActionScript version, but there are several complementary patterns that make management simpler and safer over time.
For simple show/hide behavior, toggling the visible property (and animating alpha for fades) keeps objects in place without touching display ordering. To prevent interaction while hidden, set mouseEnabled/mouseChildren appropriately. When a symbol must be taken off-stage entirely, moving it between container clips (or removing and re-adding it to the parent) gives explicit layer control and keeps the display list tidy—using named layer containers (background, content, UI) reduces index juggling.
For predictable ordering at scale, store small metadata objects in the array (for example: instance reference plus an explicit z-index or priority), sort that array when priorities change, and then re-apply the order by iterating the sorted list and placing instances into the intended container. Always detach event listeners when permanently removing clips, and preserve original parent/index if an object must be restored later.
Performance and long-term considerations: avoid frequent reparenting or depth churn for hundreds of clips; enable cacheAsBitmap for static artwork; clean up listeners to prevent leaks; and handle null/undefined parents before calling display-list APIs. Note that Flash Player has been deprecated (end-of-life in 2020), so for new work consider modern runtimes or export paths (for legacy .fla work, keep AS2/AS3 targeting and tooling in mind). Thanks to for the version-specific pointers that started this discussion, and to for the clear question about arrays and symbols.
erico564 0 Newbie Poster
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.
// 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
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.