6 Replies Latest reply on Aug 28, 2006 3:34 AM by lunchBoxCoder

    ? on boundries VS attachEmptyMovie

    lunchBoxCoder
      I've wrote these boundries:

      var xCenter = Stage.width / 2;
      var yCenter = Stage.height / 2;
      var xRight = (Stage.width -(xCenter/2));
      var xLeft = (xRight-xCenter);
      var yTop = (yCenter-(yCenter/2));
      var yBot = (Stage.height - (yCenter/2));
      trace(xRight);
      trace(xLeft);
      trace(yTop);
      trace(yBot);

      Right now I have tweened attachMovie clips on the stage. I would like them to be confined to these bounderies.. that onResize to stage.

      Is there a way of doing this That doesn't intale nesting movies inside emptyMovie clip????
        • 1. Re: ? on boundries VS attachEmptyMovie
          abeall Level 3
          Depends on you're code, and what you mean by "confine". I don't see how nesting them in another MovieClip would change the situation at all.
          • 2. Re: ? on boundries VS attachEmptyMovie
            lunchBoxCoder Level 1
            abeall wrote:
            "I don't see how nesting them in another MovieClip would change the situation at all."

            we're right, tried that, didn't work at all..

            the objects are randomely tweening when you roll over, click them etc.
            so I would like to confine them to a certain section of the stage so there not floating all over the stage..
            My hope was to use this code that gives four coordinates and use thaem to confine the objects within them..
            I'm looking into using hit test next..
            Any suggestion will be Greatly Appreciated!!

            Cheers
            • 3. Re: ? on boundries VS attachEmptyMovie
              abeall Level 3
              By default, an MC is inanimate. It doesn't move. You are moving them, so the key is to not move them outside of the confines you choose. Therefor, you need to edit you're "random tween" code to not send them outside a certain confines. You should post your tweening code here if you want further help.
              • 4. Re: ? on boundries VS attachEmptyMovie
                lunchBoxCoder Level 1
                Thankyou for both of your replies.
                here is one of the objects that it would like to confine..
                starting to play around with Stage.width & height in the tween code. It's getting closer..
                please send me criticism and suggestions you might have.
                cheers

                ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////
                var at:MovieClip;
                at = this.attachMovie("ant_l","ant",this.getNextHighestDepth());
                at._x = Math.random()*Stage.width;
                at._y = Math.random()*Stage.height;
                at.dx = Math.round(Math.random()*Stage.width);
                at.dy = Math.round(Math.random()*Stage.height);
                var atw:Tween = new Tween(at,"_x",Strong.easeOut,at._x,at.dx,1,true);
                var atw:Tween = new Tween(at,"_y",Strong.easeOut,600,at.dy + 9,3,true);
                TransitionManager.start(at, {type:Rotate, direction:Transition.IN, duration:4, easing:Strong.easeInOut, ccw:false, degrees:30});

                ant.onRollOver = function() {
                this.useHandCursor = false;
                var t2:MovieClip;
                at2 = attachMovie("ant_tx_l","ant_tx",getNextHighestDepth());
                ant.filters = [ds];
                at2._x = Math.random()*Stage.width;
                at2._y = Math.random()*Stage.height + Stage.height;
                var atw2:Tween = new Tween(at2,"_x",Strong.easeOut,at2._x,at._x,2,true);
                var atw2:Tween = new Tween(at2,"_y",Strong.easeOut,at2._y,at._y,2,true);

                };

                ant.onRollOut = function() {
                var atw3:Tween = new Tween(at,"_x",Strong.easeOut,at._x,_xmouse,1,true);
                var atw3:Tween = new Tween(at,"_y",Strong.easeOut,at._y,_ymouse,1,true);
                TransitionManager.start(at, {type:Rotate, direction:Transition.IN, duration:2, easing:Strong.easeOut, ccw:true, degrees:60});
                var mTemp:MovieClip = this.getInstanceAtDepth(0);
                ant_tx.swapDepths(0);
                ant.filters = null;
                ant_tx.removeMovieClip();
                if(mTemp != undefined) {
                mTemp.swapDepths(0);
                };
                };
                • 5. Re: ? on boundries VS attachEmptyMovie
                  abeall Level 3
                  Did you write that code? I'd probably do something like this:

                  Create vars representing the limits:
                  minY = 25;
                  maxY = 500;
                  minX = 25;
                  maxX = 500;

                  And then hunt all code that involves starting a Tween to take that into consideration. For instance, this:
                  at._x = Math.random()*Stage.width;

                  Might become:
                  at._x = minX+(Math.random()*(maxX-minX));
                  • 6. Re: ? on boundries VS attachEmptyMovie
                    lunchBoxCoder Level 1
                    thanks again for your reply abeall
                    I came up w/ a concept ,started w/ code that i read in a AS book,onLine turtorials, Docs, and Forums pieced it all together w/ alot of trail and error, Emphasizing Error. So if you call that coding, Yes I wrote that, I've only been at AS for 2 months

                    at._x = minX+(Math.random()*(maxX-minX));
                    Perfect..
                    the passed day i was putting everything after (Math.random()*, writing minX before makes all the differance.

                    I really love your CurrentExperimentalProject -- Nice and smooth --- I'll shure need some more time till I get there..
                    cheers