Skip navigation
goodsnow82
Currently Being Moderated

loading mc into empty mc with button

May 4, 2012 11:02 AM

I did this many years ago and I tried searching for this but did not find what I was looking for. I basically have a group of buttons and I want the buttons to load movie clips into an empty mc and then have the movie clip close again when the user clicks somewhere else. Do I actually have to save the movie clips as swf files first and then load them in to the empty mc?

 

Thanks!

 
Replies
  • Currently Being Moderated
    May 4, 2012 11:56 AM   in reply to goodsnow82

    You can save them as swfs if you like, or you can have them as movieclips in your library and add them from there.  To add them from the library you need to assign a class name for each one and then you can create a new instance using the class name.  To assign a class name, right click the mc in the library and select Linkage.  In the panel that appears select the option to export for actionscript and then assign a clas name for the object in the field labeled as such.

     

    Then to add it to your empty movieclip you would use... (assume you gave it a class name of "NewMC", and your empty movieclip is named "emptyMC")...

     

    var newmc:NewMC = new NewMC();

    emptyMC.addChild(newmc);

     

     

    "newmc" is just an arbirtrary name assigned to the instance being created

     
    |
    Mark as:
  • Currently Being Moderated
    May 4, 2012 2:17 PM   in reply to goodsnow82

    never add code to your objects. keep all code on an actions layer.

     
    |
    Mark as:
  • Currently Being Moderated
    May 4, 2012 2:44 PM   in reply to goodsnow82

    You probably haven't created your empty_mc movieclip, or at least you haven't named it that.(instance names are assigned in the properties panel.)

     

     

    Until you get the empty_mc figured out you can create it dynamically using...

     

    var empty_mc:MovieClip = new MovieClip(); // creates an empty movieclip

     

    var newmc:bio_mc = new bio_mc();  // creates the mc you want to put in it

     

    empty_mc.addChild(bio_mc);  // puts the mc in the empty one

     

    addChild(empty_mc);  // puts the empty mc on the display list

     
    |
    Mark as:
  • Currently Being Moderated
    May 4, 2012 2:53 PM   in reply to goodsnow82

    What does frame 1, line 5 look like?

     
    |
    Mark as:
  • Currently Being Moderated
    May 4, 2012 4:46 PM   in reply to goodsnow82

    I missed that error...

     

    should be:   empty_mc.addChild(newmc);

     

    bio_mc is the class name.  Class names as a standard start with capital letters (as in Bio_mc) to help avoid confusing them with variables and instance names.

     
    |
    Mark as:
  • Currently Being Moderated
    May 7, 2012 8:30 AM   in reply to goodsnow82

    If you expect a button to process those commands, then you need to incorporate those commands into the button's event handler function.

     

    It sounds like you have the registration mark centered if it is halfway off where you think it should be.  You can always adjust the objects x and y properties to place it wherever you want it to be.

     
    |
    Mark as:
  • Currently Being Moderated
    May 7, 2012 8:34 AM   in reply to goodsnow82

    You could copy and paste them, or you could type them.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points