了解 Flex 应用程序和框架
在好奇心的驱使下,我试图了解 Flex 应用程序使用的生命周期。
所以,我对这个论点做了一些研究; FlashPlayer 中使用的两个关键概念是:
- SWF 帧:它是包含图形代码和代码的逻辑单元
- Flash Player 帧:它是 Flash 运行时用于更新屏幕的时间间隔,由 frameRate 属性定义
如果是这样,您可以吗解释一下这两个概念之间的关系?特别是,它们是否配对在一起?
主要规则是:Flash Player 在 swf 中进行流传输;在读取完整的 SWF 帧之前,Flash Player 无法渲染它。
我将尝试解释我需要理解的内容。为了简单起见,假设您有一个两帧应用程序:SWF FR 1 和 SWF FR 2。
一般情况下(例如在 CS4 中),帧被视为逻辑单元(由 ShowFrame 标记分隔),您可以在其中附加 as3 代码。这是 swf 文件的简化版本,我认为:
- 标头 // 帧速率在这里定义
- 符号、类等… // 这是 FR1 === ShowFrame ===
- 符号、类等… // 这是 FR2 === 显示框架 === 结束
如果有两个帧,FR1 和 FR2,Flash 开始执行 FR1 并转到下一个帧 (FR2)。如果不停止执行,播放器将通过无限循环执行并渲染 FR1 和 FR2 中包含的代码。相反,当您停止执行时(例如在 FR2 中),Flash 播放器将循环执行 FR2 中包含的代码。
那么,Flash Player 帧是否可以在每个 SWF 帧中出现多次?
FR1下载时(FR1未完全加载)是否有enterFrame事件?当 FR1 完全加载时,第一个frameEvent 是否发生? FR1 在什么时间段内呈现? 另一种情况,如果您在 FR1 中调用了 stop 命令,您将以您指定的速率获得 EnterFrame(当前帧是 FR1)。同时 FR2 正在下载。完成后,您将转到下一帧 (FR2)。 FR2 在什么时间段内渲染? Flash Player 是否尝试将 FR2 渲染到下一个时间间隔?
考虑这个简单的序列:
- FR1 正在下载
- FR1 已完全下载
- FR1 调用 stop() 方法,同时 FR2 正在下载
- FR2 已完全下载
- 转到 FR2
- FR2 调用 stop() 方法
- 依此
类推 当 Flash Player EnterFrame 时,您能帮我划下划线吗事件发生?
感谢您抽出时间。谨致问候,Flex_Addicted。
Driven on by curiosity, I’m trying to understand the Life Cycle used by Flex Application.
So, I’ve done a little research on this argument; the two key concepts used into the FlashPlayer are:
- SWF Frame: it’s the logical unit that contains graphical code and as code
- Flash Player Frame: it’s the time interval used by Flash runtime to update the screen and defined by frameRate property
If so, could you explain me the relationship bewteen these two concepts? In particular, are they paired togheter or not?
The main rule is: the Flash Player streams in a swf; until a full SWF Frame is read, the Flash Player cannot render it.
I’ll try to explain what I need to understand. For the sake of simplicity, suppose you have a two frame application: SWF FR 1 and SWF FR 2.
In general (for example in CS4) a frame is considered as a logical unit (delimited by ShowFrame tag) where you can attach as3 code. This as a simplified version of a swf file, i think:
- Header // frameRate is defined here
- Symbols, classes etc… // this is FR1
=== ShowFrame === - Symbols, classes etc… // this is FR2
=== ShowFrame ===
End
If you have two frame, FR1 and FR2, Flash starts executing FR1 and goes to the next one (FR2). If you don’t stop the excution, the Player executes and renderes code contained into FR1 and FR2 through an infinite loop. On the contrary, when you stop the execution, for example in FR2, the flash player loops executing code contained in FR2.
So, can Flash Player Frames took place many times per SWF Frame?
When FR1 is downloading (FR1 is not fully loaded) is there any enterFrame events or not? Does the first frameEvent take place when the FR1 is fully loaded? During what period of time is FR1 rendered?
An other scenario, if you have called the stop command into FR1, you will get enterFrame at the rate you specify (the current frame is FR1). Meanwhile FR2 is downloading. When it’s finished, you go to the next frame (FR2). During what period of time is FR2 rendered? Does Flash Player try to render FR2 to its next time interval?
Take in account this simple sequence:
- FR1 is downloading
- FR1 is fully downloaded
- FR1 calls stop() method, meanwhile FR2 is downloading
- FR2 is fully downloaded
- Go to FR2
- FR2 calls stop() method
- And so on
Could you underscore for me when Flash Player enterFrame events take place?
Thank you for your time. Best regards, Flex_Addicted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尽管看起来您确实一直在调查事情,但您的一些假设是不正确的。
Flex 是一种编写到一个漂亮框架中的 Flash 代码。因此,一切都归结为帧,这些帧是代码执行和代码执行结果、渲染的混合体。当所有必需的代码都已执行并且渲染过程完成时,该帧就完成了,Flash 播放器将移至下一帧。
那么你的 EnterFrame 就会被调用。
现在,Flex 开发人员通常不会监听 EnterFrame 事件。
要理解 Flex 应用程序,您只需将它们视为 Flash 应用程序,第一帧是加载帧,第二帧是应用程序。构成所有其余帧的是子部分及其各自的时间线。这个概念肯定会让人们感到困惑,因为他们认为 EnterFrame 应该只被调用两次,但事实并非如此。
许多人的下一个错误假设是,仅仅因为“没有代码正在执行”,框架就没有被调用。事实也并非如此。仅仅因为某些内容没有改变并不意味着帧没有被调用,并且 - 如果没有适当的检查 - 大量的处理不会发生。
华泰
Though it looks like you have definitely been looking into things, some of your assumptions are incorrect.
Flex is Flash code written up into one pretty framework. So everything comes down to frames which are a mixture of code executing and the results of that code executing, rendering. When all the required code has executed and the rendering process is complete, the frame is complete and the flash player moves on to the next frame.
So then your enterFrame is called.
Now it isn't typical as a Flex developer to be listening for the enterFrame event.
To understand Flex Apps, you just need to think that they are Flash apps, with the first frame being a loading frame, and the second being the app. It is the subparts and their individual timelines that make up all the rest of the frames. This concept definitely confuses people because then they believe that the enterFrame should only be called twice, this isn't the case.
The next wrong assumption many people has is that just because "no code is executing" that the frames aren't still being called. This also isn't the case. Just because something isn't changing doesn't mean that frames aren't being called and - without the appropriate checks - large amounts of processing aren't happening.
HTH