# Simultaneous alpha tweens

**URL:** <https://forum.kirupa.com/t/simultaneous-alpha-tweens/260044>\
**Category:** Uncategorized\
**Created:** [May 12, 2008, 3:01am UTC](https://forum.kirupa.com/t/simultaneous-alpha-tweens/260044 "2008-05-12T03:01:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![freestyle](https://avatars.discourse-cdn.com/v4/letter/f/b19c9b/32.png) [@freestyle](https://forum.kirupa.com/u/freestyle)\
**Post date:** [May 12, 2008, 3:01am UTC](https://forum.kirupa.com/t/simultaneous-alpha-tweens/260044/1 "2008-05-12T03:01:28Z")

</div>

I’m a Web Teacher for a HS academy. We want to create a slideshow of different size images using Flash CS3.

In Flash AS3, I have two Sprites being dynamically loaded with different dimension images. In the end, I want these different size photos to fade out and fade in simultaneously. I can only get Tween to perform one after the other but not simultaneously with

var fadeout:Tween = new Tween(one, “alpha”, Strong.easeOut, 100, 0, 3, true);  
var fadeIn:Tween = new Tween(two, “alpha”, Strong.easeIn, 0, 100, 3, true);

Basically, how do you perform 2 simultaneous alpha tweens (in my case, because of DIFFERENT SIZE photos)?

Thanks!

---

<div class="post-metadata">

**Author:** ![RebuiltJorge](https://avatars.discourse-cdn.com/v4/letter/r/94ad74/32.png) [@RebuiltJorge](https://forum.kirupa.com/u/RebuiltJorge)\
**Post date:** [May 12, 2008, 3:40am UTC](https://forum.kirupa.com/t/simultaneous-alpha-tweens/260044/2 "2008-05-12T03:40:01Z")

</div>

here try this, you might have to fine tune it to meet your specifications

package {  
import flash.display.Sprite;  
import flash.events.Event;

```
public class Pulse extends Sprite {
	private var ball:Ball;
	private var angle:Number = 0;
	private var centerScale:Number = 1;
	private var range:Number = -1;
	private var speed:Number = .5;

	public function Pulse() {
		init();
	}
	private function init():void {
		for (var i:int = 0; i &lt; 2; i++) {
			ball = new Ball();
			addChild(ball);
			ball.x = stage.stageWidth / 2 + 100 * i;
			ball.y = stage.stageHeight / 2;
			ball.addEventListener(Event.ENTER_FRAME, startPulse);
		}
	}
	public function startPulse(event:Event):void {
		event.target.alpha = centerScale + Math.sin(angle) * range;
		angle += speed;

	}
}

```

}

---

<div class="post-metadata">

**Author:** ![Rezmason](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rezmason/32/30447_2.png) [@Rezmason](https://forum.kirupa.com/u/Rezmason)\
**Post date:** [May 12, 2008, 3:56am UTC](https://forum.kirupa.com/t/simultaneous-alpha-tweens/260044/3 "2008-05-12T03:56:51Z")

</div>

[QUOTE=freestyle;2324877]Basically, how do you perform 2 simultaneous alpha tweens (in my case, because of DIFFERENT SIZE photos)?[/QUOTE]

Great question. It’d be nice if Tweens would let you manipulate multiple properties of multiple objects at the same time. To overcome their inflexibility, you can do this with a single Tween:

```auto

var guineaPig1:GuineaPig = new GuineaPig();
var guineaPig2:GuineaPig = new GuineaPig();
var tween:Tween = new Tween(guineaPig1, "alpha", Regular.easeInOut, 0, 1, 1, true);
// ...
tween.stop(); // Tweens play automatically. I hate this!
tween.addEventListener(TweenEvent.MOTION_CHANGE, updateOtherThings);
// ...
function updateOtherThings(event:TweenEvent):void {
	guineaPig2.alpha = guineaPig1.alpha;
}

```

The disadvantage to doing this is that now the objects affected by the Tween are in two places: in the Tween’s constructor, and in the updateOtherThings function. We can improve the code above by doing this:

```auto

var guineaPig1:GuineaPig = new GuineaPig();
var guineaPig2:GuineaPig = new GuineaPig();
var prop:Number;
var tween:Tween = new Tween(this, "prop", Regular.easeInOut, 0, 1, 1, true);
// ...
tween.stop();
tween.addEventListener(TweenEvent.MOTION_CHANGE, updateThings);
// ...
function updateOtherThings(event:TweenEvent):void {
	guineaPig1.alpha = prop;
	guineaPig2.alpha = prop;
}

```
