Do what Justin said on CreationComplete of the image in question.

Justin Haygood wrote:

photopanel.removeChild(pgBar); ?

Justin Haygood | Software Engineer | EyeWonder Atlanta

Phone 678-891-2031 | Mobile 404-271-2273
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> | aim - ewjhaygood

*EyeWonder
Interactive Digital Advertising. Advance.
*www.eyewonder.com <http://www.eyewonder.com>

*From:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] *On Behalf Of *Gabsaga Tata
*Sent:* Friday, July 25, 2008 12:51 PM
*To:* [email protected]
*Subject:* Re: [AFFUG Discuss] ProgressBar question

I tried that already and it didn't work. But I found an alternate way. The only thing I'm trying to figure out why now is to remove the progress bar from the panel when the image completely loads. Do you know how I can do that?

private var image:Image;
private var pgBar:ProgressBar;

public function clickHandler(event:MouseEvent):void
{
   if (image != null)
   {
       photopanel.removeChild(image);
   }

   if (pgBar != null)
   {
      photopanel.removeChild(pgBar);
   }

   pgBar = new ProgressBar();
   pgBar.mode = ProgressBarMode.POLLED;
   pgBar.label = "Loaded %1 of %2 bytes, %3%%";
   pgBar.indeterminate = false;


   image = new Image();
   image.source = list.selectedItem.photoUrl;
   photopanel.addChild(image);
   photopanel.addChild(pgBar);
   pgBar.source = image;
}


private function completeHandler(event:Event):void
{
   // remove the progress from the featured phototgraph panel
   if (pgBar != null)
   {
      photopanel.removeChild(pgBar);
   }
}

Do you know how I can call the completeHandler function after the image finishes loading?

I know in mxml you can do like the following:

<mx:Image id="image" width="100%" height="100%" complete="completeHandler(event)" />

But I'm trying to do it from the ActionScript which I haven't figured out yet.

Thanks.

Gabsaga

-----Original Message-----
*From:* Davy Strube [mailto:[EMAIL PROTECTED]
*Sent:* Thursday, July 24, 2008 10:43 PM
*To:* [EMAIL PROTECTED]
*Subject:* Re: [AFFUG Discuss] ProgressBar question

    Try this:
    In the completeHandler,
    photoLoadProgressBar.setProgress(0,1);

    I doubt this will work because the documentation says this method
    is for mode=manual, but it's something to try.
    http://livedocs.adobe.com/flex/2/langref/mx/controls/ProgressBar.html

    -Davy

    On Thu, Jul 24, 2008 at 5:31 PM, Gabsaga Tata
    <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    I am new to flex and I have developed this very simple application
    with the source could included below.

    The problem I'm having is how to reset the progress bar. When the
    first image is loaded in the Featured Photograph panel, the
    progress bar shows the % complete as the image is being loaded.
    So far, so good.

    But when the subsequent images are loaded, the progress bar does
    not change. It just shows the last state after the first image
    completely loaded.

    Is there a way to make it such that the progress bar shows the
    progress of subsequent images being loaded?

    Thanks for any help in advance!!


    Gabsaga

    ********************  Source Code ********************

    <?xml version="1.0" ?>

    <mx:Application xmlns="*"
    xmlns:mx="http://www.adobe.com/2006/mxml"; layout="vertical">

    <mx:Style>

    Panel {

    backgroundAlpha: 1;

    borderAlpha: 1;

    headerColors: #c7c7c7, #ffffff;

    footerColors: #ffffff, #c7c7c7;

    paddingTop: 15;

    paddingRight: 25;

    paddingLeft: 25;

    paddingBottom: 15;

    shadowDirection: "right";

    }

    .header {

    color: #ffffff;

    fontSize: 15;

    fontWeight: "bold";

    }

    </mx:Style>

    <mx:Script>

    <![CDATA[

    import mx.rpc.events.ResultEvent;

    import mx.rpc.events.FaultEvent;

    import mx.utils.ObjectUtil;

    import mx.controls.Alert;

    import mx.utils.StringUtil;

    private function resultHandler(event:ResultEvent):void

    {

    //used for debugging - shows details about result

    //returned by the Java class method

    //Alert.show( ObjectUtil.toString(event.result) );

    }

    private function faultHandler(event:FaultEvent):void

    {

    Alert.show( ObjectUtil.toString(event.fault) );

    }

    private function updateHandler(event:Event):void

    {

    remoteObj.updatePhoto(updatedPhoto);

    remoteObj.getPhotos();

    }

    public function clickHandler(event:MouseEvent):void

    {

    image1.source = list.selectedItem.photoUrl;

    photoLoadProgressBar.visible = true;

    progressHandler(event);

    }

    private function completeHandler(event:Event):void

    {

    // make progress bar invisible

    photoLoadProgressBar.visible = false;

    }

    public function progressHandler(event:Event):void

    {

    photoLoadProgressBar.indeterminate=false;

    }

    ]]>

    </mx:Script>

    <mx:RemoteObject id="remoteObj" destination="photosvc"
    result="resultHandler(event)" fault="faultHandler(event)" />

    <Photo id="updatedPhoto"

    photoId="{list.selectedItem.photoId}"

    photoUrl="{list.selectedItem.photoUrl}"

    photoDescription="{txtPhotoDescription.text}" />

    <mx:VBox verticalGap="10">

    <mx:Panel id="gridpanel" title="Simpaq Inc. (Flex Rocks!!)"
    width="800" height="350">

    <mx:DataGrid id="list"
    dataProvider="{remoteObj.getPhotos.lastResult}" width="100%"
    height="80%" click="clickHandler(event)" >

    <mx:columns>

    <mx:DataGridColumn dataField="photoId" headerText="Photo ID"
    width="100" />

    <mx:DataGridColumn dataField="photoDescription" headerText="Photo
    Comments" width="300" />

    <mx:DataGridColumn dataField="photoUrl" headerText="Photo URL"
    width="400" />

    </mx:columns>

    </mx:DataGrid>

    <mx:Form width="100%">

    <mx:FormItem label="Comments" width="100%">

    <mx:TextArea id="txtPhotoDescription"
    text="{list.selectedItem.photoDescription}" width="100%"
    height="20%"/>

    </mx:FormItem>

    </mx:Form>

    <mx:ProgressBar id="photoLoadProgressBar" width="300"
    source="image1" mode="polled" visible="false" label="Loaded %3%%"
    labelWidth="400" labelPlacement="top" />

    <mx:ControlBar>

    <mx:Button label="Get Photos" click="remoteObj.getPhotos()" />
    <mx:Button label="Update comments" click="updateHandler(event);"/>

    </mx:ControlBar>

    </mx:Panel>

    <mx:Panel id="photopanel" title="Featured Photograph" width="800"
    height="400">

    <mx:Image id="image1" width="100%" height="100%"
    maintainAspectRatio="true" complete="completeHandler(event)" />

    </mx:Panel>

    </mx:VBox>

    </mx:Application>


    -------------------------------------------------------------
    To unsubscribe from this list, simply email the list with
    unsubscribe in the subject line

    For more info, see http://www.affug.com <http://www.affug.com/>
    Archive @ http://www.mail-archive.com/discussion%40affug.com/
    List hosted by FusionLink <http://www.fusionlink.com/>
    -------------------------------------------------------------


-------------------------------------------------------------
To unsubscribe from this list, simply email the list with unsubscribe in the subject line

For more info, see http://www.affug.com
Archive @ http://www.mail-archive.com/discussion%40affug.com/
List hosted by FusionLink <http://www.fusionlink.com>
-------------------------------------------------------------


-------------------------------------------------------------
To unsubscribe from this list, simply email the list with unsubscribe in the subject line

For more info, see http://www.affug.com
Archive @ http://www.mail-archive.com/discussion%40affug.com/
List hosted by FusionLink <http://www.fusionlink.com>
-------------------------------------------------------------


-------------------------------------------------------------
To unsubscribe from this list, simply email the list with unsubscribe in the 
subject line

For more info, see http://www.affug.com
Archive @ http://www.mail-archive.com/discussion%40affug.com/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------


Reply via email to