"在弦&QUOT丢失; AS3QUOT

2023-09-08 15:33:18 作者:妖精雖美已成妖。

可有人跟着做什么,并告诉我怎么做是正确的?我是新与字符串和数组。任何你可以建议将AP preciated。

Can someone follow what doing, and show me how to do it correctly? I'm new with strings and arrays. Anything you can suggest would be appreciated.

目标 我想脚本调用显示对象的舞台,定时器移动图像上下出现像滚动的数字。我开始变得马虎,扰乱了传递给中间人。

GOAL I want script to calling display objects to the stage, and the timer to move images up and down to appear like a scrolling numbers. I start getting sloppy, and mess up passing to Tweener.

思考 - 解释或策略可能就足够了,我有pretty的关闭就这一个 - 与会者一致认为,容器和addChildren混乱......看起来像阵列的

THOUGHTS - An explanation or strategy may be enough, "I've got pretty close on this one" - There was confusion regarding the Containers and addChildren...looked like arrays

THE code 走得越远误差NumbersView和数量不定等

THE CODE "get as far as error with NumbersView and numbers undefined etc"

 //-------------------------IMPORT METHODS---------------------------------------
        import flash.display.DisplayObject; 
        import flash.display.MovieClip; 
        import flash.utils.Dictionary; 
        import flash.events.Event; 
        import caurina.transitions.Tweener; 

//-----------------------TIMER---------------------------------------       
    var timer:Timer = new Timer(1000);//
    //var timer:Timer;  
    var count:int = 0; 
    var fcount:int = 0; 
    var _listItems:Array = new Array();
    var previousNums:Array;
    const numHeight:int = 120;
    //var numbers:NumbersView;
    timer.addEventListener(TimerEvent.TIMER, incrementCounter);  
    timer.start(); 

//-----------------------COUNTER-CONT-----------------------
    function incrementCounter(event:TimerEvent) {  
      count++;  
      fcount=int(count*count/1000);//starts out slow... then speeds up 
    //  mytext.text = formatCount(fcount);
    NumbersView(1);
    //}

//----------------------ZERO PLACE HOLDERS-----------------------
    }
    function formatCount(i:int):String { 
         var fraction:int = i % 100; 
         var whole:int = i / 100;  
      return ("000000000" + i).substr(-9, 9); 
       // return ("0000000" + whole).substr(-7, 7) + "." + (fraction < 10 ? "0" + fraction : fraction); 
    } 

    //

//----------------------DISPLAY for loop, integer to string "puts numbers on stage"
    function NumbersView($n:int):void {
     //function NumbersView()//
     //{
        _listItems = new Array();
        previousNums = new Array();
        var item:NumberImage;
        var offset:int = _listItems.length;
        //for (var i:int = 0; i < $n; i++)
     for (var i:Number = 0; i < 9; i++)
        {
           item = new NumberImage();
           //item.x = (i + offset) * 9;
           //item.y = (i + offset) * 9;
        item.x = i * item.width; 
           _listItems.push(item); 
           addChild(item);
        }

//----------------------SPLIT STRING "pass to Tweener or some other method"---------------
    //
       function setTime($number:String):void { 
                var nums:Array = $number.split(""); 
                for (var i:Number = 0; i < nums.length; i++) { 
                if (nums[i] == NumbersView[i]) continue; 
                Tweener.removeTweens(NumbersView[i]); 
       }

方法分别证明。 我得到的一个早期版本 文件去,但我需要工作,通过这个来理解它。

The methods were proved separately. "I got a earlier version of the document going, but I need to work through this to understand it."

符号属性 CLASS ImageView的

SYMBOL PROPERTIES CLASS ImageView

中间人 而caurina文件夹必须是present

TWEENER The "caurina" folder needs to be present

轧制数字成功装载数量和连接反击

ROLLING NUMBERS "SUCCESS loading numbers and connecting to counter"

----------------------------------------------- --------------------------------------------- 我就是这样做的得不的榜样 放置在影片剪辑对象在舞台上,在这两个动态文本字段。 注意 确保容器放置台上,具有两个文本个行业中它,并且一切给出一个适当的实例名。还包括caurina文件夹。

-------------------------------------------------------------------------------------------- What I did for Debu's example Placed the movie clip object on stage with two dynamic text fields in it. Note Make sure the container is placed on stage, has the two text fileds in it, and everything is given a proper instance name. Also include the caurina folder.

秒 MovieClip元件用秒实例名称 firstDigit 动态文本firstDigit的实例名,安置在秒域 secondDigit 与secondDigit的实例名称为动态文本字段,放在秒

seconds MovieClip symbol with instance name of seconds firstDigit Dynamic text field with instance name of firstDigit, placed in seconds secondDigit Dynamic text field with instance name of secondDigit, placed in seconds

符号 取消选中为ActionScript导出 使用名称,类别和实例'正确

Symbol Un-tick 'Export for ActionScript' Use 'Name, Class, and Instance' correctly

推荐答案

我已经实现了我相信你试图做一个很简单的例子。它仅包含一个数字,秒,并简单地向上计数到9,然后再返回到0和最多9试。每次我创建Timer对象触发(每1000毫秒,或1),它运行的功能是补间,在新的数字。我已经贴了code以下,并评论各行;让我知道如果你不明白它的任何。

I've implemented a very simple example of what I believe you're trying to do. It only contains one digit, the seconds, and simply counts up to 9, then back to 0 and up to 9 again. Each time the Timer object I've created is fired (every 1000ms, or 1s) it runs a function which tweens in the new digit. I've pasted the code below, and commented each line; let me know if you don't understand any of it.

import caurina.transitions.*;

//Create a timer that will run for 1 second, and repeat
var secondTimer:Timer = new Timer(1000);

//A counter for seconds
var secondsCount:int = 0;

//The original position of the rolling numbers object on the stage
var originalYPosition:Number = 0;
//The position of the rolling numbers object on stage when it's displaying its second digit
var upwardYPosition:Number = -127;
//The speed you want the odometer to roll at. As this is the seconds counter it needs to be less than 1
var rollSpeed:Number = 0.25; //seconds

//Start the timer
secondTimer.start();
//Add an event listener to fire each time it reaches its limit
secondTimer.addEventListener(TimerEvent.TIMER, updateOdometer);

//Add a generic update loop, to test for when the odometer has been moved to its 'up' position
addEventListener(Event.ENTER_FRAME, checkOdometerPosition);

function updateOdometer(event:TimerEvent):void
{
    //When the timer fires, check if secondsCount is less than 9; if it is, increment secondsCount
    if (secondsCount < 9)
    {
        secondsCount++;
    }
    else 
    {
        //Otherwise set secondsCount to 0, so the odometer will loop from 9 back to 0
        secondsCount = 0;
    }

    //Set the text inside seconds > secondDigit equal to the next digit it needs to display.
    seconds.secondDigit.text = secondsCount.toString();

    //Do the tween, so that the secondDigit changed above will become visible
    Tweener.addTween(seconds, { y: upwardYPosition, time: rollSpeed, transition:"easeOutQuad" } );
}

//This function runs all the time, to check when the rolling object has moved upwards
function checkOdometerPosition(event:Event):void
{
    //Do the check to see if it's in its upward position..
    if (seconds.y <= upwardYPosition)
    {
        //If it is, make the first digit equal to the current second digit
        seconds.firstDigit.text = secondsCount.toString();
        //Then move the odometer back into its original position..
        seconds.y = originalYPosition;

        //This is so that the odometer is ready to be moved upwards again when the timer fires again.
    }
}

这一切,code要求是在里面坐了两个动态文本域的舞台简单的MovieClip对象;其中一条进行放置恰好低于其他。我命名包含对象'秒',最上面的文本字段'firstDigit,底部文本字段secondDigit。一个Flash文档中重新创建它,将它保存(确保隆突是在同一文件夹),粘贴code在第1帧,它应该工作的罚款。 编辑:我创建了一个图像来说明如何对象应你的根里面的结构:的

呵呵,并作为该专家谁告诉你引用自己,他不听起来像这样的专家我;!)无论如何,希望它有助于

Oh, and as for that expert who told you to quote yourself, he doesn't sound like such an expert to me ;) Anyway, hope it helps!