-
[CS3] Clicking a button to cause a tween
Hi there,
I'm trying to use AS3 and have a tween happen to a movie clip when I click on a button.
For a simple example I've drawn a box and converted it into a movie clip called 'box'.
Then I've made a button called 'Btn'
When I click on the button I want the alpha of the box to change.
I have both the box and the button position on the stage and so far I have the following action script in frame 1:
//button event listener
Btn.addEventListener(MouseEvent.CLICK, onButtonClick, false, 0, true);
//change the alpha of the box from 30% to 100%
function onButtonClick(evt:MouseEvent):void {
var boxTween:Tween = new Tween(box, "alpha", None.easeOut, .3, 1, 3, true);
}
but of course this doesn't work!
but why?
any help would be greatly appreciated.
thanks
Wilbo
-
Jack Foster
you need to import the classes to be able to use the Tween class,
so import tween class and easing classes and should work just fine.
here is the code;
import fl.transitions.Tween;
import fl.transitions.easing.*;
Btn.addEventListener(MouseEvent.CLICK, onButtonClick, false, 0, true);
function onButtonClick(evt:MouseEvent):void {
var boxTween:Tween = new Tween(box, "alpha", None.easeOut, .3, 1, 3, true);
}
-
Yeah, I already have that, sorry I forgot to include it in the code I typed.
Any other ideas?
-
OK, I got it to work.
I forgot to set the linkage for the movieclips.
Thanks
Wilbo
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
|