Question : alpha towards the end of the stage

is there some AS3 code that will automatically start the alpha to go to zero as it starts to get to the end of the stage. I am have some cloulds moving across the screen when they come to the edge of the stage it just goes behind a straight line..i want it to look seemless..having an issue with it...

i have attached my code so far. I am using Tweenmax as well...t
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
import com.greensock.*; 
import com.greensock.plugins.*;
import com.greensock.easing.*;
//*****====================================================*****
cloud1.alpha = 0;
cloud2.alpha = 0;
cloud3.alpha = 0;
cloud4.alpha = 0;
TweenMax.to(cloud1, 1, {blurFilter:{blurX:75}});
TweenMax.to(cloud2, 1, {blurFilter:{blurX:75}});
TweenMax.to(cloud3, 1, {blurFilter:{blurX:75}});
TweenMax.to(cloud4, 1, {blurFilter:{blurX:75}});
//-----------------------------------------------
var clouds:TimelineMax = new TimelineMax({repeat:-1, yoyo:true, repeatDelay:3});
  clouds.insert(TweenMax.to(cloud1, 10,  {x:"100"}));
  clouds.insert(TweenMax.to(cloud1, 10,  {alpha:1, delay:10}));
  clouds.insert(TweenMax.to(cloud1, 100, {x:1200}));
  clouds.insert(TweenMax.to(cloud1, 100, {scaleX:1.25}));
  clouds.insert(TweenMax.to(cloud1, 100, {scaleY:1.5}));
  //----------------------------------------------- 
  clouds.insert(TweenMax.to(cloud2, 10,  {x:"100"}));
  clouds.insert(TweenMax.to(cloud2, 10,  {alpha:1, delay:25}));
  clouds.insert(TweenMax.to(cloud2, 120, {x:1200, delay:20}));
  clouds.insert(TweenMax.to(cloud2, 120, {scaleX:1.25, delay:20}));
  clouds.insert(TweenMax.to(cloud2, 120, {scaleY:1.5, delay:20}));
  //----------------------------------------------- 
  clouds.insert(TweenMax.to(cloud3, 10,  {x:"100"}));
  clouds.insert(TweenMax.to(cloud3, 10,  {alpha:1, delay:35}));
  clouds.insert(TweenMax.to(cloud3, 115, {x:1200, delay:30}));
  clouds.insert(TweenMax.to(cloud3, 115, {scaleX:1.25, delay:30}));
  clouds.insert(TweenMax.to(cloud3, 115, {scaleY:1.5, delay:30}));
  //----------------------------------------------- 
  clouds.insert(TweenMax.to(cloud4, 10,  {x:"100"}));
  clouds.insert(TweenMax.to(cloud4, 10,  {alpha:1, delay:45}));
  clouds.insert(TweenMax.to(cloud4, 120, {x:1200, delay:40}));
  clouds.insert(TweenMax.to(cloud4, 120, {scaleX:1.25, delay:40}));
  clouds.insert(TweenMax.to(cloud4, 120, {scaleY:1.5, delay:40}));

Answer : alpha towards the end of the stage

Your actionscript approach could definitely be optimized.  I haven't tested this, but it should do the trick.  Hopefully you can see where I was going with it.  I put a comment in there for the fade out script.  You might need to mass with that a little bit.  Post back to let me know how it works.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
import com.greensock.*; 
import com.greensock.plugins.*;
import com.greensock.easing.*;
//*****====================================================*****

var clouds:TimelineMax = null;
var cloudArray:Array = new Array();
cloudArray.push('cloud1');
cloudArray.push('cloud2');
cloudArray.push('cloud3');
cloudArray.push('cloud4');

init();

function init():void {
	clouds = new TimelineMax({repeat:-1, yoyo:true, repeatDelay:3});
	
	for(var i:int = 0; i < cloudArray.length; i++) {
		var cloud:MovieClip = this[cloudArray[i]] as MovieClip;
		var dur:int = rndm(100, 120);
		var del:int = (i == 0) ? 0 : (i* 10 + 10);
		
		cloud.alpha = 0;
		TweenMax.to(cloud, 1, {blurFilter:{blurX:75}});
		
		clouds.insert(TweenMax.to(cloud, 10,  {x:"100"}));
		clouds.insert(TweenMax.to(cloud, 10,  {alpha:1, delay:del + 5}));
		clouds.insert(TweenMax.to(cloud, dur, {x:1200, delay:del}));
		clouds.insert(TweenMax.to(cloud, dur, {scaleX:1.25, delay:del}));
		clouds.insert(TweenMax.to(cloud, dur, {scaleY:1.5, delay:del}));
		
		// This should fade out the cloud near the end
		clouds.insert(TweenMax.to(cloud, 20, {alpha:0, delay:del + dur - 20}));
	}
}

/** 
* Generate a random number
* @return Random Number
* @error throws Error if low or high is not provided
*/  
function rndm(low:Number=NaN, high:Number=NaN):Number
{
	var low:Number = low;
	var high:Number = high;
	
	if(isNaN(low)) {
		throw new Error("low must be defined");
	}
	if(isNaN(high)) {
		throw new Error("high must be defined");
	}
	
	return Math.round(Math.random() * (high - low)) + low;
}
Random Solutions  
 
programming4us programming4us