Actionscript 3 Actionscript 3.0问题-为什么即使在I';你重新检查过代码了吗?

Actionscript 3 Actionscript 3.0问题-为什么即使在I';你重新检查过代码了吗?,actionscript-3,Actionscript 3,我正在使用AdobeFlashCS4Professional来完成这个ActionScript3.0项目 () 我甚至试着按照评论中的建议做,但这个错误总是出现: TypeError:Error#1010:术语未定义且没有属性。 在旋转菜单\u fla::MainTimeline/frame1()处 (有关完整的详细信息,请单击链接-) 我一直在遵循教程的每一步,但我对编码感到困惑。。。 顺便说一下,这是代码 //Save the center coordinates of the stage

我正在使用AdobeFlashCS4Professional来完成这个ActionScript3.0项目 ()

我甚至试着按照评论中的建议做,但这个错误总是出现: TypeError:Error#1010:术语未定义且没有属性。 在旋转菜单\u fla::MainTimeline/frame1()处 (有关完整的详细信息,请单击链接-)

我一直在遵循教程的每一步,但我对编码感到困惑。。。 顺便说一下,这是代码

//Save the center coordinates of the stage
var centerX:Number=stage.stageWidth/2;
var centerY:Number=stage.stageHeight/2;
 //The number of items we will have (feel free to change!)
var NUMBER_OF_ITEMS:uint=5;
 //Radius of the menu circle (horizontal and vertical)
var radiusX:Number=200;
var radiusY:Number=100;
 //Angle difference between the items (in radians)
var angleDifference:Number = Math.PI * (360 / NUMBER_OF_ITEMS) / 180;
 //How fast a single circle moves (we calculate the speed
//according to the mouse position later on...)
var angleSpeed:Number=0;
 //Scaling speed of a single circle
var scaleSpeed:Number=0.0002;
 //This vector holds all the items
//(this could also be an array...)
var itemVector:Array = new Array ('1', '2', '3', '4','5');
 //This loop creates the items and positions them
//on the stage
for (var i:uint = 0; i < NUMBER_OF_ITEMS; i++) {
    //Create a new menu item
    var item:Item = new Item();
    //Get the angle for the item (we space the items evenly)
    var startingAngle:Number=angleDifference*i;
    //Set the x and y coordinates
    item.x=centerX+radiusX*Math.cos(startingAngle);
    item.y=centerY+radiusY*Math.sin(startingAngle);
    //Save the starting angle of the item.
    //(We have declared the Item class to be dynamic. Therefore,
    //we can create new properties dynamically.)
    item.angle=startingAngle;
    //Add an item number to the item's text field
    item.itemText.text=i.toString();
    //Allow no mouse children
    item.mouseChildren=false;
    //Add the item to the vector
    itemVector.push(item);
    //Add the item to the stage
    addChild(item);
}
 //We use ENTER_FRAME to animate the items
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
 //This function is called in each frame
function enterFrameHandler(e:Event):void {
    //Calculate the angle speed according to mouse position
    angleSpeed = -(mouseX - centerX) / 5000;
    //Loop through the vector
    for (var i:uint = 0; i < NUMBER_OF_ITEMS; i++) {
        //Save the item to a local variable
        var item:Item=itemVector[i];
        //Update the angle
        item.angle+=angleSpeed;
        //Set the new coordinates
        item.x=centerX+radiusX*Math.cos(item.angle);
        item.y=centerY+radiusY*Math.sin(item.angle);
        //Calculate the vertical distance from centerY to the item
        var dy:Number=centerY-item.y;
        //Scale the item according to vertical distance
        item.scaleY = (dy / radiusY)+2;
        //Set the x scale to be the same as y scale
        item.scaleX=item.scaleY;
        //Adjust the alpha according to y scale
        item.alpha=item.scaleY+1.1;
    }
}
我本可以提供更多的屏幕截图,但由于我是一个新用户,我最多只能使用两个屏幕截图——与此标签相反,我没有使用Android应用程序。 (一旦你们中的任何人回答这个问题,我会给你们补充信息…)

我必须承认,第三步到第六步让人困惑,对我来说没有意义——尤其是第六步,当你不得不从舞台上移除电影剪辑时。对我来说,如果我要这么做,那么脚本会做什么呢

知道我做错了什么吗

编辑: 谢谢,我意识到了我的错误-谢谢你的提示:-)

但是现在,我试着修改一下本教程的代码,让单词出现在圆圈内(如“Home”、“About”等),就像我在Screenshot中键入的一样-

但是,尽管我相信我做了适当的修改,还是出现了一个错误(请看这里-)


为什么会这样?在我忘记之前,我必须在代码的哪个部分插入一行,使单击的按钮显示与之对应的信息?(也就是说,如果我单击“联系人”或任何按钮,舞台上的菜单下会出现一个窗口…

错误意味着ActionScript不知道项目是什么。确保在库中的项目MovieClip上勾选了Export for ActionScript,并且该类也命名为Item

更新: 下面的教程提到itemVector是项实例的向量,而不是像代码中那样的字符串数组。这就是为什么会在屏幕截图中显示错误。这意味着ActionScript无法将项目转换为字符串。 一个简单的修复方法是为菜单项标签创建另一个数组:

var itemVector:Array = [];// = new Array ('1', '2', '3', '4','5');
var itemLabels:Array = ["Home","About","Contact","Gallery"];
NUMBER_OF_ITEMS = itemLabels.length;
并在for循环中交换this
item.itemText.text=i.toString()tem.itemText.text=itemLabels[i]的代码>

您似乎没有完全理解变量类型之间的差异。我建议在前进之前先熟悉as3的基础知识。此外,更多地关注您的代码并充分理解他人编写的代码将使您避免麻烦。但是,您仍然会遇到错误。您可以在页面上找到这些错误的解释


关于Carosel教程,还可以看看。这可能有助于更好地解释问题。

错误意味着ActionScript不知道项目是什么。确保在库中的项目MovieClip上勾选了Export for ActionScript,并且该类也命名为Item

更新: 下面的教程提到itemVector是项实例的向量,而不是像代码中那样的字符串数组。这就是为什么会在屏幕截图中显示错误。这意味着ActionScript无法将项目转换为字符串。 一个简单的修复方法是为菜单项标签创建另一个数组:

var itemVector:Array = [];// = new Array ('1', '2', '3', '4','5');
var itemLabels:Array = ["Home","About","Contact","Gallery"];
NUMBER_OF_ITEMS = itemLabels.length;
并在for循环中交换this
item.itemText.text=i.toString()tem.itemText.text=itemLabels[i]的代码>

您似乎没有完全理解变量类型之间的差异。我建议在前进之前先熟悉as3的基础知识。此外,更多地关注您的代码并充分理解他人编写的代码将使您避免麻烦。但是,您仍然会遇到错误。您可以在页面上找到这些错误的解释


关于Carosel教程,还可以看看。这可能有助于更好地解释问题。

编译器找不到Item类。
进入您的库并打开“项目”MovieClip的属性。

验证是否设置为导出到actionscript。

编译器找不到Item类。
进入您的库并打开“项目”MovieClip的属性。

验证是否已设置为导出到actionscript。

感谢您的提示-但请参考上面的回复了解其他详细信息-再次遇到新问题…:-(@Flash_-Flea本网站的理念是提出一个问题,得到一个答案,然后接受它。当你修改你的问题并提出另一个问题时,关注你手头的问题变得越来越困难。你需要做的是,如果这里的一个答案有效,那么就接受它,然后继续一个新问题。为你的问题发布一个新的帖子新问题。感谢您的提示-但请参考上面的回复了解其他详细信息-再次遇到新问题…:-(@Flash_-Flea本网站的理念是提出一个问题,得到一个答案,然后接受它。当你修改你的问题并提出另一个问题时,关注你手头的问题变得越来越困难。你需要做的是,如果这里的一个答案有效,那么就接受它,然后继续一个新问题。为你的问题发布一个新的帖子新问题。感谢您的提示-但请参考下面的回复了解其他详细信息-再次遇到新问题…:-(@Flash_flea检查我的最新答案。另外,你的笔记应该是一条评论而不是答案。好吧,我非常想知道我的其他问题-该网站对新注册用户的限制太多了。谢谢你的提示:-)很高兴能解决这个问题。如果你认为有帮助,请随意勾选/接受这个答案;)我想问三件事:1)我注意到你在视频中提到我(仅适用于Flash 8版本-那里的代码也适用于AS3吗