2 Replies Latest reply on Dec 14, 2006 6:24 AM by injpix

    Movie Clips vs the Stage help me out plz

    SSJ4Puar
      Before i start i currently am taking a class on flash and i dont think we have gone terribly in depth.

      I have 2 sets of Code one in a Movie Clip and another on the Stage.

      the issue i have is neither one can see variables from the other. is there some special syntax or notation i need to pass the variables

      I cant see the Current Unit in the Button
        • 1. Re: Movie Clips vs the Stage help me out plz
          Metro Media Level 1
          first of all...you need to be ending your command lines with a ;
          like this:


          //Code on stage
          MouseCount = 0;
          CurrentUnit = 4;
          currentguy.gotoAndStop(CurrentUnit);
          _root.onEnterFrame = function()
          {
          PrevButton.onRelease = function ()
          {
          trace(CurrentUnit);
          CurrentUnit--;

          if(CurrentUnit == 2)
          CurrentUnit = 14;


          currentguy.gotoAndStop(CurrentUnit)
          }



          also all of your if statements need brackets to hold the commands.

          If you have code applied to a button and want to access a variable you set on the main timeline... put _root. in front of it:
          trace(_root.CurrentUnit);

          you need to go through all of this code..there are syntax errors everywhere. Mostly just brackets and semi-colons, but you also have so path problems...fix those parts and see what happens then post again
          • 2. Re: Movie Clips vs the Stage help me out plz
            injpix Level 3
            Syntactically your code is just fine. I didn’t receive any errors when I checked it. However I would rearrange some things in it. The 2 eventhandlers in the onEnterFrame function, I would pull these out and put them outside of the onEnterFrame function but on the same frame.

            “the issue i have is neither one can see variables from the other. is there some special syntax or notation i need to pass the variables”

            Inside that mc, the code that you have below “//Code in Button”, it is typically recommended that you don’t reference other movieclips by using ‘_levelX’. Use a relative path, such as ‘this._parent” or “this._parent._parent” depending on how many movieclips are nested into it. Also note, when you reference a movieclip from inside an eventHandler (onPress, onRelease, onEnterFrame, etc.) you are already within an object. So to reference something on the same tier you should use ‘this._parent’. Once you find the correct tier by using the code I mentioned in the last sentence, you then need to attach the instance name of the movieclip you are trying to access (that is if you are trying to access a movieclip). For an example, ‘this._parent.currentguy’.
            I hope this helps, I understand it may be hard to grasp however give it a shot and post back.

            You may be interested in this link that is from the livedocs;
            http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context= LiveDocs_Parts&file=00001220.html