A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] Can't get this loop to work for some reason

  1. #1
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389

    resolved [RESOLVED] Can't get this loop to work for some reason

    Hi,

    I have tried this loop on my clips with no success:

    Code:
    _root["subMenuButton"+i].onRollOver = function():Void {
    	_root["subMenuButton"+i]._alpha = 50;
    }
    while if I refer to the clips individually it works:

    Code:
    _root.subMenuButton1.onRollOver = function():Void {
    	trace("I have been rolledOver");
    	_root.subMenuButton1._alpha = 50;
    }
    the clips can tlle when they are rolled over because this works as well:

    Code:
    for(i=1;i<=15;i++){
    _root["subMenuButton"+i].onRollOver = function():Void {
    	trace("I have been rolledOver");
    	_root["subMenuButton"+i]._alpha = 50;
    	_root["subMenuButton"+i].onRollOut = function():Void {
    	_root["subMenuButton"+i]._alpha = 100;
    	}
    }
    is my code wrong or is this some sort of a bug? I have also tried referring to the clips by their _level but I get no response either.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    You were putting the rollout inside the rollover and the alpha did not work.

    Try,
    PHP Code:
    for (1<= 15i++)
    {
        
    this["subMenuButton" i].Num i;
        
    this["subMenuButton" i].onRollOver = function()
        {
            
    trace("Rollover - Button " this.Num);
            
    this._alpha 50;
        };
        
    this["subMenuButton" i].onRollOut = function()
        {
            
    trace("Rollout - Button " this.Num);
            
    this._alpha 100;
        };


  3. #3
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389
    FruitBeard, thanks so much!

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