Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US :: FAQ
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 4, 2012 at 8:53:00 pm

Good, 'cause my AS2 skills are rusty :)

First thing you'll want to do is go into the Library and create a class for all movie clips that you want to load.

Here's a screenshot of what it should look like:
http://screencast.com/t/f1awsbWik

Next, you'll want to put the following code on your buttons:



import flash.events.MouseEvent;
import flash.display.MovieClip;

function clearContainer():void {
while(myContainerMC.numChildren > 0) {
myContainerMC.removeChildAt(0);
}
}

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



FORUMSTUTORIALSFEATURESVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

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

[Top]