AS 101 question on loops

I'm stuck on something that's really fundamental and it's
driving me nuts.
I've got five buttons labeled "btn_1", "btn_2", etc. When a
button is pressed, I'd like to trace it's corresponding number.
When I try this:
for(var i:Number=1;i<6;i++){
this["btn_"+i].onPress = function(){
trace(i);
... it traces "6" regardless of which button is pressed. I
know I'm missing a variable somewhere, but my grey matter's crapped
out. Help? Many thanks in advance.

yeah this is common with loops of this nature - because the
'last' number iterated to is 6 so the value of i is now 6 once the
loop completes. to remedy, store the current value of i in a
property of the btn instance then call that prop as in:

Similar Messages

  • Few questions - game loop, data types, speed

    Hello, I have a few questions after studying some topics in this forum regarding game creation:
    1) What's the fastest way to wait in the game loop? I've seen two approaches:
    thread.sleep(10)andsynchronized(this) { wait(10); }2) What data types shall I use? In C++ I use to prefer int over short in all cases, because 32bit hardware works faster with integers. Is this same on cell phones?
    3) Speed of applications is slow. I just wonder wheter it's my fault. I was testing application, which only cleared the buffer and outputted FPS and I got around 20 frames. It was Nokia 6300 with 240x320 display. After testing on other phones I've found out that the bigger the resolution, the slower the game is going. Is this normal?
    Thanks for replies...

    1) You're not going to notice any really speed difference between the two code snippets. Read up on 'Threads', and you'll see why one may be used in place of the other depending on the situation. In general there may be a slight performance loss, however unnoticable, when using the synchronized version, but when you are multithreading it is likely necessary.
    sleep(int) is impossible to interrupt, so it's generally a no-no in most situations. However we are talking about devices where every bit of performance helps, so as long as it works for ya, it's not a big deal.
    2) The performance difference is fairly negligable, if any. The biggest thing to consider is memory requirements, and shorts take 1/2 the data.
    Also, many phones don't support floating point data types, so you'll likely need to use ints/longs to calculate your values if you want to have any accuracy beyond whole numbers. Doing something like shifting bits or using 1000x values in your calculations can get around most of the problems when you can't use floats.
    3) The biggest performance killers are IO, memory allocation, screen drawing; pretty much in that order. So I imagine that you are re-creating a new String object every time you output your FPS value on screen right? Doing that every frame would destroy any hopes of getting high-performance.
    Just be careful, and never allocate objects when you can avoid it. anything where you concat String objects using + will cause your performance to die a horrible painful slow death. Remove anything that says 'new' from your main loop, and all String operations, and it'll likely speed things up a lot for ya.
    Does your main loop have something like this?
    g.drawString("FPS: " + currentFps, 0,0,Graphics.TOP | Graphics.LEFT);
    This is very bad because of the String operation. It'll create a new String every frame.
    If you have any more specicif questions, or you'd just like to pick the brain of a mobile game dev, stop by my messageboard:
    http://attackgames.proboards84.com
    Message was edited by:
    hooble

  • Performance question on looping thrue blocks and items (forms 10.1.2.3)

    Hi all,
    I'm back again in Forms forum : ) !!! and I'm working on a new and very interesting project
    version used : Forms [32 bits] Version 10.1.2.3.0 (Production)
    A little question for gurus :
    On former projects I used to call loops on blocks and item like shown below to do various things such as displaying buttons or showing canvas or different VA depending on the user or scenarios .
    PROCEDURE FRM_BLK_ITM_LOOP IS
    v_curblk varchar2(90); -- bloc courant
    v_curitm varchar2(90); -- item courant
    BEGIN
      v_curblk := get_form_property(:SYSTEM.CURRENT_FORM,first_block); -- on récupère le 1er block de la form
      LOOP
      v_curitm := v_curblk||'.'||get_block_property(v_curblk,first_item); -- on récupère le 1er item du block
        WHILE v_curitm != v_curblk||'.'||get_block_property(v_curblk,last_item)
         LOOP -- tant que l'item n'est pas le dernier du block on loop
            v_curitm :=  v_curblk||'.'||get_item_property(v_curitm,nextitem); -- on récupère l item suivant
            if get_item_property(v_curitm,<some property>) = 'TRUE' then
              --- I can do something.... or adding more conditions if then etc...
            end if;
        END LOOP;
      EXIT WHEN v_curblk = get_form_property(:SYSTEM.CURRENT_FORM,last_block); -- on sort losrqu on arrive au dernier block
      v_curblk := get_block_property(v_curblk, nextblock); -- on passe au block suivant
      END LOOP;
    END;In my current project we work on quite huge forms which can have a consequent number of blocks and items.
    And we must be very careful regarding performance issues as these forms are accessed via LAN and WAN.
    So my question :
    This method seems to be quite efficient as it goes thrue blocks and items sequences as they are defined in the builder comparing to go_block -> go_item ->do_something which can easily turn into nightmare-programming.
    But I don't really know about network roundtrips with this kind of method.
    Is everything done in the app server and then fetched to the client?
    What triggers block-level and item-level can be fired during the execution of the loop ? and so one...
    Thanks in advance for your advices on this matter.
    Jean-Yves

    Hmmm, I have to say I never bothered if Forms is in Socket mode or not; I enabled the network statistics, counted the roundtrips and looked for ways to get them lower (my old friend wireshark did also a good job regarding this) ;). But regarding the note Forms 6i uses Socket Connections by default, this might apply to 10g too (or the enhancement request was approved, who knows).
    Frankly I am not entirely sure what Socket Mode means; I guess it's the mode the forms applet talks to the forms runtime; wheter it's stateful (via Sockets) or stateless (via HTTP / HTTPS) but this is just a wild guess, and I can't find informations on it quickly. I also enabled networkStats on my Developer Suite only, so I cannot tell if you can enable them on a full-fledged Application Server.
    Anyway; as said I just counted the roundtrips and looked where I can avoid them when I made our application ready for WAN.
    Another useful tool was Shunra VE Desktop which I used to simulate low bandwith networks with high latencys; I installed it on a virtual XP, started the application and tested how the Application performs. If something looked odd, I looked behind the scenes, built a little testform basing on the code behind and tried out various things; very often you can take advantage of the event bundling forms seems to make when you use several set_xyz calls as Francois also noted; e.g.
    set_custom_property('bean_item', 1, 'PROPERTY', prop);
    set_custom_property('bean_item', 1, 'PROPERTY', prop);
    set_custom_property('bean_item', 1, 'PROPERTY', prop);
    set_custom_property('bean_item', 1, 'PROPERTY', prop);
    set_custom_property('bean_item', 1, 'PROPERTY', prop);
    vRet := get_custom_property('bean_item', 1, 'PROPERTY);most certainly will cause just 1 roundtrip; but if you use get_custom_property in the middle of the set_custom_property calls you will encounter 2 roundtrips as forms needs to synchronize (you get a value from the bean so the forms runtime needs a response) with the forms applet whereas set_custom_property is a one-way-street which can be fired off simultaneous. The same applies to fbean.invoke and fbean.invoke_bool, fbean.invoke_char and the like. Of course if you are using more then one get_custom_property in this case the roundtrips will increase accordingly.
    If you want to make use of event bundling make sure you fire off as much set_xyz as you can before forcing forms to synchronize (e.g. with get_xyz, or synchronize, create_timer,...)
    cheers

  • Questions on looping

    Hi all experts of iDVD,
    I have burn the video in iDVD. My movies are set to loop. So, as expected the movie keeps looping. But how do I get back to the selection page ?
    I press STOP but it doesn't go back to the selection page & it gives me a blank page.
    I have to press EJECT & EJECT again to place the video in, then only will I be able to see the Selection page.
    So when I set the video to loop, how do I get back to the selection page ?
    Thanks

    Captivate 8 introduced the common JavaScript API which gets and sets Captivate variables for both SWF and HTML5 output in the same way.  You can read more about that here:
    https://helpx.adobe.com/captivate/using/common-js-interface.html
    Another great thing about Captivate 8, is that they exposed Captivate events to JavaScript.  So, for example, you can listen for when a user submits a quiz question and execute your own JavaScript when that submit event occurs.  Not only can you listen for this event, you also get information sent to you about that event... like what the correct answer was vs. what the student chose.  What I'd recommend is that you subscribe to the following events:
    CPAPI_QUESTIONSUBMIT
    CPAPI_INTERACTIVEITEMSUBMIT
    The event data sent back from the event will give you the information you need.  Download the sample project from the article to find out how to subscribe to these events.

  • Satellite L20-101: Question about memory modules mixing PC2-4300 and PC2-4200

    Hello
    I have Toshiba Satellite L20-101. It has onboard 512MB RAM (PC2-4300). Today I added another RAM module but this new module is PC2-4200. Is there anything wrong doing this? Both modules are DDR2 and 533MHz and 512MB.

    Hi Pawel,
    In principle there is no problem with mixing RAM modules of slightly different types but normally the total RAM will only run at the speed of the slower module. If your notebook recognises the correct amount of RAM from both sticks then there will ne no problem.
    regards,

  • Basic Questions about Looping and Headers

    Hello,
    Relative SSRS newcomer here and I have a couple of foundational questions...  These are based on the simple premise of the underlying dataset returning multiple rows of data, elements of each to be displayed on subsequent pages of the report.
    Is it fair to day that the Table (or Matrix) are the basic elements used for an iterative report?
    Assuming the above is true, I'm using a Table for my first experiment here.
    I can iterate and display my records but I'm struggling with header and footer information.
    I want to display header and footer information on each page the is part of the current record.  I've tried to add these elements in the 'header row' of the table, but that doesn't seem to do it.  I don't see any facility for a footer.  Is
    this to be accomplished with row groups or something?
    Any guidance would be appreciated.

    Hi Steven,
    According to your description, you want to display interview questions and answers between interview name and date, and different interview name displays in different page. After testing the issue in my environment, we can use list to achieve your goal.
    Please refer to the following steps:
    Add a table to the design surface, drag question_name, question_answer fields from the Report Data pane to the table cells, and delete the last column of the table.
    Click anywhere in a tablix data region, in the Grouping pane, Click Add Group, select Parent Group, in the Tablix Group dialog box, select interview_name, then click OK. 
    Right click [interview_name] next to details symbol, click insert row, select Inside Group – Below, then Inside Group – Above.
    Delete the first row and the first column.
    Merge all the cells in the first and last row, then drag interview_name to the first row and drag interview_date to the last row from the Report Data pane. 
    Add a List to the design surface, drag the tablix into the List.
    Select and right click the List, in the Grouping pane, Click Group Properties, click Add button and select interview_name from the drop down list. Then click Page Breaks, and check Between each instance of a group check box, click OK.
    The following screenshot is for your reference:
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu

  • DW:101 Question - Site folder and file naming - best practices

    OK - My 1st post! I’m new to DW and fairly new to developing websites (have done a couple in FrontPage and a couple in SiteGrinder), Although not new at all to technical concepts building PCs, figuring out etc.
    For websites, I know I have a lot to learn and I'll do my best to look for answers, RTFM and all that before I post. I even purchased a few months of access to lynda.com for technical reference.
    So no more introduction. I did some research (and I kind of already knew) that for file names and folder names: no spaces, just dashes or underscores, don’t start with a number, keep the names short, so special characters.
    I’ve noticed in some of the example sites in the training I’m looking at that some folders start with an underscore and some don’t. And some start with a capital letter and some don’t.
    So the question is - what is the best practice for naming files – and especially folders. And that’s the best way to organize the files in the folders? For example, all the .css files in a folder called ‘css’ or ‘_css’.
    While I’m asking, are there any other things along the lines of just starting out I should be looking at? (If this is way to general a question, I understand).
    Thanks…
    \Dave
    www.beacondigitalvideo.com
    By the way I built this site from a template – (modified quite a bit) in 2004 with FrontPage. I know it needs a re-design but I have to say, we get about 80% of our video conversion business from this site.

    So the question is - what is the best practice for naming files – and especially folders. And that’s the best way to organize the files in the folders? For example, all the .css files in a folder called ‘css’ or ‘_css’.
    For me, best practice is always the nomenclature and structure that makes most sense to you, your way of thinking and your workflow.
    Logical and hierarchical always helps me.
    Beyond that:
    Some seem to use _css rather than css because (I guess) those file/folder names rise to the top in an alphabetical sort. Or perhaos they're used to that from a programming environment.
    Some use CamelCase, some use all lowercase or special_characters to separate words.
    Some work with CMSes or in team environments which have agreed schemes.

  • EDL Exporting and Importing 101 - Questions

    We are testing Premiere's EDL exporting and importing capabilities for the first time, and are having issues. We set up a very simple test project with only 13 clips and a timeline with only 10 edits. This is what it looks like:
    http://img819.imageshack.us/img819/760/j00s.jpg
    We then exported an EDL, started a new Premiere project, and imported the EDL that we had created. It looks like this:
    http://imageshack.us/scaled/landing/32/6hd9.jpg
    In the bin, Premiere has now turned our 13 clips into 41. There are a lot of duplicates, some of them appear to be audio files, even though they're still listed as .mxf, and the start and end times are all over the place. Our two questions are: Why is it making all of these clips? And how do you link the media? We started linking some media manually, but because the start and end times are scrambled, the edits appear completely wrong in the sequence that we've created.

    There are a variety of options offered when exporting an EDL.
    These options need to be considered in conjunction with how the Sequence (audio/video layers) are set up. (managed for the edl export)
    Source footage management is vital in any EDL workflow and even more so when digital clip based ( as opposed to tape based linear assets).  ie. Digital clips have "unusual" filenames and are buried deep in folder structures. Filenames can be duplicated in a card to cards system. (mxf would be an exception)
    The EDL is usually used between systems.
    In your case  you are testing on the same system and assumeably the source footage resides there as well.  This is a case for managing the "source" so as the links work.
    Example. When I take footage to a Resolve Suite out of house.  I set up all the source footage on an transfer drive in the same manner ( filenames, folder names etc) as the original local drive .

  • Security question infinite loop.  How to break it?

    My account rescue email address was set to an unauthorized address.  The unauthorized user reset the security questions. 
    To change the security questions, you have to have the correct answers, OR the rescue address.
    To change the rescue address, you have to have the security question answers.
    There seems to be no way to fix this, and I've been trying for 20 minutes to find a phone number for account support, can't find it.

    You might try contacting Apple through iTunes Store Support

  • Question about loops

    hey guys,
    with this piece of code here... right now I have it reading a dataSet and printing out the first Value out of 9 datapoints. How can I tweak this so that it would read through ALL 9 datapoints. I know i can do a loop but im not sure how to go about it!...
    int numDataSets = dc.size(); // determine number of data sets in collection
          for (int i=0; i<numDataSets; i++) {
            dataSet ds = dc.get(i); // get the ith dataset
            String  filename = ds.sourceFileName;
            System.out.println("the number of DataSets: " + numDataSets);
            dataEl  el = ds.get(0); // get the 0th element of the ith dataset
            double value = el.getMainValue(); // get the associated main value
            int dateInt = el.getDateInt();
            //for (int dateInt=0; dateInt<0; dateInt++) {
            System.out.println("data set " + filename + ": value " + value + dateInt);
          }

    You'd use a nested loop. It's no trouble to nest one loop inside another. Traditionally, if i is the index variable of the outer loop, then j is the index variable of the inner one.
    By the way, if dc is a java.util.Collection (saying that it's a java.util.Collection means that it's a class that implements that interface, or implements a sub-interface of that interface), and if you're using JDK 1.5 or above, then you don't need to use an explicitly indexed for loop. You could just do this:
    for(dataSet ds : dc) {
        // your code here
    }And you could easily nest a similar loop inside of that.

  • Quick question about looping movie clips

    I'm a REAL Flash novice, and I'm trying to get a movie clip to loop 3 times, and then continue on.
    Here's the code I've written (I'm sure it's painful to see)
    stop();
    if (!loopCount) {
      var loopCount:Number = 0;
    loopCount++;
    if (loopcount < 3) {
    gotoAndPlay (1)
    if (loopCount = 3) {
      gotoAndPlay(363);
    Could someone help me out?
    Thanks,
    Brandon

    use double equal (==) to test for equality:
    stop();
    if (!loopCount) {
      var loopCount:Number = 0;
    loopCount++;
    if (loopcount < 3) {
    gotoAndPlay (1)
    if (loopCount == 3) {
      gotoAndPlay(363);

  • Question on Loop

    Why is it when I try to print num, it cannot find symbol, but when I use while loop it can?
    public class ForLoop {
         public static void main (String[] args) {
              int sum=0;
              for (int num=0; num<10; num++) {
                   sum+=num;
              System.out.println(num);
              System.out.println("Total: "+sum);
    }

    ashok.kulhari wrote:
    num variable is local variable for a LOOP block only and outside it cannot be access.Really? Gee I wish I had said that in my first reply.
    </sarcasm>

  • Question about Looping through tables in Adobe Form

    Hello,
    We have an adobe form which is to be filled offline. It consists of a table. Table can have repeating rows and user can add\remove rows as they wish.  The cardinality of the context node where we need to bind this table data is set to 1…n
    We want to know the process to get all the values in the table back into our context node once the form is uploaded. I assume we need to loop through the table, and add elements to the context node.  Can someone please let us know if we’re on the right track, and provide some sample code if possible?
    <b>We can’t figure out a way to loop through a table inside an Adobe form.</b>
    We are using Web Dynpro Java with Adobe Livecycle Designer 7.1
    Your help is much appreciated.
    Thanks,
    Rob.

    Try using...
    for (z = 0; z < 16; z++) {
         this["cb"+z].setStyle("styleName", "cssCBstyle");
    That is the way to target them.  I haven't dealt with setting styles, so I can't answer for that aspect working or not.

  • Dpexp 101 (question on exporting 3 schemas)

    Scenario: Exporting 3 schemas from staging to dev. I am a beginner DBA and want to verify my steps. Please don't flame me or give me the "let a real dba do this". You all started somewhere too.
    So, I have used datapump before, but the concern I have in this case is making sure I have all of the dependencies, and so forth taken into consideration, so I can provide the users with the definitive "its done, you can use the schemas now".
    Example of what I am going to do:
    $expdp scott/tiger DIRECTORY=data_pump_dir DUMPFILE=scott_schema.dmp
    SCHEMAS=SCOTT,HR,ALI
    My questions are these.
    1. The schemas (old versions) already exist in dev, so I am going to need to remove/truncate/whatever those schemas and dependencies (except for dblinks, I'll keep those inplace so I don't have to worry about passwords, etc... and I'll use IGNORE=Y on import). How would you guys go about removing the current schemas?
    2. Exporting these three schemas - anything you guys look for? Any gotchas or obvious issues/configurations I need to take into consideration?
    Thank you for any supportive information.

    Hello,
    I don't think so.
    If you just set the SCHEMAS parameter you'll get all the object belonging to it.
    But if you set the INCLUDE parameter you'll have just the objects specified by the INCLUDE.
    More over, with INCLUDE you can specify the TYPE of object.
    For instance the following will select all the function:
    INCLUDE=FUNCTIONSo, if for instance you want all the objects of a Schema just set this:
    SCHEMAS=<schema>All its Packages (and only its Package):
    SCHEMAS=<schema>
    INCLUDE=PACKAGEHope this help.
    Best regards,
    Jean-Valentin

  • Questions reg Looping through a Node inside a Currently Selected Node.

    i have the following context structure in my WD application.
    Parent Customer Node  A<Cardinality 1.n & Selection 1.n & Singleton True>
          Child Addresses Node B<Cardinality 1.n & Selection 1.n & Singleton True>
                  Child Attribute B.City
          Child Attribute A.Name
          Child Attribute A.Age
    For the currently selected Parent Customer Element, i want to read the all the addresses this customer has. How to read all the addresses of the customer and loop through it & show it.
    Any inputs are appreciated.

    Hello Saravanan,
    Please use the Singleton Concept.
    Refer the following links.
    http://help.sap.com/saphelp_nwce711core/helpdata/en/47/be673f79c8296fe10000000a42189b/frameset.htm
    http://wiki.sdn.sap.com/wiki/display/WDJava/SupplyFunctionin+Webdynpro
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/60086bd5-9301-2b10-6f97-a14366a5602b/
    if you have doubt in implementation then let us know.
    Regards
    Nizamudeen SM

Maybe you are looking for