0 Replies Latest reply on Aug 23, 2010 6:13 PM by Morham

    An issue with classes, and movieclips with buttons.

    Morham

      Hello I am attempting to delve into the world of coding and felt flash was a good place to start since I had flash 8, however I am running into a problem I just can't seem to work around.

       

      This is my project as it currently stands, you click and drag to move about, it randomly places/sizes the planets every time.

       

      The idea is to be able to click the planets and an interactive menu pop up, this menu in fact.  As you can see the buttons in the movieclip are supposed to light up and things, alas they do not.

       

      I am trying to do everything in classes and at the moment by calling movieclips from the Library, the Planet class is what holds the planets, selection ring and menu, it looks like this:

       

      class Planet {
           private var container_mc:MovieClip;
           private var p:MovieClip;
           private var select:MovieClip;
           private var pMenu:MovieClip;
           private static var randomX:Number;
           private static var randomY:Number;
           private static var randomScale:Number;
           
           public function Planet(target:MovieClip, depth:Number){
                container_mc = target.createEmptyMovieClip("Planet"+depth, depth);
                               
                        //Attach Planet, Selection and Menu MovieClips
                        p = container_mc.attachMovie("Planet", "p1", container_mc.getNextHighestDepth());
                        select = container_mc.attachMovie("Selection", "select", container_mc.getNextHighestDepth());
                              pMenu = container_mc.attachMovie("PMenu_mc", "pMenu", container_mc.getNextHighestDepth());
                     
                     //Make Select and Menu Invisible
                     select._visible = false;
                     pMenu._visible = false;
                     
                     //When you mouse over Select MovieClip becomes visible.
                     container_mc.onRollOver = function(){
                          select._visible = true;
                     }
                     //When you click Menu MovieClip becomes visible.
                     container_mc.onPress = function(){
                          pMenu._visible = true;
                     }
                     //When you move mouse away Select and Menu MoviClips become invisible.
                     container_mc.onRollOut = function(){
                          select._visible = false;
                          pMenu._visible = false;
                     }
                     
                     //define coordinates and size of Planet and Select MovieClips randomly.  
                     randomX = Math.floor(Math.random()*(1836-(0-1036)+1))+(0-1036);
                     randomY = Math.floor(Math.random()*(500-100+1))+100;
                     randomScale = Math.floor(Math.random()*(80-30+1))+30;
                     
                     //set scale and coordinates of Planet, Menu and Select MovieClips.
                     p._x = randomX;
                     p._y = randomY;
                     select._x = randomX;
                     select._y = randomY;
                     pMenu._x = randomX+70;
                     pMenu._y = randomY+30;
                     p._xscale = randomScale;
                     p._yscale = randomScale;
                     select._xscale = randomScale;
                     select._yscale = randomScale;
                               
           }
      }
      

       

       

      If someone would kinly help me realise and resolve the problem of my Buttons not working, it would be much appreciated.  If you need more info just ask, but try and keep it simple or explain stuff because I'm new to this!

       

      Thanks

       

      PS - I am also trying to figure out if it's possible to automatically place a number of planets based on some user input, so say if I have a text box pop up, I put 5 into that box and it places 5 planets on the screen (or creates 5 variables with the planet class)...I hope that makes sense, I'm not too sure how to go about wording it properly.