473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Two loaders interchanging images

Hi guys,

As usual, I've found some code from the net, changed it around, added some things and it works, but not exactly the way that I'd like it to work. I want it to work like the app on mtv.com, where one image remains on the main stage, then another image eases in over the top of the previous image.

Basically, I have two loaders. When the timer ends, the bottom loader assumes the image that was on the stage and the second loader eases in the second image. The problem is that when the timer ends, both images disappear momentarily while the loaders reload with the previous image going to the underneath loader and the new image being eased in with the above loader.

How can avoid the momentary loss of images?

Here's the code:
Expand|Select|Wrap|Line Numbers
  1. // don't worry about this img, it's used for another loader in a different location on stage.
  2. image_loader.contentPath = "someOtherImg.jpg";
  3.  
  4. //images to load 
  5. var pictures:Array= ["img1.jpg", "img2.jpg","img3.jpg","img4.jpg","img5.jpg","img6.jpg"]; 
  6. //image to start on, 0 is the first image in the array 
  7. var myItem:Number =0;
  8. var myFlag:Number =0; // used for distinguishing between the beginning of the array and the end of the array of images, because the loop will reset to myItem to 0 when the loop completes
  9.  
  10.  
  11. //loop variables 
  12. var loopAmount:Number = 5000; 
  13. var endTimer:Number = getTimer()+ loopAmount; 
  14.  
  15. //load first image 
  16. loader.contentPath = pictures[myItem]; 
  17.  
  18. onEnterFrame = loop; 
  19. function loop() { 
  20.     timer = getTimer(); 
  21.  
  22.     if (timer >= endTimer) 
  23.     { 
  24.         if (myItem < (pictures.length-1)) 
  25.         { 
  26.             myItem++;
  27.             myFlag=0;
  28.         }
  29.         else 
  30.         { 
  31.             myItem=0;
  32.             myFlag=1;
  33.         } 
  34.  
  35.         loader.contentPath = pictures[myItem];
  36.                 // myFlag let's me know that we are at the beginning of the pictures array
  37.         if(myItem==0 && (myFlag==0))
  38.         {
  39.             loader2.contentPath = pictures[myItem];
  40.         }
  41.                 // myFlag let's me know that we are at the end of the pictures array and to load the last image in the underneath loader
  42.         else if(myItem==0 && (myFlag==1))
  43.         {
  44.             loader2.contentPath = pictures[5];
  45.         }
  46.         else
  47.         {
  48.             loader2.contentPath = pictures[myItem-1];
  49.         }
  50.  
  51.         easeType = mx.transitions.easing.Regular.easeOut;
  52.  
  53.         var begin = 660;
  54.         var end = 10;
  55.         var time = 1.5;
  56.         var mc = loader;
  57.         ballTween = new mx.transitions.Tween(mc, "_x", easeType, begin, end, time, true);
  58.  
  59.                // my feeble attempt at synchronizing the transitions to allow the underneath loader to remain a little longer than the above loader
  60.         /* easeType2 = mx.transitions.easing.Regular.easeIn;
  61.         var begin2 = 10;
  62.         var end2 = 10;
  63.         var time2 = 0;
  64.         var mc2 = loader2;
  65.         ballTween2 = new mx.transitions.Tween(mc2, "_x", easeType2, begin2, end2, time2, true); */
  66.  
  67.             endTimer = getTimer()+ loopAmount;
  68.     }
  69. }
  70.  
I've tried two separate loops as well, in the attempt to have the underneath loader remain visible while the above loader changed images.

Any help is appreciated as usual and thanks in advance :-)
May 16 '08 #1
1 1756
The solution was for me to create an image that was 4000 px wide, which would be in the underneath loader, followed by having it move the exact width of each individual image, plus 10 px before the image in the above loader would be loaded.

I know crude, but simple.

Getting ready to post another question in regards to stopping the loop in the onEnterFrame.
May 19 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Wayne | last post by:
I have a script that uses filesystemobject that reads files from a given path, in my case images. It is running on a server that is 2000 adv svr w/ all current patches. The script prior to some...
11
by: Penelope Baker | last post by:
Greetings: I cannot seem to get IE 6.0 to pre-cache my rollover images. Every time the user rolls over a link, it rereads it from the server, even though it is well into the cache by that time....
2
by: Julie | last post by:
Hi, I'm trying to change images on a website without reloading the whole page and use the following code to preload the images: var preloadFlag = false; function preloadImages() { if...
3
by: Simon | last post by:
This problem has been driving me mad for months.... Seen a few posts on forums about it but no answers... No mention on MSDN etc. XP Pro SP1, VS.NET (c#) .Net framework 1.1, IIS 5.1. In a...
4
by: Bernie Raffe | last post by:
When I change the 'cookieless' flag in the WebConfig file to true, everything works fine on my local PC, but the images fail to appear when using the remote server. I specify my images...
2
by: Alex | last post by:
I have a web application hosted on the server's F:\www directory. I have images stored on the file system at E:\Images. I have the website shared thru IIS pointing to the F:\www directory. 1.)...
4
toxicpaint
by: toxicpaint | last post by:
Hi, can anyone give me a hand. I'm currently displaying 4 random images at the top of a page. I did this using an array of 35 pictures and then writing them to page. The problem I have is that in...
5
by: remon87 | last post by:
I need some help. I have javasript that creates the submenu but it works if I have a text with css. I need it to do the same with a roll over images. so when I click on the image the submenu...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.