dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [CS3] Tweener code help

  1. #1
    Junior Member
    Join Date
    Mar 2007
    Posts
    18

    [CS3] Tweener code help

    Hello,

    I got this code which works really well (below), when one movie clip is on the stage. Now I want multiple movies/buttons and the other buttons don't seem to work. What do I need to do?

    I've changed the instance name to "scale_mc1" but not sure where to put it.

    Rather than having the code in the timeline, should I put it on the symbol itself?

    thanks
    ----------------------------
    import mx.transitions.Tween;
    import flash.geom.ColorTransform;
    import flash.geom.Transform;

    var myTween:Tween = new Tween(scale_mc, "_xscale", mx.transitions.easing.Elastic.easeOut, 100, 200, 1, true);
    var myTween1:Tween = new Tween(scale_mc, "_yscale", mx.transitions.easing.Elastic.easeOut, 100, 200, 1, true);

    var myTween2:Tween = new Tween(scale_mc, "_xscale", mx.transitions.easing.Elastic.easeOut, 200, 100, 1, true);
    var myTween3:Tween = new Tween(scale_mc, "_yscale", mx.transitions.easing.Elastic.easeOut, 200, 100, 1, true);

    scale_mc.onRollOver = function():Void {

    myTween.start();
    myTween1.start();
    };

    scale_mc.onRollOut = function():Void {
    myTween2.start();
    myTween3.start();

    };


    import mx.transitions.Tween;
    import flash.geom.ColorTransform;
    import flash.geom.Transform;

    var myTween:Tween = new Tween(scale_mc, "_xscale", mx.transitions.easing.Elastic.easeOut, 100, 200, 1, true);
    var myTween1:Tween = new Tween(scale_mc, "_yscale", mx.transitions.easing.Elastic.easeOut, 100, 200, 1, true);

    var myTween2:Tween = new Tween(scale_mc, "_xscale", mx.transitions.easing.Elastic.easeOut, 200, 100, 1, true);
    var myTween3:Tween = new Tween(scale_mc, "_yscale", mx.transitions.easing.Elastic.easeOut, 200, 100, 1, true);

    scale_mc.onRollOver = function():Void {

    myTween.start();
    myTween1.start();
    };

    scale_mc.onRollOut = function():Void {
    myTween2.start();
    myTween3.start();

    };

  2. #2
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    var myTween:Tween = new Tween(scale_mc, "_xscale", mx.transitions.easing.Elastic.easeOut, 100, 200, 1, true);

    the first parameter is the MC that the tween is applied to.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  3. #3
    Junior Member
    Join Date
    Mar 2007
    Posts
    18

    Thanks

    Thanks I know that's what I need to change, but how do I write it when there is more than one MC that I want to write the script too? I tried putting a comma next to it and putting (scale_mc, scale_mc1....) without any luck. I then tried putting the code on each individual movie clip still no luck.

  4. #4
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    You have to have one tween per object and property (to run them concurrently at least).
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  5. #5
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    or... using functions and a for loop:
    PHP Code:
    import mx.transitions.Tween;
    import mx.transitions.easing.*;

    // 4 movieclips with instance names named scale_mc1, scale_mc2, scale_mc3 and scale_mc4

    function scaleUp(clip) {
    var 
    myTween:Tween = new mx.transitions.Tween(clip"_xscale",Elastic.easeOut1002001true);
    var 
    myTween1:Tween = new mx.transitions.Tween(clip"_yscale",Elastic.easeOut1002001true);
    }
    function 
    scaleDown(clip) {
    var 
    myTween2:Tween = new Tween(clip"_xscale"Elastic.easeOut2001001true);
    var 
    myTween3:Tween = new Tween(clip"_yscale"Elastic.easeOut2001001true);
    }
        
    for (
    i=1i<=4i++) {
        
    this["scale_mc"+i].onRollOver = function():Void  {
            
    scaleUp(this);
        };
        
            
    this["scale_mc"+i].onRollOut = function():Void  {
            
    scaleDown(this);
        };

    gparis

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