简单的 AddChild 问题

发布于 2024-09-13 11:37:48 字数 549 浏览 1 评论 0原文

我正在检查这个人的代码... http://www.codingcolor.com/as3/as3-youtube-chromless -api/

我已经下载了源代码...但我不明白他是如何在舞台上添加播放、暂停和停止按钮的。我知道在他的VideoPlayerControl.as中,他在

playbackControl = new PlayPauseButton();
playbackControl.addEventListener(Event.CHANGE,setPlaybackState);
addChild(playbackControl); 

他的PlayPauseButton.as中。没有按钮位置的代码(x,y).. 我不确定他如何放置控制按钮...

另外...是否有办法以面向对象的方式给出按钮位置,而不是用静态数字指定它???

我很感激任何帮助...

I am checking this guy's code...
http://www.codingcolor.com/as3/as3-youtube-chromless-api/

I have download the source code...but I couldn't figure out how he add the play, pause and stop button in the stage. I know in his VideoPlayerControl.as, he has

playbackControl = new PlayPauseButton();
playbackControl.addEventListener(Event.CHANGE,setPlaybackState);
addChild(playbackControl); 

in his PlayPauseButton.as. there is not code for the location of the button(x,y)..
I am not sure how he place the control buttons....

Also...Are there anyways to give the button location with object oriented way instead of specify it with static number???

I appreciate any help...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╰沐子 2024-09-20 11:37:48

不检查他的代码...

听起来您需要阅读 Flex 组件生命周期

正常情况下,PlayPauseButton 将在 createChildren() 中创建并添加。

updateDisplayList() 方法将定位元素并调整其大小。此外,许多组件实现了一个measure()方法来确定它的理想大小。许多容器都有代码来自动布局子容器。如果 PlayPauseButton 有一个测量方法并且将其添加到容器(例如 VBox 的 HBox)中,则他不需要代码来定位或调整按钮的大小,因为该工作已经在他从 Flex 框架继承的代码中完成。

Without reviewing his code...

it sounds like you need to read up on the Flex Component Lifecycle.

In normal cases, the PlayPauseButton will be created and added in createChildren().

the updateDisplayList() method will position and size the elements. Additionally, many components implement a measure() method that will determine the ideal size for it. And many containers have code to automatically lay out the children. If the PlayPauseButton has a measure method and it is added to a container (such as an HBox of VBox) he won't need code to position or size the button as that wrk is already done in the code that he inherits from the Flex framework.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文