2014-09-11 85 views
-1

闪存说,代码是我的第二个行,但我已经做了一些阅读,它说这个错误主要是由于我试图将值赋给一个值,我回顾了我的代码,我似乎无法找到任何此类实例。错误1105:分配的目标必须是一个参考值

这里是我的代码:

this.mc=new MovieClip(); 
addChild(mc)=("myButton1", this.DisplayOBjectContainer.numChildren()); 
myButton1.createEmptyMovieClip("buttonBkg", myButton1.getNextHighestDepth()); 

myButton1.buttonBkg.lineStyle(0, 0x820F26, 60, true, "none", "square", "round"); 
myButton1.buttonBkg.lineTo(120, 0); 
myButton1.buttonBkg.lineTo(120, 30); 
myButton1.buttonBkg.lineTo(0, 30); 
myButton1.buttonBkg.lineTo(0, 0); 

谢谢!

+1

这不是一个真正的代码,因为它混合了AS3和AS2。 – BotMaster 2014-09-11 11:09:06

回答

0

检查你正在试图在这些行的内容:

addChild(mc)=("myButton1", this.DisplayOBjectContainer.numChildren()); 
myButton1.createEmptyMovieClip("buttonBkg", myButton1.getNextHighestDepth()); 

要创建一个空的影片剪辑,你可以创建一个新的显示对象W/O它在这样的库链接到剪辑:

addChild(mc); 
var myButton1:MovieClip = new MovieClip(); // creates an empty MovieClip 
addChildAt(myButton1, numChildren); // adds the MovieClip at a defined level (on this case, the numChildren added on stage 
+0

我试图用名称'myButton1'创建一个新的影片剪辑并告诉它去到下一个最大深度 – 15leungjs1 2014-09-11 06:54:10

0

您的代码非常混乱。将AS2方法(createEmptyMovieClip,getNextHighestDepth)与AS3方法(addChild)混合使用。这里是你正在尝试做的:

const MC:Sprite = new Sprite(); // Sprite container 
this.addChild(MC); 

const MYBUTTON1:Sprite = new Sprite(); // button in container 
MC.addChild(MYBUTTON1); 

const BUTTONBKG:Shape = new Shape(); // background in button 
MYBUTTON1.addChild(BUTTONBKG); 
const BTG:* = BUTTONBKG.graphics; 

BTG.beginFill(0x86B1FB); 
BTG.lineStyle(0, 0x820F26, 0.6, true, "none", "square", "round"); 
BTG.lineTo(120, 0); 
BTG.lineTo(120, 30); 
BTG.lineTo(0, 30); 
BTG.lineTo(0, 0); 

MYBUTTON1.addEventListener(MouseEvent.CLICK, pressButton); 

function pressButton(e:MouseEvent):void { 
    trace('I click on you'); 
} 

注意:在AS3的alpha值为0和1之间。如果你希望你的按钮可以点击,你应该使用的beginFill方法。

相关问题