Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
ADOBE FLASH:HomeFlash ForumFlash TutorialsFlash Video TutorialsWeb Streaming ForumAdobe FlashPodcast

Re: loading mc into empty mc

COW Forums : Adobe Flash

FAQ   •   VIEW ALL   •   ADD A NEW POST   •   PRINT
Share on Facebook
Respond to this post   •   Return to posts index   •   Read entire thread


Pieter HelsenRe: loading mc into empty mc
by on May 9, 2012 at 10:41:36 am

Woops, looks like I missed this one...
Yes, you should definitely have an instance of the empty MC on the stage.

// this means that you are creating an instance of a class
// or movieclip in the library...
var myMC:MovieClip = new MyTestMC();

// this means that there is already an instance of the container MC
// on the stage and the instance name is 'myContainerMC'.
myContainerMC.addChild(myMC);


If you DON'T have an instance on the stage, you could do something similar as we did with the MyTestMC:


var myContainerMC:MovieClip = new MyContainerMC();
addChild(myContainerMC);

// myButton would have to be an instance on the stage...
myButton.addEventListener(MouseEvent.CLICK, myButtonClick, false, 0, true);

function myButtonClick(e:MouseEvent):void {

// if the container is not empty (i.e. if you have previously
// loaded another MC), the container's contents will be cleared.
clearContainer();

// create a new instance of your movieclip
// and add it to the container
var myMC:MovieClip = new MyTestMC();
myContainerMC.addChild(myMC);

}



Kind regards,
Pieter

General notice: from now on, I would like to ask everyone to put [AS2] or [AS3] (corresponding to the version of actionscript you are using on your project) in front of their post titles when the question is actionscript related! Please help us help you faster. Thank you.


Posts IndexRead Thread
Reply   Like  
Share on Facebook


Current Message Thread:




LOGIN TO REPLY



FORUMSTUTORIALSMAGAZINESTOCKYARDVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2013 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]