Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.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 Flash AS3:根据当前帧更改变量_Actionscript 3_Flash_Variables_Actionscript_Charts - Fatal编程技术网

Actionscript 3 Flash AS3:根据当前帧更改变量

Actionscript 3 Flash AS3:根据当前帧更改变量,actionscript-3,flash,variables,actionscript,charts,Actionscript 3,Flash,Variables,Actionscript,Charts,好的,我有这个代码,它创建了一个饼图 package { import flash.display.Sprite; import flash.display.MovieClip; public class App extends MovieClip { function App() { this.graphics.lineStyle(3, 0xFF0000); this.graphics.beginFill(0xFF0000, 0.5);

好的,我有这个代码,它创建了一个饼图

package {
import flash.display.Sprite;
import flash.display.MovieClip; 

public class App extends MovieClip {
    function App() {
        this.graphics.lineStyle(3, 0xFF0000);
        this.graphics.beginFill(0xFF0000, 0.5);
        this.drawSegment(this, stage.stageWidth/2, stage.stageHeight/2, piesize, -90, 0);
        this.drawSegment(this, stage.stageWidth/2, stage.stageHeight/2, piesize, 0, 110);
        this.drawSegment(this, stage.stageWidth/2, stage.stageHeight/2, piesize, 110, 180);
        this.drawSegment(this, stage.stageWidth/2, stage.stageHeight/2, piesize, 180, 270);
        this.graphics.endFill();
    }


var piesize:Number = 140;   

    var wedge1:Number = 90;
    var wedge2:Number = 110;
    var wedge3:Number = 90;
    var wedge4:Number = 90;


    /**
     * Draw a segment of a circle
     * @param target    <Sprite> The object we want to draw into
     * @param x         <Number> The x-coordinate of the origin of the segment
     * @param y         <Number> The y-coordinate of the origin of the segment
     * @param r         <Number> The radius of the segment
     * @param aStart    <Number> The starting angle (degrees) of the segment (0 = East)
     * @param aEnd      <Number> The ending angle (degrees) of the segment (0 = East)
     * @param step      <Number=1> The number of degrees between each point on the segment's circumference
     */
    function drawSegment(target:Sprite, x:Number, y:Number, r:Number, aStart:Number, aEnd:Number, step:Number = 1):void {
            // More efficient to work in radians
            var degreesPerRadian:Number = Math.PI / 180;
            aStart *= degreesPerRadian;
            aEnd *= degreesPerRadian;
            step *= degreesPerRadian;

            // Draw the segment
            target.graphics.moveTo(x, y);
            for (var theta:Number = aStart; theta < aEnd; theta += Math.min(step, aEnd - theta)) {
                target.graphics.lineTo(x + r * Math.cos(theta), y + r * Math.sin(theta));
            }
            target.graphics.lineTo(x + r * Math.cos(aEnd), y + r * Math.sin(aEnd));
            target.graphics.lineTo(x, y);
    };
}
}
我希望这是有意义的,我基本上是试图实现饼图分段和大小的变化,因为我向前或向后移动通过时间。变量存在,但我似乎无法从文件外部更改它们

我应该使用输入框还是什么的


感谢您的帮助,很抱歉问了这么长的问题

假设您发布的类是您的文档类,您只需将变量公开即可:


然后在主时间线上,您可以按名称访问它们,就像在伪代码中一样。

谢谢。现在,我已经在动画的第2帧和第4帧上更改了变量。然而,我一直缺少的是在enter frame上创建饼图。我尝试在“函数应用程序”周围添加ENTER_FRAME侦听器,但每次都因为某些内容未定义而出现错误。我知道这个阶段还没有定义,但我不知道如何定义它,或者如何定义将这个行动付诸实施的东西!我是stuckstage,在将内容添加到显示列表时自动定义。你可以在活动中收听它。添加到舞台活动。如果你还有问题的话,我明天可以帮你更多的忙。好吧,我现在每一帧都画一个饼图,所以“饼图大小”会影响它的大小。我没有意识到的是,精灵不会消失,所以我有数百个饼图加载在彼此的顶部,这创造了一些奇怪的结果。。。现在我只需要知道如何在卸下之前的皮卡,我在路上…如果你明天能帮我,那就太棒了,我可以为你的时间付钱。我现在给你留言。谢谢,看来我不能给你发信息,如果你能把你的联系人发给gogeye.com的pete,我将不胜感激。感谢您无需直接发送信息或付款。你是在同一个精灵上画饼图,还是每次都画一个新精灵?您是否可以更新您的问题,使其包含用于创建新饼图的代码?在伪代码中,您可以将其绘制到文档类中。
wedge1start == -90
wedge1end == wedge1start + wedge1
wedge2end == wedge1end + wedge2
wedge3end == wedge2end + wedge3
wedge4end == wedge2end + wedge4


this.drawSegment(this, stage.stageWidth/2, stage.stageHeight/2, piesize, wedge1start, wedge1end);
this.drawSegment(this, stage.stageWidth/2, stage.stageHeight/2, piesize, wedge1end, wedge2end);
this.drawSegment(this, stage.stageWidth/2, stage.stageHeight/2, piesize, wedge2end, wedge3end);
this.drawSegment(this, stage.stageWidth/2, stage.stageHeight/2, piesize, wedge3end, wedge4end);
public var wedge1:Number = 0;