English 中文(简体)
Understand Flex Application and Frames
原标题:

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:

  1. FR1 is downloading
  2. FR1 is fully downloaded
  3. FR1 calls stop() method, meanwhile FR2 is downloading
  4. FR2 is fully downloaded
  5. Go to FR2
  6. FR2 calls stop() method
  7. And so on

Could you underscore for me when Flash Player enterFrame events take place?

Thank you for your time. Best regards, 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. 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

问题回答

暂无回答




相关问题
Disable button tooltip in AS3

I want to disable the tooltip on certain buttons. The tooltip manager seems to be an all or nothing solution. Is it possible to disable the tooltip for just one or two buttons?

Multiple Remote call made simultenously

I was making multiple remote calls and they are done sequentially and when I am getting a result event back it s triggering calls to all the methods with ResultEvent as an argument . I am supposed to ...

Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

Clearing RSL in Cache

I have built a flex application which has a "main" project and it is assosciated with a few RSL s which are loaded and cached once i run my "main" application. The problem i am facing is that the ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

热门标签