简体   繁体   English

了解Flex应用程序和框架

[英]Understand Flex Application and Frames

Driven on by curiosity, I'm trying to understand the Life Cycle used by Flex Application. 在好奇心驱使下,我试图了解Flex应用程序使用的生命周期。

So, I've done a little research on this argument; 因此,我对这一论点做了一些研究。 the two key concepts used into the FlashPlayer are: FlashPlayer中使用的两个关键概念是:

  • SWF Frame: it's the logical unit that contains graphical code and as code SWF框架:它是包含图形代码和as代码的逻辑单元
  • Flash Player Frame: it's the time interval used by Flash runtime to update the screen and defined by frameRate property Flash Player帧:这是Flash运行时用来更新屏幕并由frameRate属性定义的时间间隔

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; 主要规则是:Flash Player以swf流式传输; until a full SWF Frame is read, the Flash Player cannot render it. 在读取完整的SWF帧之前,Flash Player无法渲染它。

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. 为简单起见,假设您有两个框架应用程序:SWF FR 1和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. 通常,例如在CS4中,帧被视为逻辑单元(由ShowFrame标记分隔),您可以在其中附加as3代码。 This as a simplified version of a swf file, i think: 我认为这是swf文件的简化版本:

  • Header // frameRate is defined here 标头// frameRate在此处定义
  • Symbols, classes etc… // this is FR1 === ShowFrame === 符号,类等…//这是FR1 === ShowFrame ===
  • Symbols, classes etc… // this is FR2 === ShowFrame === End 符号,类等…//这是FR2 === ShowFrame ===结束

If you have two frame, FR1 and FR2, Flash starts executing FR1 and goes to the next one (FR2). 如果有两帧FR1和FR2,则Flash开始执行FR1,然后转到下一帧(FR2)。 If you don't stop the excution, the Player executes and renderes code contained into FR1 and FR2 through an infinite loop. 如果不停止执行,播放器将通过无限循环执行并渲染FR1和FR2中包含的代码。 On the contrary, when you stop the execution, for example in FR2, the flash player loops executing code contained in FR2. 相反,例如在FR2中停止执行时,Flash Player会循环执行FR2中包含的代码。

So, can Flash Player Frames took place many times per SWF Frame? 那么,每个SWF框架能否多次播放Flash Player框架?

When FR1 is downloading (FR1 is not fully loaded) is there any enterFrame events or not? 当FR1正在下载(FR1未完全加载)时,是否有enterFrame事件? Does the first frameEvent take place when the FR1 is fully loaded? FR1完全加载时,是否发生第一个frameEvent? During what period of time is FR1 rendered? FR1在什么时间渲染? 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). 另一种情况,如果您在FR1中调用了stop命令,则将以您指定的速率获得enterFrame(当前帧为FR1)。 Meanwhile FR2 is downloading. 同时FR2正在下载。 When it's finished, you go to the next frame (FR2). 完成后,您将转到下一帧(FR2)。 During what period of time is FR2 rendered? FR2在什么时间渲染? Does Flash Player try to render FR2 to its next time interval? Flash Player是否尝试将FR2渲染到下一个时间间隔?

Take in account this simple sequence: 考虑以下简单顺序:

  1. FR1 is downloading FR1正在下载
  2. FR1 is fully downloaded FR1已完全下载
  3. FR1 calls stop() method, meanwhile FR2 is downloading FR1调用stop()方法,与此同时FR2正在下载
  4. FR2 is fully downloaded FR2已完全下载
  5. Go to FR2 转到FR2
  6. FR2 calls stop() method FR2调用stop()方法
  7. And so on 等等

Could you underscore for me when Flash Player enterFrame events take place? Flash Player enterFrame事件发生时,您能为我强调一下吗?

Thank you for your time. 感谢您的时间。 Best regards, Flex_Addicted. 最好的问候,Flex_Addicted。

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. Flex是将Flash代码编写到一个漂亮的框架中。 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. 当所有必需的代码都已执行并且渲染过程完成时,该框架就完成了,Flash Player继续进行下一个框架。

So then your enterFrame is called. 因此,您的enterFrame被调用。

Now it isn't typical as a Flex developer to be listening for the enterFrame event. 现在,作为Flex开发人员来侦听enterFrame事件已经不是通常的事了。

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. 要了解Flex Apps,您只需要认为它们是Flash应用程序,第一帧是加载框架,第二帧是该应用程序。 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. 这个概念肯定使人感到困惑,因为然后他们认为enterFrame应该只被调用两次,事实并非如此。

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 高温超导

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM