FadeIn and fadeOut

Software: Away3D 3.x

ppalmeida, Newbie
Posted: 12 July 2011 06:10 PM   Total Posts: 2

Hi, folks.
I’m trying to make a cube have a fadeIn and fadeOut. The alpha property doesn’t work. So I try to take each face’s material. But it doesn’t have a alpha property too.

So my newbie question is: how can I set an alpha/transparency of a primitive? In its materials? In alpha property of the primitive? Nothing is working on this matter.

The most funny part: in “Cookbook” AND ‘3D in Flash” books I didnt find one, neighter a unique simple line of “alpha” or “fadeIn” “fadeOut” example. It is drive me crazy hahahah.

Thanks for all your help.


—Editing:

Well… this is what I did to “work around” this alpha problem. I dont know if this is the best (or correct) way to achieve this, but It is working:

package  {
 import away3d
.materials.ColorMaterial;
 
import away3d.materials.Material;
 
import away3d.materials.MovieMaterial;
 
import away3d.primitives.Cube;
 
import away3d.primitives.data.CubeMaterialsData;
 
import com.greensock.TweenLite;
 
 
/**
  * ...
  * @author Pedro Paulo Almeida
  */
 
public class FaceNumber extends Cube {
  
  
private var _materials:Array;
  
  
override public function set alpha(value:Number):void {
   super
.alpha value;
  
}
  
  
public function FaceNumber(init:Object null{
   super
(init);
   
this._materials = new Array();
  
}
  
  
public function init(front:MovieMaterialback:MovieMaterial):void {
   
var cubeData:CubeMaterialsData = new CubeMaterialsData();
   
cubeData.front  front;
   
cubeData.left  = new ColorMaterial(0xffffff);
   
cubeData.right  = new ColorMaterial(0xffffff);
   
cubeData.top  = new ColorMaterial(0xffffff);
   
cubeData.bottom = new ColorMaterial(0xffffff);
   
cubeData.back  back;
   
   
this._materials.push(frontbackcubeData.leftcubeData.rightcubeData.topcubeData.bottom);
   
this.cubeMaterials cubeData;
  
}
  
  
  
public function setAlpha(value:Numberspeed:Number):void {
   
// If the value is zero, min value is 0.01 to avoid bitmap null bug
   
if (value <= 0value 0.01;
   
// if the desired value is upper than 0.01 turn it visible:
   
if (value 0.01this.visible true;
   
// just matain "alpha" value updated in Cube, just in case....
   
this.alpha value;
   
// Update materials alpha:
   
for (var i:int 0this._materials.lengthi++) {
    
(== 0) ? TweenLite.to(this._materials[i]speed{ alpha:valueonComplete:invisible } ) : TweenLite.to(this._materials[i]speed{alpha:value});
   
}
  }
  
  
// After the tween get finished, turn it visible= false, to improve performance (right?)
  
private function invisible():void {
   this
.visible false;
  

  
 }

Well, if someone here with a lof of experience has a better/different way or even a comment/suggestion I would love to hear.

Thank you all.

Pedro Paulo Almeida

   

Avatar
SasMaster, Sr. Member
Posted: 16 July 2011 05:16 PM   Total Posts: 127   [ # 1 ]

First as the author of the ” Cookbook” I would like to apologize wink . But I think you have actually overdid in your attempt . All you had to do was to turn ownCanvas = true and then assign a value to the alpha property of the object . That is if you mean Away 3x . You can’t change alpha Of the object if it is not wrapped with it’s own container . Hope that helps

 Signature 

This looks like a job for superman
http://blog.alladvanced.net

   

ppalmeida, Newbie
Posted: 16 July 2011 05:54 PM   Total Posts: 2   [ # 2 ]

Hey Sas!
Such an honor to have my post readed and answered by you. The Cookbook is so wonderful. Congratulations!

About the alpha matter, I’ll try to do as you said. It seems much more appropriate than the loop that I implemented on materials.

Again, congratulations for Cookbook and thank you!

   

Avatar
Choons, Sr. Member
Posted: 16 July 2011 06:17 PM   Total Posts: 281   [ # 3 ]

ObjectContainer3D has an alpha property. You could just put your cube in a “box” and do it that way. Interesting solution you came up with there though as often setting ownCanvas = true causes some weird artifacts.

   

Avatar
SasMaster, Sr. Member
Posted: 16 July 2011 06:40 PM   Total Posts: 127   [ # 4 ]

The artifacts (z ordering) are due to the fact that once you wrap an object with its own canvas its depth is not managed as before.The solutions is pretty simple, you need either use pushBack/pushFront or using render sessions to group objects in layer like style and define the depth manually .
@Choons ,you still need to set ownCanvas=true for ObjectContainer3D if you want its alpha prop to work smile .

 Signature 

This looks like a job for superman
http://blog.alladvanced.net

   

Avatar
Choons, Sr. Member
Posted: 16 July 2011 06:46 PM   Total Posts: 281   [ # 5 ]

right but his approach up there circumvents ownCanvas is what I meant. So how do you manage pushBack/pushFront when using a HoverCamera to rotate around a complex object? I wanted to use it for a GlowFilter effect but it was such a mess trying to get z-sorting right and there like these weird mirror image things going on at the edges of the canvas

   

Avatar
SasMaster, Sr. Member
Posted: 16 July 2011 07:01 PM   Total Posts: 127   [ # 6 ]

Yes I understand the problem.Well tweening the material alpha is a possible solution .I am not sure how it impacts the performance though.Using canvases in the scene where you have many objects overlapping on different depth can really become a headache once you try to look at them from different angles.But you can always make something up,like dynamically controlling pushback/pushfront to make sure the needed object gets the correct z order .That is not a perfect solution but that the trade off to get filters on the geometry etc.

 Signature 

This looks like a job for superman
http://blog.alladvanced.net

   

Avatar
SasMaster, Sr. Member
Posted: 16 July 2011 07:04 PM   Total Posts: 127   [ # 7 ]
ppalmeida - 16 July 2011 05:54 PM

Hey Sas!
Such an honor to have my post readed and answered by you. The Cookbook is so wonderful. Congratulations!

BTW, Ppalmeida, it would be even a greater honor to me if you could put a couple of words + rating to my book at amazon.com:

http://www.amazon.com/Away3D-3-6-Cookbook-Michael-Ivanov/dp/1849512809

Thanks a lot and I am glad you like the book. smile

 Signature 

This looks like a job for superman
http://blog.alladvanced.net

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X