best way to loadmovie by variable?

  • rockafromhell
  • Student
  • Student
  • rockafromhell
  • Posts: 70
  • Loc: Erie,Pa

Post 3+ Months Ago

im wondering what the best way to load content would be or how i would im using actionscript now too pick up what menu number i clicked and so on i want to load a movie by clicking the button and have it pick up a variable of the menu number and load content how would i do this heres what i got for actionscript so far

Code: [ Select ]
if (oMenu != cMenu) {
    if (cMenu>0) {
        if (oMenu>0) {
            contentReady = 1;
    if (oMenu>0) {
    if (cMenu == 0) {
        if (oMenu>0) {
    oMenu = cMenu;
  1. if (oMenu != cMenu) {
  2.     if (cMenu>0) {
  3.         _root["Menu"+cMenu].gotoAndStop("Hit");
  4.         if (oMenu>0) {
  5.       ;
  6.         }else{
  7.             contentReady = 1;
  8.             Movies.gotoAndPlay("In");
  9.         }
  10.     }
  11.     if (oMenu>0) {
  12.         _root["Menu"+oMenu].gotoAndPlay("Out");
  13.     }
  14.     if (cMenu == 0) {
  15.         if (oMenu>0) {
  16.         }
  17.     }
  18.     oMenu = cMenu;
  19. }

Thx in advance

  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1825
  • Loc: In the Great White North

Post 3+ Months Ago

What does the code you posted do right now? I assume its asking if the clip is loaded all the way. Passing a variable that matches a menu number is pretty easy but you'll have to figure out how to adapt it to the code you already have.

Imagine I have 6 menu items all named btn0, btn1, btn2 etc and I want to load mc0, mc1, mc2, etc. I would use a loop to assign button code for the actions and pass the correct number

Code: [ Select ]

var targetBtn = _root["btn"+i];
targetBtn.IDNumber = i;

targetBtn.onRelease = function(){



function loadContent(ID){
var stuffToLoad = "mc"+ID;
loadMovie(stuffToLoad, mcToLoadInto );
  1. for(i=0;i<5;i++){
  2. var targetBtn = _root["btn"+i];
  3. targetBtn.IDNumber = i;
  4. targetBtn.onRelease = function(){
  5. _root.loadContent(this.IDNumber);
  6. }
  7. }
  8. function loadContent(ID){
  9. var stuffToLoad = "mc"+ID;
  10. loadMovie(stuffToLoad, mcToLoadInto );
  11. }

Ok whats going on here

First line is a loop this happens a set number of times. In our case as long as the variable i is less than 5 and the i++ adds to the variable each loop.

Next we specify which button on the stage to interact with and we set a variable inside the button "IDNumber" to be the same as the current "i"

Then we create an onrelease handler for the button and tell it to run the function called "loadContent" and to pass the ID into that function.

loadContent adds the "mc"+ID together and you end up with the name of the movieclip you want to load.
  • rockafromhell
  • Student
  • Student
  • rockafromhell
  • Posts: 70
  • Loc: Erie,Pa

Post 3+ Months Ago

yeh code i have right now is on click of a button from Menu1 menu2 so on it takes the button to the hit state and loads a transition this code will help thx ill mess with it a little bit and tr to get it working thx. :)


wait how would i if i wanna load it on a movie frame because after the transition is done i want it to load

second though im kinda could you possibly look at the file real quick and write it so i could check it out its real simple file

Link: its website code finally.fla

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 6 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.