Copy link to clipboard
Copied
I would like to Add multible instances of one Movieclip, (Library Name = Bats | instance name = none), inside of another Movieclip (instance name = back.visuals) // (By HAND) NOT by addChild(mc_name); // Easy
If anyone could help me out with code to do the next steps:
Search the Movieclip, (instance name = back.visuals), that contains the Movieclips, (Library Name = Bats | instance name = none), manually added to the stage by hand.
Then for all instances of this movieclip (Library Name = Bats | instance name = none) add them to an Array.
Thank You,
Dyami
Assuming you are talking about runtime, if you export symbol for action script and give it a Class name you can always read whether child of an object is an instance of this symbol.
Say, if symbol name is Bats you can identify it in the loop as following:
var enemyList:Array = [];
for (var i:int = 0; i < back.visuals.numChildren; i++)
{
var child:DisplayObject = back.visuals.getChildAt(i);
if (child is Bats)
{
enemyList.push(child);
}
}
Copy link to clipboard
Copied
you want to search in the ide?
are you using flash pro cc?
Copy link to clipboard
Copied
I am using Flash Pro CC.
I want to search a MovieClip container I manually added to the stage/"Timeline" and gave an instance name of (back.visuals) for all instances of a different Movieclip (with no stage/"TimeLine" instance name) and add all instances of that Movieclip to an Array.
So I guess no I do not want to use the Library Search Function on the IDE.
Copy link to clipboard
Copied
either use jsfl or use an earlier version of flash pro.
Copy link to clipboard
Copied
I think we are having some missed communication. I do not wish to Change Flash's IDE or deveolp new features for flash. I was wondering if there was a way to do my question with AS3. something along the lines of :
var enemyList:Array = new Array;
for (var index:int = 0;index < back.visuals.numChildren;index++)
{
var wall:MovieClip = back.visuals.getChildAt(index) as MovieClip;
/* Check to see if wall is of a Specfic MovieClip */
/* if (Above is True){ enemyList.push(wall) };
Copy link to clipboard
Copied
Assuming you are talking about runtime, if you export symbol for action script and give it a Class name you can always read whether child of an object is an instance of this symbol.
Say, if symbol name is Bats you can identify it in the loop as following:
var enemyList:Array = [];
for (var i:int = 0; i < back.visuals.numChildren; i++)
{
var child:DisplayObject = back.visuals.getChildAt(i);
if (child is Bats)
{
enemyList.push(child);
}
}
Copy link to clipboard
Copied
in general the answer to your question is, no. you cannot determine symbol names (or library names) using actionscript. you can using jsfl during author-time and using cs6's search panel during author-time.
using actionscript (ie, during run-time) you are much more limited, but can check class name (as indicated by andrei1) or other object properties if you have some combination of those that select the objects of interest..
Copy link to clipboard
Copied
You're probably better off just watching the display list and checking as objects get added, rather than going back after the fact.
so:
protected var things:Vector.<YourType> = new Vector.<YourType>;
protected function init():void {
stage.addEventListener(Event.ADDED_TO_STAGE, addYourTypeOfThingToVector, true);
}
protected function addYourTypeOfThingToVector(e:Event):void {
var thing:YourType = e.target as YourType;
if (thing) {
things[things.length] = thing;
thing.addEventListener(Event.REMOVED_FROM_STAGE, removeYourTypeOfThing);
}
}
protected function removeYourTypeOfThing(e:Event):void {
var thing:YourType = e.target as YourType;
if (thing) {
thing.removeEventListener(Event.REMOVED_FROM_STAGE, removeYourTypeOfThing);
var index:int = things.indexOf(thing);
if (index>0) {
things.splice(index, 1);
}
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now