• beyond tellerrand – play. Register Now!
Zurück   Flashforum > Flash > Flash Einsteiger

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 18-01-2010, 08:56   #1 (permalink)
Neuer User
 
Registriert seit: Jul 2009
Beiträge: 2
Zufallsbilder aus XML

Hallo zusammen,

ich weiss dieses Thema hatten wir auch schon zum wiederholten mal hier und ich hab mir auch die Tutorials angeschaut, aber da der Flash code nicht von mir geschrieben wurde (sondern im Internet gekauft) und ich Anfänger bin was script angeht, krieg ich es einfach nicht hin. Das Script lädt externe Bilder über eine einfache XML Datei als Hintergrund der Website. Das funktioniert auch einwandfrei, nur muss ich im Moment noch per hand alle paar Tage das Startbild ändern. Schön wäre es einfach wenn die Bilder per Zufall ausgewählt werden würden. Hier erstmal das vorhandene script:

_t = 0;
backgrounds = new Array();

configData = new XML();
configData.ignoreWhite = true;
configData.load("Backgrounds/autoBG.xml");
configData.onLoad = function(success){
if(success){
for(i = 0 ; i < configData.firstChild.childNodes[0].childNodes.length ; i++){
backgrounds.push(configData.firstChild.childNodes[0].childNodes[i].firstChild.nodeValue);
}
ind = -1;
interval = configData.firstChild.childNodes[0].attributes.interval;
loop = configData.firstChild.childNodes[0].attributes.loop.toLowerCase();
ContainerAuto.createEmptyMovieClip("_timer" , ContainerAuto.getNextHighestDepth());
ContainerAuto._timer.onEnterFrame = function(){
if(_t >= interval*30){
loadIMG();
_t = 0;
}else{
_t++;
}
}
loadIMG();
}
}

lr = new Object();
lr.onResize = function(){
ContainerAuto._width = Stage.width;
ContainerAuto._height = Stage.width*ContainerAuto._Container._height/ContainerAuto._Container._width;
if(ContainerAuto._height < Stage.height){
ContainerAuto._height = Stage.height;
ContainerAuto._width = Stage.height*ContainerAuto._Container._width/ContainerAuto._Container._height;
}
}
Stage.removeListener(lr);
Stage.addListener(lr);

img_ld = new MovieClipLoader();
img_ld.onLoadProgress = function(e){
_root.Loading_BG_Target = e.getBytesLoaded()/e.getBytesTotal();
}
img_ld.onLoadInit = function(e){
delete _root.Loading_BG.onEnterFrame;
_root.Loading_BG._width = 0;
_root.Loading_BG._alpha = 0;
_root.Loading_BG_Target = 0;

bmd = new flash.display.BitmapData(e._width , e._height , true , 0);
bmd.draw(e);
e.attachBitmap(bmd , 0 , false , true);

ContainerAuto._width = Stage.width;
ContainerAuto._height = Stage.width*ContainerAuto._Container._height/ContainerAuto._Container._width;
if(ContainerAuto._height < Stage.height){
ContainerAuto._height = Stage.height;
ContainerAuto._width = Stage.height*ContainerAuto._Container._width/ContainerAuto._Container._height;
}

ContainerAuto.onEnterFrame = function(){
this._alpha += (105 - this._alpha)/3;
if(this._alpha > 100){
this._alpha = 100;
delete this.onEnterFrame;
}
}
}

function loadIMG(){
ind++;

if(ContainerAuto == undefined){
clearInterval(myInt);
return;
}

if(ind == backgrounds.length){
if(loop == "yes"){
ind = 0;
}else{
clearInterval(myInt);
return;
}
}

delete ContainerAuto.onEnterFrame;
ContainerAuto.onEnterFrame = function(){
this._alpha += (0 - this._alpha)/3;
if(this._alpha < 1){
this._alpha = 0;
delete this.onEnterFrame;
img_ld.loadClip(backgrounds[ind] , ContainerAuto._Container);
_root.Loading_BG.onEnterFrame = function(){
this._alpha += (100 - this._alpha)/3;
if(isNaN(_root.Loading_BG_Target)){
_root.Loading_BG_Target = 0;
}
this._width += (_root.Loading_BG_Target*Stage.width - this._width)/3;
}
}
}
}

Wenn jemand eine Idee hätte, wo ich was ändern oder einfügen muss, wäre ich ihm sehr dankbar. Vielen Dank schon mal.
soshey ist offline   Mit Zitat antworten
Alt 18-01-2010, 10:58   #2 (permalink)
Harry, Wagen!
 
Benutzerbild von uncle.sam
 
Registriert seit: Jan 2006
Beiträge: 574
Ein bisschen übersichtlicher:

ActionScript:
  1. _t = 0;
  2. backgrounds = new Array();
  3.  
  4. configData = new XML();
  5. configData.ignoreWhite = true;
  6. configData.load("Backgrounds/autoBG.xml");
  7. configData.onLoad = function(success){
  8. if(success){
  9. for(i = 0 ; i < configData.firstChild.childNodes[0].childNodes.length ; i++){
  10. backgrounds.push(configData.firstChild.childNodes[0].childNodes[i].firstChild.nodeValue);
  11. }
  12. ind = -1;
  13. interval = configData.firstChild.childNodes[0].attributes.interval;
  14. loop = configData.firstChild.childNodes[0].attributes.loop.toLowerCase();
  15. ContainerAuto.createEmptyMovieClip("_timer" , ContainerAuto.getNextHighestDepth());
  16. ContainerAuto._timer.onEnterFrame = function(){
  17. if(_t >= interval*30){
  18. loadIMG();
  19. _t = 0;
  20. }else{
  21. _t++;
  22. }
  23. }
  24. loadIMG();
  25. }
  26. }
  27.  
  28. lr = new Object();
  29. lr.onResize = function(){
  30. ContainerAuto._width = Stage.width;
  31. ContainerAuto._height = Stage.width*ContainerAuto._Container._height/ContainerAuto._Container._width;
  32. if(ContainerAuto._height < Stage.height){
  33. ContainerAuto._height = Stage.height;
  34. ContainerAuto._width = Stage.height*ContainerAuto._Container._width/ContainerAuto._Container._height;
  35. }
  36. }
  37. Stage.removeListener(lr);
  38. Stage.addListener(lr);
  39.  
  40. img_ld = new MovieClipLoader();
  41. img_ld.onLoadProgress = function(e){
  42. _root.Loading_BG_Target = e.getBytesLoaded()/e.getBytesTotal();
  43. }
  44. img_ld.onLoadInit = function(e){
  45. delete _root.Loading_BG.onEnterFrame;
  46. _root.Loading_BG._width = 0;
  47. _root.Loading_BG._alpha = 0;
  48. _root.Loading_BG_Target = 0;
  49.  
  50. bmd = new flash.display.BitmapData(e._width , e._height , true , 0);
  51. bmd.draw(e);
  52. e.attachBitmap(bmd , 0 , false , true);
  53.  
  54. ContainerAuto._width = Stage.width;
  55. ContainerAuto._height = Stage.width*ContainerAuto._Container._height/ContainerAuto._Container._width;
  56. if(ContainerAuto._height < Stage.height){
  57. ContainerAuto._height = Stage.height;
  58. ContainerAuto._width = Stage.height*ContainerAuto._Container._width/ContainerAuto._Container._height;
  59. }
  60.  
  61. ContainerAuto.onEnterFrame = function(){
  62. this._alpha += (105 - this._alpha)/3;
  63. if(this._alpha > 100){
  64. this._alpha = 100;
  65. delete this.onEnterFrame;
  66. }
  67. }
  68. }
  69.  
  70. function loadIMG(){
  71. ind++;
  72.  
  73. if(ContainerAuto == undefined){
  74. clearInterval(myInt);
  75. return;
  76. }
  77.  
  78. if(ind == backgrounds.length){
  79. if(loop == "yes"){
  80. ind = 0;
  81. }else{
  82. clearInterval(myInt);
  83. return;
  84. }
  85. }
  86.  
  87. delete ContainerAuto.onEnterFrame;
  88. ContainerAuto.onEnterFrame = function(){
  89. this._alpha += (0 - this._alpha)/3;
  90. if(this._alpha < 1){
  91. this._alpha = 0;
  92. delete this.onEnterFrame;
  93. img_ld.loadClip(backgrounds[ind] , ContainerAuto._Container);
  94. _root.Loading_BG.onEnterFrame = function(){
  95. this._alpha += (100 - this._alpha)/3;
  96. if(isNaN(_root.Loading_BG_Target)){
  97. _root.Loading_BG_Target = 0;
  98. }
  99. this._width += (_root.Loading_BG_Target*Stage.width - this._width)/3;
  100. }
  101. }
  102. }
  103. }

und benutze mal "Math.random" in der Suchfunktion.
__________________
- uncle.sam -
uncle.sam ist offline   Mit Zitat antworten
Alt 18-01-2010, 18:54   #3 (permalink)
Neuer User
 
Registriert seit: Jul 2009
Beiträge: 2
schon mal vielen dank für die schnelle Antwort und das ordnen des scripts, aber ich habs mit math random schon versucht ich weiß boss überhaupt nicht in welchen teil ich das unterbringen muss. Das würde mir schon sehr helfen. Also falls jemand einen Code schnipsel parat hat und mir auch noch sagen könnte wo er hingehört, das wär perfekt.
soshey ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Stichworte
hintergrund, xml, zufallsbild

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


Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
Zufallsbilder Kuferl Flash CS3 Professional 1 11-06-2009 17:27
Zufallsbilder auf Schaltflächen dino5 ActionScript 1 4 07-05-2005 15:56
Zufallsbilder maclion ActionScript 1 8 13-07-2004 21:28
Zufallsbilder snuxxy Flash 4 und Flash 5 2 20-08-2002 13:43
zufallsbilder - mal wieder! smo Flash 4 und Flash 5 5 22-07-2002 12:11


Alle Zeitangaben in WEZ +1. Es ist jetzt 21:12 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele