dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [CS3] Clicking a button to cause a tween

  1. #1
    Junior Member
    Join Date
    Sep 2008
    Posts
    5

    [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

  2. #2
    Jack Foster cabbar's Avatar
    Join Date
    Feb 2007
    Location
    England
    Posts
    111
    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);
    }

  3. #3
    Junior Member
    Join Date
    Sep 2008
    Posts
    5
    Yeah, I already have that, sorry I forgot to include it in the code I typed.
    Any other ideas?

  4. #4
    Junior Member
    Join Date
    Sep 2008
    Posts
    5
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center