Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 在greensock LinePath2D中淡入淡出项目_Actionscript 3_Gsap - Fatal编程技术网

Actionscript 3 在greensock LinePath2D中淡入淡出项目

Actionscript 3 在greensock LinePath2D中淡入淡出项目,actionscript-3,gsap,Actionscript 3,Gsap,这是LinePath2D类中提供的示例代码 import com.greensock.*; import com.greensock.easing.*; import com.greensock.motionPaths.*; import flash.geom.Point; //create a LinePath2D with 5 Points var path:LinePath2D = new LinePath2D([new Point(0, 0),

这是LinePath2D类中提供的示例代码

import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.motionPaths.*;
import flash.geom.Point;

//create a LinePath2D with 5 Points
var path:LinePath2D = new LinePath2D([new Point(0, 0), 
                                      new Point(100, 100), 
                                      new Point(350, 150),
                                      new Point(50, 200),
                                      new Point(550, 400)]);

//add it to the display list so we can see it (you can skip this if you prefer)
addChild(path);

//create an array containing 30 blue squares
var boxes:Array = [];
for (var i:int = 0; i < 30; i++) {
    boxes.push(createSquare(10, 0x0000FF));
}

//distribute the blue squares evenly across the entire path and set them to autoRotate
path.distribute(boxes, 0, 1, true);

//put a red square exactly halfway through the 2nd segment
path.addFollower(createSquare(10, 0xFF0000), path.getSegmentProgress(2, 0.5));

//tween all of the squares through the path once (wrapping when they reach the end)
TweenMax.to(path, 20, {progress:1});

//while the squares are animating through the path, tween the path's position and rotation too!
TweenMax.to(path, 3, {rotation:180, x:550, y:400, ease:Back.easeOut, delay:3});

//method for creating squares
function createSquare(size:Number, color:uint=0xFF0000):Shape {
    var s:Shape = new Shape();
    s.graphics.beginFill(color, 1);
    s.graphics.drawRect(-size / 2, -size / 2, size, size);
    s.graphics.endFill();
    this.addChild(s);
    return s;
}
淡入淡出元素的最简单方法是什么


我应该在每个项目中添加一个tween,还是挂接到更新侦听器中?

我已经准备好了

        TweenMax.to(path, $speedNorm, { progress:1, ease:Linear.easeNone, repeat: -1, onUpdate:function():void
            {
                for (var j:int = 0; j < path.followers.length; j++) 
                {
                    var $follower:PathFollower = path.followers[j];
                    if ($follower.progress < 1/$numPoints) {
                        $follower.target.alpha = $follower.progress * $numPoints;
                    }
                    else if ($follower.progress > 1-1/$numPoints) {
                        $follower.target.alpha = (1-$follower.progress) * $numPoints;
                    }
                }
            }
        });
TweenMax.to(path,$speedNorm,{progress:1,ease:Linear.easeNone,repeat:-1,onUpdate:function():void
{
对于(var j:int=0;j1-1/$numPoints){
$follower.target.alpha=(1-$follower.progress)*$numPoints;
}
}
}
});

其中,$numpoints根据示例为30。我会做一个更新侦听器,因为它可能会稍微更有效。这是我正在尝试的方向,它有点困难,因为它需要更改/扩展LinePath2D类,以允许访问一些受保护的属性。看起来比我想象的要复杂。我不清楚你到底想做什么。你想让你的方块在到达你路径的尽头时分别淡入淡出吗?还是在这两个孩子开始和结束的同时?最好更新您的问题,使其更清晰地显示我确实需要的属性(追随者)已经公开。我确实在类中发现了一个小错误,但是,第一个和最后一个对象重叠(因为0和1的进度相同)最后一个对象不应添加或相应地调整位置。