Looping Through Object Properties?

hello,
i have a movie clip with the class name "block" , am gonna use this object many times in the stage so i need to loop through it, i was able to do that but i can't access to their properties (x,y,height,width,etc...)
here is the code :
var blocks:Array = new Array  ;
//blocks is the array that must contains the movieClips
for (var i = 0; i < numChildren; i++)
                                             if (getChildAt(i) is block)
           //what should i write here to make the variable blocks[i] a movieClip and access to it's properties ?
thank you

for (var i=0; i< numChildren; i++)
                                             if (getChildAt(i) is block)
                                                                 blockss.push(MovieClip(getChildAt(i)));
                                                                 var tempBlock = MovieClip(getChildAt(i));
                  //i can access to all blocks properties through tempBlock      
thank you sir

Similar Messages

  • Looping through objects - testing links

    Hi
    I have a script that moves all instances of a linked object according to user defined X,Y values.
    In order to do this, I need to loop through all objects with links
    What is the best way to do this?
    As of now, this is what I am doing:
    var g = myDoc.allGraphics;
    for (var i=0; i<g.length; i++) {
         if (g[i].itemLink.name == USER_LINK) {
              g[i].parent.move(undefined, [USER_X, USER_Y]);
    It works well, however I ran into some problems where link was null
    Also, is it always the graphic that is linked, or can its parent be linked as well?
    If not, then I can just condition that if itemLink == null - continue
    Any advice and guidance would be much appreciated
    Thanks
    David

    It works well, however I ran into some problems where link was null
    if (g[i].itemLink && g[i].itemLink.name == "USER_LINK")     //     should be enough
    Also, is it always the graphic that is linked, or can its parent be linked as well?
    Graphic can be linked ==> itemLink !=null and itemLink.status can vary
    or pasted ==> itemLink == null.
    As far as I know graphic.parent can not be linked.
    However not every linked graphic.parent can be moved. I e. those one which are anchored with
    AnchorPosition.INLINE_POSITION and AnchorPosition.ABOVE_LINE
    Above case can be a source of error as well.
    Consider also locked object or locked entire layers.
    Jarek

  • Looping through objects on stage

    I know I've done this type of thing before, but I can't
    remember how... How do I loop through all the objects on a stage to
    check their names for a specific substring. On my stage I have a
    number of movieclips with names that end with either _a_mc or
    _b_mc. I want to check for everything that has _a_mc so I can
    change the frame of that movieclip.

    The for...in loop should be handy for this:
    for (var obj in _root){
    trace( obj + ": " + _root[obj] );
    greets,
    blemmo

  • Looping through Objects

    Hi,
    I'm trying to design business entities with ABAP Objects. I have been able to create internal tables of custom object types.
    I stumbled into a very peculiar situation in which i have to loop through my custom object internal table. i couldn't use the WHERE specification since the line type is not a structure. READ TABLE doesnt work either. What i did to overcome the problem was to do a LOOP AT with an IF statement inside and an EXIT command to quit the search when found.
    Is there a better solution? And Is the whole idea of wrapping everything in classes and accessing the through an internal idea a good idea in the first place?
    Thanks.

    heres an example:
    * DEFINITIONS
    CLASS cl_drag_drop_picture DEFINITION INHERITING FROM cl_gui_picture.
      PUBLIC SECTION.
        DATA: row     TYPE I,
              col     TYPE I.
    DATA: g_wa_pic_ctrl TYPE REF TO cl_drag_drop_picture.
    DATA: g_it_pic_ctrl LIKE TABLE OF g_wa_pic_ctrl.
    * PROCESS
    * lets assume that g_it_pic_ctrl has several entries and
    * each entry is uniquely identified by the attributes
    * row AND col.
    PERFORM GetObjectByRowCol USING p_row
                                    p_col
                           CHANGING g_wa_pic_ctrl.
    * SUBROUTINES
    FORM GetObjectByRowCol USING p_row
                                 p_col
                        CHANGING r_pic_ctrl.
      DATA: l_wa_pic_ctrl LIKE g_wa_pic_ctrl.
    * Search for picture
      LOOP AT g_it_pic_ctrl INTO l_wa_pic_ctrl.
        IF l_wa_pic_ctrl->row EQ p_row AND
           l_wa_pic_ctrl->col EQ p_col.
          r_pic_ctrl = l_wa_pic_ctrl.
          EXIT.
        ENDIF.
      ENDLOOP.
    * Collect Garbage
      CLEAR l_wa_pic_ctrl.
    ENDFORM.
    What I couldn't do is access my internal table like:
    READ TABLE g_it_pic_ctrl
          INTO r_pic_ctrl
      WITH KEY row = p_row
               col = p_col.
    OR
    LOOP AT g_it_pic_ctrl INTO r_pic_ctrl
                         WHERE row EQ p_row
                               col EQ p_col.

  • Loop through..getProperties --Simple question!

    Hello,
    I like to use System.getProperties() and display the name and value of each property by loop through all properties (without specify the name for a particular property).
    It sounds very simple but I cannot find any example code in Java's online documentation.
    Thanks for any help

    Try these lines of code:
    public class test
        public static void main (String args[])
            java.util.Properties systemProps = System.getProperties();
            String name = "";
            String value = "";
            for (java.util.Enumeration names = systemProps.propertyNames(); names.hasMoreElements() ;) {
                name = (String)names.nextElement();
                value = systemProps.getProperty(name);
                System.out.println("property '"+name+"' has value '"+value+"'");
    }

  • Question on how to loop through a variable amount of objects

    I have a csv file which I am parsing with powershell and it works perfectly. I would like to speed it up. Currently, I call a line that is customized for each groups list of subnets.
    I have about 30 groups.
    Some groups have one subnet, some have 5 subnets.
    I want to set up some sort of loop to parse everything while executing a single Import-CSV. Currently I call Import-CSV once per group. It takes me about 2-4 minutes to parse the entire file depending on the speed of the machine.
    The csv file has about 30,000 rows. I am not concerned about running out of resources. This is as much a learning challenge as a desire to make better powershell scripts.
    Below is a portion of the one liner that would parse the entire csv file looking only for those items that match, and writing them out to that groups specific csv file.
    Example #1
    Import-Csv $HostList |  Where-Object {$_."IP Address" -Match "^192.1.*" -or $_."IP Address" -Match "^192.2.*" -or $_."IP Address" `-Match "^192.3.*"  .....}| do more stuff...
    Example #2
    Import-Csv $HostList |  Where-Object {$_."IP Address" -Match "^192.7.*" ....}| do more stuff...
    The example above is just a snippet from code that works perfectly.
    The problem I am asking for help with is, when I loop through the items I am matching against (subnets), if one group has 3 items to match against, another has 1, another has 7, how do I set up such a loop?
    Am I using some sort of 'while'  $_."IP Address" or...?
    Do I create a big 30,000 array (Does PS even use arrays?)
    I would love to know what this type of looping is called, and what I can read with examples on how to understand approaching this challenge..
    Thank you for any help.
    -= Bruce D. Meyer

    The reason for the parsing (I thought I explained it, must have been too vague) is I have about 30 agencies in a csv file.
    Each agency can be determined by their subnet(s) and domain(s)
    I need to put all lines in the csv relating to each agency in their own separate csv file to distribute to them so I am not sharing agency 'A' info with the other 29 agencies.
    I get the regex comment. Thank you. For some reason I am rather hesitant to use PCRE under windows. I'll see how it works.
    Your comment on "Reloading a large file repeatedly takes more time", is the exact reason why I asked the question. I want to get away from that.
    I appreciate your quick reply, I think your example will work nicely. 
    -= Bruce

  • How do I: Loop through Application objects

    How would I loop through the application object?  My goal is to see if the object is a label and change its font size.
    pseudocode would look like this:
    function setsize(change int) {
      for each obj in application {
        if obj is of type label {
          set font size to font size + change
    Once I got that working, I'd add other objects that display text.  The "change" would be a number to increase (positive) or decrease (negative) the size.
    Thanks,
    Jerry

    I have this:
              <mx:HBox id="resultTextBox"
                  width="100%"
                  verticalScrollPolicy="off" horizontalScrollPolicy="auto">
                  <mx:Label id="resultPotentialResultsLabel"
                      text="Food Stamp potential eligibility for household, estimated monthly benefit amount "
                      styleName="textNormal"
                      toolTip="Results message"
                      tabIndex="200" tabEnabled="true"  fontSize="40"/>
                  <mx:Text id="resultPotentialResultsData"
                      styleName="resultNumberNormal"
                      toolTip="Final results"
                      tabIndex="202" tabEnabled="true" />
              </mx:HBox>
    When I expand the font size it pushes the "resultPotentialResutsData" to limbo.  I tried adding the horizonal scroll bar to allow the user to still see the results,  The scroll doesn't appear.
    1) is there a way to get the box to expand to fix the content?
    2) is there a way to get the scroll bar to appear when needed?
    3) is there a way to wrap the text (in this case the second field) in the HBox?

  • Looping through an objects children

    This post is related to another post I have in the forums:
    "Dynamically adding containers".
    However, I am using an object (note this object can change -
    is dynamic):
    [CODE]
    [Bindable]
    public var dashboardDP:Object =
    {item:"dashboard", children: [
    {item:"vbox", id:"vbox 1", children: [
    {item:"panel", id:"panel 1", children: [
    {item:"hbox", id:"hbox 1", children: [
    {item:"view" id:"view 1"},
    {item:"view" id:"view 2"},
    {item:"view" id:"view 3"}
    {item:"hbox", id:"hbox 2", children: [
    {item:"view" id:"view 4"},
    {item:"panel", id:"panel 2", children: [
    {item:"vbox", id:"vbox 2", children: [
    {item:"view" id:"view 5"},
    {item:"view" id:"view 6"},
    [/CODE]
    And I want to loop through every child in this object but am
    struggling to do so :(
    e.g. the following loop will ony return the first child of
    the object:
    [CODE]
    for(var i:int=0; i<dashboardDP.children.length; i++)
    // some code.....
    [/CODE]
    I want to advance this loop so that it "drills" into and
    retrieves / reads every child and sub child of each parent etc.....
    Is this possible???
    Any help would be much appreciated on this one.
    Thanks in advance,
    Jon.

    Hi "xtempore" thanks for the fast reply!!!
    Just off the top of my head... I am using an Object type for
    "dashboardDP".
    Will this work as in your example to loop through and get all
    the children?
    I notoce you are using a type UIComponent and referencing
    UIComponent.children - will this work?
    I have train but am getting errors... with the line:
    for each (var c: UIComponent in comp.children) {
    when trying to access the ".children"
    Could you please expand?
    Thanks again,
    Kind Regards,
    Jon

  • Looping through json object in a query string

    Hi
    I have a json object in my query string and would like to loop through it, do i convert it to an array, or a map, so that i can loop through it?
    I get the object from the url which looks like this:
    {"CREATEDBYNAME":"TEST_ADMIN","FIRSTNAME":"John","TYPEID":"1900000000"}
    I would then like to loop through it so that i can make a string that would look like:
    "CREATEDBYNAME" = "TEST_ADMIN" AND "FIRSTNAME" = "John" AND "TYPEID"="1900000000"
    I want to use a loop because there can be up to 15 options in the json object. and the if statement would just not do.
    Plz help.

    What you can do with that object, I can't tell you because I don't know what it can or can't do. What's its API? Where does it come from?

  • Looping through serialized objects?

    I have made a program which stores the game score such as seen 3d pinball. I know how to store then but I don't know how to loop through all records so that I can store them in one single array so that I can perform diffenent operations on that array.
    such I should arrange them and find out the top five scorer. Give me some valueable hints.

    Demo:
    import java.io.*;
    import java.util.*;
    public class Example implements Serializable {
        private static final long serialVersionUID = 1;
        private String text;
        public Example(String text) {
            this.text = text;
        public String toString() {
            return text;
        public static void main(String[] args) throws IOException, ClassNotFoundException {
            List<Example> list = new ArrayList<Example>();
            Collections.addAll(list, new Example("hello"), new Example("world"));
            File file = new File("temp.dat");
            ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file));
            out.writeObject(list);
            out.flush();
            out.close();
            ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
            List<Example> input = (List<Example>) in.readObject();
            in.close();
            System.out.println(input);
    }

  • Loop through all controls in view

    Hi Everyone,
    I need to cycle through all the controls on a view.
    I have set each of the controls of type UISegmentedControl with a unique tag number.
    I am using this tag number to perform a lookup in database for the value of the segmented control.
    So, my question is this.... how do i cycle through all the controls on a view?
    thank you
    take care
    tony

    alt-088 wrote:
    I think we are close - just one correction.
    The segmented controls are all at design time, there will be no new controls added.
    I'm not clear on what's been corrected. The sample code I gave you assumed all the controls were known at compile time. So I think the example code addressed the problem you're trying to solve. The last paragraph of that post was just an afterthought, to explain what to do in case you ever needed to add controls dynamically.
    -> loop through all controls on view
    -> if control is of type uisegmentdcontrol
    then do database lookup on tag
    Set segment value to value returned from database
    Once again, if I correctly understand the above, the code I gave you does exactly what you want. You haven't indicated you want to take any action when a control is not a segmented control, so I don't see why you'd want to include them in the loop. However, if you actually do need to enumerate non-segmented controls (or other subviews), my last response advised you to set the tag properties of all those other controls, making sure the range of those tags is different from the range of the seg control tags.
    The part that eludes me is the looping through all the controls on the view
    I guess the part that eludes me is why you're so interested in enumerating all the controls, when you only seem to be interested in the segmented controls. But even if you really do need to look at every control, I don't see why you're rejecting the solution I gave you. [viewWithTag:|http://developer.apple.com/iphone/library/documentation/UIKit/Ref erence/UIViewClass/UIView/UIView.html#//appleref/doc/uid/TP40006816-CH3-SW26] is a powerful method which recursively walks the entire view hierarchy to find whatever tag it's looking for. If you use it correctly (e.g. by assigning unique tag numbers that tell you what type of control you've found), it will save you lots of trouble.
    If, for some reason, you insist on doing this job without using viewWithTag, the next best might be something like this:
    - (void)doSomethingWithEachSegCtrlInView:(UIView *theView) {
    UIView *subView;
    for (subView in theView.subviews) {
    if ([subView respondsToSelector:@selector(selectedSegmentIndex)]) {
    // subView is a segmented control ...
    else {
    // subView is not a segmented control ...
    if ([subView.subviews count]) {
    // this subview has its own subviews
    [self doSomethingWithEachSegCtrlInView:subView];
    Note that the above is a more difficult, more error prone method than the sample in my first response. Firstly, it needs to recurse in case any controls are placed on subviews of the main view (or on subviews of those subviews, etc.), a capability already built into viewWithTag. Secondly it needs to identify the type of each subview object. [respondsToSelector:|http://developer.apple.com/iphone/library/documentation/Co coa/Reference/Foundation/Protocols/NSObjectProtocol/Reference/NSObject.html#//appleref/occ/intfm/NSObject/respondsToSelector:] is the preferred way of identifying the class of an object, especially when the selector argument represents one of the methods you intend to use. However there's no reason to get into the business of identifying the class of an object, when you could have given that object a unique tag number in the xib, where there was no question about its class.
    Hope the above communicates the solution better than my first response!
    - Ray

  • Display object properties into spreadsheet

    For a VAB excel 2013 project, I created a class module with 20 properties. In the project I created 30 instances of the object. I did some calculations and populate all the porteties with values. My challenge is now  how to efficiently
    display the result intoa worksheet as a table ?
    I would like to have the first column populated with the 20 preperty names.
    The first line  populated by the 30 object instance names.
    Each line populated with the property values.
    Thanks for you help

    Hi Paykun,
    >> My challenge is now  how to efficiently display the result intoa worksheet as a table ?
    In my option, to achieve your requirement, you would need two steps. First step is getting the value of the properties and objects, second is writing the value into a table. Since this forum is discussing about Excel developing like Excel automation, Excel
    Customation which use the vba to operate Excel, your first step is more related with vba, if you have any issue about getting values, I will recommend you go to the link below for help.
    VBA forum: http://social.msdn.microsoft.com/Forums/en-US/home?forum=isvvba
    For the second step, I will recommend you creating a table in the worksheet, and then loop through the values to the cells of the table. For how to set the value, you could refer the link below:
    # ListObject Object (Excel)
    https://msdn.microsoft.com/en-us/library/office/ff197604.aspx?f=255&MSPPError=-2147217396
    Based on my experience, there is no significant performance issue when you write 600 values into excel.​​
    Best Regards,
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

  • Looping through channels is really slow in CC

    I've been working on .Net application and ran into a little performance snag. I have a simple method that loops through the channel layers by index, grabs the indexed channel name, and if it matches a predetermined variable then it simple deletes that channel. It works as written but is painfully SLOW. Being fairly new at programming I figured it was just me and opened up ExtendScript to run a few test.
    var docChannels = app.activeDocument.channels;
    for (i = 0; i < docChannels.length; i++ ){
            alert(docChannels[i].name);
    To run this script in a document containing only the RGB channels plus 3 other alpha channels takes approximately 30 to 40 seconds. Running the same script modified to cycle through about 20 document layers only takes about 5 seconds.
    I don't know if this is a bug in Photoshop CC or not. I don't have any earlier versions to test on. I've can accomplish the programing method by using a Try Catch statement and directly trying to delete the layer by name. This seems to run a little bit faster but not by much and is not really a proper use of a Try Catch statement.
    Any insight into this problem or a better way to impliment my programing method would be most appreciated.

    I am not sure about .Net apps but I think the reason the javascript Object Model can be slow when working with layers and channels it every time you create a layer or channel object all the properties of that object created. I think building the histogram property is the biggest reason for the slow down. Especially is the document has a large canvas.
    Action Manger can be much faster because you can get only the property you need and avoid creating a DOM object and building the histogram. Try this to see if faster getting the channel names.
    function getProperty( psClass, psKey, index ){// integer:Class, integer:key
        var ref = new ActionReference();
        if( psKey != undefined ) ref.putProperty( charIDToTypeID( "Prpr" ), psKey );
        if(index != undefined ){
            ref.putIndex( psClass, index );
        }else{
            ref.putEnumerated( psClass , charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
        try{
            var desc = executeActionGet(ref);
        }catch(e){ return; }// return on error
        if(desc.count == 0) return;// return undefined if property doesn't exists
        var dataType = desc.getType(psKey);
        switch(dataType){// not all types supported - returns undefined if not supported
            case DescValueType.INTEGERTYPE:
                return desc.getInteger(psKey);
                break;
            case DescValueType.ALIASTYPE:
                return desc.getPath(psKey);
                break;
            case DescValueType.BOOLEANTYPE:
                return desc.getBoolean(psKey);
                break;
            case DescValueType.BOOLEANTYPE:
                return desc.getBoolean(psKey);
                break;
            case DescValueType.UNITDOUBLE:
                return desc.getUnitDoubleValue(psKey);
                break;
            case DescValueType.STRINGTYPE:
                return desc.getString(psKey);
                break;
            case  DescValueType.OBJECTTYPE:
                return desc.getObjectValue(psKey);
                break;
            case  DescValueType.LISTTYPE:
                return desc.getList(psKey);
                break;
            case  DescValueType.ENUMERATEDTYPE:
                return desc.getEnumerationValue(psKey);
                break;
    var channelCount = app.activeDocument.channels.length;
    var channelNames = [];
    for(var channelIndex=1;channelIndex<=channelCount;channelIndex++){
        channelNames.push(getProperty(charIDToTypeID("Chnl"),charIDToTypeID("ChnN"),channelIndex));
    alert(channelNames);

  • Looping through an array to get the index for each measure in a combo box

    Hi folks,
    I am working on a web application that has two combo boxes, one for year (called yearcombo) and for measures (called myURL) for that selected year, and also two radiobuttons (in radioBtnGroup). I have two years and a bunch of measure for each year. I  have a map tool tip that when you mouse over the county you see a measure for that specific year. However I have a bunch of measures for each year and I want to be able to loop through the measures (which are in an array collection inside a combobox) so my "if" expression can find every selectedIndex and bring me the tool tip for that selected measure for that selected radio button. Right now I would have to create if statements for each measure (each selectedIndex inside the myURL combobox)and each radiobutton (inside the radioBtnGroup) instead of creating a if expression to get a map tip tool for each measure. I know I would have to create a loop to search for these indexes and enter that in the if expression and also change the graphic.attributes to reflect the right measure or index selected. Do you API for Flex wizards  can give me any tips on how to code this according to my code below ? Any  help is greatly appreciated! (the print scree is attached)
    Below is the code snippet:
    if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 0 && radioBtnGroup.selectedValue == 0)
    fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
    var graphic:Graphic = Graphic(event.currentTarget);
    graphic.symbol = mouseOverSymbol;
    var htmlText:String = graphic.attributes.htmlText;
    var textArea:TextArea = new TextArea();
    try{
    textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirIndOut.toString()
    myMap.infoWindow.content=textArea
    myMap.infoWindow.label = graphic.attributes.NAME;
    myMap.infoWindow.closeButtonVisible = false;
    myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
    catch(error:Error) {
    trace("Caught Error: "+error);
    And below is the combo boxes with the arrays
    <mx:FormItem label="Year        :"  >
    <mx:ComboBox   id="yearcombo" selectedIndex="0" labelField="label" width="100%" change="changeEvt(event)"  >
    <mx:ArrayCollection id="year"  >
    <fx:Object label="2007"  year="2007" />
    <fx:Object label="2009"  year="2009" />
    </mx:ArrayCollection>
    </mx:ComboBox>
    </mx:FormItem>
    <mx:FormItem label="Measure:">
    <mx:ComboBox   id="myURL" selectedIndex="8" width="80%" mouseOver="clickEv2(event)" close="closeHandler(event)">
    <mx:ArrayCollection id="measures"   >
    <fx:Object id="forindout07" labeltext="2007 Forestry Industry Output" label="Forestry Industry Output " value="RADIO_BUTTONS/TFEI_07_forest_industry_output" year="2007"  />
    <fx:Object id="foremp07" label="2007 Forestry Employment " value="RADIO_BUTTONS/TFEI_07_forest_employment" year="2007" />
    <fx:Object id="forlabinc07" label="2007 Forestry Labor Income " value="RADIO_BUTTONS/TFEI_07_forest_labincome" year="2007" />
    <fx:Object id="forindbustax07" label="2007 Forestry Indirect Business Tax" value="RADIO_BUTTONS/TFEI_07_forest_business_tax" year="2007" />
    <fx:Object id="forindout09" label="Forestry Industry Output " value="RADIO_BUTTONS/TFEI_09_forest_industry_output" year="2009"  />
    <fx:Object id="foremp09" label="2009 Forestry Employment " value="RADIO_BUTTONS/TFEI_09_forest_employment" year="2009" />
    <fx:Object id="forlabinc09" label="2009 Forestry Labor Income " value="RADIO_BUTTONS/TFEI_09_forest_labincome" year="2009" />
    <fx:Object id="forindbustax09" label="2009 Forestry Indirect Business Tax" value="RADIO_BUTTONS/TFEI_09_forest_business_tax" year="2009" />
    <fx:Object id="blank" label=" "  />
    </mx:ArrayCollection>

    And here is the entire code
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application       
                    xmlns:fx="http://ns.adobe.com/mxml/2009"
                    xmlns:s="library://ns.adobe.com/flex/spark"
                    xmlns:mx="library://ns.adobe.com/flex/mx"
                    xmlns:esri="http://www.esri.com/2008/ags"
                    paddingBottom="8" paddingLeft="8"
                    paddingRight="8" paddingTop="8"
                    backgroundColor="0xffffff"
                    layout="vertical" >
        <!-- Start Declarations -->
    <fx:Declarations>
            <esri:SimpleFillSymbol id="mouseOverSymbol" alpha="0.5" color="0x808080">
                <esri:SimpleLineSymbol width="0" color="#000000"/>
            </esri:SimpleFillSymbol>
            <esri:SimpleFillSymbol id="defaultsym" alpha="0.01" color="#E0E0E0"   >
                <esri:SimpleLineSymbol width="1" color="#000000"/>
            </esri:SimpleFillSymbol>
        <!-- End Declarations -->
    </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import com.esri.ags.Graphic;
                import com.esri.ags.SpatialReference;
                import com.esri.ags.esri_internal;
                import com.esri.ags.events.GraphicEvent;
                import com.esri.ags.geometry.Extent;
                import com.esri.ags.layers.ArcGISDynamicMapServiceLayer;
                import com.esri.ags.symbols.SimpleFillSymbol;
                import com.esri.ags.symbols.SimpleLineSymbol;
                import flash.utils.flash_proxy;
                import mx.collections.ArrayCollection;
                import mx.controls.Alert;
                import mx.controls.RadioButton;
                import mx.controls.TextArea;
                import mx.events.DropdownEvent;
                import mx.events.ItemClickEvent;
                import mx.rpc.Fault;
                import mx.rpc.events.FaultEvent;
                import flash.display.Sprite;
                import flash.events.ErrorEvent;
                import flash.events.MouseEvent;
                private function closeHandler(evt:DropdownEvent):void {
                    myLabel.text = ComboBox(evt.target).selectedItem.labeltext;
                private function loadLayerName():void
                    myLegend.layers = null;
                    layerPanel.removeAllChildren();
                    //loop through each layer and add as a radiobutton
                    for(var i:uint = 0; i < (dynamicLayer.layerInfos.length); i++)
                        var radioBtn:RadioButton = new RadioButton;
                        radioBtn.groupName = "radioBtnGroup";
                        radioBtn.value = i;
                        radioBtn.label = dynamicLayer.layerInfos[i].name;
                        if (dynamicLayer.layerInfos[i].name == "Direct Impact (Million $)")
                            radioBtn.label = "Direct Impact";
                        else if (dynamicLayer.layerInfos[i].name == "Total Impact (Million $)")
                        {radioBtn.label = "Total Impact";
                        else if (dynamicLayer.layerInfos[i].name == "Total Impact (Jobs)")
                        {radioBtn.label = "Total Impact";
                        else if (dynamicLayer.layerInfos[i].name == "Direct Impact (Jobs)")
                        {radioBtn.label = "Direct Impact";
                        else
                        {radioBtn.visible= false;
                        layerPanel.addChild(radioBtn);
                    /*     myDividerBox.getDividerAt(0).visible = false; */
                    //set the visible layer the first radio button
                     radioBtnGroup.selectedValue = 0;
                     dynamicLayer.visibleLayers = new ArrayCollection([0]);
                    myLegend.layers = [dynamicLayer];
                    myLegend.visible = true;
                private function radioClickHandler(event:ItemClickEvent):void
                    myLegend.layers = null;
                    // update the visible layers to only show the layer selected
                    dynamicLayer.visibleLayers = new ArrayCollection([event.index]);
                    myLegend.layers = [dynamicLayer];
                private function changeEvt(event:Event):void {
                if (yearcombo.selectedItem.year == "2007")
                    measures.filterFunction=filter1
                    measures.refresh()
                    myURL.dataProvider=measures
                else if (yearcombo.selectedItem.year == "2009")
                    measures.filterFunction=filter2
                    measures.refresh();
            public function filter1(item:Object):Boolean
                if (item.year=="2007") return true
                else return false
                public function filter2(item:Object):Boolean
                    if (item.year=="2009") return true
                    else return false
                private function clickEvt(event:Event):void {
                    if (yearcombo.selectedItem.year == "2007")
                        measures.filterFunction=filter3
                        measures.refresh()
                        myURL.dataProvider=measures
                    else if (yearcombo.selectedItem.year == "2009")
                        measures.filterFunction=filter4
                        measures.refresh();
                public function filter3(item:Object):Boolean
                    if (item.year=="2007") return true
                    else return false
                public function filter4(item:Object):Boolean
                    if (item.year=="2009") return true
                    else return false
                private function clickEv2(event:Event):void {
                    if (yearcombo.selectedItem.year == "2007")
                        measures.filterFunction=filter5
                        measures.refresh()
                    else if (yearcombo.selectedItem.year == "2009")
                        measures.filterFunction=filter6
                        measures.refresh();
                    else if (yearcombo.selectedItem.year == 2007 && myURL.selectedIndex==8)
                        myLegend.layers = null;
                        layerPanel.removeAllChildren();
                public function filter5(item:Object):Boolean
                    if (item.year=="2007") return true
                    else return false
                public function filter6(item:Object):Boolean
                    if (item.year=="2009") return true
                    else return false
                /* IF YOU WANT TO INCLUDE OTHER VALUES IN THE MAP TOOLTIP LIKE COUNTY NAME AND THE LABEL OF THE SELECTED ITEM
                if (myURL.selectedIndex==0)
                myTextArea.htmlText = "<b>County: </b>" + gr.attributes.NAME + "\n"
                + "<b>Measure: </b>" + myURL.selectedItem.label + gr.attributes.ForDirIndOut.toString()
                public function fLayer_graphicAddHandler(event:GraphicEvent):void
                    event.graphic.addEventListener(MouseEvent.MOUSE_OVER, onMouseOverHandler);
                    event.graphic.addEventListener(MouseEvent.MOUSE_OUT, onMouseOutHandler);
                public function onMouseOverHandler(event:MouseEvent):void
                    if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 0 && radioBtnGroup.selectedValue == 0)
                        fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
                        var graphic:Graphic = Graphic(event.currentTarget);
                        graphic.symbol = mouseOverSymbol;
                        var htmlText:String = graphic.attributes.htmlText;
                        var textArea:TextArea = new TextArea();
                        try{
                        textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirIndOut.toString()
                        myMap.infoWindow.content=textArea
                        myMap.infoWindow.label = graphic.attributes.NAME;
                        myMap.infoWindow.closeButtonVisible = false;
                        myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
                        catch(error:Error) {
                            trace("Caught Error: "+error);
                    if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 0 && radioBtnGroup.selectedValue == 1)
                        fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
                        var graphic:Graphic = Graphic(event.currentTarget);
                        graphic.symbol = mouseOverSymbol;
                        var htmlText:String = graphic.attributes.htmlText;
                        var textArea:TextArea = new TextArea();
                        try{
                            textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpIndOut.toString()
                            myMap.infoWindow.content=textArea
                            myMap.infoWindow.label = graphic.attributes.NAME;
                            myMap.infoWindow.closeButtonVisible = false;
                            myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
                        catch(error:Error) {
                            trace("Caught Error: "+error);
                    if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 1 && radioBtnGroup.selectedValue == 0)
                        fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
                        var graphic:Graphic = Graphic(event.currentTarget);
                        graphic.symbol = mouseOverSymbol;
                        var htmlText:String = graphic.attributes.htmlText;
                        var textArea:TextArea = new TextArea();
                        try{
                            textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirEmp.toString()
                            myMap.infoWindow.content=textArea
                            myMap.infoWindow.label = graphic.attributes.NAME;
                            myMap.infoWindow.closeButtonVisible = false;
                            myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
                        catch(error:Error) {
                            trace("Caught Error: "+error);
                    if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 1 && radioBtnGroup.selectedValue == 1)
                        fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
                        var graphic:Graphic = Graphic(event.currentTarget);
                        graphic.symbol = mouseOverSymbol;
                        var htmlText:String = graphic.attributes.htmlText;
                        var textArea:TextArea = new TextArea();
                        try{
                            textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpEmp.toString()
                            myMap.infoWindow.content=textArea
                            myMap.infoWindow.label = graphic.attributes.NAME;
                            myMap.infoWindow.closeButtonVisible = false;
                            myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
                        catch(error:Error) {
                            trace("Caught Error: "+error);
                    if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 2 && radioBtnGroup.selectedValue == 0)
                        fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
                        var graphic:Graphic = Graphic(event.currentTarget);
                        graphic.symbol = mouseOverSymbol;
                        var htmlText:String = graphic.attributes.htmlText;
                        var textArea:TextArea = new TextArea();
                        try{
                            textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirLabInc.toString()
                            myMap.infoWindow.content=textArea
                            myMap.infoWindow.label = graphic.attributes.NAME;
                            myMap.infoWindow.closeButtonVisible = false;
                            myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
                        catch(error:Error) {
                            trace("Caught Error: "+error);
                    if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 2 && radioBtnGroup.selectedValue == 1)
                        fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
                        var graphic:Graphic = Graphic(event.currentTarget);
                        graphic.symbol = mouseOverSymbol;
                        var htmlText:String = graphic.attributes.htmlText;
                        var textArea:TextArea = new TextArea();
                        try{
                            textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpLabInc.toString()
                            myMap.infoWindow.content=textArea
                            myMap.infoWindow.label = graphic.attributes.NAME;
                            myMap.infoWindow.closeButtonVisible = false;
                            myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
                        catch(error:Error) {
                            trace("Caught Error: "+error);
                    if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 3 )
                        fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
                        var graphic:Graphic = Graphic(event.currentTarget);
                        graphic.symbol = mouseOverSymbol;
                        var htmlText:String = graphic.attributes.htmlText;
                        var textArea:TextArea = new TextArea();
                        try{
                            textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForIndirBusTax.toString()
                            myMap.infoWindow.content=textArea
                            myMap.infoWindow.label = graphic.attributes.NAME;
                            myMap.infoWindow.closeButtonVisible = false;
                            myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
                        catch(error:Error) {
                            trace("Caught Error: "+error);
                    if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 0 && radioBtnGroup.selectedValue == 0)
                        fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
                        var graphic:Graphic = Graphic(event.currentTarget);
                        graphic.symbol = mouseOverSymbol;
                        var htmlText:String = graphic.attributes.htmlText;
                        var textArea:TextArea = new TextArea();
                        try{
                            textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirIndOut.toString()
                            myMap.infoWindow.content=textArea
                            myMap.infoWindow.label = graphic.attributes.NAME;
                            myMap.infoWindow.closeButtonVisible = false;
                            myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
                        catch(error:Error) {
                            trace("Caught Error: "+error);
                    if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 0 && radioBtnGroup.selectedValue == 1)
                        fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
                        var graphic:Graphic = Graphic(event.currentTarget);
                        graphic.symbol = mouseOverSymbol;
                        var htmlText:String = graphic.attributes.htmlText;
                        var textArea:TextArea = new TextArea();
                        try{
                            textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpIndOut.toString()
                            myMap.infoWindow.content=textArea
                            myMap.infoWindow.label = graphic.attributes.NAME;
                            myMap.infoWindow.closeButtonVisible = false;
                            myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
                        catch(error:Error) {
                            trace("Caught Error: "+error);
                    if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 1 && radioBtnGroup.selectedValue == 0)
                        fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
                        var graphic:Graphic = Graphic(event.currentTarget);
                        graphic.symbol = mouseOverSymbol;
                        var htmlText:String = graphic.attributes.htmlText;
                        var textArea:TextArea = new TextArea();
                        try{
                            textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirEmp.toString()
                            myMap.infoWindow.content=textArea
                            myMap.infoWindow.label = graphic.attributes.NAME;
                            myMap.infoWindow.closeButtonVisible = false;
                            myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
                        catch(error:Error) {
                            trace("Caught Error: "+error);
                    if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 1 && radioBtnGroup.selectedValue == 1)
                        fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
                        var graphic:Graphic = Graphic(event.currentTarget);
                        graphic.symbol = mouseOverSymbol;
                        var htmlText:String = graphic.attributes.htmlText;
                        var textArea:TextArea = new TextArea();
                        try{
                            textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpEmp.toString()
                            myMap.infoWindow.content=textArea
                            myMap.infoWindow.label = graphic.attributes.NAME;
                            myMap.infoWindow.closeButtonVisible = false;
                            myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
                        catch(error:Error) {
                            trace("Caught Error: "+error);
                    if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 2 && radioBtnGroup.selectedValue == 0)
                        fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
                        var graphic:Graphic = Graphic(event.currentTarget);
                        graphic.symbol = mouseOverSymbol;
                        var htmlText:String = graphic.attributes.htmlText;
                        var textArea:TextArea = new TextArea();
                        try{
                            textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirLabInc.toString()
                            myMap.infoWindow.content=textArea
                            myMap.infoWindow.label = graphic.attributes.NAME;
                            myMap.infoWindow.closeButtonVisible = false;
                            myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
                        catch(error:Error) {
                            trace("Caught Error: "+error);
                    if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 2 && radioBtnGroup.selectedValue == 1)
                        fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
                        var graphic:Graphic = Graphic(event.currentTarget);
                        graphic.symbol = mouseOverSymbol;
                        var htmlText:String = graphic.attributes.htmlText;
                        var textArea:TextArea = new TextArea();
                        try{
                            textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpLabInc.toString()
                            myMap.infoWindow.content=textArea
                            myMap.infoWindow.label = graphic.attributes.NAME;
                            myMap.infoWindow.closeButtonVisible = false;
                            myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
                        catch(error:Error) {
                            trace("Caught Error: "+error);
                    if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 3 )
                        fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
                        var graphic:Graphic = Graphic(event.currentTarget);
                        graphic.symbol = mouseOverSymbol;
                        var htmlText:String = graphic.attributes.htmlText;
                        var textArea:TextArea = new TextArea();
                        try{
                            textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForIndirBusTax.toString()
                            myMap.infoWindow.content=textArea
                            myMap.infoWindow.label = graphic.attributes.NAME;
                            myMap.infoWindow.closeButtonVisible = false;
                            myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
                        catch(error:Error) {
                            trace("Caught Error: "+error);
                public function onMouseOutHandler(event:MouseEvent):void
                    var gr:Graphic = Graphic(event.target);
                    gr.symbol = defaultsym;
                    myMap.infoWindow.hide();
            ]]>
        </fx:Script>
        <fx:Style>
            @namespace esri "http://www.esri.com/2008/ags";
            @namespace s "library://ns.adobe.com/flex/spark";
            @namespace mx "library://ns.adobe.com/flex/mx";
            @namespace esri "http://www.esri.com/2008/ags";
            @namespace components "com.esri.ags.components.*";
            components|InfoWindow
                content-background-alpha : 0.4;
                background-color : #4A7138;
                background-alpha : 0.7;
                border-style : solid;
        </fx:Style>
        <mx:HBox   width="930" height="800"  id="mapHbox"  horizontalAlign="center" >   
        <mx:HBox width="80">
        </mx:HBox>
        <mx:HBox id="myHBox" width="800" height="600" backgroundColor="0xffffff"  >
            <mx:VBox  height="590" width="358"  >
            <!--    <mx:Panel
                    width="356" height="100%"
                    color="0x000000"
                    borderAlpha="0.15"
                    >
                    -->
                    <mx:Canvas height="100%" width="100%" backgroundColor="0xffffff" >
                        <esri:Map id="myMap" openHandCursorVisible="false"
                                  height="100%" 
                                  logoVisible="false"
                                  doubleClickZoomEnabled="false"
                                  scrollWheelZoomEnabled="false"
                                  zoomSliderVisible="false"
                                  scaleBarVisible="false" scale="4000000" >
                            <esri:extent>
                                <esri:Extent xmin="-10736651.061900" ymin="4024099.909700" xmax="-10409195.669800" ymax="3440153.831100"      >
                                    <esri:SpatialReference wkid="102100"/>
                                </esri:Extent>
                            </esri:extent>
                            <esri:ArcGISDynamicMapServiceLayer id="dynamicLayer2"
                                                               url="http://tfs-24279/ArcGIS/rest/services/RADIO_BUTTONS/counties_layer/MapServer" />
                            <esri:ArcGISDynamicMapServiceLayer id="dynamicLayer" name=" "
                                                               alpha="1"
                                                               load="loadLayerName()"
                                                       url="http://tfs-24279/ArcGIS/rest/services/{myURL.selectedItem.value}/MapServer"   />
                            <esri:FeatureLayer id="fLayer"
                                               graphicAdd="fLayer_graphicAddHandler(event)"
                                               mode="snapshot"
                                               outFields="*"
                                               symbol="{defaultsym}"
                                               url= "http://tfs-24279/ArcGIS/rest/services/RADIO_BUTTONS/feature_layer_0709_five/FeatureServer/ 0" />
                        </esri:Map>
                    </mx:Canvas>
            <!--    </mx:Panel>-->
            </mx:VBox>       
            <mx:VBox  height="590" width="20"  >
            </mx:VBox>       
            <mx:Canvas height="500" width="400" backgroundColor="0xffffff"
                       horizontalScrollPolicy="off"
                       verticalScrollPolicy="off" >
                <mx:VBox  width="420" height="50%" paddingLeft="5" paddingTop="10" paddingRight="10" paddingBottom="10"
                         verticalGap="8">
                    <mx:Form  >
                        <mx:FormItem label="Year        :"  >
                            <mx:ComboBox   id="yearcombo" selectedIndex="0" labelField="label" width="100%" change="changeEvt(event)"  >
                                <mx:ArrayCollection id="year"  >
                                    <fx:Object label="2007"  year="2007" />
                                    <fx:Object label="2009"  year="2009" />
                                </mx:ArrayCollection>
                            </mx:ComboBox>
                        </mx:FormItem>
                        <mx:FormItem label="Measure:">
                            <mx:ComboBox   id="myURL" selectedIndex="8" width="80%" mouseOver="clickEv2(event)" close="closeHandler(event)">
                            <mx:ArrayCollection id="measures"   >
                                <fx:Object id="forindout07" labeltext="Forestry Industry Output" label="Forestry Industry Output " value="RADIO_BUTTONS/TFEI_07_forest_industry_output" year="2007"  />
                                <fx:Object id="foremp07" label="Forestry Employment " value="RADIO_BUTTONS/TFEI_07_forest_employment" year="2007" />
                                <fx:Object id="forlabinc07" label="Forestry Labor Income " value="RADIO_BUTTONS/TFEI_07_forest_labincome" year="2007" />
                                <fx:Object id="forindbustax07" label="Forestry Indirect Business Tax" value="RADIO_BUTTONS/TFEI_07_forest_business_tax" year="2007" />
                                <fx:Object id="forindout09" label="Forestry Industry Output " value="RADIO_BUTTONS/TFEI_09_forest_industry_output" year="2009"  />
                                <fx:Object id="foremp09" label="Forestry Employment " value="RADIO_BUTTONS/TFEI_09_forest_employment" year="2009" />
                                <fx:Object id="forlabinc09" label="Forestry Labor Income " value="RADIO_BUTTONS/TFEI_09_forest_labincome" year="2009" />
                                <fx:Object id="forindbustax09" label="Forestry Indirect Business Tax" value="RADIO_BUTTONS/TFEI_09_forest_business_tax" year="2009" />
                                <fx:Object id="blank" label=" "  />
                            </mx:ArrayCollection>
                        </mx:ComboBox>
                        </mx:FormItem>
                    </mx:Form>
                    <mx:VBox  id="layerPanel" width="50%" height="8%" verticalGap="3" paddingLeft="17">
                        <mx:RadioButtonGroup id="radioBtnGroup" itemClick="radioClickHandler(event)"  />
                    </mx:VBox>
                    <mx:VBox paddingLeft="17" height="50%" >
                    <mx:Canvas  id="legendPanel" width="100%"  >
                        <mx:Label id="myLabel" text=" " fontWeight="bold" />
                        <esri:Legend id="myLegend"
                                     layers="{[dynamicLayer]}"
                                     map="{myMap}" visible="false"
                                     respectCurrentMapScale="false"/>
                    </mx:Canvas>
                    <mx:TextArea width="275"  borderAlpha="0" height="200"  >
                        <mx:htmlText   >
                            <![CDATA[<font size='11'><b>Note:</b> Counties in white indicate either no data is available for that measure or the data has been supressed due to confidentiality.</font>
                            ]]>
                        </mx:htmlText>
                    </mx:TextArea>
                    </mx:VBox>   
                </mx:VBox>
            </mx:Canvas>
        </mx:HBox>
        </mx:HBox>   
    </mx:Application>

  • Looping through inbox items on timer event is really slow...?

    Hi,
    I have an issue with a email sync event that I am running.  Essentially, I am given a date (the received date of the last email synced) via another process and then need to return all the emails in the user's inbox the where receivedDate > this given
    date.
    I have a timer object than triggers my sync event every 15 mins.  I also have a button that allows the user to manually activate the sync - this basically changes the timer to 3 secs and so it fires the sync event.
    If the sync event is fired manually as per above, it loops through everything quite quickly (~12,000 emails in 30 secs) and I can stored the sender/recipient and received time data I require from these in a list of objects, which I sync later on in a background
    process.  During this loop the main UI freezes up, which is fine since I show a progress bar so the user knows how long they need to wait, and a large sync like this should only occur on their first sync theoretically.  If the first sync event is
    fired without the manual input - so still called from the same timer event, but just on the normal 15 min event, not the shortened 3 sec one - then it runs differently.  The sync takes a lot lot longer, and the UI doesn't freeze up.
    I presume this might be because it is fired slightly differently and does not hog up the main thread, but rather shares it with normal Outlook operations.  Maybe the operations are being run on a background thread and then keep having to jump into the
    main thread to access the email items...?  Either way, I'm not quite sure how this is happening since the only difference is the user pressing a button that changes the timer.interval.  The code that is run is the same, and the button press doesn't
    trigger the actual sync itself.
    Is there a way I can force this first sync to always run solely in the main thread, it can freeze up Outlook and show the progress bar until it is done?  Ideally any subsequent syncs would then be run with no progress bar and no freezing up of the UI.
    Many thanks,
    Tom

    Hello Tom,
    > Maybe the operations are being run on a background thread and then keep having to jump into the main thread to access the email items...?
    You shouldn't use another threads when dealing with the Outlook object model. Office applications use the single threaded apartment (STA) model and don't support multithreading. All calls made from another threads are marshalled by Outlook to the main
    thread. However, you can use a low-level code (Extended MAPI) to access the data from secondary threads. For example, you can use Redemption which is based on Extended MAPI.
    >  it loops through everything quite quickly (~12,000 emails in 30 secs)
    Instead of looping over all items in the folder I'd recommend using the
    Find/FindNext
    or
    Restrict methods of the Items class. You can read more about them in the following articles:
    How To: Use Find and FindNext methods to retrieve Outlook mail items from a folder (C#, VB.NET)
    How To: Use Restrict method to retrieve Outlook mail items from a folder
    You can use the System.Windows.Forms.Timer class which uses the main thread for invoking the Tick event. The .NET
    Framework Class Library provides three different timer classes: System.Windows.Forms.Timer, System.Timers.Timer, and System.Threading.Timer. Each of these classes has been designed and optimized for use in different situations. The Comparing
    the Timer Classes in the .NET Framework Class Library article examines the three timer classes and helps you gain an understanding of how and when each class should be used.
    Also you may find the
    AdvancedSearch method of the Application class helpful. Pay special attention to the fact that the search is performed in another thread. You don’t need to run another thread manually since the
    AdvancedSearch method runs it automatically in the background. See
    Advanced search in Outlook programmatically: C#, VB.NET for more information.

Maybe you are looking for

  • Group rows in alv

    Hi, I want my alv to appear this way. Id1     ID1 test1          ID1 test2 Id2     ID2 test1          ID2 test2          ID2 test3          ID2 test4 How will I do this? I don't want Id1 and Id2 to appear in each line item.

  • IPhoto Events

    When in events why has IPhoto stopped rolling over when mouse overed Richard

  • How do I reboot my iMac in Lion? Right now it opens a black screen with dos and asks me to insert the boot disk.

    How do I reboot my iMac in Lion? Right now it opens a black screen with Dos and asks me to insert the boot disk.I recently installed Parallels & Windows 7. Now if I have to turn the system off, it starts up as per above in Dos. know I need to start u

  • Unable to Sync Centro with Vista 32; device driver problem

    I currently sync my Palm Centro (Verizon) to my Desktop Computer running Windows XP and Palm Desktop 6.2.2 with no problem. I am trying to move everything to an HP Notebook running Vista Business 32 bit. I disabled Norton Internet Security and loaded

  • Premiere Pro CS6 Render and Export Screen Glitch and Freeze

    I use Premiere Pro CS6 on a 2012 Macbook Retina display - 16GB RAM, 751GB Flash Storage, NVIDIA GeForce 650m Graphics Card, 2 External 4TB hardrives for scratch disks, Thunderbolt connection. When I try to render and export videos I often get a graph