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

Similar Messages

  • 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

  • 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.

  • 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?

  • Insert Loop through a Report or Insert using a Column Link

    Hello!
    I think I have an easy one.
    I have created a site that tracks "issues" with the curriculum of a university's courses. If a curriculum developer sees something that must be updated, they use this site to log the "issue" so we have a running list of how the curriculum has changed for the particular course or courses. Some "issues" span multiple courses, so a table was created to allow the issue to be associated with as many courses as necessary.
    The "Courses" table holds a list of all courses at the university
    The "Issue_Courses" table combines the primary key for the "issue" and the "course" and creates the association between issues and courses.
    The page users use to create the associations has a report called "add_courses" which is searchable and filterable so the user can narrow down the list of courses they want to view (the list is well into the thousands), and this report contains a column with check boxes. This page also contains a hidden field containing the primary key for the issue, "p13_Issue_ID"
    I would like to create an insert statement that grabs the primary key for the issue from "p13_issue_ID" and loops through the report, inserting a new record for each checked box in the report. Any assistance would be great! Admittedly, my sql is pretty week.
    Another option that I think would work, if possible, would be to have a "column link" that simply runs the insert process by grabbing the issue primary key from "p13_issue_ID" and the course id from the report. Then, the user could simply click on an "Add" link or something similar on the report, which would run the insert statement, and basically create that association. Is this possible?
    Thanks in advance!
    Edited by: 846852 on Mar 23, 2011 3:12 PM
    Edited by: 846852 on Mar 23, 2011 3:14 PM

    Start with adding a checkbox column to the report in page (13 ??)
    select apex_item.checkbox(1,course_id) CHECK
           ,course_name
    FROM courses
    I assumed that course_id is the PK of the courses table , if not change the column names appropriately
    In report attributes of the "CHECK" column, change the column type to "*Standard Report Column*" (important).
    Now you should see a report with courses lists and checkboxes to choose them, You can also do the same with an interactive report(if you want to use it features to filter down records)
    Inorder to process the records create a PLSQL process that loops over the selected records(courses) and creates the relation in the Issue courses table using the hidden item and checked course primary key(course_id above)
    DECLARE
      ln_course_id NUMBER;
    BEGIN
      FOR 1 IN 1..APEX_APPLICATION.G_f01.COUNT
      LOOP
        ln_course_id := APEX_APPLICATION.G_f01(i);
        --Insert new relation using Issue Id and course ID
        INSERT INTO ISSUE_COURSES(course_id,issue_id) VALUES( ln_course_id,:P13_ISSUE_ID);
      END LOOP;
    END;If you have a submit/save button , make the process conditional for that button.

  • 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);
    }

  • How to loop through XML data in a table of XMLType?

    Hi,
    I am failry new to xml document processing in Oracle using PL/SQL.
    My DB version: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    I have successfully loaded an xml document into a table using the following two statements:
    1) CREATE TABLE mytable2 OF XMLType;
    2) INSERT INTO mytable2 VALUES (XMLType(bfilename('IMAGE_FILE_LOC', 'IFTDISB20100330172157C002.xml'), nls_charset_id('AL32UTF8')));
    Now I need to traverse through the various nodes within the xml document and extract values of elements of each node. The question I have is:
    How do I loop through a node? A VALID record is enclosed within the <checkItem> </checkItem> tags.
    Here is a snippet of the data in that xml document:
    ++++++++++++++++++++++++++++++++++++++++++++++++
    <?xml version="1.0" encoding="UTF-8"?>
    <bdiData>
    <documentControlInfo>
    <documentInfo>
    <docDescription>Check images and data for Test Company, account number 1234567890</docDescription>
    <docID>
    <ID>20100330172157</ID>
    </docID>
    <docModifier>Test Company</docModifier>
    <docCreateDate>2010-03-30</docCreateDate>
    <docCreateTime>17:21:57-0700</docCreateTime>
    <standardVersion>1.0</standardVersion>
    <testIndicator>0</testIndicator>
    <resendIndicator>0</resendIndicator>
    </documentInfo>
    <sourceInfo>
    <sourceName>The Bank IFT</sourceName>
    <sourceID>
    <idOther>TheBankIFT</idOther>
    </sourceID>
    </sourceInfo>
    <destinationInfo>
    <destinationName>Test Company</destinationName>
    <destinationID>
    <idOther>FEI3592</idOther>
    </destinationID>
    </destinationInfo>
    </documentControlInfo>
    <checkItemCollection>
    <collectionInfo>
    <description>Items</description>
    <ID>1269994919135</ID>
    <Classification>
    <classification>Items</classification>
    </Classification>
    </collectionInfo>
    <checkItemBatch>
    <checkItemBatchInfo>
    <description>Paid Checks</description>
    <ID>1269994919135</ID>
    <Classification>
    <classification>Paid Checks</classification>
    </Classification>
    </checkItemBatchInfo>
    <checkItem>
    <checkItemType>check</checkItemType>
    <checkAmount>86468</checkAmount>
    <postingInfo>
    <date>2010-03-29</date>
    <RT>10700543</RT>
    <accountNumber>1234567890</accountNumber>
    <seqNum>009906631032</seqNum>
    <trancode>001051</trancode>
    <amount>86468</amount>
    <serialNumber>300040647</serialNumber>
    </postingInfo>
    <totalImageViewsDelivered>2</totalImageViewsDelivered>
    <imageView>
    <imageIndicator>Actual Item Image Present</imageIndicator>
    <imageViewInfo>
    <Format>
    <Baseline>TIF</Baseline>
    </Format>
    <Compression>
    <Baseline>CCITT</Baseline>
    </Compression>
    <ViewSide>Front</ViewSide>
    <imageViewLocator>
    <imageRefKey>201003260000738400851844567205_Front.TIF</imageRefKey>
    <imageFileLocator>IFTDISB20100330172157M002.zip</imageFileLocator>
    </imageViewLocator>
    </imageViewInfo>
    <imageViewInfo>
    <Format>
    <Baseline>TIF</Baseline>
    </Format>
    <Compression>
    <Baseline>CCITT</Baseline>
    </Compression>
    <ViewSide>Rear</ViewSide>
    <imageViewLocator>
    <imageRefKey>201003260000738400851844567205_Rear.TIF</imageRefKey>
    <imageFileLocator>IFTDISB20100330172157M002.zip</imageFileLocator>
    </imageViewLocator>
    </imageViewInfo>
    </imageView>
    </checkItem>
    <checkItem>
    <checkItemType>check</checkItemType>
    <checkAmount>045</checkAmount>
    <postingInfo>
    <date>2010-03-29</date>
    <RT>10700543</RT>
    <accountNumber>1234567890</accountNumber>
    <seqNum>008518967429</seqNum>
    <trancode>001051</trancode>
    <amount>045</amount>
    <serialNumber>200244935</serialNumber>
    </postingInfo>
    <totalImageViewsDelivered>2</totalImageViewsDelivered>
    <imageView>
    <imageIndicator>Actual Item Image Present</imageIndicator>
    <imageViewInfo>
    <Format>
    <Baseline>TIF</Baseline>
    </Format>
    <Compression>
    <Baseline>CCITT</Baseline>
    </Compression>
    <ViewSide>Front</ViewSide>
    <imageViewLocator>
    <imageRefKey>201003290000713900851896742901_Front.TIF</imageRefKey>
    <imageFileLocator>IFTDISB20100330172157M002.zip</imageFileLocator>
    </imageViewLocator>
    </imageViewInfo>
    <imageViewInfo>
    <Format>
    <Baseline>TIF</Baseline>
    </Format>
    <Compression>
    <Baseline>CCITT</Baseline>
    </Compression>
    <ViewSide>Rear</ViewSide>
    <imageViewLocator>
    <imageRefKey>201003290000713900851896742901_Rear.TIF</imageRefKey>
    <imageFileLocator>IFTDISB20100330172157M002.zip</imageFileLocator>
    </imageViewLocator>
    </imageViewInfo>
    </imageView>
    </checkItem>
    <checkItemBatchSummary>
    <totalItemCount>1028</totalItemCount>
    <totalBatchAmount>61370501</totalBatchAmount>
    <totalBatchImageViewsDelivered>2056</totalBatchImageViewsDelivered>
    </checkItemBatchSummary>
    </checkItemBatch>
    <collectionSummary>
    <totalBatchCount>1</totalBatchCount>
    <totalItemCount>1028</totalItemCount>
    <totalCollectionAmount>61370501</totalCollectionAmount>
    <totalCollectionImageViewsDelivered>2056</totalCollectionImageViewsDelivered>
    </collectionSummary>
    </checkItemCollection>
    <documentSummaryInfo>
    <totalCollectionCount>1</totalCollectionCount>
    <totalBatchCount>1</totalBatchCount>
    <totalItemCount>1028</totalItemCount>
    <totalDocumentAmount>61370501</totalDocumentAmount>
    <totalDocumentImageViewsDelivered>2056</totalDocumentImageViewsDelivered>
    </documentSummaryInfo>
    </bdiData>
    ++++++++++++++++++++++++++++++++++++++++++++++++
    Any ideas and or suggestions will be greatly appreciated.
    Cheers!
    Edited by: user12021655 on Aug 3, 2010 1:25 PM

    I really need to update my blog to get the example you are looking for posted. I did a quick search on the forums for XMLTable and found a good example at {message:id=4325701}. You will want to use OBJECT_VALUE in the PASSING clause where you need to reference the column in your table.
    Note: See the FAQ in the upper right for how to use the tag to wrap objects to retain formatting.  Also your XML is missing closing nodes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Problem finding object for Custom Object Test

    I need to create a custom object test that tests whether a an element is present after a record gets inserted into the database. The script is databanked and each iteration needs to insert a databanked record, then evaluate my custom object test to make sure the record was inserted. The trick is in writing the expression that finds the correct custom object. After one iteration, this is the code that finds the custom object;
    RSWApp.om.GetElementByPath "window(index=0).link(text=""Category D"" | href=""javascript:OpenModal('DocumentCategoryAddEdit.aspx?documentCategoryId=377','400');"" | index=19)", element
    Instead of always grabbing the object whose text is "Category D", I want to grab the object whose text is <<category>> (ie retrieved from a databank file). Search in the href or index isn't helpful because these will change with each iteration through my script.
    I tried to modify the GetElementByPath to this:
    RSWApp.om.GetElementByPath "window(index=0).link(text=dbValue|)", element
    where dbValue is a local parameter that I set earlier on. When I run this, I get an object not found error.
    Any ideas?

    I much prefer to use RSWAPP.om.findElement. It is much more robust than FindElements.<BR>
    RSWApp.GetDatabankValue Is what is needed anytime you want to return Databank values to the VBA environment<BR>
    <BR>
    Your code should look something like the following:<BR>
    <BR>
    Dim dbVal as string
    <BR>
    RSWApp.GetDataBankValue "MyDbVariable", dbVal<BR>
    <BR>
    This will return the contents of "MyDbVariable" which is defined and bound in the databank wizard to VBA variable dbVal.<BR>
    <BR>
    You can then use DBVal in your path:
    <BR>
    RSWApp.om.GetElementByPath "window(index=0).link(text="" & dbVal & "" | href=""javascript:OpenModal(&#39;DocumentCategoryAddEdit.aspx?documentCategoryId=377&#39;,&#39;400&#39;);"" | index=19)", element<BR>
    <BR>
    If you decide to use Find elements instead of GetElementByPath, the syntax would like the following: <BR>
    <BR>
    Set element = RSWApp.om.FindElement(dbVal, "A", "InnerText") <BR>
    As you can see it is much simpler.<BR>
    <BR>
    Hope this helps!

  • How do I loop through AFrames?

    I feel dumb asking this but I really think the code I have should work. All I want to do is loop through all the aframes in a document. To do this, I assign the first Aframe to a variabe named vAFrame. Then, I created a while loop where the test is vAFrame.ObjectValid(). however, the while loop never tests to true even though the data browsers shows that the vAFrame variable contains a valid object AND it supports the ObjectValid() method AND the valid object is an AFrame. I must be missing something really obvious here. Any ideas?
    main ()
    function main()
        var vDoc=app.ActiveDoc;
        var vFlow=vDoc.MainFlowInDoc;
        var vTextFrame=vFlow.FirstTextFrameInFlow;
        var vAFrame=vTextFrame.FirstAFrame;
        while (vAFrame.ObjectValid())
            vAFrame=vAFrame.NextAFrame;

    I am heads down on a project so I can't give you much code right now, but I can point you in the right direction. The method you are using only works for a single text frame, so you would also have to include a loop for all of the text frames in the flow. A better approach is to get a list of FrameAnchor items from the main flow of the document. Then you can loop through the text items to process each anchored frame.
    // Set a variable for the main flow in the document.
    var flow = doc.MainFlowInDoc;
    // Get a list of the anchored frames in the flow.
    var textItems = flow.GetText(Constants.FTI_FrameAnchor);
    // Loop through the anchored frames.
    for (var i = 0; i < textItems.len; i += 1) {
      var aFrame = textItems[i].obj;
      // Do something with the anchored frame here.
    Note that this will only get anchored frames in the main flow itself; it will skip anchored frames that are inside table cells or nested in other anchored frames. Please let me know if you have any questions or comments.
    Rick Quatro

  • Looping through an array, i dont want duplicates

    hello,
    I am wondering if anyone can help me please, I have an array
    containing numbers, these numbers are attached to movie clips to
    determine where they are on the stage, and they are generated
    randomly, so the movie clips are always in a new place when a
    certain button is pressed.
    My problem is that I dont know how to avoid duplicates. The
    way I have done it is I have put the values in an array, and I loop
    through this with a for loop, from here I take the values and link
    them to another array that contains the movie clips, this all works
    well but some of the movie clips are stacked on top of one another
    because the same array values are coming up :S I have attached the
    code, so any suggestions would be gratefully recieved, I just
    havent a clue on this one :S
    Many thanks any help is gratefully recieved :D

    Hi. You were wise to trace the value of n. Your problem seems
    to be that the tests succeed (almost always) in the very first
    iteration because they truly don't match (where n = 0) and
    execution breaks out. You need to adjust the logic. As one
    approach, while sticking with your code and not changing it too
    much (such as using more efficient int vs Number):
    at the very top, define a counter var ct:int = 0;
    before the testing loop, define a flag, such as var
    flag:boolean = false;
    you could then invert the logic in the loop and test for ==
    rather than for !=
    if you find a match, do--> flag = true;
    and break
    at the end of testing, use the flag to decide whether to
    store the new value
    if (!flag) {
    // add to array
    ct++;
    also, use a while loop for controlling the whole thing-->
    while(ct < max) { }
    to know when you're done
    You can also check out the Array functions indexOf() and
    some(), to make things more efficient and faster/easier
    when you're all done, you can also look into using if (a != b
    && c != d)
    for efficiency, instead of nesting them separately
    good luck :)

  • Problem looping through recordset

    Hi,
    I am having a problem with the following code. In the test case, the recordset returns more than one record. Only one record is inserted, and the loop aborted after the insert. If I take out the insert statement the loop cycles through for every record. I do not believe there is anything wrong with the insert statement, as the first record is inserted. Any help would be appreciated.
      while(rs.next()){
                     System.out.println("test");
                     String equip = rs.getString("EQUIP");
                     String pm = rs.getString("PM");
                     String lim = rs.getString("LIMIT");
                     String item_val = rs.getString("ITEM_VALUE");
                     String source = rs.getString("SOURCE");
                     myStatement.executeQuery("INSERT INTO TESTTBL(ACTION,STATUS,TOOL,REMARK) VALUES('STACK VALIDATION','UPDATED', '" + equip + "','LIMIT: " + lim + " - VALUE: " + item_val + " SOURCE: " + source + "')");
                     System.out.println("INSERT INTO TESTTBL(ACTION,STATUS,TOOL,REMARK) VALUES('STACK VALIDATION','UPDATED', '" + equip + "','LIMIT: " + lim + " - VALUE: " + item_val + " SOURCE: " + source + "')");
                 }

    Did rs come from myStatement?
    From http://java.sun.com/j2se/1.4.2/docs/api/java/sql/ResultSet.html :
    A ResultSet object is automatically closed when the Statement object that generated it is closed, re-executed, or used to retrieve the next result from a sequence of multiple results.
    You have to use two different statements: one for the rs that you're looping through and one for the insert that occurs while still using the first rs.

Maybe you are looking for

  • Kernel panic on mac os x 10.8.2 mountain lion

    Hello my friends. my macbook pro panic is : Interval Since Last Panic Report:  4763 sec Panics Since Last Report:          13 Anonymous UUID:                    C9449238-DBAF-B7E7-A188-25C1724B041B Thu Feb 21 16:52:05 2013 panic(cpu 2 caller 0xffffff

  • HP 2600n Not Printing Correctly and Lost Functions

    The 2600n has lost the following functions with the HP/Apple update based on my normal use. Note that all of these were functioning prior to update. 1. Double sided printing not selectable; no double sided printing available 2. Cannot print 2 pages o

  • Material Ledger -- WIP values

    Hi,   We have material ledger functionality active and want to extract the WIP values based on the Production Order. Currently we are executing transaction Code CKMLWIPDISP for viewing the WIP details and the values in object currency and controlling

  • Windows sensor button on monitor stopped working - Yoga Pro 2

    I have had my Yoga Pro 2 all of 3 days, and today the sensor button located on the monitor that brings you to the windows start screen has stopped working. When I purchased the laptop, the sensor worked fine - it vibrated when touched and brought me

  • Editing colors of an imported JPEG image

    I have imported this jpeg into illustrator. How do I edit the color of the image, as in the color of the letters?