# Flash AS3.0 Website Class Tween code help



## jamesjh (Apr 5, 2009)

The following is class which make pages come into view when a button is clicked, using arrays. It's pretty much copied from a tutorial I saw. My question is, how do I make the pages fade into view instead of just appearing?
I've made up some tween code at the bottom but don't know where to put it.


package 
**
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;

public class WebSite extends MovieClip
**
var aContent:Array;
var aButtons:Array;
var aLabels:Array;

public function setUpContent(aContentList:Array):void
**
aContent = aContentList;
}
public function setUpButtons(aButtonList:Array,aLabelList:Array):void
**
aButtons = aButtonList;
aLabels = aLabelList;

var count:Number = aButtons.length;
for (var i:Number = 0; i < count; i++)
**
this.aButtons_.setLabel(aLabel);
this.aButtons.addEventListener(MouseEvent.CLICK, btnClick);
this.aButtons.mouseChildren = false;
this.aButtons.setIndex(i);
}
}
public function clearAllContent():void
**
var count:Number = aContent.length;
for (var i:Number = 0; i < count; i++)
**
this.aContent.visible = false;
}
}
function btnClick(evt:Event):void{
clearAllContent();
this.aContent[evt.target.contentIndex].visible = true;
}
}
}
// WHERE DO I PUT THIS CODE TO MAKE THE IMAGE FADE INTO VIEW?
/*function fadeIn(evt:Event):void
**
var tweenAlpha:Tween = new Tween(this,alpha,None.easeOut,0,1,.3,true);
}

*/_


----------



## FredT (Nov 16, 2007)

I'm a little confused by the situation. Could you attach a .fla file so I can see what's going on a little better?


----------



## jamesjh (Apr 5, 2009)

Hi FredT and thanks for taking the time,

my completed site is at www.sarahweiss.co.uk

what I want to achieve is nicer transitions between pages and also when the product images appear

at the moment, all the photos and pages are already there at start-up, with their visible=false until the mousevent makes it true and the photo or page appears

thing is, the pages and photos are held in arrays, and the following is one of the functions that brings them up:
}
function btnClick(evt:Event):void{
clearAllContent();
this.aContent[evt.target.contentIndex].visible = true;
}

so my question is, how do I make it so that instead of just changing from non-visible to visible, the movieclip tweens in?

I can't be the only one who's come across this issue.....

James.


----------



## FredT (Nov 16, 2007)

Well, how are the 'pages' grouped? Are they on separate frames? Are they movie clips?


----------



## jamesjh (Apr 5, 2009)

All of the pages are movie clips on their own layers, on the stage from frame 1 with their 'visible' property set to false. Buttons have event listeners to make their page visible on CLICK.


----------



## FredT (Nov 16, 2007)

This is my idea, I haven't tested it.


```
function btnClick(evt:Event):void{
	clearAllContent();
	this.aContent[evt.target.contentIndex].visible = true;
	fadeIn(this.aContent[evt.target.contentIndex]);
}
function fadeIn(target_mc:MovieClip):void{
var tweenAlpha:Tween = new Tween(target_mc,alpha,None.easeOut,0,1,.3,true);
}
```


----------



## jamesjh (Apr 5, 2009)

I've tried it, but it doesn't work in that format.

function btnClick(evt:Event):void{
clearAllContent();
this.aContent[evt.target.contentIndex].visible = true;
fadeIn(this.aContent[evt.target.contentIndex]);
}
function fadeIn(target_mc:MovieClip):void{
var tweenAlpha:Tween = new Tween(target_mc,alpha,None.easeOut,0,1,.3,true);
}

I think the problem may be that "this.aContent[evt.target.contentIndex]" is the mc that I want to fade in, but if I put that expression in place of "target_mc", Flash doesn't like it.
Maybe I need to change that line "this.aContent[evt.target.contentIndex].visible = true;"
to something that says 'when I click, do a function' and then make this new function the tween. I'm a bit in the dark here, not having a lot of AS knowledge.


----------

