5 Replies Latest reply: Nov 14, 2012 8:15 AM by Ned Murphy RSS

    Do MC’s from a graphic need placing on stage ?

    Envirographics Community Member


      Flash CS5

      I have a graphic on stage with a series of spots and names representing settlements. I have double clicked my way into it and selected a spot and name, made it a MovieClip and given it an instance name. Repeated this for each and every spot/name .


      Are those MC’s now on stage hiding behind the graphic or do they need placing there ?


      If I return to stage and select a spot/name I get still the graphic selected.


      I wish to code this such that a settlement spot only appears when coding makes that MC visible.


      I don’t wish to see that graphic of them all displayed now.


      Do I need to drag drop each and every MC from Lib onto stage and position over the same settlement in graphic, then turn graphic layer into a guide layer to stop it appearing when movie runs ?...or is it sufficient to delete the graphic after making these MC’s from it and only the MC’s  will appear when told to do so by coding ?


      If not and I do need to drag drop each MC from Lib to stage, is manual placement over the graphic the best way ?

      It would seem so as if one d/clicks the graphic and selects the MC in the top left corner, properties shows e.g. x 0 y 0

      If I drag drop that MC from Lib to stage and make it x 0 y0 in properties, it sits in a different location, top left of stage, so obviously the first x0 y0 is its position within the graphic and not within the stage.


      To avoid this double labour, is there a way of making each settlement spot and name into a graphic and have it use that location on stage without needing to be drag dropped from Lib to that location ?



        • 1. Re: Do MC’s from a graphic need placing on stage ?
          Ned Murphy MVP

          If you created each spot as a movieclip within the graphic that is on the stage, then the movieclips are on the stage within the graphic.  You do not need to drag anything in at this stage.


          If you do not want to see them you need to target them with code and either set their visible property to false or their alpha properrty to zero.  If that is truly a graphic symbol that they are sitting in, then you need to change it to being a movieclip symbol so that you can assign it an instance name just like you did for the spots and then you can use that name to target the inner movieclips to make them invisible... as in...


          graphicName.spotName.visible = false;  (this assumes AS3 is being used)

          • 2. Re: Do MC’s from a graphic need placing on stage ?
            Envirographics Community Member


            putting some names to things....


            if Graphic comes from Lib and it was called AllSettlementsGraphic, as we know the graphic cant be named in properties so for control, it must be an MC with instance name.

            First settlement created as MC from it is called DrewsBottom

            Second settlement created is called UpperLowing


            I dont wish to see that graphic showing now.


            you say to then convert the graphic to an MC., call it in instance AllSettlementsGraphic

            code is:-

            AllSettlementsGraphic.DrewsBottom.visible = false

            AllSettlementsGraphic.UpperLowing.visible = false



            If I had 30 settlements from it, there would be thirty lines of this code.


            If I delete the graphic off stage, do I also kill the MC's  ?


            To have just

            DrewsBottom.visible = false

            UpperLowing.visible = false

            and so on, would that mean placing MC's from lib onto stage ?


            If I wish to minimise the file size of the created movie, would deleting the graphic and doing the drag/drops do so ?


            I in fact stand to have maybe a few hundred MC's, is there an easier command to hide them but not the county border and roads etc without having a few hundred lines of code all of the style 

            DrewsBottom.visible = false


            We did a previous map and many lines of code and 90% of it was visible = false



            • 3. Re: Do MC’s from a graphic need placing on stage ?
              Ned Murphy MVP

              If I delete the graphic off stage, do I also kill the MC's  ?


              Anything that is in your library can only be deleted (killed) if you delete them from the library.  Removing them from the stage does not delete them from the library... you should be able to see this if you try.


              There are ways to code using loops to minimize the amount of code you need to use.  Here are a few ways to consider


              By naming things with specific names like "DrewsBottom" rather than something generic like "mc1", "mc2", etc..., you are creating a scenario where more coding is needed. If you go the generic route you can create loops to go thru numerous objects with just a few lines.


              You could place all of the specific object instance names into an array and still use a loop to make them all visible/invisible, but that still requires you to have the specific names written into the array.


              If the objects within the settlements movieclip were the only children of that movieclip, then you could loop thru them all using the numChildren property and getChildAt() method.

              • 4. Re: Do MC’s from a graphic need placing on stage ?
                Envirographics Community Member



                Ref the killing off, I was wondering if by deleting the graphic off stage, would the movie clips show up when told to do so by the code ? Whilst they exist in Lib I would think they have been removed off stage with the graphic deletion.


                AllSettlementsGraphic.DrewsBottom.visible = false


                would the visible true option of this make just the child (DrewsBottom) to be visible ?

                I wouldnt want the AllSettlementsGraphic MC also to show anymore.


                We have a datagrid  that has a unique settlement name per cell so I cant see how flash would know which MC to make visible on mouse hover on grid with names like mc1 mc2 though.


                I will look into what you say ref loops etc.



                • 5. Re: Do MC’s from a graphic need placing on stage ?
                  Ned Murphy MVP

                  If you delete the object from the stage, you cannot do anything with it since it does not exist.  You could add the object dynamically using code, but I don't think that is what you are looking for since you seem to want to use rollovers to make things happen... something has to exist for the rollover to be recognized.


                  If the event listeners are on mc1, mc2, etc, then you can use the event.currentTarget to target the object that was rolled over.