Trying to figure out a Code that uses the [i] syntax

OK I'm having a grip on the use of loops in flex and I found somewhere the following code that uses a for loop. It is essentially a function that creates multiple labels for all elements in an object. One thing I do not understand what is the [i] on line 5 i.e. (myArray [i]) or specifically what the purpose of these hooks in situations like these are used for. It refers in search of all the strings in the array (as defined on line 3) as I assume it is? It's just quite confusing. Can someone point me to a guide on the syntax of hooks and what they mean or help out me? with an explanation? See you soon.

private function createLabels():void{

var myArray:Array = ['one', "two", 3];

for(var i:String in myArray){

var myLabel:Label = new Label();
myLabel.text = (myArray[i]);
myBox.addChild(myLabel);
}
}


You've probably seen these, but here are some links that may help.

access http://help.adobe.com/en_US/FlashPlatform//Reference/ActionScript/3/Operators.html#array_a

http://www.Adobe.com/LiveDocs/Flash/9.0/ActionScriptLangRefV3/array.html

What's happening essentially is that the loop 'for' runs through each element of the array.  Don't be confused by the fact that two of the elements of the array are strings and one is a whole number - variable I being a string has nothing to do with the data type of the elements in the table.

The following code:

private function createLabels():void
{
     var myArray:Array = ['one', 'two', 3];

     for(var i:String in myArray)
     {
          trace("i = " + i);
          trace(myArray[i]);
     }
}

gives the following results:

i = 0
one
i = 1
two
i = 2
3

We can see that the loop 'for' is the allocation of the index number of each element of the array, not the real element array ('one', 'two' or 3) to the variable i.  If appellant myArray [i] same as calling MonTableau [0] is the first time in the loop.  This type of loop 'for' is just a shorter way to do the following, which produces exactly the same results:

private function createLabels():void
{
     var myArray:Array = ['one', 'two', 3];

     for(var i:int = 0; n < myArray.length; i++)
     {
          trace("i = " + i);
          trace(myArray[i]);
     }
}

Hope that helps.

See you soon!

Tags: Flex

Similar Questions

  • I have a Verizon Tablet and trying to figure out how I can download the software on this subject?

    I have a Verizon Tablet and the invitation to the cloud of AdobeCreative through my school, University of Everest online. I was trying to figure out how I can get the same download to my Tablet?

    Hello

    Please see: -.

    Adobe mobile, iPhone, iPad, Android apps | Adobe Creative Cloud

    Also, you can read:-what tablet do you use with creative cloud / Apps?

  • Issue while deploying code that uses the api of the IOM: OIMClient

    We strive to deploy a war file with some java code that is interfaced with the IOM by using the api OIMClient. Note that we have all necessary spring pots and it works great on Tomcat. Our production env is on weblogic and when deploy us the file. War on weblogic deploys it fine. But when we test some web pages, we get the following error:

    Root cause]] of ServletException.
    java.lang.NoClassDefFoundError: org/springframework/jndi/JndiTemplate
    to oracle.iam.platform.OIMClient. < init > (OIMClient.java:83)
    ......
    Truncated. check the log file full stacktrace
    >


    The class file is available in a container called Spring framework with the same package structure: org.springframework.jndi.jnditemplate. I wonder why he cannot find the definition for this class. I also tried to delete these jars to war file and adding them to the lib dir field. I always find myself with the same exception.

    Appreciate all the help I can get.

    Published by: 958829 on Sep 12, 2012 23:01

    try to add the jar of spring separately to help:->-> deployments weblogic console add jars

  • New to vCO. Trying to figure out which cluster a virtual machine lives in

    Hello.


    I created a simple 'Hello' workflow VM in vCO and added to vcenter so that it appears in the right click menu of a virtual machine.


    When I run it, the entrance is pre-populated with the name of the virtual machine just as I expected.


    In the Scripting section, I am just running


    System.log ('Hello', + vm.displayName);

    System.log (' VM ID: "+ vm.id");

    I'm trying to figure out how I can get the cluster who lives this virtual machine, but the property is not part of the VC:VirtualMachine.

    I have to take advantage of another type of entry to obtain data or another workflow to get this information?

    Thank you.

    My bad. I didn't know this when I tried first.

    https://communities.VMware.com/thread/464671

    I'll try that. Thank you!

  • I really need someone to help me. I tried to figure out how to select a PDF to convert a Word doc. When I go to select a PDF file, all that comes is the WORD documents. doesn't show ANY of my PDF files... Please help me understand wh

    I really need someone to help me. I tried to figure out how to select a PDF to convert a Word doc. When I go to select a PDF file, all that comes is the WORD documents. doesn't show ANY of my PDF files... Please help me understand what is happening? We put it on automatic renewal so I know it's not that we have not renewed this subscription, because we pay automatically.

    Hi olivias,.

    Looks like there may be some confusion on your system which application should be associated with PDF files. You can reset the file name associations by following the steps described in these articles (depending on your operating system):

    How to change the default application for a file type. Macworld

    http://Windows.Microsoft.com/en-us/Windows/change-default-programs#1TC=Windows-7

    Please let us know if you have any additional questions.

    Best,

    Sara

  • Trying to figure out how to put my adobe on my other computer

    Trying to figure out how to put my first from adobe on my other computer so I can use it when I'm not on this computer. I read that I have two computers with one license as long as I'm not on both at the same time.

    Please help if you can guide me in this process or give a link that already has the answer.

    I am running windows 10 on my system, main and windows 7 on the other. Don't know if it's important, but I thought I would mention it.

    Thank you!

    Download the desktop CC app, connect to your Aperture controls session, download apps & start working.

    That's all. Assuming that you are on the CC program.

    If you are on the old CC version, and have a drive for example, just do what you did before... or download from ProTools & give your activation number on the other machine.

    http://prodesigntools.com/Adobe-CC-2015-updates-links-Windows.html

    Neil

  • My Webcam has problems detected by Skype and repeat myself there is another program that uses the webcam. Skype device code 43 usb video.

    My Webcam has problems detected by Skype and repeat myself there is another program that uses the webcam.

    Also got the guests when using Skype as a video device usb was not detected and that it is a code 43.

    Have tried several way sto resolve this problem. CyberLink YouCam HP's running came preloaded on the laptop. The webcam is running when this program is being used separately.

    Inappropriate Feedback Forum of Windows hardware and drivers Forum.

    My Webcam has problems detected by Skype and repeat myself there is another program that uses the webcam.

    Also got the guests when using Skype as a video device usb was not detected and that it is a code 43.

    Have tried several way sto resolve this problem. CyberLink YouCam HP's running came preloaded on the laptop. The webcam is running when this program is being used separately.

    Inappropriate Feedback Forum of Windows hardware and drivers Forum.

    Hello, Aadi467,

    A device driver has notified the operating system that the device failed.

    Run the diagnostic tool of hardware devices do not work or are not detected in Windows on the Microsoft Fix it Center.

    You can also uninstall the software from Cyberlink.  There is a found here download link to reinstall the software after restarting the computer.

    http://h30434.www3.HP.com/T5/notebook-operating-systems-and/lost-my-CyberLink-and-UCAM/TD-p/760367

  • Trying to figure out how to 'Cancel' option on the e-mail hotmail page? Is it possible to display the arrows to "undo" on the page e-mail through Hotmail?

    Trying to figure out how to 'Cancel' option on the e-mail hotmail page? Is it possible to display the arrows to "undo" on the page e-mail through Hotmail? Do not see it as a tool bar option? Thank you!

    Hello

    I'm sorry, but we cannot help with hotmail problems in these forums in response to vista

    Please repost your question in hotmail in the hotmail link below forums

    http://windowslivehelp.com/product.aspx?ProductID=1

    Forums
  • Trying to figure out the TYPE clause

    Hi all

    I'm finally bite the bullet and learn how to use the clause type, but I'm having a little trouble.

    The following example data comes from a book "Advanced CQL works in Oracle 10g".

    with sales1 as (select 'blueberries' product
                          ,'pensacola' location
                          ,9000 amount
                          ,2001 year
                      from dual
                    union all
                    select 'cotton', 'pensacola',16000,2001 from dual
                    union all 
                    select 'lumber','pensacola',3500,2001 from dual
                    union all
                    select 'cotton','mobile',24000,2001 from dual
                    union all
                    select 'lumber', 'mobile',2800,2001 from dual
                    union all
                    select 'plastic','mobile',32000,2001 from dual
                    union all
                    select 'blueberries','pensacola',9000,2002 from dual
                    union all
                    select 'cotton', 'pensacola',16000,2002 from dual
                    union all 
                    select 'lumber','pensacola',3500,2002 from dual
                    union all
                    select 'cotton','mobile',24000,2002 from dual
                    union all
                    select 'lumber', 'mobile',2800,2002 from dual
                    union all
                    select 'plastic','mobile',32000,2002 from dual
                    union all
                    select 'blueberries','pensacola',9000,2003 from dual
                    union all
                    select 'cotton', 'pensacola',16000,2003 from dual
                    union all 
                    select 'lumber','pensacola',3500,2003 from dual
                    union all
                    select 'cotton','mobile',24000,2003 from dual
                    union all
                    select 'lumber', 'mobile',2800,2003 from dual
                    union all
                    select 'plastic','mobile',32000,2003 from dual
                    )
    select location, product, year, s
    from sales1
    model
    --return updated rows
    partition by (product)
    dimension by (location,year)
    measures (amount s) ignore nav
    (s['pensacola',2003] = sum(s)['pensacola',cv() > cv()-1])
    I expect the provision of measures to return the sum of all the amounts of pensacola where year > 2003 - 1 = 2002. which would make the total [blueberries, 2003] is 1800, but instead, it comes out like 27000, apparently adding up all the values for blueberries for this partition... equivalent to concern ["pensacola", ANY].

    How would I go about doing s ["pensacola", 2003] = the sum of itself and the previous row?

    I realize I can do
    s['pensacola',cv()]+s['pensacola',cv()-1]
    but I'm really trying to figure out why what I have doesn't seem to work the way I expected.

    Because

    (s['pensacola',2003] = sum(s)['pensacola',cv() > cv()-1])
    means
    (s['pensacola',2003] = sum(s)['pensacola',cv(year) > cv(year)-1])
    means
    (s['pensacola',2003] = sum(s)['pensacola',2003 > 2003-1])
    means
    (s['pensacola',2003] = sum(s)['pensacola',2003 > 2002])
    means
    (s['pensacola',2003] = sum(s)['pensacola',year is any])
    
    s['pensacola',cv()]+s['pensacola',cv()-1]
    means
    sum(s)['pensacola',year between cv()-1 and cv()]
    
  • How do I step manually in code that uses a structure of the event, when I want to select a particular event?

    I use an architecture of producer/consumer for an application with a structure of the event in the upper loop. Events are triggered by the user from the control panel using Boolean switches that are "change when you press on" and "release switch. My question is how can I manually step through the code using various events? It doesn't matter what I'm still not in the same event.

    Thank you.

    You can view the code? Is what event still enter? I did have problems step by step in code that uses a structure of the event. You must be patient, but because the application is slowed down a bit and it can take a while to get into the case of the specific event depending on what events you deal. Usually, I place a breakpoint in the case I am interested and run the application as usual. Once I hit the breakpoint is when I turn on highlighting of execution.

  • Trying to figure out what model of monitor I have here

    Trying to figure out what model it is, at the back is a sticker with this (but no service tag, being a monitor):

    CN-OMK7Y4-64180-155-06FS

    Thank you!

    MK7Y4 = IN2030M of a 20 "monitor. Built on 5 May 2011

  • I am a student and I bought the web of adobe design premium in my first year. Recently, my computer got crashed and I had to buy a new one. I'm trying to figure out how to reinstall adobe web design premium on my new computer.

    I am a student and I bought the web of adobe design premium in my first year. Recently, my computer got crashed and I had to buy a new one. I'm trying to figure out how to reinstall adobe web design premium on my new computer.

    Click on the drop-down list below the product you wish to download. Then you will receive the link to download the installation file.

  • I'm trying to follow the video to "Change color" and I don't have a lot of options that uses the presenter.  I'm on a PC.  Can someone walk me by changing the color of an object step by step?

    I'm trying to follow the video to "Change color" and I don't have a lot of options that uses the presenter.  I'm on a PC.  Can someone walk me by changing the color of an object step by step?

    Sorry for the delay. Here is the video

  • Setting the properties of elements of façade in XControl to a VI that uses the XControl

    Hi all

    I'm new to XControls and I try to use them to make a generic digital indicator that fit into a matrix of waveforms of a similar measure and allow the user to display the first value of a waveform, it chooses by selecting the name of the desired channel in the waveform table. I have the XControl work, with a ring filled automatically with the NI_ChannelName of the input waveform array fields and the value of the ring being used to index the waveform table to select the appropriate data.

    What I want to do next is automatically set the value of control of ring in the XControl to the value that the user has selected the last time he ran the VI that uses the indicator. However, the properties of the control ring do not seem to be accessible from the VI that uses the XControl, and none of the XControl General properties seem to be accessible from the front VI in the XControl. The value of the ring is not part of the entrance of DataIn cable waveform table, so I don't have a good method to pass data to the control of the ring outside of what is in this table of waveform. I might add the value in the waveform table, if this helps, but indicators XControl do not transmit their return DataOut appellant VI to allow me to record the user selected value.

    Is there a good way to read and write the properties of façade elements in an XControl of VI that uses the XControl?

    I apologize for not posting my code; the computer with LabVIEW license is having network problems at the present time. I'll post the code when I can.

    Thank you!

    Erik

    In your State cluster typedef container, include a reference to a control of the ring.

    In your vi of façade, in the case of change of Direction, create a reference to your ring and connect to a plan by which he sends out the view state.  Also be sure to write true to the status changed in the result of the Action.

    In your xctl, select New-> property.  Name it after the property in the ring that you want to access.  Use the view clustered State (in your new property VI) to access the reference to the ring; son of a property node.  Change the control value in the appropriate type & connect to the property you want.

    Be sure to connect the path error through everything that might cause an error.

    When you drop an instance of the xctl and create a property from this node, your new property will be available.

  • I try to use windows excel for windows vista and am asked for a product key. How can I find out what order to use the product?

    I try to use windows excel for windows vista and asks me to enter a product key. I am the sole owner of the computer but have no installation CD for recharge Excel. How can I find out what order to use the product? From now the product doesn't let me do anything. Help, please!

    Hello

    Did you pay for Office (including Excel) in a packaging separated when you bought your computer?

    Office is not included with your purchase of computer for free.

    Most new computers come with a trial version of Office that lets 'x' number of days usuage.

    After this test times out, you will have to buy Office.

    And the product key on the computer case or laptop for the operating system, not for the desktop Suite.

    Here is the link for the Microsoft Store to Office products:

    http://www.microsoftstore.com/store/msstore/HTML/pbPage.Office_Category_Page?ICID=Home_4up_1_OfficeCatPage

    And you might be interested in the free Open Office Suite of Office Applications.

    http://www.OpenOffice.org/

    For any other question about Office, please repost in the Office Forums:

    http://answers.Microsoft.com/en-us/Office

    See you soon.

Maybe you are looking for

  • Inhalation of toxic gas!

    So, recently, I was sucking on my iPad pregnant cuz i though there's something in it, and I felt as if I was breathing something dang cuz it tasted really weird . is - this toxic or my just being paranoid?

  • Help please with iMAP

    Hello This question was easy to fix on my iOS devices, but on my iMac its driving me nuts. I recently changed all my accounts pop3 to iMap to sync all of my accounts on devices to save time deleting emails but my iMac will not play. I used to use the

  • Satellite A300 - how to clean?

    Hi dear Toshiba owners; I would like to clean my laptop after 9 months of good use. Well,. I'm not talking about cleaning the keyboard or LCD, of course, I'm no fan talking inside. I've noticed recently that this laptop is producing heat wrong lately

  • Can't install or uninstall Starlight

    Try to install windows live essentials - download cannot take place due to a Starlight.msi problem. Error message says cannot find the resource installation package. Try to uninstall it, get the same message. How to solve this?

  • My icons passed to big and I can't seem to understand how to make new

    I use my computer for gaming. After playing a game all my icons on my desktop got twice the size, and I don't know how to change back to the small