- Where Developers Learn, Share, & Build Careers
I want to add a progress bar while loading my module in my Flex application. In this way I have created a module loader. But I do not know how to use it in my application to load the module. Could anyone help me with this. My codes are as follows: My main application has a view-stack with 2 modules, which is as follows. Note that Module 1 is a login form and when I right click on the entry form, I need to load module 1.
& lt; Mx: seestacks id = "main stack" width = "100%" height = "100%" & gt; & Lt; Mx: HBox id = "Mod1Loader" width = "100%" height = "100%" label = "mode 1 loader" horizontal alliance = "center" vertical align = "medium" & gt; & Lt; Mx: moduleloader url = "mod1.swf" id = "module1" /> & Lt; / Mx: hbox & gt; & Lt; Mx: HBox id = "Mod2Loader" width = "100%" height = "100%" label = "mode 2 loader" horizontal alliance = "center" vertical align = "medium" & gt; & Lt; Mx: Module Loader url = "Mod2.swf" id = "Module2" width = "100%" height = "100%" /> & Lt; / Mx: hbox & gt; & Lt; / Mx: viewstack & gt; CustomModuleLoader.mxml is as follows:
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; S: Module Loader xmlns: fx = "http://ns.adobe.com/mxml/2009" xmlns: s = "Library: //ns.adobe.com/flex/spark" xmlns: mx = "Library: // Ns.adobe.com/flex/mx "width =" 400 "height =" 300 "creation end =" init () "& gt; & Lt; Fx: Announcements & gt; & Lt ;! - Place non-visible elements (for example, services, value objects) - & gt; & Lt; / Fx: Announcements & gt; & Lt; Fx: script & gt; & Lt ;! [CDATA [import mx.core.UIComponent; Public Priority: UIComponent; Public function init (): zero {addEventListener ("urlChanged", onUrlChanged); AddEventListener ("Loading", Onloading); AddEventListener ("Progress", in progress); AddEventListener ("Setup", on Setup); AddEventListener ("Ready", Reed on); AddEventListener ("Error", onError); AddEventListener ("unload", on-load); Standin = panel; RemoveElement (standing); } URL changed to public function (event: event): zero {if (url == blank) {if (in the standin) is included, remove the element (standin); } And (if! (Standin)! (Standin);) Progress.indeterminate = true;} Public function onloading (event: event): zero {progress.label = "loading module" + url; if (! (Standin)) Adjustment (standin); progress.indeterminate true =;} Public function in progress (Event: Event): zero {progress.label = "% 2 bytes% loaded ..."; progress. Indeterminate = false;} Setup on public function (event: event): zero {progress.label = "Module" + url + "initial!"; Progress.indeterminate = false;} universal RDE (incident: incident) at the Junk festival: zero {progress.label = "module" + url + "successfully loaded!"; If (standin) () contains element (standin);} error on public function (events) : Event): Zero {progress.label = "error loading module" + url;} Public event download (event: event): zero {if (url == faucet) {if (in standin) include elements (standin );} And (if (! In it (standin)) Adjustment (standin);} Progress.indeterminate = true; Progress.label = "Mood Ul "+ url +" was unloaded! "; }] & Gt; & Lt; / Fx: script & gt; & Lt; S: panel id = "panel" width = "100%" title = "operation status" & gt; & Lt; S: layout & gt; & Lt; S: VerticalLayout / & gt; & Lt; / S: Layout & gt; & Lt; Mx: width of progressbar = "100%" id = "progress" source = "{this}" /> & lt; / S: cell & gt; & Lt; / S: ModuleLoader & gt;
text ">
As written in the documentation You can tie modules directly to the progress bar:
You have to set the source to define the progress bar for the module loader and your label Set mode for the survey and everything should work automatically. - In fact, for some reasons, Adobe documents are out of synchronization because The modular loader has those attributes.
A simple solution is to add the required attribute:
[bindable] Public preferred byte loaded: number = 0; [bindable] Public byte total : Number = 100; Then change the on-progress function to update the properties:
Public functions on progress (Event: Progressive Event): Zero {// update attributes bytesloaded = events .bytesLoaded; bytestekel = event.b Itstal; Progress.label = "% loaded 1 to 2 bytes% ..."; progress.indeterminate = false; } As I am testing in a local env, I can not see the progress bar, but at least I have no problem.
M.
Comments
Post a Comment