Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Execution of notification  (Read 7835 times)
shizny
Full Member
***
Posts: 31


View Profile Email
« on: April 30, 2009, 08:57:51 »

Hello,

I'm working on a progressBar for the loading of several local files in an AIR app.  I am sending notifications out of a loop that runs on every line of a file that has loaded.  I can't, for the life of me, get the progressbar to visually update, and was wondering if something may be weird with the way notifications work.  Do they dispatch events and run asynchronously with the execution thread or are they fired synchronously.  From what I've seen it looks pretty sycronous because I set breakpoints in my setProgress function which is supposed to update the progressBar.  I've tried just about everything with the progressBar, manual mode, event mode (dispatching my own ProgressEvents, etc.) and nothing will work.  I'm running mac os x10.4 and compiling for flash player 9.  Anybody have any ideas.  Here is a code snippet from where I'm updating the progressbar.  I know this post goes a little outside of PureMVC, but thought maybe, somewhere it has something to do with it, or at least it is worth my time asking.

Like I said, I can verify, through breakpoints, that setPercentage is getting called, but no visual result displayed.

<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml">
   <!--<mx:Dissolve id="myShow" duration="500" alphaFrom="0.0" alphaTo="1.0"/>-->
   <mx:Box>
      <mx:Script>
          <![CDATA[
             import com.widgetmakers.coolwidget.globals.MessageStrings;
             
            [Bindable] private var progressLabel:String = MessageStrings.EXTRACTING_INVOICE_INFO;
                        
            public function setPercentage(thePercentage:Number):void {
               var theP:Number = Math.round(thePercentage);
               this.bar.setProgress( theP, 100 );
            }
            
          ]]>
      </mx:Script>
      
   <mx:VBox>
      <mx:ProgressBar id="bar" labelPlacement="bottom" themeColor="#F20D7A"
            minimum="0" visible="true" maximum="100" label="{this.progressLabel}"
            direction="right" mode="manual" width="100%"/>
   </mx:VBox>
   </mx:Box>
</mx:Module>
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: May 06, 2009, 03:56:34 »

Yes, Notifications are synchronous.

I recently did a progress bar update on http://seaofarrows.com  The first buttons that come up are playlists. Click one and you'll see that it goes into the playlist, starts playback of the first track. On the left side, at the bottom under the track name, you'll see a small progress bar that shows while the track is buffering. It should increase until you've got the whole track, then it'll disappear.

The source code for the app is at: http://seaofarrows.com/srcview

The class displaying the bar is com.seaofarrows.musicplayer.modules.playlist.view.Playback and the class that started the sound and placed event listeners is com.seaofarrows.musicplayer.modules.playlist.view.TrackSelector.

That's all updating within the MXML plane, and are not coming through the notification system. But there is no reason why the event couldn't be captured by a Mediator, which sends a notification with the info which is in turn heard by another Mediator which updates a progress bar. I have in the past listened for progress events in a Proxy and sent notifications that updated a progress bar at the view without issue.

-=Cliff>
Logged
Pages: [1]
Print