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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.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
Flash 带AS3的帧到帧间过渡_Flash_Actionscript 3 - Fatal编程技术网

Flash 带AS3的帧到帧间过渡

Flash 带AS3的帧到帧间过渡,flash,actionscript-3,Flash,Actionscript 3,我在“第1帧”中有一个按钮,它指向“第2帧”。该文件有简单的代码: myButton.addEventListener(MouseEvent.CLICK, gotoFrame02); function gotoFrame02(event:MouseEvent):void { gotoAndStop(2); } 问题是帧更改时没有转换。当帧发生变化时,是否可以应用Tween转换?frame1: stop(); myButton.addEventListener(MouseEvent.C

我在“第1帧”中有一个按钮,它指向“第2帧”。该文件有简单的代码:

myButton.addEventListener(MouseEvent.CLICK, gotoFrame02);

function gotoFrame02(event:MouseEvent):void {
    gotoAndStop(2);
}

问题是帧更改时没有转换。当帧发生变化时,是否可以应用Tween转换?

frame1:

stop();
myButton.addEventListener(MouseEvent.CLICK, gotoFrame02);
function gotoFrame02(event:MouseEvent):void {
    gotoAndStop(2);
}
stop();
import fl.transitions.Tween;
import fl.transitions.easing.*;
var myTween:Tween = new Tween(myButton, "x", Elastic.easeOut, 0, 300, 3, true);
框架2:

stop();
myButton.addEventListener(MouseEvent.CLICK, gotoFrame02);
function gotoFrame02(event:MouseEvent):void {
    gotoAndStop(2);
}
stop();
import fl.transitions.Tween;
import fl.transitions.easing.*;
var myTween:Tween = new Tween(myButton, "x", Elastic.easeOut, 0, 300, 3, true);
有关更多信息,请参阅此链接。

框架1:

stop();
myButton.addEventListener(MouseEvent.CLICK, gotoFrame02);
function gotoFrame02(event:MouseEvent):void {
    gotoAndStop(2);
}
stop();
import fl.transitions.Tween;
import fl.transitions.easing.*;
var myTween:Tween = new Tween(myButton, "x", Elastic.easeOut, 0, 300, 3, true);
框架2:

stop();
myButton.addEventListener(MouseEvent.CLICK, gotoFrame02);
function gotoFrame02(event:MouseEvent):void {
    gotoAndStop(2);
}
stop();
import fl.transitions.Tween;
import fl.transitions.easing.*;
var myTween:Tween = new Tween(myButton, "x", Elastic.easeOut, 0, 300, 3, true);
有关更多信息,请参阅此链接。

这完全不可能,不可能。使用时间线从一个帧移动到另一个帧就可以做到这一点,因为时间线上的对象(及其状态)在代码中不可用,除非您已经存在,否则您无法轻松地向前看以创建二者之间的关系。我想说,你有两个选择,虽然我不能说哪一个是更好的不知道什么存在于第二帧

1。时间轴动画

不要使用
gotoAndStop
在第2帧转到完全不同的状态,而是使用
gotoAndPlay
,然后从第2帧开始在两种状态之间创建所需的动画。在动画末尾放置一个关键帧,其中包含一个
stop()

2。忘记时间线

ActionScript3是面向对象的,当您将自己从时间线中解放出来时效果最佳。将第2帧的内容创建为库中的符号,并将符号设置为“Export for Actionscript”。现在,单击按钮时,您可以附加此符号并对其应用编码的二元符号。对于基于代码的tweens,我强烈建议您使用免费库,如果您有文件大小方面的顾虑,请使用TweenLite。它们非常易于使用,并且比内置的tweening类更高效、功能更丰富。您还可以使用将多个tween分组在一起,并将它们作为一个组进行控制

例如:

import com.greensock.TweenMax;
import com.greensock.TimelineMax;

myButton.addEventListener(MouseEvent.CLICK, gotoFrame02);

var frame2State:Frame2State;

function gotoFrame02(event:MouseEvent):void 
{
    //remove listener for memory management purposes
    myButton.removeEventListener(MouseEvent.CLICK, gotoFrame02);
    //create instance of your next state from the library
    frame2State = new Frame2State();  //assuming that the class name you set for the symbol is Frame2State
    addChild(frame2State);
    //create timeline
    var timeline:TimelineMax = new TimelineMax({onComplete:onTimelineComplete});
    //add button fade down animation
    timeline.append(new TweenMax(myButton,0.4,{alpha:0}));
    //add content fade up animation
    timeline.append(new TweenMax(frame2State,0.4,{alpha:1}));
    timeline.play();
}

function onTimelineComplete():void
{
    //remove button
    removeChild(myButton);
    myButton = null;
}

不可能。使用时间轴从一个帧移动到另一个帧就是这样,因为时间轴上的对象(及其状态)在代码中不可用,除非您已经在那里,否则您无法轻松地向前看以创建二者之间的关系。我想说,你有两个选择,虽然我不能说哪一个是更好的不知道什么存在于第二帧

1。时间轴动画

不要使用
gotoAndStop
在第2帧转到完全不同的状态,而是使用
gotoAndPlay
,然后从第2帧开始在两种状态之间创建所需的动画。在动画末尾放置一个关键帧,其中包含一个
stop()

2。忘记时间线

ActionScript3是面向对象的,当您将自己从时间线中解放出来时效果最佳。将第2帧的内容创建为库中的符号,并将符号设置为“Export for Actionscript”。现在,单击按钮时,您可以附加此符号并对其应用编码的二元符号。对于基于代码的tweens,我强烈建议您使用免费库,如果您有文件大小方面的顾虑,请使用TweenLite。它们非常易于使用,并且比内置的tweening类更高效、功能更丰富。您还可以使用将多个tween分组在一起,并将它们作为一个组进行控制

例如:

import com.greensock.TweenMax;
import com.greensock.TimelineMax;

myButton.addEventListener(MouseEvent.CLICK, gotoFrame02);

var frame2State:Frame2State;

function gotoFrame02(event:MouseEvent):void 
{
    //remove listener for memory management purposes
    myButton.removeEventListener(MouseEvent.CLICK, gotoFrame02);
    //create instance of your next state from the library
    frame2State = new Frame2State();  //assuming that the class name you set for the symbol is Frame2State
    addChild(frame2State);
    //create timeline
    var timeline:TimelineMax = new TimelineMax({onComplete:onTimelineComplete});
    //add button fade down animation
    timeline.append(new TweenMax(myButton,0.4,{alpha:0}));
    //add content fade up animation
    timeline.append(new TweenMax(frame2State,0.4,{alpha:1}));
    timeline.play();
}

function onTimelineComplete():void
{
    //remove button
    removeChild(myButton);
    myButton = null;
}

您可以轻松地从舞台上获取位图数据,并在放入电影剪辑时淡出alpha

这是我制作的github回购协议:

Fade.as,将此文件导入文件夹com中的videogamecheatsultra中,并使用函数
Fade.fadeIntoFrame()
对帧进行淡入淡出:

package com.videogameascheatsultra
{
导入flash.display.Stage;
导入flash.display.BitmapData;
导入flash.display.Bitmap;
导入flash.events.Event;
导入flash.display.MovieClip;
导入flash.display.DisplayObject;
/*
此代码将帧淡入您定义的帧和/或场景。
代码由Cornelia Rose LLC编制(http://www.videogamecheatsultra.com)
此文件不可出售,也不可声称为您的文件或代码。祝您有愉快的一天!
*/
公共类淡出
{
公共静态函数fadeIntoFrame(根、阶段、帧:int、场景:String=null、alphaPerFrame:Number=0.05)
{
变量数据:BitmapData=新的BitmapData(stage.stageWidth,stage.stageHeight,true,0);
数据绘制(阶段);
var stageData:位图=新位图;
stageData.bitmapData=数据;
var stageClip:MovieClip=新的MovieClip();
stageClip.addChild(stageData);
如果(场景!=null)
{
MovieClip(根)、gotoAndStop(帧、场景);
}否则
{
MovieClip(根)、gotoAndStop(帧);
}
stageClip.x=0;
stageClip.y=0;
stage.addChild(stageClip);
var highIndex:int=stage.getChildIndex(stage.getChildAt(stage.numChildren-1));
stage.setChildIndex(stageClip,highIndex);
stageClip.addEventListener(Event.ENTER_FRAME,fadeTo);
功能fadeTo(e:事件)
{
e、 currentTarget.alpha-=alphaPerFrame;

如果(e.currentTarget.alpha,您可以轻松地从舞台上获取位图数据,并在放入电影剪辑时将alpha淡出

这是我制作的github回购协议:

Fade.as,将此文件导入文件夹com中的videogamecheatsultra中,并使用函数
Fade.fadeIntoFrame()
对帧进行淡入淡出:

package com.videogameascheatsultra
{
导入flash.display.Stage;
导入flash.display.BitmapData;
导入flash.display.Bitmap;
导入flash.events.Event;
导入flash.display.MovieClip;
导入flash.display.DisplayObject;
/*
此代码将帧淡入您定义的帧和/或场景。
代码由Cornelia Rose LLC编制(http://www.videoga