A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [RESOLVED] 50%alpha, onRollOver+onRelease=100%alpha

  1. #1
    Member
    Join Date
    Jul 2008
    Posts
    73

    resolved [RESOLVED] 50%alpha, onRollOver+onRelease=100%alpha

    I've been trying to code this so the thumbnails are at 50% alpha. Then when you rollover or click on the thumbnail they go to 100% alpha. The thumbnail that has been clicked on should stay at 100% to indicate that it is presently selected.

    I've tried everything but can't seem to get it. What am I missing?

    Code:
    function callThumbs() {
    	_root.createEmptyMovieClip("container_mc",_root.getNextHighestDepth());
    	container_mc._x = _root.gallery_x;
    	container_mc._y = _root.gallery_y;
    	container_mc._alpha = 50;
    Code:
    preloader.onLoadComplete = function(target) {
    			new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
    			target.my_txt.removeTextField();
    			target.onRelease = function() {
    				callFullImage(this._name);
    			};
    
    			target.onRollOver = function() {
    				this._alpha = 200;
    			};
    
    			target.onRollOut = function() {
    				this._alpha = 100;
    			};
    I've attached the .fla and thumbs to look at
    Last edited by Playdoe; 01-19-2010 at 11:59 PM.

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    var picked:MovieClip = undefined;
    function callThumbs() {
    	_root.createEmptyMovieClip("container_mc",_root.getNextHighestDepth());
    	container_mc._x = _root.gallery_x;
    	container_mc._y = _root.gallery_y;
    	container_mc._alpha = 50;
    	var clipLoader = new MovieClipLoader();
    	var preloader = new Object();
    	clipLoader.addListener(preloader);
    	for (i=0; i<myImagesTotal; i++) {
    		thumbURL = myImages[i].attributes.thumb_url;
    		myThumb_mc = container_mc.createEmptyMovieClip(i, container_mc.getNextHighestDepth());
    		myThumb_mc._x = _root.thumb_width*i;
    		clipLoader.loadClip(+thumbURL,myThumb_mc);
    		preloader.onLoadStart = function(target) {
    			target.createTextField("my_txt",target.getNextHighestDepth(),0,0,100,20);
    			target.my_txt.selectable = false;
    		};
    		preloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
    			target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
    		};
    		preloader.onLoadComplete = function(target) {
    			new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
    			target.my_txt.removeTextField();
    			target.onRelease = function() {
    				callFullImage(this._name);
    				picked._alpha = 100;
    				picked = this;
    			};
    			target.onRollOver = function() {
    				this._alpha = 200;
    			};
    			target.onRollOut = function() {
    				if (this != picked) {
    					this._alpha = 100;
    				}
    			};
    		};
    	}
    }

  3. #3
    Member
    Join Date
    Jul 2008
    Posts
    73
    Dawsonk. I cannot thank you enough for your help here. One last detail. The 1st image loads on enter but the 1st thumbnail doesn't go to 100% alpha to show that it is selected.

  4. #4
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    preloader.onLoadComplete = function(target) {
    	if (target._name == "0") {
    		new Tween(target, "_alpha", Strong.easeOut, 0, 200, .5, true);
    		picked = target;
    	} else {
    		new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
    	}
    	target.my_txt.removeTextField();
    	target.onRelease = function() {
    		callFullImage(this._name);
    		picked._alpha = 100;
    		picked = this;
    	};
    	target.onRollOver = function() {
    		this._alpha = 200;
    	};
    	target.onRollOut = function() {
    		if (this != picked) {
    			this._alpha = 100;
    		}
    	};
    }

  5. #5
    Member
    Join Date
    Jul 2008
    Posts
    73
    Perfect! Thank you very much for that.

    For anyone who is interested: to prevent the thumbnail from being clicked again (if already selected) add the following:

    Code:
    target.onRelease = function() {
          if (this != picked) {      //added
                 callFullImage(this._name);
    	     picked._alpha = 100;
    	     picked = this;
          }  //added
    };
    Last edited by Playdoe; 01-19-2010 at 02:13 PM.

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