在AS2中,我只想添加一个stop();进入clickTag,但我不确定如何在AS3中这样做。
以下是clickTag的示例代码
package
{
import com.greensock.*;
import com.greensock.easing.*;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.net.navigateToURL;
public class main300x250 extends MovieClip
{
public var paramList:Object;
public function main300x250()
{
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
myBTN.addEventListener(MouseEvent.CLICK, clickHandler);
myBTN.addEventListener(MouseEvent.ROLL_OVER, clickOver);
myBTN.addEventListener(MouseEvent.ROLL_OUT, clickOut);
TweenNano.from( t1, .5, {alpha:0, scaleX:0, scaleY:0, ease:Back.easeOut, delay:0});
TweenNano.to( t1, .5, {scaleX:0, scaleY:0, ease:Back.easeIn, delay:1.75});
TweenNano.from( f2.a, .35, {y:"+35", alpha:0, delay:2.25});
TweenNano.from( f2.b, .35, {y:"+35", alpha:0, delay:2.4});
TweenNano.from( f2.nugsL, .5, {x:"-200", ease:Quad.easeIn, delay:2.75});
TweenNano.from( f2.nugsR, .5, {x:"+200", ease:Quad.easeIn, delay:3.15});
TweenNano.to( f2.a, .25, {y:"+15", alpha:0, delay:5.5});
TweenNano.to( f2.b, .25, {y:"+15", alpha:0, delay:5.65});
TweenNano.from( f3.a, .35, {y:"+35", alpha:0, delay:5.75});
TweenNano.to( f2.nugsL, .5, {x:6.5, y:30.5, ease:Quad.easeIn, delay:6.2});
TweenNano.to( f2.nugsR, .5, {x:6.5, y:30.5, ease:Quad.easeIn, delay:6.2});
TweenNano.from( f3.d, .5, {x:"-20", y:"+20", alpha:0, delay:6.6});
TweenNano.to( f3.a, .25, {y:"+15", alpha:0, delay:8.75});
TweenNano.to( f2.nugsL, .25, {x:"+350", delay:8.9});
TweenNano.to( f2.nugsR, .25, {x:"+350", delay:8.9});
TweenNano.to( f3.d, .15, {alpha:0, delay:9});
TweenNano.from(t2, 0.65, {delay:9.15, y:'+='+250, ease:Back.easeOut});
TweenNano.from(t2.a, 0.2, {delay:9.25, y:'+='+75});
TweenNano.from(t2.b, 0.2, {delay:9.45, y:'+='+75});
TweenNano.from(t2.c, 0.2, {delay:9.45, y:'+='+75});
TweenNano.to(t2.b, 0.25, {delay:10.2, x:"-30"});
TweenNano.to(t2.c, 0.25, {delay:10.2, x:"-30"});
TweenNano.to(t2.d, 0.25, {delay:10.2, alpha:1, x:"+31"});
TweenNano.to(endLockUp, 1, {delay:10.2, scaleX:1.15, scaleY:1.15, ease:Quad.easeIn});
TweenNano.from(endLockUp.a, 0.2, {delay:10.2, y:"+200"});
TweenNano.from(endLockUp.b, 0.2, {delay:10.4, x:"-200"});
TweenNano.from(endLockUp.c, 0.2, {delay:10.4, x:"+200"});
TweenNano.from(endLockUp.d, 0.2, {delay:10.6, x:"-200"});
TweenNano.from(endLockUp.e, 0.2, {delay:10.6, x:"+200"});
TweenNano.from(endLockUp.f, 0.2, {delay:10.8, x:"-200"});
TweenNano.from(endLockUp.g, 0.2, {delay:10.8, x:"+200"});
TweenNano.from(endLockUp.h, 0.2, {delay:11, x:"-120"});
TweenNano.from(endLockUp.i, 0.2, {delay:11, x:"+120"});
TweenNano.to(endLockUp, 0.2, {delay:11.2, scaleX:1, scaleY:1});
TweenNano.from( cta, .5, {y:"+200", ease:Back.easeOut, delay:11.4});
TweenNano.from( logo, .15, {y:-62.65 , delay:11.85});
TweenNano.from( legal, .1, {alpha:0, delay:11.9});
}
private function clickOver(e:MouseEvent):void
{
TweenNano.to( cta, .25, {scaleX:1.15, scaleY:1.15});
}
private function clickOut(e:MouseEvent):void
{
TweenNano.to( cta, .25, {scaleX:1, scaleY:1});
}
function clickHandler(e:MouseEvent):void {
var click_url:String = root.loaderInfo.parameters.clickTAG;
if(click_url) {
navigateToURL(new URLRequest(click_url), '_blank');
TweenNano.stop();
}
}
}
}
动画嵌套到另一个.as文件中 编辑:粘贴整个.as文件代码。
提前致谢。
答案 0 :(得分:1)
这会停止所有动画:
package
{
import flash.display.MovieClip;
import flash.display.DisplayObject;
public function stop_animation(object:Object, checker:Function=null):void
{
if (checker != null)
{
if(!checker(object))
return;
}
if(!object)
return;
if(object as MovieClip)
object.gotoAndStop(object.currentFrame);
if(!object.hasOwnProperty("numChildren")||(! object as DisplayObject))
return;
for(var i:int=0;i<object.numChildren;++i)
stop_animation(object.getChildAt(i));
}
}
这将停止鼠标单击位置下的所有动画: 编辑:实际上,当剪辑嵌套
时,它不会package
{
import flash.display.MovieClip;
import flash.display.DisplayObject;
public function stop_animation(object:Object, stage:*, checker:Function=null):void
{
if (checker != null)
{
if(!checker(object))
return;
}
if(!object)
return;
if(object as MovieClip)
if(object.hitTestPoint(stage.mouseX,stage.mouseY))
object.gotoAndStop(object.currentFrame);
if(!object.hasOwnProperty("numChildren")||(! object as DisplayObject))
return;
for(var i:int=0;i<object.numChildren;++i)
stop_animation(object.getChildAt(i),stage);
}
}
可以调用如:stop_animation(this,stage); 如果您传递了一个检查函数,那么它将返回false的所有对象都将被排除在应用函数之外。
这可能与数组,字典等无关,但您可以迭代它们并从当前元素调用它。 (假设他们没有内部数组/词典)
应该停止绿色摇滚动画的代码:
package
{
import flash.events.Event;
import com.greensock.*;
import com.greensock.easing.*;
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class main extends MovieClip
{
var is_stopped:Boolean=false;
var tweens:Array=new Array();
public function main()
{
addEventListener(Event.ADDED_TO_STAGE,setup);
addEventListener(MouseEvent.MOUSE_DOWN, clickHandler);
}
public function setup(e:Event):void
{
tweens.push(TweenNano.from( t1, .5, {alpha:0, scaleX:0, scaleY:0, ease:Back.easeOut, delay:0}));
tweens.push((TweenNano.to( t1, .5, {scaleX:0, scaleY:0, ease:Back.easeIn, delay:1.75})));
}
public function clickHandler(e:MouseEvent):void
{
trace("!");
is_stopped=true;
t1.stop();
for(var i in tweens)
{
tweens[i].kill();
}
}
}
}
CLICK
有时行为不正确,因此我将其替换为DOWN