Topic: Transparent Frame pt. 2 - making the image transparent

This is part 2 of the transparent frame 'how to'...making the image transparent.  In my response to the 'Transparent Frame' post I pointed out how to build the frame as a hollow rectangle instead of a solid rectangle using a different function available in the DrawUtil class.  This effectively makes the frame a border around the image and if the image were 100% transparent you would see whatever is behind it (either the stage or the page background depending on how the transparency of the stage is set). 

The other part of the equation is making the image transparent.  By default you can set the image to either side of the "current" image to a brightness value of -255 to 255 (black to white).  To make the image transparent you need to modify the Image class.  Again, I am not a flash developer and while this works it is almost certainly a hack...but in the interest of sharing...here goes.

In the Image.as file:

In function Image (around line 85) replace:

mColorTween = new Tween(mcLoader,"offset",sTweenFunc,-255,-255,1,false);            
mColorTween.onMotionChanged = Delegate.create(this,setColorOffset);    
mColorTween.onMotionFinished = Delegate.create(this,onColorTweenDone);

with:

mColorTween = new Tween(mcLoader, "_alpha", sTweenFunc, 50, 0, 1, true);
mColorTween.onMotionFinished = Delegate.create(this,onColorTweenDone);

This change will Tween the _alpha property of the Image instead of the offset property.  In order to make this work I also had to remove delegate to the setColorOffset function from the onMotionChanged event (the second line in the 'before' part)...but I have no idea why except that it doesn't seem like it has much to do with the _alpha property.  The 50 in the 4th parameter of the Tween constructor makes the image 50% transparent to start with. 

In the onColorTweenDone function replace:

if(mcLoader.offset == 0){
    mCaptionTween.continueTo(100,5);
}

with:

mCaptionTween.continueTo(100,5);

All that does is remove the if statement around the main logic.  The offset property is not being manipulated anymore based on the first set of changes so whatever it would have done to make it equal to 0 no longer happens.

In the show function replace:

mColorTween.continueTo(0,Options.colorFadeAnimationLength);

with:

mColorTween.continueTo(100,1);

This makes the image 100% visible when the show function is called.

And in the hide function replace:

mColorTween.continueTo(Options.fadeBrightness,Options.colorFadeAnimationLength);
mCaptionTween.continueTo(0,1);

with:

mColorTween.continueTo(50,1);
mCaptionTween.continueTo(0,1);

This makes the image 50% visible again.  There is also something happening with the caption and it doesn't work quite right but I haven't had time to try to figure that out yet. 

Anyway, I hope this helps!  Here's the link to the sample again:
http://www.brianchapmanphotography.com/ … /index.php

Brian