|
-
[RESOLVED] Help to fade-in pictures
Hey!
I've made this picture slideshow.
It got 6 buttons, used as navigation between pictures. It works fine. But i want to add some fade in & out when the buttons is pushed. I've tried a couple of diffrent codes, but i can't manage to solve it.
Code loke like this:
import flash.events.MouseEvent;
button1.addEventListener(MouseEvent.CLICK,showpic1 );
button2.addEventListener(MouseEvent.CLICK,showpic2 );
button3.addEventListener(MouseEvent.CLICK,showpic3 );
button4.addEventListener(MouseEvent.CLICK,showpic4 );
button5.addEventListener(MouseEvent.CLICK,showpic5 );
button6.addEventListener(MouseEvent.CLICK,showpic6 );
button_1.addEventListener(Event.ENTER_FRAME, fadebutton_1ind);
button_1.alpha = 0;
function showpic1(Event:MouseEvent):void{
gotoAndStop("billed1");
}
function showpic2(Event:MouseEvent):void{
gotoAndStop("billed2");
}
function showpic3(Event:MouseEvent):void{
gotoAndStop("billed3");
}
function showpic4(Event:MouseEvent):void{
gotoAndStop("billed4");
}
function showpic5(Event:MouseEvent):void{
gotoAndStop("billed5");
}
function showpic6(Event:MouseEvent):void{
gotoAndStop("billed6");
}
function fadebutton_1ind(event:Event)
{
button_1.alpha += 0.1;
if(button_1.alpha >= 1)
{
button_1.removeEventListener(Event.ENTER_FRAME, fadebutton_1ind);
}
}
And i still doesnt work.
Hope you understand my problem
Link to the flash in action:
Sport-Helse.dk
-
Flash/Flex Developer
I suggest that you use the tween class to alter the alpha of your object. What is the difference between button1 and button_1. I am assuming that button_1 is the MC that is holding all of the pictures.
Anyway, this is something like what I would do. This is untested so it may need some tweaking.
Actionscript Code:
import flash.event.MouseEvent; import fl.transitions.Tween; import fl.transitions.easing.*; import fl.transitions.TweenEvent;
//Hide the picture frame button_1.alpha = 0;
//Give the buttons their functions for(var i:int = 0; i < 6; i++) { this["button" + (i + 1)].addEventListener(MouseEvent.CLICK, showPicture); }
function showPicture(evt:MouseEvent):void { //Hide current picture button_1.alpha = 0; //Identify which frame to goto based on button number var index:int = evt.currentTarget.name.substring(6, 1); //Switch to the appropriate frame gotoAndStop("billed" + index); //Use the Tween class to fade the object in over five seconds var picTween:Tween = new Tween(button_1, "alpha", Strong.easeOut, button_1.alpha, 1, 5, true); }
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
-
Thank you!
It helped alot!
Apreciate it!
-
Flash/Flex Developer
If it worked for you, please mark this thread as closed.
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|