Need help understanding dynamic functions...

  • AlphaOne
  • Newbie
  • Newbie
  • User avatar
  • Posts: 8

Post 3+ Months Ago

I've created a simple movie that uses attachMovie to add the objects to the main stage. each objects needs to have an onClipEvent handler but I seem to figure out how its done? so far I have...

Code: [ Select ]
for (nCurr = 1; nCurr < 5; nCurr++)
{
  szName = "mcIcon" + i;
  
  this.attachMovie("mcTest", szName, i);

  mcTmp = eval(szName);

  /////////////////////////////////////////
  // need to add onClipEvent for every instance
  //
  /*
  mcTmp..???..onClipEvent = new function(mouseMove)
  {
     // do interesting stuff here
  }
}
  1. for (nCurr = 1; nCurr < 5; nCurr++)
  2. {
  3.   szName = "mcIcon" + i;
  4.   
  5.   this.attachMovie("mcTest", szName, i);
  6.   mcTmp = eval(szName);
  7.   /////////////////////////////////////////
  8.   // need to add onClipEvent for every instance
  9.   //
  10.   /*
  11.   mcTmp..???..onClipEvent = new function(mouseMove)
  12.   {
  13.      // do interesting stuff here
  14.   }
  15. }

i've tried allot of things, but it just boils down to, 'i dont know what im doing' so, if anyone could assist, i'ld really appreciate it.

thanks,
-AlphaOne
  • AlphaOne
  • Newbie
  • Newbie
  • User avatar
  • Posts: 8

Post 3+ Months Ago

ok, well im partially there, now i get a reaction to mousemove, but it still looks horribly wrong. first off here's the new source ...

Code: [ Select ]
for (i = nFirstPage; i <= nLastPage; i++)
{
    szName = "mcIcon" + i;
    this.attachMovie("img1", szName, i);
    mc = eval(szName);
    mc._x = i * 30;
    mc.nCurrPage.text = i;
    
    mc.onMouseMove = function ()
            {
            //trace("["+mc+"] x:"+_xmouse+", y:"+_ymouse);    
            this._xscale =
              Math.max(50, 100 - Math.sqrt(_xmouse * _xmouse));
            this._yscale =
              Math.max(50, 100 - Math.sqrt(_xmouse * _xmouse));
           
            updateAfterEvent();    
        }
}
  1. for (i = nFirstPage; i <= nLastPage; i++)
  2. {
  3.     szName = "mcIcon" + i;
  4.     this.attachMovie("img1", szName, i);
  5.     mc = eval(szName);
  6.     mc._x = i * 30;
  7.     mc.nCurrPage.text = i;
  8.     
  9.     mc.onMouseMove = function ()
  10.             {
  11.             //trace("["+mc+"] x:"+_xmouse+", y:"+_ymouse);    
  12.             this._xscale =
  13.               Math.max(50, 100 - Math.sqrt(_xmouse * _xmouse));
  14.             this._yscale =
  15.               Math.max(50, 100 - Math.sqrt(_xmouse * _xmouse));
  16.            
  17.             updateAfterEvent();    
  18.         }
  19. }


not much to that. what is supposed to happen, is a reaction like a linux menu, where the closer a mouse get to a button the larger it gets. currently, all the buttons are enlarging at the same time, based on the x value of 1 button.

any help appreciated,
thx,
AlphaOne
  • AlphaOne
  • Newbie
  • Newbie
  • User avatar
  • Posts: 8

Post 3+ Months Ago

well, i got it using a different approach, thx anyway
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6375
  • Loc: twitter.com/unflux

Post 3+ Months Ago

what did you do differently to get it to work? sorry no one got
to your questions, but I'm glad you figured it out on your own. :D

btw - please use code tags ;)

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 9 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.