Adding onRollOver through a for statement

  • diciccod
  • Born
  • Born
  • diciccod
  • Posts: 1

Post 3+ Months Ago

I think my question is very similar to LordofLimbos but before this one except he is using an array and i am not. Well here goes:

The function populatealbum is called somewhere else in the movie.
It holds a code to create several movieclips filled with pictures loaded from a folder. That all works fine.
What i want to do is have it also make the pictures i load in be interactive with an onRollOver or onPress.
So i then figure why not just assign an onRollOver function to each ["pic"+i] movieclip which holds each image. But it isnt working.. it isnt even recognizing it as something that can be rolled over when i run the movie. Help would be appreciated greatly.

Code: [ Select ]
function populatealbum() {
    
    for(i=1; i<=_root.picnumber; i++)
    {
        menubar.menuone.createEmptyMovieClip("pic"+i, i);
        menubar.menuone["pic"+i]._xscale = 100;
        menubar.menuone["pic"+i]._yscale = 100;
        if (i == 1)
        {
            menubar.menuone["pic"+i]._x = 30;
            menubar.menuone["pic"+i]._y = 0;
        }
            else
            {
                menubar.menuone["pic"+i]._x = menubar.menuone["pic"+(i-1)]._x + 120;
            }
        loadMovie(_root.selectedphoto+"thumbs/"+i+".jpg", menubar.menuone["pic"+i]);
        _root.menuwidth += 120;
        
        // THE PROBLEM IS IN HERE
        menubar.menuone["pic"+i].onRollOver = function()
        {
            // JUST USING A Y MOVEMENT TO TEST
            this._y += 20;
            
        }
        
        
    }// END OF FOR STATEMENT    

_root.prepicnumber = _root.picnumber;
}// END OF FUNCTION
  1. function populatealbum() {
  2.     
  3.     for(i=1; i<=_root.picnumber; i++)
  4.     {
  5.         menubar.menuone.createEmptyMovieClip("pic"+i, i);
  6.         menubar.menuone["pic"+i]._xscale = 100;
  7.         menubar.menuone["pic"+i]._yscale = 100;
  8.         if (i == 1)
  9.         {
  10.             menubar.menuone["pic"+i]._x = 30;
  11.             menubar.menuone["pic"+i]._y = 0;
  12.         }
  13.             else
  14.             {
  15.                 menubar.menuone["pic"+i]._x = menubar.menuone["pic"+(i-1)]._x + 120;
  16.             }
  17.         loadMovie(_root.selectedphoto+"thumbs/"+i+".jpg", menubar.menuone["pic"+i]);
  18.         _root.menuwidth += 120;
  19.         
  20.         // THE PROBLEM IS IN HERE
  21.         menubar.menuone["pic"+i].onRollOver = function()
  22.         {
  23.             // JUST USING A Y MOVEMENT TO TEST
  24.             this._y += 20;
  25.             
  26.         }
  27.         
  28.         
  29.     }// END OF FOR STATEMENT    
  30. _root.prepicnumber = _root.picnumber;
  31. }// END OF FUNCTION
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

It's working, but you can't tell because your loadMovie() is overwriting the actions with the image it is loading. You have to wait until the image is fully loaded to the clip before you can assign any dynamic event handlers to it.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 6 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
 
 

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