A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [F8] As mouse gets closer MC1._alpha++

  1. #1

    [F8] As mouse gets closer MC1._alpha++

    Hi,

    I wanted to do this with multiple movie clips, but its reacting opposite to what i want at this time. The alpha is getting near to 0 as mouse gets closer. But it should be getting closer to 100. Also how do I go about doing this with multiple MC?

    PHP Code:
    function findDist(mc1:MovieClip):Number {
        var 
    dx:Number mc2._x-_xmouse;
        var 
    dy:Number mc2._y-_ymouse;
        return (
    Math.round((dx*dx+dy*dy)/1000));

    }

    this.onEnterFrame = function() {
        
    findDist;
        
    trace(findDist(mc1));
        
    mc2._alpha = (findDist(mc1));

    }; 
    Appreciate much!

    Sunny
    Attached Files Attached Files

  2. #2
    Member
    Join Date
    Apr 2006
    Posts
    50
    Have fun with it... LMAO, I'm sooo lazy. I'm still workin on reversed alpha effect, I didn't notice that in your post =/.

    Edit::::::::::::::
    Alright....
    Code:
    function findDist(clip:MovieClip):Number {
    	var xdist:Number = _xmouse - clip._x;
    	var ydist:Number = _ymouse - clip._y;
    	var distancefromthis:Number  = Math.round(Math.sqrt((xdist*xdist)  + (ydist*ydist)));
    	return (100 - distancefromthis) + 20;
    }
    
    for(i=1;i<=2;i++){
    	trace("mc" + i);
    eval("mc" + i).onEnterFrame = function() {
    	trace(findDist(this));
    	this._alpha = findDist(this);
    };
    }
    I used: http://www.kirupa.com/developer/acti..._distance2.htm
    because I was baffled as to why it was doing what it did. =/
    Attached Files Attached Files
    Last edited by LifeToTake; 05-17-2008 at 06:38 AM.

  3. #3
    Thanks for that, you solved one part of the problem though.

    Anyone else wanna take a shot at this?

  4. #4
    Member
    Join Date
    Apr 2006
    Posts
    50
    ummm, dude, that fixes both of your problems?

    1: The alpha is getting near to 0 as mouse gets closer. But it should be getting closer to 100.

    2: Also how do I go about doing this with multiple MC?

    Look at the code in my post.... and the link... I edited my post because I noticed the file that I uploaded only fixed 1 problem.....

  5. #5
    Ahh, thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center