日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java 不执行构造函数_函数作为构造函数执行,但不作为函数执行

發布時間:2023/12/10 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 不执行构造函数_函数作为构造函数执行,但不作为函数执行 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我在displayandmove.as文件中有以下代碼:

package {

import flash.display.MovieClip;

public class FigureConstruct extends MovieClip {

public function displayandmove() {

this.height = stage.stageHeight/5;

this.width = stage.stageWidth/5;

}

}

}

我在displayandmove.fla的第1幀上有以下內容:

var figure:FigureConstruct = new FigureConstruct();

stage.addChild(figure);

figure.x = stage.stageWidth/2;

figure.y = stage.stageHeight/2;

這些文件位于同一目錄中 . 在我的FLA庫中,我有我的數字MovieClip,它有一類“FigureConstruct”和基類“flash.display.MovieClip” .

目前上面的代碼工作正常,因為我發現如果我執行對象大小代碼作為構造 - 使用文件名作為函數名稱 - 它的工作原理 .

我原本打算做的是在我的AS文件中將我的函數命名為“sizeFigure()”,然后調用“figure.sizeFigure();”在“stage.addChild(figure);”之后在我的FLA的第1幀 .

這個輸出

錯誤#1006:值不是函數 .

任何人都可以解釋我缺少什么來讓它作為一個函數而不是作為構造函數執行?

我想也許當我為庫對象設置我的類和基類指針時我會搞砸......但不確定 .

PS - 對不起,如果我濫用條款,仍然在我去的時候把它們釘死 .

Edit: Below is the original code that does not seem to work until after I changed the name of my function to the name of the file, making it the class constructor. The above version works, below does not.

displayandmove.as

package {

import flash.display.MovieClip;

public class FigureConstruct extends MovieClip {

public function sizeFigure() {

this.height = stage.stageHeight/5;

this.width = stage.stageWidth/5;

}

}

}

displayandmove.fla:

var figure:FigureConstruct = new FigureConstruct();

stage.addChild(figure);

figure.sizeFigure();

figure.x = stage.stageWidth/2;

figure.y = stage.stageHeight/2;

總結

以上是生活随笔為你收集整理的java 不执行构造函数_函数作为构造函数执行,但不作为函数执行的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。