Problem with the FOR statement.....again!

Hi everyone,
Well I'm still trying to do a car slideshow using external
files and can't seem to see the end. The current movie is here:
http://www.virtuallglab.com/projects.html
I also attach the code. My problem is I had originally set up
an animation with 2 pictures sliding in with some text, and then
wait 4 seconds before sliding out, and then next pictures and text
would slide in and so on, using a setInterval.
The problem is the FOR loop seems to skip the setInterval and
the function "wait", so it just loops quickly and jumps to last
picture, so on the example above, it just slides the last picture
(i=9) and that's it!
Can you not include another function within a FOR statement.
Or is there a way to tell the FOR loop to wait until all motion is
finished?
Any help greatly appreciated
import mx.transitions.*;
import mx.transitions.easing.*;
for (i=0; i<10 ; i++) {
var picLeft = "pics/"+i+".jpg";
var picRight = "pics/"+i+"b.jpg";
var txtToLoad = "text/"+i+".txt";
this.createEmptyMovieClip("leftHolder",1);
leftHolder.loadMovie(picLeft,i,leftHolder.getNextHighestDepth());
leftHolder._x = -200;
leftHolder._y = 15;
var leftTween:Tween = new Tween(leftHolder, "_x",
Strong.easeOut, leftHolder._x, 10, 2, true);
this.createEmptyMovieClip("centerHolder",2);
centerHolder.loadMovie(picRight,i+"b",centerHolder.getNextHighestDepth());
centerHolder._x = 180;
centerHolder._y = 250;
var centerTween:Tween = new Tween(centerHolder, "_y",
Strong.easeOut, centerHolder._y, 15, 2, true);
text._x = 600;
myData = new LoadVars();
myData.onLoad = function(){
text.carText.text = this.content;
myData.load(txtToLoad);
var textTween:Tween = new Tween(text, "_x", Strong.easeOut,
text._x, 420, 2, true);
myInterval = setInterval(wait, 4000);
function wait() {
var leftTweenFinished:Tween = new Tween(leftHolder, "_x",
Strong.easeOut, leftHolder._x, -200, 1, true);
var centerTween:Tween = new Tween(centerHolder, "_y",
Strong.easeOut, centerHolder._y, 250, 1, true);
var textTween2:Tween = new Tween(text, "_x", Strong.easeOut,
text._x, 600, 1, true);
clearInterval(myInterval);
***************************************************************************************** ***

There is no way to tell a for loop to wait. That is not what
they do.
The entire for loop will execute (if possible, and it doesn't
enter some kind of continuous infinite loop) completely before each
time the frame is rendered.
If you want to spread things out over time you need to use
the setInterval -- but not inside a for loop! If you do that you
immediately set however many intervals as your loop has. In this
case you will also assign the ids for those intervals to the same
variable, effectively overwriting the value so you will never be
able to clear most of those intervals.
So you need to rethink you whole structure. Set up some kind
of counter and limit like this:
var slidesToShow:Number=10;
var curSlide:Number=0;
Then have your setInterval increment the curSlide each time
it is called and check to see if it has shown all of them. That is
where your "loop" comes in.
As for the other part of your question -- yes you actually
have two different issues going on -- again you cannot make a for
loop wait for anything. So no there is no way to pause it while you
wait for your tween to end. But you can be notified when a tween
ends.
Check out the documentation about the tween class in the help
files. There you will find the onMotionFinished event. So you can
set up one of those to start whatever needs to be started when the
tween has finished.
You should also use the MovieClipLoader class to load your
images, because you have no idea how long it will take to load
them. Using that class you get a nice event (onLoadInit) that tells
you when the asset is ready to be used.
Finally I'm thinking you might want to use setTimeout instead
of setInterval. It only goes once, while setInterval repeats
forever. So I would think your algorithm would be something like
this.
1. load external asset
2. when ready animate in and set onMotionFinished handler
3. when motion is finished start loading next asset and
setTimeout for 4 seconds.
4. when 4 seconds is up or the clip is loaded (which ever
takes longer) go to 2 and repeat.
If this is going to be run locally on a hard drive or CD you
won't have any problem with the length of time it takes to load the
external assets, but if it is over the web it will take time.

Similar Messages

  • I refurbished my macbook air 7 months ago because there was a problem with the steady state drive. Now my battery seems to be dead again. How long does the warranty last? Do I need to pay for a new battery?

    I refurbished my macbook air 7 months ago because there was a problem with the steady state drive. Now my battery seems to be dead again. How long does the warranty last? Do I need to pay for a new battery?

    As I wrote Apple will diagnose an Apple product even if it is out of warranty for free. That should be your first step to find out if the problem is the battery or something else.
    Once you have Apple telling you a 7 month old battery is defective (if that turns out to be the case)  then it becomes a game of horse trading. You'll need to speak to the tech and when he tells you there is nothing he can do you will need to speak to the tech manager and when she says most likely there is nothing they can do you go to the store manager, etc.  It is unlikely (though possible) that they will give in easily you need to be firm, polite and let on that you're willing to accept a partial reimbursement.
    So again the first step is to find out what is wrong.
    good luck

  • Problem with the Matrix State

    Hi Guys,
    I am facing a problem with the use of the matrix.
    I am not able to select cells from the matrix with a click  although I set the SelectMode = ms_Auto.
    does someone know how to solve this problem ??
    Thanks
    Bop

    Hi Peter,
    It depends on what selection style you want the grid to have.  I usually set the selection mode to ms_None, this mode allows you to select the individual cells. The ms_Auto selection mode enables an entire row to be selected.
    Regards, Lita

  • Problems with the new NAT in ASA 5510 (8.4)

    Hi together,
    i have some problems with the NAT statements in ASA Version 8.4.
    What i want is to translate the internal address of a server to the external address with a NAT rule.
    The ASA has only one WAN connection (named outside)
    The internal server has the ip address 192.168.0.221 (as example) and i want to translate all incoming traffic on port 3389 to the Server (192.168.0.221).
    This is only for training, i dont want to forward a 3389 port into the BAD in a productive Network
    first i create the network object for the inside server (192.168.0.221)
    object network Network_Obj_RDP
    host 192.168.0.221
    After that i create the access rule for incoming traffic on outside interface:
    access-list outside_access_in extended permit ip any any log debugging
    Next i create a access rule for the inside-prod network to allow the traffic to the RDP Server:
    access-list inside-prod_access_in extended permit object RDP interface outside object Network_Obj_RDP
    Now i create the NAT rule in the network object (Network_Obj_RDP):  
    object network Network_Obj_RDP
    nat (inside-prod,outside) static interface service tcp 3389 3389
    But if i want to connect via 3389 on the outside interface i see in the syslog this entry:
    Built inbound TCP connection 23248 for outside:80.187.107.132/7445 (80.187.107.132/7445) to inside-prod:192.168.0.221/3389 (External IP/3389)
    After a while the connection will be teardown with this message:
    Teardown TCP connection 23289 for outside:80.187.107.132/2294 to inside-prod:192.168.0.221/3389 duration 0:00:30 bytes 0 SYN Timeout
    It looks like that the acl works fine, but the NAT translation are wrong...
    perhaps somebody has a idea to fix this
    Looking forward and hope for help...
    Many thanks
    Greetings

    Hi Jouni,
    this is the correct Packet Tracer output i think:
    packet-tracer input inside-prod tcp 192.168.0.220 3389 8.8.8.8 4567
    Phase: 1
    Type: ACCESS-LIST
    Subtype:
    Result: ALLOW
    Config:
    Implicit Rule
    Additional Information:
    MAC Access list
    Phase: 2
    Type: ROUTE-LOOKUP
    Subtype: input
    Result: ALLOW
    Config:
    Additional Information:
    in   0.0.0.0         0.0.0.0         outside
    Phase: 3
    Type: ACCESS-LIST
    Subtype: log
    Result: ALLOW
    Config:
    access-group inside-prod_access_in in interface inside-prod
    access-list inside-prod_access_in extended permit ip object Network_Obj-Productiv any log debugging
    Additional Information:
    Phase: 4
    Type: IP-OPTIONS
    Subtype:
    Result: ALLOW
    Config:
    Additional Information:
    Phase: 5
    Type: NAT
    Subtype:
    Result: ALLOW
    Config:
    object network Network_Obj_RDP
    nat (inside-prod,outside) static interface service tcp 3389 3389
    Additional Information:
    Static translate 192.168.0.220/3389 to 80.146.252.162/3389
    Phase: 6
    Type: USER-STATISTICS
    Subtype: user-statistics
    Result: ALLOW
    Config:
    Additional Information:
    Phase: 7
    Type: IP-OPTIONS
    Subtype:
    Result: ALLOW
    Config:
    Additional Information:
    Phase: 8
    Type: USER-STATISTICS
    Subtype: user-statistics
    Result: ALLOW
    Config:
    Additional Information:
    Phase: 9
    Type: FLOW-CREATION
    Subtype:
    Result: ALLOW
    Config:
    Additional Information:
    New flow created with id 825, packet dispatched to next module
    Result:      
    input-interface: inside-prod
    input-status: up
    input-line-status: up
    output-interface: outside
    output-status: up
    output-line-status: up
    Action: allow
    That looks preety fine, but the way back isn´t right:
    packet-tracer input outside tcp 8.8.8.8 4567 192.168.0.220 3389
    Phase: 1
    Type: ROUTE-LOOKUP
    Subtype: input
    Result: ALLOW
    Config:
    Additional Information:
    in   192.168.0.0     255.255.255.0   inside-prod
    Phase: 2
    Type: ROUTE-LOOKUP
    Subtype: input
    Result: ALLOW
    Config:
    Additional Information:
    in   0.0.0.0         0.0.0.0         outside
    Phase: 3
    Type: ACCESS-LIST
    Subtype: log
    Result: ALLOW
    Config:
    access-group outside-in in interface outside
    access-list outside-in extended permit tcp any object Network_Obj_RDP eq 3389 log debugging
    Additional Information:
    Phase: 4
    Type: IP-OPTIONS
    Subtype:
    Result: ALLOW
    Config:
    Additional Information:
    Phase: 5
    Type: VPN
    Subtype: ipsec-tunnel-flow
    Result: ALLOW
    Config:
    Additional Information:
    Phase: 6
    Type: NAT
    Subtype: rpf-check
    Result: DROP
    Config:
    object network Network_Obj_RDP
    nat (inside-prod,outside) static interface service tcp 3389 3389
    Additional Information:
    Result:      
    input-interface: outside
    input-status: up
    input-line-status: up
    output-interface: inside-prod
    output-status: up
    output-line-status: up
    Action: drop
    Drop-reason: (acl-drop) Flow is denied by configured rule
    I have no idea...

  • HT4864 I am getting a triangle with an exclamation point next to my inbox...it says: There may be a problem with the mail server or network. Verify the settings for account "MobileMe" or try again.  The server returned the error: Mail was unable to log in

    I can send but cannot recieve email
    This is the messege I am gewtting:
    There may be a problem with the mail server or network. Verify the settings for account “MobileMe” or try again.
    The server returned the error: Mail was unable to log in to the IMAP server “p02-imap.mail.me.com” using “Password” authentication. Verify that your account settings are correct.
    The server returned the error: Service temporarily unavailable

    Also if I go to system preferences accounts and re-enter the password it fixes the glitch sometimes.

  • Is anyone having problems with the battery heating up and draining the power?  Mine has been doing this for about 2 months now.

    Is anyone having problems with the battery heating up and draining the power?  Mine has been doing this for about 2 months now.

    This is a major problem with Lollipop, but yo said it started 2 months ago.   Several people have fixed problem by removing FaceBook And Face book messenger and then re loading the apps again.   You might want to clear your cache before reloading.  Not sure this is your problem, but worth a try.  Good Luck

  • I need advise and help with this problem . First , I have been with Mac for many years ( 14 to be exact ) I do have some knowledge and understanding of Apple product . At the present time I'm having lots of problems with the router so I was looking in to

    I need advise and help with this problem .
    First , I have been with Mac for many years ( 14 to be exact ) I do have some knowledge and understanding of Apple product .
    At the present time I'm having lots of problems with the router so I was looking in to some info , and come across one web site regarding : port forwarding , IP addresses .
    In my frustration , amongst lots of open web pages tutorials and other useless information , I come across innocent looking link and software to installed called Genieo , which suppose to help with any router .
    Software ask for permission to install , and about 30 % in , my instinct was telling me , there is something not right . I stop installation . Delete everything , look for any
    trace in Spotlight , Library . Nothing could be find .
    Now , every time I open Safari , Firefox or Chrome , it will open in my home page , but when I start looking for something in steed of Google page , there is
    ''search.genieo.com'' page acting like a Google . I try again to get raid of this but I can not find solution .
    With more research , again using genieo.com search eng. there is lots of articles and warnings . From that I learn do not use uninstall software , because doing this will install more things where it come from.
    I do have AppleCare support but its to late to phone them , so maybe there some people with knowledge , how to get this of my computer
    Any help is welcome , English is my learned language , you may notice this , so I'm not that quick with the respond

    Genieo definitely doesn't help with your router. It's just adware, and has no benefit to you at all. They scammed you so that they could display their ads on your computer.
    To remove it, see:
    http://www.thesafemac.com/arg-genieo/
    Do not use the Genieo uninstaller!

  • Error message "there is a problem with the printer turn the printer off than on again"

    I have a new HP 7525 HP photosmart printer, went to use it to find all lights flashing with an error message on screen   " There is a problem with the printer. turn the printer off than on again" this does not resolve the problem.. unable to clear this error message!  Unable to use this printer!!!!
    This question was solved.
    View Solution.

    Hi sandrafranks,
    Thank you for your reply! 
    I believe this is a hardware related issue. Please call our technical support at 800-474-6836. If you live outside the US/Canada Region, please click the link below to get the support number for your region. Country-language selector.
    Hope this helps, and have a great day!
    RnRMusicMan
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" to say “Thanks” for helping!

  • Getting error and cannot download itunes.  says there is a problem with the windows installer package. a program required for the install to be complete could not be run.  any ideas?

    getting an error downloading itunes 64bit for windows 7.  says there is a problem with the windows installer package.  a program required for the install to be complete could not be run.  any ideas?  i uninstalled it last night when it would not open.

    Just in case, let's try a standalone AppleSoftwareUpdate.msi install.
    Download and save a copy of the iTunesSetup.exe (or iTunes64setup.exe) installer file to your hard drive:
    http://www.apple.com/itunes/download/
    Download and install the free trial version of WinRAR:
    http://www.rarlab.com/
    Right-click the iTunesSetup.exe, and select "Extract to iTunesSetup". WinRAR will expand the contents of the file into a folder called "iTunesSetup".
    Go into the folder and doubleclick the AppleSoftwareUpdate.msi to do a standalone ASU install.
    (If it offers you the choice to remove or repair, choose "Remove", and if the uninstall goes through successfully, see if you can reinstall by doubleclicking the AppleSoftwareUpdate.msi again.)
    Does it install (or uninstall and then reinstall) properly for you? If not, what error message do you get? (Precise text, please.)

  • HT1567 GOOD DAY I JUST WANNA ASK IF,, WHAT IS THE POSSIBLE THING FOR ME TO DO IF MY IPOD 2ND GEN HAS A PROBLEM WITH THE BACKLIGHT,,, IT ALWAYS TURNS INTO DIM WHEN I USE IT ,,, BUT SOMETIMES IT WORKS JUST FINE,,, PLS TELL ME WHAT TO DO,, THANKS AND MORE PO

    GOOD DAY I JUST WANNA ASK IF,, WHAT IS THE POSSIBLE THING FOR ME TO DO IF MY IPOD 2ND GEN HAS A PROBLEM WITH THE BACKLIGHT,,, IT ALWAYS TURNS INTO DIM WHEN I USE IT ,,, BUT SOMETIMES IT WORKS JUST FINE,,, PLS TELL ME WHAT TO DO,, THANKS AND MORE POWER

    Please don't shout.
    Has the unit EVER been jailbroke?  Has it EVER been dropped?  Did it EVER get excessively wet?  Did you EVER load a pirated developer's version of the IOS?
    If "No" to all the above, first try a system reset.  It cures many ills and it's quick, easy and harmless...
    Hold down the on/off switch and the Home button simultaneously until you see the Apple logo.  Ignore the "Slide to power off" text if it appears.  You will not lose any apps, data, music, movies, settings, etc.
    If the Reset doesn't work, try a Restore.  Note that it's nowhere near as quick as a Reset.  It could take well over an hour!  Connect via cable to the computer that you use for sync.  From iTunes, select the iPad/iPod and then select the Summary tab.  Follow the on-screen directions for Restore and be sure to say "yes" to the backup.  You will be warned that all data (apps, music, movies, etc.) will be erased but, as the Restore finishes, you will be asked if you wish the contents of the backup to be copied to the iPad/iPod.  Again, say "yes."
    At the end of the basic Restore, you will be asked if you wish to sync the iPad/iPod.  As before, say "yes."  Note that that sync selection will disappear and the Restore will end if you do not respond within a reasonable time.  If that happens, only the apps that are part of the IOS will appear on your device.  Corrective action is simple -  choose manual "Sync" from the bottom right of iTunes.
    If you're unable to do the Restore and you have IOS-6 or lower, go into Recovery Mode per the instructions here.  Also, if you have IOS-7, read this.

  • TS3297 My downloaded song stops suddenly halfway through. I assume there was a problem with the download. Can I download the file again??

    My downloaded song stops suddenly halfway through. I assume there was a problem with the download. Can I download the file again?? Will I have to purchase the song again?

    You need to delete the current copy of the broken track from your library before it will be offered up for download. It may help to close and reopen iTunes.
    If the problem persists and you can't get a good version of the file contact the iTunes Store support staff through the report a problem links in your account history, or via Contact Support.
    tt2

  • I can not upgrade to quicktime 7.7.3 for windows vista.  Error message says there is a problem with the program installer.  Any clue as to how to get around this.

    I can not download quicktime 7.7.3 for windows vista.  The error message says that there is a problem with the windows installer.  Any clues?

    The error message says that there is a problem with the windows installer.
    What's the precise text of the message, please? (There's a few different ones I can think of that you might be getting.)

  • Problem with the new server UCS C220 for set IP to CIMC

    Hi
    We’ve a problem with the new server UCS C220.
    We bought two servers UCS C220 M3 for CallManager 8.6 with High Availability.
    When we turn on the server during the boot and when it tells us, oppress F8 to enter at the CIMC and set the IP. But it never enters at the CIMC.
    Then, we configure our DHCP server and our switch, we connect the three gigabyte ports to our switch to give him an IP to the CIMC, so and then can enter via browser, but neither works.
    Note. The dedicated management NIC does not link, the other two ports do make link.
    What do you suggest to put an IP to CIMC and start installing our applications?
    regards

    You may have noticed that there is no DVD rom on the c220. What you need to do is:
    Login into the CIMC from your browser
    Luanch the KVM
    Insert the VMware DVD in your machines drive
    On the KVM pop up there should be a tab to mount the drive, after mounting it click on Macros and choose ctrl_alt+delete to restart.
    After the VMware OS installs press F2 to enter IP.
    Browse to the VMware ip to download the Vsphere client
    Open the Vsphere client, enter the ip of the vmware and the username will be root and no password if you did not set one.
    You can now upload OVA templates or manually create virtua machine from this enviroment.
    Hope this help

  • Problem with SimepleDateFormat for the military pattern....

    i have the code, which has to display date in the military format i.e., "yyyyMMddhhmm".
    java.util.Date date = new SimpleDateFormat("yyyyMMddhhmm").parse("200709201700");
    System.out.println("Expected Date : " + date);
    but output displays everytime i.e., Thu Sep 20 17:00:00 IST 2007
    is there any problem with the pattern???

    By military format you mean 24 hour clock time, right? I believe "hh" in SimpleDateFormat is for 12 hour clock time and "HH" is for 2 digits of 24 hour clock time.
    EDIT: Also, you're just parsing the string into a Date object. When you're printing, it'll simply use the toString() for Date, giving you an output as you see. If you want the output also to be formatted in the same way, you need to use the format() method of SimpleDateFormat with the same pattern on the Date.
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    (Yes I know it's on JavaRanch but I think it applies everywhere)
    Edited by: nogoodatcoding on Oct 3, 2007 6:03 PM

  • I have problem with fonts for my site, i have used "Lucida sans unicode " family for certain texts. it shows perfect in mozilla 3.5 and mozilla 4. But the font not supporting in mozilla 5.0? please help me

    i have problem with fonts for my site, i have used "Lucida sans unicode " family for certain texts. it shows perfect in mozilla 3.5 and mozilla 4. But the font not supporting in mozilla 5.0? please help me

    i have problem with fonts for my site, i have used "Lucida sans unicode " family for certain texts. it shows perfect in mozilla 3.5 and mozilla 4. But the font not supporting in mozilla 5.0? please help me

Maybe you are looking for