2014-09-11 84 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方法。

相關問題