Trying To Understand Some Code Which Uses the [i] Syntax
Ok I'm trying to get a grip on using loops within flex and I found the following code somewhere which utilises a for in loop. It basically is a function that creates several labels for all of the elements in an object. One thing I cannot understand is what the [i] is used for on line 5 i.e. (myArray[i]) or more specifically what the purpose of such Square brackets in situations like these are used for. Does it refer to looking for all Strings in the array (as defined on line 3) as I assume it does? It's just pretty confusing. Can anyone point me to a guide on the syntax of square brackets and what they mean or help me out? with an explanation? Cheers.
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 already seen these, but here are a couple of links that may help.
http://help.adobe.com/en_US/FlashPlatform//reference/actionscript/3/operators.html#array_a ccess
http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/Array.html
What's basically happening is that the "for" loop goes through each item in the array. Don't be confused by the fact that two of the items in the array are Strings and one is an Integer - variable i being a String has nothing to do with the data type of the elements in the array.
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
From that we can see that the "for" loop is assigning the index number of each array element, not the actual array element ('one', 'two', or 3) to the variable i. So calling myArray[i] is the same as calling myArray[0] the first time through the loop. This type of "for" loop is just a shorter way of doing 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.
Cheers!
Similar Messages
-
I'm trying to prepare some new iPads using Apple Configurator and the download of IOS8 failed.
The error in Apple Configurator is "Unable to download iOS 8.0. The firmware image was corrupted. Please retry the operation."
Is there a way to get the Apple Configurator to try to re-download iOS 8?Apple Support had me delete the image file from the following location:
~/Library/Containers/com.apple.configurator/Data/Library/Caches/com.apple.confi gurator/firmware/
The file name was iPad3,4_8.0_12A365_Restore.ipsw
I deleted this file and ran the prepare again and it download the iOS 8 ok and successfully prepared the iPad. -
Where are the codes which support the system functions in calculate scripts
Hi all,
I want to create some user-defined functions to meet some sepecial requirements. Before this job, I really like to see the codes which support the system functions such as "@Idescendants". where can i find the .class files or .jar files which the system functions used to perform calculation at background? consider the user-defined function usually have one.
Thanks alot!
Edited by: tony.lee on 2012-6-12 上午2:45Hi,
You can get the sample codes from the below link
http://www.oracle.com/technetwork/indexes/samplecode/essbase-sample-522117.html
Cheers..!! -
I have a photo of an ice surface and another of a flower. Now I want to create a merged photo with the flower lying under the ice. I understand that I shall use the function "Layer" and have even read in the manual and looked on a video, but that information is not sufficiently detailed for me. I have tried several options, but I come now way. Generally it seems that your information is only for the ones who can, not for the people who can´t although it is we who really need to learn. Please give me a step by step (click by click) information on how I can get the ice above the flower and then make the ice partly transparent so the flower is seen underneath. Please send me an e-mail Erik Solbu [email protected]
Open a new document big enough for your image. Then additional open your ice and flower image as well. Copy each and paste it into your blank document. They will be placed on their own separate layers.
Make sure in your layers panel. (Bottom right) the ice is above the flower, by dragging it in place. In that same layers panel click the ice layer to select in and find the opacity meter above. Drag to the left until you get the effect you desire. -
I have quickbooks software. I am traveling. I tried to send an invoice out, using the mac email (version 5.3) I can't send the mail out. I get a pop up asking for my password, I put the password in and it does not accept it. This is the 1st time I've had this problem.
slpmtnsWhilst it may not be your fault I am afraid it appears that your post is on a forum which is not the best for your OS. It will save the time of the unpaid volunteers here, and may resolve your issue faster, if you could examine the list below and see if there is a more appropriate forum to which you could direct your question.
OS X 10.9 Mavericks
OS X 10.8 Mountain Lion
OS X 10.7 Lion
OS X 10.6 Snow Leopard
OS X 10.5 Leopard
OS X 10.4 Tiger
OS X 10.3 and earlier
OS 9, OS 8 & System 7
OS X Technologies
OS X Server
iPad
iPhone
iPod
Other -
I have a VGA adapter and an iPad2. Tried projecting my iPad2 to projector using the VGA but doesn't work. Tried it with friend's iPad1 and it works. Why?? Pls help.
Yup - nothing happens. I then took the same VGA cable and plugged it into my friend's iPad1 and it worked perfectly when she opened Keynote. My understanding is that the iPad2 mirrors the entire screen, so no need to go into any specific application in order to project to the screen, right? Do I need to download any specific app or change any settings in order to be able to project the screen using VGA?
Sorry - novice at this. Not very tech minded either... -
I'm trying to distribute a DB Application using the Instant Client provided
Hi!!
I'm trying to distribute a DB Application using the Instant Client provided by Oracle.
I've checked the FAQ of Oracle and says the Instant Client supports all existant versions of Oracle.
But I've also seen in another posting that the oci.dll needs the same Oracle version file it was created with.
I need to distribute an application that provides all the 8i, 9i and 10g versions.
Do I have to distribute the oci.dll for each version?
I just wanted to check if this was true.
One more question, when I uncompress the Instant Client, many files appear from which
I only left oci.dll, oraocci11.dll and oraociei11.dll and erased them all, but the program
still works. Is it ok?
thanx
Edited by: user11139984 on 2009. 5. 6 오후 11:10I am not sure what you mean if you say that you "need to distribute an application that provides all the 8i, 9i and 10g versions".
If you mean that you want your application to be able to access Oracle Databases of versions 8, 9 and 10, then you can use Instant Client 10.2.0.4 which is able to connect to all of them.
If your application does not need more than the three DLLs you mention to run, that should be fine.
Yours,
Laurenz Albe -
I tried to download latest windows support using the boot camp , but the download stopped beacause of a network proplem , can you help?!
I have the same issues. I keep getting a "network error" even though my connections are fine. I have installed Bootcamp fine on another Macbook, but am having major issues with my brand new one. I have read the support forums where they say to keep trying because the servers are notoriously slow, but this seems a little ridiculous. Hope I can get some help as well.
Thanks! -
My 10 yr. old went behind me and downloaded some music which used all my money on my account. Is it any way that I can delete it and get my money back on my account.
You can try contacting iTunes support via this page and see if they will refund or credit you : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption
-
Error code "A valid key code to use the Business View Manager is not found"
Hello.
I am trying to resolve this message in the Business View Manager. The message of " A valid key code to use the Business View Manager is not found" appears when accessing a folder in the Repositiry Explorer. I have admin rights for View, Edit and Set Security.
What am I doing wrong?Try running this query in the CMS Query Builder tool:
Select * from CI_SystemObjects where si_id = 4
When the query returns, look for the attribute "SI_CAN_USE_METADATA" and see if its set to false. Or see if something else in there is set to false that looks more suitable. Your keycode might have the BusinessView manager locked out. The error sounds more like a keycode restriction than a permissions issue with security. -
Hard code accounts using the dynamic report templates?
Anyone ever been able to hard code accounts using the dynamic report templates?
How about getting the Property name/value fields to work?Hi,
No, this is not possible.
In Dynamic Report templates (which are not based on EVDRE function in version 7 and below), the only thing you can do is to not use any expansion at all and to list your specific accounts on the layout itself. Or to expand your accounts based on a dimension property.
In version 7.5, all Dynamic Templates for Report and Input Schedules will use EVDRE function.
Hope this helps.
Kind Regards,
Patrick -
I am trying to set an open DNS using the MacAir. But when I tried to flush the existing one at utilities/terminal, it will not work. I am using Yosemite. May I know what should be the command line so that I can shift to an open DNS? Thanks
>SystemPreferences>Network>DNS
-
Mac book pro stops responding after Maverick OS restart. Currently have a circle with a line through it after 20+ hours. Tried to shut it down and use the Time Machine to restore but no response. How can I restore with Time Machine if it will not start?
sonjadg,
you can purchase a replacement pair of grey installation DVDs for your MacBook Pro from either Apple or iFixit. If Startup Manager is only showing an OS X Installer volume, then it sounds like the Mavericks installer had a problem midway through its installation process. To fix this, you’re going to need to erase your internal disk and reïnstall your original version of OS X from the grey Mac OS X Install DVD, use Software Update to get it back to 10.6.8 (presuming that your MacBook Pro originally came with Snow Leopard), and then restore from Time Machine. -
Revision: 11118
Author: [email protected]
Date: 2009-10-23 16:35:38 -0700 (Fri, 23 Oct 2009)
Log Message:
Did some code cleanup on the Spark components to enforce the conventions about how to order stuff within an AS file.
QE notes: None
Doc notes: None
Bugs: None
Reviewer: None; no functional changes
Tests run: ant checkintests
Is noteworthy for integration: No
Modified Paths:
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/ButtonBar.as
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/CheckBox.as
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/DropDownList.as
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/List.as
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/NumericStepper.as
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/Panel.as
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/RadioButton.as
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/Spinner.as
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/TextArea.as
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/TextInput.as
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/ButtonBase.a s
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/ListBase.as
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/SkinnableTex tBase.as
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/Slider.asHi Rod,
different sources (i.e. different branches) are mapped to different local folders in your workspace - in fact you cant map two different server folder to the same local folder.
In you example the mapping would be (for example) like this:
Server path
local path
$/../WpfHelloWorld
C:\Src\WpfHelloWorld
$/../WpfHelloWorldDev
C:\Src\WpfHelloWorldDev
You can see your Workspace mappings when you select "Workspaces..." in the Workspace selection drop down:
Within the "Manage Workspaces" dialog select your workspace and klick "Edit" to see and edit all you mappings. -
I've imported some midi tracks, used the mixer to set pan, volume etc, but when I stop playback and restart it sets every midi track back to '0'. I've been using LE for years, this is a new one, any ideas?
Hi,
that's because Logic reads the volume information out of the imported MIDI tracks and sets the volume fader according to this information. The MIDI information overrides volume settings you have done, so you have to identify the MIDI events that contain volume (or expression or pan or whatever) information and delete them. You can use the event list editor for this.
Fox
Maybe you are looking for
-
1300 Root-Bridge and Non-Root Bridge setup
I have two 1300s that I am trying to set up as Root Bridge and Non-Root Bridge, however, everytime i specify one of them as a Non-Root bridge, the radio0 interface becomes disabled. The only option that i am able to pick that enables the radio0 inter
-
Where to obtain Update 3 for Solaris 10 x86
Hello all, For some reason my smpatch is broken and won't download patches. I need to locate Update 3 for Solaris 10 x86 but with all the new changes to the website I'm completely lost and can't seem to find the download link. Can anyone help out? Th
-
Can't get itunes to download and I tried everything
I have a windows 7 64 bit and in order to use my new i-pad, I had to update to the newest version of itunes (10.5.2). The update wouldn't install, and I have spent about 6 hours trying all of the following (multiple times!!): updated and repaired .N
-
Reg Data in table in two languages
Hi, Here i am having the reqt that i need to extract the data from SQL Table in to BI 7 system.In SQL, I am having the customer table, in that, Customer name and Customer phone numbers will be there in both English as well as arabic. so, we have to
-
What is the ac cord used for ? do i need to use it?
what is the ac cord used for ? do i need to use it?