6 Replies Latest reply on May 13, 2006 11:31 PM by sampurtill

    "Floating" a movieclip

    sampurtill
      Real quick,

      Does anyone have any ideas as to how to make a movieclip appear to float in the air? I want it to stay within... say 40 pixels of its original x and y coordinates. I'm just not that good at making visual effects, I'm more into data integration. Thanks!

      Sam
        • 1. Re: "Floating" a movieclip
          sampurtill Level 1
          Hey guys,

          I am totally not trying to be rude, but it seems since Macromedia's site was switched to Adobe, no one answers any questions anymore. The last 5 questions I've posted I haven't even gotten a reply. Is this because my questions are too hard? I don't think so. I think the main reason is because the new navigation has thrown a lot of people off. At least Adobe could have sent us all a newsletter telling us how things have changed... I miss the MM forums

          Sam
          • 2. Re: "Floating" a movieclip
            kglad Adobe Community Professional & MVP
            i read your post after your first (and second) message. i just didn't understand what you were asking and thought someone else might understand.

            can you post a link to a website that displays the effect you want?
            • 3. Re: "Floating" a movieclip
              sampurtill Level 1
              I haven't found any websites that do it, I know I've seen them a million times before though. Pretty much it's a movieclip that just floats around and stays within the same region the whole time. But it has the "floating" look... Thanks for answering kglad, out of everyone here you're by far the most helpful guy.
              • 4. Re: "Floating" a movieclip
                tonyhigham Level 1
                hey, i just signed up and posted my own question, so i thought that in the spirit of reciprocity, i'd try and answer a few....
                place this code on the first frame of the movie that you want to float:

                var xMin:Number = this._x - 10
                var xMax:Number = this._x + 10
                var yMin:Number = this._y - 10
                var yMax:Number = this._y + 10
                var tSec:Number = 1 //number of seconds for the tween to take, and how often to start a new tween
                var me:MovieClip = this

                function newTween(){
                //adjust the easing class as needed
                //see the different easing classes at: http://www.actionscript.org/tutorials/advanced/Tween-Easing_Classes_Documented/index.shtml
                var xNew:Number = (Math.random()*(xMax-xMin)) + xMin
                var yNew:Number = (Math.random()*(yMax-yMin)) + yMin
                xTween = new mx.transitions.Tween(me, "_x", mx.transitions.easing.Regular.easeInOut, me._x, xNew, tSec, true)
                yTween = new mx.transitions.Tween(me, "_y", mx.transitions.easing.Regular.easeInOut, me._y, yNew, tSec, true)
                }

                var IntID:Number = setInterval(newTween,tSec*1000) //use IntID to clear the interval later if needed

                hope that helped
                • 5. Re: "Floating" a movieclip
                  sampurtill Level 1
                  Thanks Tony, good stuff man.

                  I'll test to see if it works and get back to you, it looks clean though.

                  Sam
                  • 6. Re: "Floating" a movieclip
                    sampurtill Level 1
                    Great, it works perfect.

                    Here's the final function if anyone wants it

                    function floatMc(float_mc:MovieClip, range_num:Number, frames_num:Number):Void {
                    var xMin:Number = float_mc._x-range_num;
                    var xMax:Number = float_mc._x+range_num;
                    var yMin:Number = float_mc._y-range_num;
                    var yMax:Number = float_mc._y+range_num;
                    var frames:Number = frames_num;
                    //number of seconds for the tween to take, and how often to start a new tween
                    var me:MovieClip = float_mc;
                    function newTween() {
                    //adjust the easing class as needed
                    var xNew:Number = (Math.random()*(xMax-xMin))+xMin;
                    var yNew:Number = (Math.random()*(yMax-yMin))+yMin;
                    xTween = new mx.transitions.Tween(me, "_x", mx.transitions.easing.Regular.easeInOut, me._x, xNew, frames, false);
                    yTween = new mx.transitions.Tween(me, "_y", mx.transitions.easing.Regular.easeInOut, me._y, yNew, frames, false);
                    }
                    var IntID:Number = setInterval(newTween, (frames*(1000/31)));
                    }
                    floatMc(hotAir_mc, 20, 62);