A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Changing alpha on multiple movie clips?

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    17

    Question Changing alpha on multiple movie clips?

    Hi all.

    So, I know how to change the alpha of one movie clip at a time on rollover, rollout, and release. But I'm a bit stuck trying to figure out how I would change the alpha of multiple movie clips, when one is clicked.

    It's for a simple photo gallery and I want all the thumbnails to darken once one has been clicked & the image is loading. I can't just fake it by having a somewhat transparent black movie clip appear over everything, because I need the alpha of each thumbnail to be able to change again once people roll over a new thumbnail.

    Is there any simple way to do this? Any help is much appreciated.

    Thanks!

    (a section of my code is included for reference but there are like 30 thumbnails so I didn't include it all, the code is the same for everything)

    Code:
    thumb_001.onRollOver = over;
    thumb_001.onPress = down;
    thumb_001.onRollOut = out;
    thumb_001.onRelease () {
    	_parent.gotoAndPlay("test");
    }
    
    thumb_002.onRollOver = over;
    thumb_002.onPress = down;
    thumb_002.onRollOut = out;
    
    
    thumb_003.onRollOver = over;
    thumb_003.onPress = down;
    thumb_003.onRollOut = out;
    
    
    function over() {
    this._alpha=100;
    }
    
    function down() {
    this._alpha=50;
    }
    
    function out() {
    this._alpha=60;
    }

  2. #2
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    If all of your thumbnails have a similar name i.e.: thumb_###, then you are in luck and there is a easier way to do it. Try something like this:
    PHP Code:
    var totalThumbCount 30;

    for(
    i=0totalThumbCounti++)
    {
        var 
    numFormat "";
        
        
    //Format the unique numbering system
        
    if (10)
        {
            
    numFormat "00" i;
        }
        else if (
    100)
        {
            
    numFormat "0" i;
        }
        else
        {
            
    numFormat i;
        }
        
            
    //Add functions for buttons
        
    this["thumb_" numFormat + (1)].onRollOver = function()
        {
            
    this._alpha 100;
        }
        
        
    this["thumb_" numFormat + (1)].onRollOut = function()
        {
            
    this._alpha 60;
        }
        
        
    this["thumb_" numFormat + (1)].onPress = function()
        {
            
    this._alpha 50;
        }
        
        
    this["thumb_" numFormat + (1)].onRelease = function()
        {
            
    _parent.gotoAndStop("test");
        }

    Last edited by samac1068; 01-07-2010 at 07:50 PM.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  3. #3
    Junior Member
    Join Date
    Nov 2009
    Posts
    17
    Thanks for the response. Maybe I need to change something though because unfortunately that code didn't seem to have any effect on my files. I'm not a big coder so I don't really know what I would need to change?

    There are 27 thumbs numbered like 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, etc...

Tags for this Thread

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