Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 25-10-2005, 13:08   #1 (permalink)
Neuer User
 
Registriert seit: Aug 2001
Beiträge: 39
Question Slideshow - mit JPG klappts, mit SWF nicht! Wo liegt der Fehler?

Hallo,
ich hab mir unter http://whatdoiknow.org/archives/001629.shtml die Slideshow AS1 runtergeladen. Die Slideshow ist genau was ich brauch und funktioniert prima - aber leider nur mit JPGs. Wenn ich SWFs laden möchte klappts plötzlich nichtmehr!

Ich vermute dass es an Zeile 75 liegt:
ActionScript:
  1. thisLoader.loadMovie(data[num].path);
da sich die SWFs mit loadMovieNum schon laden lassen, bin mir aber nicht sicher!

Hat jemand eine Idee wie man das lösen könnte?

Hier noch der Code:
ActionScript:
  1. /****************************/
  2. /* Crossfading slide show   */
  3. /* Author: Todd Dominey     */
  4. /* [url]http://whatdoiknow.org[/url]   */
  5. /* [url]http://domineydesign.com[/url] */
  6. /****************************/
  7.  
  8. // set random # variables - each must be 0 for first 'while' loop below
  9. var randomNum = 0;
  10. var randomNumLast = 0;
  11.  
  12. // parent container
  13. var container_mc = this.createEmptyMovieClip("container",0);
  14. // movie clip containers
  15. container_mc.createEmptyMovieClip("loader1_mc",2);
  16. container_mc.createEmptyMovieClip("loader2_mc",1);
  17.  
  18. // preload watcher
  19. this.createEmptyMovieClip("watcher_mc",100);
  20.  
  21. // load xml
  22. images_xml = new XML();
  23. images_xml.ignoreWhite=true;
  24. images_xml.onLoad = parse;
  25. images_xml.load("images.xml");
  26.  
  27. function parse(success) {
  28.     if (success) {
  29.         imageArray = new Array();
  30.         var root = this.firstChild;
  31.         _global.numPause = Number(this.firstChild.attributes.timer * 1000);
  32.         _global.order = this.firstChild.attributes.order;
  33.         _global.looping = this.firstChild.attributes.looping;
  34.         _global.fadetime = Number(this.firstChild.attributes.fadetime);
  35.         _global.xpos = Number(this.firstChild.attributes.xpos);
  36.         _global.ypos = Number(this.firstChild.attributes.ypos);
  37.         var imageNode = root.lastChild;
  38.         var s=0;
  39.         while (imageNode.nodeName != null) {
  40.             imageData = new Object;
  41.             imageData.path = imageNode.attributes.path;
  42.             imageArray[s]=imageData;
  43.             imageNode = imageNode.previousSibling;
  44.             s++;
  45.         }
  46.         // place parent container
  47.         container_mc._x = _global.xpos;
  48.         container_mc._y = _global.ypos;
  49.         // parse array
  50.         imageArray.reverse();
  51.         imageGen(imageArray);
  52.     } else {
  53.         trace('problem');
  54.     }
  55. }
  56.  
  57. // depth swapping
  58. function swapPlace(clip,num) {
  59.     eval(clip).swapDepths(eval("container_mc.loader"+num+"_mc"));
  60. }
  61.  
  62. function loadImages(data,num) {
  63.     if (i==undefined || i == 2) {
  64.         i=2;
  65.         createLoader(i,data,num);
  66.         i=1;
  67.     } else if (i==1) {
  68.         createLoader(i,data,num);
  69.         i=2;
  70.     }
  71. }
  72. function createLoader(i,data,num) {
  73.     thisLoader=eval("container_mc.loader"+i+"_mc");
  74.     thisLoader._alpha=0;
  75.     thisLoader.loadMovie(data[num].path);
  76.     watcher_mc.onEnterFrame=function () {
  77.         var picLoaded = thisLoader.getBytesLoaded();
  78.         var picBytes = thisLoader.getBytesTotal();
  79.         if (isNaN(picBytes) || picBytes < 4) {
  80.             return;
  81.         }
  82.         if (picLoaded / picBytes >= 1) {
  83.             swapPlace("container_mc.loader2_mc",1);
  84.             thisLoader.alpha(_global.fadeTime,100);
  85.             timerInterval = setInterval(imageGen,_global.numPause,data);
  86.             delete this.onEnterFrame;
  87.         }
  88.     }
  89. }
  90. function imageGen(data) {
  91.     // random, or sequential?
  92.     if (_global.order=="random") {
  93.         // choose random # between 0 and total number of images
  94.         while (randomNum == randomNumLast) {
  95.             randomNum = Math.floor(Math.random() * data.length);
  96.             trace(randomNum);
  97.         }
  98.         loadImages(data,randomNum);
  99.         randomNumLast = randomNum;
  100.     } else if (_global.order=="sequential") {
  101.         // start at 0, increment to total number of images, then drop back to zero when done
  102.         if (p==undefined || p==data.length && _global.looping=="yes") { p=0; } else { break; }
  103.         loadImages(data,p);
  104.         p++;
  105.     } else {
  106.         trace ("order attribute in xml isn't correct - must specify either 'random' or 'sequential'");
  107.     }
  108.     clearInterval(timerInterval);
  109. }
  110. stop();

MfG
Illuminatus ist offline   Mit Zitat antworten
Alt 25-10-2005, 22:58   #2 (permalink)
Neuer User
 
Registriert seit: Aug 2001
Beiträge: 39
Lightbulb Lösung

Hey,
habs hin bekommen!

Weiß zwar nicht genau was der Fehler ist, aber hab mal gehört, dass loadMovie alle Variablen und Eigenschaften des MovieClips löscht, in den ein neuer Geladen wird. Das hatte wohl Einfluß auf den Prototype, oder den Aufruf des selbigen!?
Also hab ich einfach noch einen weiteren Container MC unten in der Hirarchie angelegt.

Wenn die Lösung jemand interessiert kann ich sie hier posten!

Ausserdem hab ich noch ein PHP Script programmiert, mit dem sich ein Verzeichnis mit Bildern / SWFs auslesen lässt und automatisch die nötige XML Datei Ausgibt ... nur falls das jemand haben will

Mfg
Illuminatus ist offline   Mit Zitat antworten
Alt 26-10-2005, 06:45   #3 (permalink)
thnkGodImAtheist
 
Benutzerbild von kurthurtig
 
Registriert seit: Nov 2003
Ort: kölle am rhing
Beiträge: 1.853
poste es doch einfach mal, denn selbst wenn es jetzt keiner braucht, wird sicherlich einer (bestimmt ich) nachher über die suche zu deinem script gelangen... ist immer besser danke!
kurthurtig ist offline   Mit Zitat antworten
Alt 26-10-2005, 09:19   #4 (permalink)
Neuer User
 
Registriert seit: Aug 2001
Beiträge: 39
Na gut, na gut - wenn's denn unbedingt sein muss

Ich hab auch noch ein kleines Feature hinzugefügt, dass die Bilder nicht nur übereinander eingeblendet werden, sondern das untere auch ausblendet, falls man (wie ich) Transparenzen hat!
ActionScript:
  1. /****************************/
  2. /* Crossfading slide show   */
  3. /* Author: Todd Dominey     */
  4. /* [url]http://whatdoiknow.org[/url]   */
  5. /* [url]http://domineydesign.com[/url] */
  6. /****************************/
  7.  
  8. // set random # variables - each must be 0 for first 'while' loop below
  9. var randomNum = 0;
  10. var randomNumLast = 0;
  11.  
  12. // parent container
  13. var container_mc = this.createEmptyMovieClip("container",0);
  14. // movie clip containers
  15. container_mc.createEmptyMovieClip("loader1_mc",2);
  16. container_mc.createEmptyMovieClip("loader2_mc",1);
  17.  
  18. // preload watcher
  19. this.createEmptyMovieClip("watcher_mc",100);
  20. // load xml
  21. images_xml = new XML();
  22. images_xml.ignoreWhite=true;
  23. images_xml.onLoad = parse;
  24. // images_xml.load("slideshow_images.xml.php?album=logos&media=swf");
  25. images_xml.load("flash/logos.xml");
  26.  
  27. function parse(success) {
  28.     if (success) {
  29.         imageArray = new Array();
  30.         var root = this.firstChild;
  31.         _global.numPause = Number(this.firstChild.attributes.timer * 1000);
  32.         _global.order = this.firstChild.attributes.order;
  33.         _global.looping = this.firstChild.attributes.looping;
  34.         _global.fadetime = Number(this.firstChild.attributes.fadetime);
  35.         _global.xpos = Number(this.firstChild.attributes.xpos);
  36.         _global.ypos = Number(this.firstChild.attributes.ypos);
  37.         var imageNode = root.lastChild;
  38.         var s=0;
  39.         while (imageNode.nodeName != null) {
  40.             imageData = new Object;
  41.             imageData.path = imageNode.attributes.path;
  42.             imageArray[s]=imageData;
  43.             imageNode = imageNode.previousSibling;
  44.             s++;
  45.         }
  46.         // place parent container
  47.         container_mc._x = _global.xpos;
  48.         container_mc._y = _global.ypos;
  49.         // parse array
  50.         imageArray.reverse();
  51.         imageGen(imageArray);
  52.     } else {
  53.         trace('problem');
  54.     }
  55. }
  56.  
  57. // depth swapping
  58. function swapPlace(clip,num) {
  59.     eval(clip).swapDepths(eval("container_mc.loader"+num+"_mc"));
  60. }
  61.  
  62. function loadImages(data,num) {
  63.     if (i==undefined || i == 2) {
  64.         i=2;
  65.         createLoader(i,data,num);
  66.         i=1;
  67.     } else if (i==1) {
  68.         createLoader(i,data,num);
  69.         i=2;
  70.     }
  71. }
  72. function createLoader(i,data,num) {
  73.     thisLoader = container_mc["loader" +i+ "_mc"];
  74.     thisLoader._alpha = 0;
  75.     thisLoader.createEmptyMovieClip("containerMc", 1);
  76.     thisLoader.containerMc.loadMovie(data[num].path);
  77.    
  78.     watcher_mc.onEnterFrame=function () {
  79.         var picLoaded = thisLoader.containerMc.getBytesLoaded();
  80.         var picBytes = thisLoader.containerMc.getBytesTotal();
  81.        
  82.         if (isNaN(picBytes) || picBytes < 4) {
  83.             return;
  84.         }
  85.         if (picLoaded / picBytes >= 1) {
  86.             swapPlace("container_mc.loader2_mc",1);
  87.             thisLoader.alpha(_global.fadeTime, 100);
  88.             if (i == 1) {container_mc.loader2_mc.alpha(_global.fadeTime,0);} else {container_mc.loader1_mc.alpha(_global.fadeTime,0);};
  89.             timerInterval = setInterval(imageGen,_global.numPause,data);
  90.             delete this.onEnterFrame;
  91.         }
  92.     }
  93. }
  94. function imageGen(data) {
  95.     // random, or sequential?
  96.     if (_global.order=="random") {
  97.         // choose random # between 0 and total number of images
  98.         while (randomNum == randomNumLast) {
  99.             randomNum = Math.floor(Math.random() * data.length);
  100.             trace(randomNum);
  101.         }
  102.         loadImages(data,randomNum);
  103.         randomNumLast = randomNum;
  104.     } else if (_global.order=="sequential") {
  105.         // start at 0, increment to total number of images, then drop back to zero when done
  106.         if (p==undefined || p==data.length && _global.looping=="yes") { p=0; } else { break; }
  107.         loadImages(data,p);
  108.         p++;
  109.     } else {
  110.         trace ("order attribute in xml isn't correct - must specify either 'random' or 'sequential'");
  111.     }
  112.     clearInterval(timerInterval);
  113. }
  114. stop();

Viel Spaß damit!
Illuminatus ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 05:44 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele