Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 27-10-2003, 15:41   #1 (permalink)
Angsthase
 
Benutzerbild von royal_flash
 
Registriert seit: Jun 2001
Ort: Kölle
Beiträge: 591
Question loadMovie random "doppelbelegung ausschließen"

Hallo Forum,

ich will aus einer pool von 10 SWF's eine Auswahl von 5 SWF's in meinen Film laden. (Dort gibt es 5 "ContainerMC's" für diese)
Allerdings soll es zu keiner "doppelbelegung" kommen.
Also wenn sagen wir Film1.swf schon geladen wurde soll er nicht ein zweites mal auftauchen.

Ich hab mir jetzt auch ein Script gebaut welches funktioniert!
Allerdings kommt es mir irgendwie viel zu umständlich vor.
Ich denke einfachmal es geht viel leichter .... nur weiß ich nicht wie!

Hier mal das Script:
ActionScript:
  1. function objekteLaden () {
  2.     _root.wertCon1 = "objekte/"+"obj"+(random(10)+1)+".swf";
  3.     _root.wertCon2 = "objekte/"+"obj"+(random(10)+1)+".swf";
  4.     _root.wertCon3 = "objekte/"+"obj"+(random(10)+1)+".swf";
  5.     _root.wertCon4 = "objekte/"+"obj"+(random(10)+1)+".swf";
  6.     _root.wertCon5 = "objekte/"+"obj"+(random(10)+1)+".swf";
  7.     _root.sort();
  8.     _root.loadObjekte();
  9. }
  10. function sort () {
  11.     if ((_root.wertCon2 eq _root.wertCon3) or (_root.wertCon2 eq _root.wertCon4) or (_root.wertCon2 eq _root.wertCon5) or (_root.wertCon2 eq _root.wertCon1)) {
  12.         _root.wertCon2 = "objekte/"+"obj"+(random(10)+1)+".swf";
  13.         trace ("shit 2");
  14.         _root.sort2();
  15.         _root.ungleich();
  16.         _root.loadObjekte();
  17.     }
  18.     if ((_root.wertCon3 eq _root.wertCon4) or (_root.wertCon3 eq _root.wertCon5) or (_root.wertCon3 eq _root.wertCon1) or (_root.wertCon3 eq _root.wertCon2)) {
  19.         _root.wertCon3 = "objekte/"+"obj"+(random(10)+1)+".swf";
  20.         trace ("shit 3");
  21.         _root.sort2();
  22.         _root.ungleich();
  23.         _root.loadObjekte();
  24.     }
  25.     if ((_root.wertCon4 eq _root.wertCon5) or (_root.wertCon4 eq _root.wertCon1) or (_root.wertCon4 eq _root.wertCon2) or (_root.wertCon4 eq _root.wertCon3)) {
  26.         _root.wertCon4 = "objekte/"+"obj"+(random(10)+1)+".swf";
  27.         trace ("shit 4");
  28.         _root.sort2();
  29.         _root.ungleich();
  30.         _root.loadObjekte();
  31.     }
  32.     if ((_root.wertCon5 eq _root.wertCon1) or (_root.wertCon5 eq _root.wertCon2) or (_root.wertCon5 eq _root.wertCon3) or (_root.wertCon5 eq _root.wertCon4)) {
  33.         _root.wertCon5 = "objekte/"+"obj"+(random(10)+1)+".swf";
  34.         trace ("shit 5");
  35.         _root.sort2();
  36.         _root.ungleich();
  37.         _root.loadObjekte();
  38.     }
  39. }
  40. function sort2 () {
  41.     if ((_root.wertCon2 eq _root.wertCon3) or (_root.wertCon2 eq _root.wertCon4) or (_root.wertCon2 eq _root.wertCon5) or (_root.wertCon2 eq _root.wertCon1)) {
  42.         _root.wertCon2 = "objekte/"+"obj"+(random(10)+1)+".swf";
  43.         trace ("shit 2");
  44.         _root.sort();
  45.         _root.ungleich();
  46.         _root.loadObjekte();
  47.     }
  48.     if ((_root.wertCon3 eq _root.wertCon4) or (_root.wertCon3 eq _root.wertCon5) or (_root.wertCon3 eq _root.wertCon1) or (_root.wertCon3 eq _root.wertCon2)) {
  49.         _root.wertCon3 = "objekte/"+"obj"+(random(10)+1)+".swf";
  50.         trace ("shit 3");
  51.         _root.sort();
  52.         _root.ungleich();
  53.         _root.loadObjekte();
  54.     }
  55.     if ((_root.wertCon4 eq _root.wertCon5) or (_root.wertCon4 eq _root.wertCon1) or (_root.wertCon4 eq _root.wertCon2) or (_root.wertCon4 eq _root.wertCon3)) {
  56.         _root.wertCon4 = "objekte/"+"obj"+(random(10)+1)+".swf";
  57.         trace ("shit 4");
  58.         _root.sort();
  59.         _root.ungleich();
  60.         _root.loadObjekte();
  61.     }
  62.     if ((_root.wertCon5 eq _root.wertCon1) or (_root.wertCon5 eq _root.wertCon2) or (_root.wertCon5 eq _root.wertCon3) or (_root.wertCon5 eq _root.wertCon4)) {
  63.         _root.wertCon5 = "objekte/"+"obj"+(random(10)+1)+".swf";
  64.         trace ("shit 5");
  65.         _root.sort();
  66.         _root.ungleich();
  67.         _root.loadObjekte();
  68.     }
  69. }
  70. function loadObjekte () {
  71.     loadMovie (_root.wertCon1, "con1");
  72.     loadMovie (_root.wertCon2, "con2");
  73.     loadMovie (_root.wertCon3, "con3");
  74.     loadMovie (_root.wertCon4, "con4");
  75.     loadMovie (_root.wertCon5, "con5");
  76. }

... geht das nicht leichter ??? Wäre für jede Idee dankbar...

so long royal
royal_flash ist offline   Mit Zitat antworten
Alt 27-10-2003, 15:56   #2 (permalink)
Genius
 
Benutzerbild von f@gju
 
Registriert seit: Sep 2003
Ort: Banned into Jail
Beiträge: 650
so krikste 5 nicht gleiche zufallszahln:
ActionScript:
  1. function randoms(){
  2.     arr = new Array();
  3.     while(true){
  4.         a = Math.ceil(Math.random()*10);
  5.         if(arr[a] != true){
  6.             arr[a] = true;
  7.             n = 0;
  8.             for(i = 1; i <= 10; i++){
  9.                 if(arr[i] == true){
  10.                     n++;
  11.                 }
  12.             }
  13.             if(n >= 5){
  14.                 for(i = 1; i <= 10; i++){
  15.                     if(arr[i] == true){
  16.                         trace(i);
  17.                     }
  18.                 }
  19.                 break;
  20.             }
  21.         }
  22.     }
  23. }
  24.  
  25. randoms();

ist 100% verbesserungsfähig
__________________
Klick hier
f@gju ist offline   Mit Zitat antworten
Alt 27-10-2003, 16:28   #3 (permalink)
Angsthase
 
Benutzerbild von royal_flash
 
Registriert seit: Jun 2001
Ort: Kölle
Beiträge: 591
Hi f@gju,

leider klappt da was nicht ... bzw ich raff von der funktion sowieso nur die hälfte ... wollte sie aber mal ausprobieren ... ergebnis:




so long royal
royal_flash ist offline   Mit Zitat antworten
Alt 27-10-2003, 16:31   #4 (permalink)
Genius
 
Benutzerbild von f@gju
 
Registriert seit: Sep 2003
Ort: Banned into Jail
Beiträge: 650
hmmm also bei mir kommt das nicht.
aber es kam mal
also ich bin eh noch am verbessern
__________________
Klick hier
f@gju ist offline   Mit Zitat antworten
Alt 27-10-2003, 16:40   #5 (permalink)
Genius
 
Benutzerbild von f@gju
 
Registriert seit: Sep 2003
Ort: Banned into Jail
Beiträge: 650
oke tschegg ma das:
ActionScript:
  1. function randoms(){
  2.     arr = new Array();
  3.     ausgabe = new Array();
  4.     while(true){
  5.         a = Math.ceil(Math.random()*10); //zufallszahl 1-10
  6.         if(arr[a] != true){ //wird genutz um zu sehen obs zufallszahl scho gibt
  7.             arr[a] = true//die zahl kommt nun nichmehr vor (siehe obn)
  8.             n = 0;      //naja sollte klar sein
  9.             for(i = 1; i <= 10; i++){   //das ganze array wird durchlaufn
  10.                 if(arr[i] == true){  //wenns die zahl gibt dann  
  11.                     n++;                //erhöhn
  12.                 }
  13.             }
  14.             if(n >= 5){     //wenns fünf verschiedene zahln sind
  15.                 for(i = 1; i <= 10; i++){
  16.                     if(arr[i] == true){   //wenns die zahl gibt
  17.                         ausgabe.push(i)//wird sie der ausgabe hinzugefügt
  18.                     }
  19.                 }
  20.                 break;
  21.             }
  22.         }
  23.     }
  24.     return ausgabe; //gibt das array zurück
  25. }
  26.  
  27. trace(randoms());
__________________
Klick hier
f@gju ist offline   Mit Zitat antworten
Alt 27-10-2003, 17:01   #6 (permalink)
Angsthase
 
Benutzerbild von royal_flash
 
Registriert seit: Jun 2001
Ort: Kölle
Beiträge: 591
Thumbs up

Yup funkt super !!!

merci & so long royal

PS: wusste doch das men Code trash is ...
royal_flash ist offline   Mit Zitat antworten
Alt 27-10-2003, 17:03   #7 (permalink)
Genius
 
Benutzerbild von f@gju
 
Registriert seit: Sep 2003
Ort: Banned into Jail
Beiträge: 650
naja meina is nich viel bessa
abab in vbhabich den ma auf unter 10 zeilen hingekriegt
__________________
Klick hier
f@gju ist offline   Mit Zitat antworten
Alt 28-10-2003, 02:17   #8 (permalink)
Techniker
 
Benutzerbild von hgseib
 
Registriert seit: Sep 2003
Ort: 64807
Beiträge: 16.322
Code:
var gAry = new Array("aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg");
var v, vv, vT, vLen = gAry.length;
// 
for (v=0; v<vLen; v++) {
	vv = random(vLen);
	vT = gAry[v];
	gAry[v] = gAry[vv];
	gAry[vv] = vT;
}
-----
die zu sortierende objekte in ein array legen, das array durchmixen und die ersten 5 nehmen.


mfg
h.g.seib
www.SeibsProgrammLaden.de

Geändert von hgseib (28-10-2003 um 05:01 Uhr)
hgseib 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 21:28 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele