Skip to main content
saratogacoach
Inspiring
August 8, 2013
Answered

Exporting/Using SWC in pure AS3 project

  • August 8, 2013
  • 1 reply
  • 1994 views

Hi,

I have multiple movieclips, each with 5 image-movieclips inside, which allows me to manipulate which image-movieclip is displayed in an animation. So, if image-mc1.alpha = 0, then image-mc2, next in the 5 layers, which has a default alpha of 1 is displayed. 5 image-mc's, so can use alpha to show whichever is needed.

There are 37 of these image-mc's in the project.

Instead of a FLA based project, I would like to try a pure-AS3 version, maybe compile using Flex/AIR SDK. One way to re-use these complex mc's would be a create a SWC for each (not sure one SWC with all 37 can be created in CS6, or how each would be called in the script?).

When I try this, using one multi-mc/multi-layer mc exported as a SWC and try to reference its internal mc's re: alpha setting, doesn't work.

image1.imagea1.alpha = 0;//image1 is the instantiated version of the SWC's mc done as addChild(image1)

In the FLA version, this script would cause the second mc, imageb1, which has a default alpha of 1, to display. But this is not happening in the AS3 version. Instead, image1.imagea1 still displays, no alpha effect.

Any way to get this to work?

This topic has been closed for replies.
Correct answer kglad

you can just remove the child movieclips that you don't want to be seen:

displayF("imagea1");

function displayF(mcS:String):void{

for(var i:int=0;i<image1.numChildren;i++){

if(image1.getChildAt(i).name!=mcS){

image1.removeChild(image1.getChildAt(i));

}

}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
August 8, 2013

you can just remove the child movieclips that you don't want to be seen:

displayF("imagea1");

function displayF(mcS:String):void{

for(var i:int=0;i<image1.numChildren;i++){

if(image1.getChildAt(i).name!=mcS){

image1.removeChild(image1.getChildAt(i));

}

}

saratogacoach
Inspiring
August 8, 2013

Thank you for this helpful suggestion.

The other issue is whether all of the 37 mc's can be exported in one SWC, instead of 37 separate SWC's?

If yes, how (for an individual mc, can right-click it in the library, not even on stage, to export as SWC? And once added to the Flex/AIR IDE, how to reference one or another in the AS3, since there would only be one class name for all?

kglad
Community Expert
Community Expert
August 8, 2013

they can all be exported in one swc by making them all children of one parent movieclip and exporting the parent as a swc.  they would each need an instance name and you could use those to display the movieclip you wanted.

for example, if your movieclip parent (exported as swc) has class P:

var p:P=new P();

addChild(p);

displayF("imagea1");