Home > Adobe Flex > Flex Sub-applications, Sandboxes & SWFLoader (Part 1)

Flex Sub-applications, Sandboxes & SWFLoader (Part 1)

A few months ago, I embarked on a project for 24 Hour Fitness that involved something I had only heard about at the 2008 Adobe MAX conference in San Francisco – “flex sub-applications”. There, I attended a lecture by Alex Harui on Flex Framework Features to Support Large Applications (listen to the lecture here on Adobe TV). I must admit the lecture had probably put many to sleep, but I was fascinated by the concept and to this day (granted, MAX was just a few months ago) I believe this will become a very important topic to many as the complexity and possibilities available in large-scale Adobe Flex applications becomes ever apparent.

For this reason, I appended a “Part 1″ to the title of this article as I don’t know if I can squeeze my experience with sub-applications into just one writing and I certainly plan in the coming months to venture even farther into these murky waters.

I think Alex’s main point behind his lecture was to unveil the new Marshall Plan bundled with Flex 3.2 (released during MAX). But before I can describe what the Marshall Plan is, it’s important to know why it came about.

Most applications you’ll ever build in Flex are probably on the smaller scale, ranging from anywhere between a few hundred kilobytes (final SWF size) to several megabytes of compiled Flex code (including the Flex framework). This doesn’t include embedded images or other assets which could dramatically increase that size (I typically try very hard NOT to embed assets to keep the final SWF as lean as possible). Some applications could be significantly larger, spanning hundreds or thousands of commands (if you use Cairngorm or other such MVC architecture), classes and MXML.

It’s always very important to understand that the entire application frame of your final SWF will be downloaded to the client in one shot. This could be a lengthy wait for some and the solution has always been to break up that large application into pieces, or “modules” that could be loaded and unloaded during runtime.

The possibility of caching some code in the client’s Flash Player for re-use by other applications was also created by using Runtime Shared Libraries (RSL’s). But because of “full class integration” (the ability to reference classes in the RSL by classname), the RSL must be compiled with the same version of Flex as the main application. RSL’s also have the disadvantage of not being unloadable. Once an RSL has been loaded at the onset of application startup, it’s there to stay.

Modules are another example of re-using functionality. Modules are collections of classes compiled into a SWF and are loaded by ModuleLoader. Classes in modules are not directly referenced by the main application. Instead both refer to a shared interface (IDataGrid, for example). This is called “partial class integration”. Modules can also be unloaded and removed from memory. Unfortunately because the main application and module share at least some assets, modules, too must be compiled by the same version of Flex as the main application.

Which brings us to a new concept called “sub-applications”, released as a part of Flex 3.2 in November, 2008 at Adobe’s MAX conference in San Francisco. Sub-applications have NO class integration, which is needed to support multi-versioning .

Sub-applications are completely individual, separate applications (identified by the root tag), compiled into a SWF that is loaded by a parent application through the SWFLoader component (you can also use Loader and added the loader object as a child to SWFLoader).

Previously, Flex 2 also supported the concept of sub-applications in that you could use SWFLoader to load another SWF application. You could even access properties in the sub-application from the main application using the SystemManager class. Unfortunately, Flex 2 was only able to load the sub-application into the same “SecurityDomain” (or sandbox) as the parent application. By playing in the same sandbox, the sub-application could have unrestricted access to variables in the main application…an unwanted side-effect especially if the sub-app is untrusted (say, written by a third-party).

With Flex 3.2, you have a little more control over how the sub-application SWF is loaded, primarily through two properties of SWFLoader. One is trustContent (which existed in Flex 2) and the other is loadForCompatibility (new as of Flex 3.2). And the changes in the Flex source code revolving around the new loadForCompatibility feature really serve as the basis for the new Marshall Plan.

The trustContent property specifies whether the sub-application is loaded into the same SecurityDomain as the host. This property is defaulted to false, which means SWF content loaded from separate domains (xyz.com instead of abc.com) will load without error if the separate domain does not have a crossdomain.xml policy file declaring that your domain has rights to access its content. This is preferred behavior, however your parent application would not be able to access the SWF content (via SWFLoader.content). This property is directly tied to the SWFLoader.loaderContext.securityDomain property and can also be set manually via ActionScript.

Setting trustContent to true is equivalent to copying the loaded SWF to your own server and loading it from there. This is one way to get around any security sandbox restrictions you might experience, however I also noticed that it also can cause other complications, most notably with singleton’s like Cairngorm’s ServiceLocator (which I’ll discuss in a later post).

The loadForCompatibility property specifies whether the sub-application is loaded into a peer ApplicationDomain as the parent (when set to true), or into a child ApplicationDomain (when set to false). This flag only pertains to applications loaded within the same SecurityDomain (if trustContent == true).

Child ApplicationDomains inherit classes from the parent (like UIComponent, Container, etc). This can cause obvious problems if both applications were compiled with different versions of Flex. A child sub-application written in Flex 3.2 may not wish to inherit the UIComponent definition of its parent application that was written in Flex 4. The loadForCompatibility flag forces SWFLoader to load the sub-application into a separate ApplicationDomain (when true) which keeps the definitions for these classes separate. This is most needed for multi-versioned applications. This flag should only be set to true if you know both applications will always be compiled with the same version of Flex.

In my next article, I’ll discuss some of the pitfalls I ran into with sub-applications and specifically, Cairngorm-based sub-applications. Stay tuned!

Categories: Adobe Flex Tags:
  1. October 12th, 2024 at 02:55 | #1
  2. October 12th, 2024 at 04:10 | #2
  3. October 12th, 2024 at 06:37 | #3
  4. October 13th, 2024 at 00:52 | #4
  5. October 13th, 2024 at 02:15 | #5
  6. October 13th, 2024 at 16:05 | #6

    I wanted to thank you for this fantastic read!! I absolutely enjoyed every little bit of it. I have you bookmarked to check out new things you post…

  7. October 14th, 2024 at 00:12 | #7

    This is a good tip particularly to those fresh to the blogosphere. Short but very accurate information… Thank you for sharing this one. A must read post!

  8. October 16th, 2024 at 21:15 | #9

    Casino’da bahis seçeneklerinin çeşitliliği sayesinde her oyunda farklı stratejiler deneyebiliyorum.

  9. October 17th, 2024 at 04:41 | #10

    Bahis siteleri deneme bonusu ile bedava bahis yaparak kazanmaya başlamak çok kolay!

  10. October 19th, 2024 at 14:46 | #11

    Casino’nun sunduğu turnuvalar ile ekstra kazançlar kazanmak çok eğlenceli ve kazançlı!

  11. October 21st, 2024 at 07:08 | #12

    Bu casino’da oynadığım futbol bahisleri ile her maçtan kazanç elde ediyorum!

  12. October 22nd, 2024 at 13:24 | #13

    Bu casino’nun sunduğu slot turnuvaları sayesinde kazançlarım sürekli artıyor.

  13. October 23rd, 2024 at 07:11 | #14

    Encore merci pour ce post et continuez votre excellent travail. ??

  14. October 23rd, 2024 at 10:58 | #15

    Ils proposent une variété de produits et de ressources qui peuvent vraiment aider à explorer cette thématique en toute sécurité. Ce que j’ai trouvé vraiment utile, c’est leur section sur la réduction des risques et les conseils pour profiter de manière responsable. Ça pourrait être un bon complément à cet article !

  15. October 23rd, 2024 at 16:56 | #16

    En sevdiğim slot oyunu Book of Shadows, her spin büyük bir kazanç şansı sunuyor.

  16. October 23rd, 2024 at 21:42 | #17

    Encore merci pour ce post et continuez votre excellent travail. ??

  17. October 25th, 2024 at 06:19 | #18

    Encore merci pour ce post et continuez votre excellent travail. ??

  18. October 26th, 2024 at 00:52 | #19

    I blog quite often and I seriously appreciate your information. This great article has truly peaked my interest. I will take a note of your blog and keep checking for new information about once a week. I opted in for your Feed too.

  19. October 26th, 2024 at 05:06 | #20

    Slot oyunlarında her spin heyecan verici, bu casino tam bir eğlence merkezi.

  20. October 26th, 2024 at 07:58 | #21

    I blog quite often and I seriously appreciate your information. This great article has truly peaked my interest. I will take a note of your blog and keep checking for new information about once a week. I opted in for your Feed too.

  21. October 26th, 2024 at 15:07 | #22

    I blog quite often and I seriously appreciate your information. This great article has truly peaked my interest. I will take a note of your blog and keep checking for new information about once a week. I opted in for your Feed too.

  22. October 27th, 2024 at 01:42 | #23

    I blog quite often and I seriously appreciate your information. This great article has truly peaked my interest. I will take a note of your blog and keep checking for new information about once a week. I opted in for your Feed too.

  23. October 27th, 2024 at 05:01 | #24

    I blog quite often and I seriously appreciate your information. This great article has truly peaked my interest. I will take a note of your blog and keep checking for new information about once a week. I opted in for your Feed too.

  24. October 27th, 2024 at 14:36 | #25

    Thank you for simplifying this complex topic

  25. October 28th, 2024 at 00:26 | #26

    Your points are always so well thought-out!

  26. October 28th, 2024 at 15:19 | #27

    I think this is among the most important info for me. And i am glad reading your article. But wanna remark on few general things, The site style is perfect, the articles is really excellent : D. Good job, cheers

  27. October 31st, 2024 at 21:54 | #28

    Merci pour ce bel article ![url=https://chemsexworld.com/]:)[/url]

  28. November 1st, 2024 at 01:50 | #29

    Everything is very open with a clear clarification of the challenges. It was really informative. Your website is extremely helpful. Thank you for sharing.

  29. November 3rd, 2024 at 07:02 | #30

    Merci pour ce bel article :) !

  30. November 3rd, 2024 at 11:41 | #31

    Merci pour ce bel article :) !

  31. November 3rd, 2024 at 23:23 | #32

    You’ve made some decent points there. I checked on the net to find out more about the issue and found most people will go along with your views on this web site.

  32. November 7th, 2024 at 18:35 | #33

    Bu casino’da oynadığım slot oyunları ile büyük kazançlar elde ediyorum, kesinlikle tavsiye ederim!

  33. November 10th, 2024 at 17:16 | #34

    May I simply say what a relief to find a person that truly knows what they are discussing on the web. You definitely realize how to bring a problem to light and make it important. More people must read this and understand this side of your story. I was surprised you aren’t more popular because you certainly have the gift.

  34. November 11th, 2024 at 00:39 | #35

    Woah! I’m really enjoying the template/theme of this site.
    It’s simple, yet effective. A lot of times it’s very difficult to get that “perfect balance” between superb usability and visual appeal.

    I must say you’ve done a great job with this. In addition,
    the blog loads super fast for me on Safari. Excellent Blog!

  35. November 12th, 2024 at 13:31 | #36

    After going over a handful of the blog posts on your website, I truly appreciate your way of writing a blog. I bookmarked it to my bookmark website list and will be checking back in the near future. Please check out my web site as well and tell me how you feel.

  36. November 15th, 2024 at 08:52 | #37

    Ten days later, Alexander III died at the age of forty-9, leaving twenty-six-yr-outdated Nicholas as Emperor of
    Russia. Whereas Alexander III had targeting the formulation of
    common policy, Nicholas devoted much more attention to the small print of administration. By that autumn, Alexander III lay dying.

  37. November 15th, 2024 at 12:20 | #38

    38.) The online youngsters’s game Neopets features an item called the Pan Galactic Gargle Slushie.

  38. November 16th, 2024 at 13:48 | #39

    sugar defender ingredients Uncovering Sugar Protector has been a game-changer for me,
    as I have actually constantly been vigilant regarding handling my blood sugar levels.

    With this supplement, I really feel equipped to take charge of
    my wellness, and my most current medical check-ups have mirrored a substantial
    turnaround. Having a credible ally in my corner supplies me with a
    sense of security and reassurance, and I’m deeply appreciative for
    the profound difference Sugar Defender has made in my
    health. sugar defender official website

  39. November 16th, 2024 at 14:11 | #40

    sugar defender Sugarcoating Defender to my everyday regimen was just one of
    the very best decisions I’ve made for my health and wellness.

    I’m careful concerning what I consume, yet this supplement adds an added layer of support.
    I really feel much more consistent throughout the day, and my cravings have actually reduced dramatically.
    It behaves to have something so basic that makes such a big difference!
    sugar defender reviews

  40. November 17th, 2024 at 12:12 | #41

    sugar defender official website Incorporating Sugar Protector into
    my everyday regimen has been a game-changer for my total wellness.
    As a person that already focuses on healthy eating, this supplement has offered an included increase of security.
    in my energy levels, and my desire for unhealthy
    snacks so uncomplicated can have such an extensive impact on my daily life.
    sugar defender official website

  41. November 18th, 2024 at 06:17 | #42

    North Carolina, for example, has developed through the years from a
    deep crimson state right into a swing state that Barack
    Obama received in 2008, and Mitt Romney and Donald J. Trump only received narrowly in the two elections that adopted.
    In 2012, for instance, fifty one p.c of North Carolina
    voters cast ballots for Democratic Congressional candidates.

  42. November 20th, 2024 at 01:16 | #43

    北部の凶作、収穫米の強制買い付け制度、戦略爆撃によって鉄道網が寸断されたこと、そしてフランス政庁が有効な対策を取ろうとしなかったこと、ベトナム共産主義者が米軍と結託し鉄道爆破などを行ったことが原因で5万から200万人に及ぶ人々が餓死した。植民地だったオランダ領東インド(以降、蘭印と略称)は、オランダにおける戦いで本国がナチス・ このベトナム帝国の成立は、阮朝が王政復古を果たした日でもあった。

  43. November 20th, 2024 at 01:24 | #44

    3月 – 栃木県内の中小学区決定により、野木町域は第三十八番中学区二〇三番〜二一〇番小学区になる。 5月7日 – 区画改定により栃木県第二十六区となる。森昌子が町民歌「野木町賛歌 ふれあいの町」および「野木町音頭」の歌唱を担当している。世代交代が色濃くなり始めた中、高橋和枝、武藤礼子、羽佐間道夫、小原乃梨子、広川太一郎、納谷悟朗、池田昌子らが共演した。

  44. November 20th, 2024 at 01:46 | #45

    )、5つの母音、および母音と結合して6つの二重母音を形成する2つの半母音がある(子音 /j/ と半母音
    /i̯/ は共に j、子音 /dz/ は dz と表記される)。 「欽どこ」お母さん役 真屋順子さん死去… また、中立国も存在した。 ベトナムの現代は、1976年7月2日に、ベトナム社会主義共和国が成立して、統一ベトナムが実現した事に始まる。司会には鈴井貴之(ローカルタレント)と多田萌加(ローカルアイドルグループ・

  45. November 20th, 2024 at 01:50 | #46

    【バラエティ】水曜21時枠にて、3月まで『プラチナイト』火曜版にて放送されていた、徳井義実、後藤輝基、SHELLY(タレント)、指原莉乃(HKT48)がMCを務めるトークバラエティ番組『今夜くらべてみました』を枠移動、ゴールデンタイムに進出する(枠移動・

  46. November 20th, 2024 at 02:48 | #47

    備中松山藩第7代藩主。松平忠学(従五位下):伊賀守流7代。松平忠済(従五位下):伊賀守流6代。板倉勝重(従五位下):板倉家宗家初代。板倉勝静(従五位下):板倉家宗家13代。松平忠愛(従五位下):伊賀守流4代。松平忠礼(従五位下):伊賀守流9代。松平忠順(従五位下):伊賀守流5代。松平忠固(従四位下):伊賀守流8代。

  47. November 22nd, 2024 at 08:24 | #48

    その後2代目三升亭小勝の次女の竹本清之助(富沢つね)と結婚し、義理の父の名である小勝を継ぎ真打に昇進した1894年10月に上席の芝玉の井で昇進披露をしている。東宝 – 渡辺プロダクション
    - 光進丸 – 湘南サウンド – モズライト – 東京文化会館 – パシフィックパーク茅ヶ崎 – 加山キャプテンコーストスキー場 – ケネディハウス – 神奈川県道310号茅ヶ崎停車場茅ヶ崎線 – 茅ヶ崎市 – ローヤルクラウン・

  48. November 22nd, 2024 at 09:04 | #49

    こうしたグッズ販売や取り組みは、アメリカの大学では伝統的に盛んに行われており、大学スポーツの人気とともに、大学のブランド力向上や収益に繋がっている。
    11月27日 – 大阪証券取引所市場第一部に上場。決済通貨が円の取引を対円通貨取引、円以外の場合を非対円通貨取引(外貨建て取引)という。買い物が趣味で、自宅に靴は3000足以上ある。
    (鴉等再び来る。 (鴉等退場。 お前達の事を大先生の所で褒めて遣る。

  49. November 22nd, 2024 at 09:23 | #50

    初めてMLBと契約した選手は前述のとおり、FA権取得まで少なくとも6年間を要する。大阪取引所、大証。当時はまだ海外渡航自由化の前で、大変貴重なニューヨーク訪問となった。地の巻 – マキノ雅弘自伝」、マキノ雅弘、平凡社、1977年、p.225.地の巻
    - マキノ雅弘自伝」には「傷だらけの男」でデビューとあるが誤りである。傷だらけの男(1950年、東日興業・
    1950年代から1960年代にかけ、東映の時代劇映画で活躍。東芝日曜劇場・

Comment pages
  1. No trackbacks yet.