Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 14th, 2007, 3:19 AM   #1
Simongcc
Newbie
 
Join Date: May 2005
Posts: 21
Rep Power: 0 Simongcc is on a distinguished road
actionscript 2.0 for-loop logic problem

Dear All,

I am using Flash 8 and actionscript 2.0 to load a photoWall into moviescript.
While the script runs smoothly if I separate the inside i-loop into 4 blocks.
Or some of the images will be missed. Did I missing something in logic?

Thanks in advance.
Simon


code Syntax (Toggle Plain Text)
  1. for (j = 0; j <= 3; j++) {
  2. for (i = 0; i <= 4; i++) {
  3. trace(i);
  4. mainImgURL = generalDir+ "apart"+ i + j + ".jpg";
  5. photoWallImg = photoWallMC.attachMovie("xternalImageMC", "xternalImgMC_"+i+j, i+j);
  6. bigImgHolderMCL.loadClip(mainImgURL, photoWallImg);
  7. photoWallImg._y = 85 * j;
  8. photoWallImg._x = i * SPACING;
  9. trace("photoWallImg._y "+ photoWallImg._y);
  10. trace("photoWallImg._x "+ photoWallImg._x);
  11. trace(mainImgURL);
  12. trace(photoWallImg);
  13.  
  14. }
  15.  
  16. }
  17.  
  18.  
  19. /* //divided into four separate loops
  20. for (i = 0; i <= 4; i++) {
  21. mainImgURL = generalDir+ "apart"+ i + "0" + ".jpg";
  22. photoWallImg = photoWallMC.attachMovie("xternalImageMC", "xternalImgMC_"+i+"0", i+"0");
  23. bigImgHolderMCL.loadClip(mainImgURL, photoWallImg.loadPhotoMC);
  24. photoWallImg._x = i * SPACING;
  25. }
  26.  
  27. for (j = 0; j <= 4; j++) {
  28. mainImgURL = generalDir+ "apart"+ j + "1" + ".jpg";
  29. photoWallImg = photoWallMC.attachMovie("xternalImageMC", "xternalImgMC_"+j+"1", j+"1");
  30. bigImgHolderMCL.loadClip(mainImgURL, photoWallImg.loadPhotoMC);
  31. photoWallImg._y = 85;
  32. photoWallImg._x = j * SPACING;
  33. }
  34.  
  35. for (k = 0; k <= 4; k++) {
  36. mainImgURL = generalDir+ "apart"+ k + "2" + ".jpg";
  37. photoWallImg = photoWallMC.attachMovie("xternalImageMC", "xternalImgMC_"+k+"2", k+"2");
  38. bigImgHolderMCL.loadClip(mainImgURL, photoWallImg.loadPhotoMC);
  39. photoWallImg._y = 170;
  40. photoWallImg._x = k * SPACING;
  41. }
  42.  
  43. for (l = 0; l <= 4; l++) {
  44. mainImgURL = generalDir+ "apart"+ l + "3" + ".jpg";
  45. photoWallImg = photoWallMC.attachMovie("xternalImageMC", "xternalImgMC_"+l+"3", l+"3");
  46. bigImgHolderMCL.loadClip(mainImgURL, photoWallImg.loadPhotoMC);
  47. photoWallImg._y = 255;
  48. photoWallImg._x = l * SPACING;
  49. }
  50. */
Attached Images
File Type: jpg Noproblem.jpg (28.0 KB, 19 views)
File Type: jpg problem.jpg (15.6 KB, 19 views)

Last edited by Simongcc; Sep 14th, 2007 at 4:19 AM.
Simongcc is offline   Reply With Quote
Old Sep 14th, 2007, 4:06 AM   #2
dr.p
Programmer
 
dr.p's Avatar
 
Join Date: Feb 2006
Location: Ohio
Posts: 93
Rep Power: 3 dr.p is on a distinguished road
I can't see what's wrong with the code at this point. It looks good.

You should put your code in code tags, by the way.
__________________
Neeley.org
dr.p is offline   Reply With Quote
Old Sep 14th, 2007, 4:18 AM   #3
Simongcc
Newbie
 
Join Date: May 2005
Posts: 21
Rep Power: 0 Simongcc is on a distinguished road
thanks a lot, have got it fixed immediately.
Simongcc is offline   Reply With Quote
Old Sep 14th, 2007, 7:46 AM   #4
Simongcc
Newbie
 
Join Date: May 2005
Posts: 21
Rep Power: 0 Simongcc is on a distinguished road
Problem resolved

Hihi!

I have resolved the problem:
There were 2 problems:
1. Since there is depth consideration in flash, the depth variable have problem. Some photos will be overlapped.
2. I have swapped the thought of column and row so that the image is missed if I combine the code together.

Hope this can set an opp. example.

Thanks!
Simon


code Syntax (Toggle Plain Text)
  1. for (j = 0, k=0; j < 4; j++) {
  2. for (i = 0; i < 5; i++, k++) {
  3. mainImgURL = generalDir+ "apart"+ j + i + ".jpg";
  4. photoWallImg = photoWallMC.attachMovie("xternalImageMC", "xternalImgMC_"+j+i, k);
  5. bigImgHolderMCL.loadClip(mainImgURL, photoWallImg);
  6. photoWallImg._x = 85 * i;
  7. photoWallImg._y = 85 * j;
  8. }
  9. }
Simongcc is offline   Reply With Quote
Old Sep 14th, 2007, 6:11 PM   #5
dr.p
Programmer
 
dr.p's Avatar
 
Join Date: Feb 2006
Location: Ohio
Posts: 93
Rep Power: 3 dr.p is on a distinguished road
Thanks for posting your solution, Simon, and I'm glad you got it fixed.
__________________
Neeley.org
dr.p is offline   Reply With Quote
Old Sep 17th, 2007, 6:51 AM   #6
Simongcc
Newbie
 
Join Date: May 2005
Posts: 21
Rep Power: 0 Simongcc is on a distinguished road
Summary of problems for all reference

Thanks, you are so nice!

Summary of image not load problem for reference:

1. movieclip name (the name inside script mismatch with the name of Mclip)
2. image path is not correct
3. depth checking(the result is weird if depth have problem)

whenever doing a complex scripts, return and make a simple script
as a testing probe. Hope this can save you from hours of frustration.

Cheers
Simongcc is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
tossing coin, logic problem ? cairo C++ 12 Jan 3rd, 2006 9:29 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:48 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC