Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 06-04-2004, 14:02   #1 (permalink)
Flash & TYPO3
 
Registriert seit: Oct 2003
Ort: Bayern
Beiträge: 2.700
loadVariables -> Timing

Hallo,

ich will eine Billdergallerie machen. Um das Bild jeweils ein Rahmen passend scaliert werden. Die Höhe & Breite des Bildes erhalte ich von einem PHP-Script.

Mein Problem: Das Timing stimmt nicht. Oft wurden die Variablen für Höhe & Breite noch nicht eingeladen.

Anguggen: http://fotoscherg.tanzstudio-scherg....ze/bilder.html

ActionScript:
  1. // ------------ Pfad erstellen ------------ //
  2. _root.directory = "coca-cola";
  3. _root.fotonr = 0;
  4. _root.path = "gallery/" add directory add "/foto" add fotonr add ".jpg";
  5. // ------------ Bild einladen und 'alphan' ------------ //
  6. _root.picCont._alpha = 30;
  7. _root.picCont.loadMovie(path);
  8. // ------------ Höhe und Breite des eingeladenen JPGs holen ------------ //
  9. _root.loadVariables("filesize.php", "POST");
  10.  
  11.  
  12.  
  13. borderScal = function() {
  14.     _root.picCont._alpha = 30;
  15.     this.onEnterFrame = function() {
  16.        
  17.         _root.borderCont._width += (pic_w - _root.borderCont._width)/10;
  18.         _root.borderCont._height += (pic_h - _root.borderCont._height)/10;
  19.        
  20.         hDiff = Math.abs((Math.ceil(_root.borderCont._height) - pic_h));
  21.         wDiff = Math.abs((Math.ceil(_root.borderCont._width) - pic_w));
  22.        
  23.         if(wDiff <= 1  && hDiff <= 1) {
  24.             _root.borderCont._height = pic_h;
  25.             _root.borderCont._width = pic_w;           
  26.             _root.picCont._alpha = 99;
  27.             delete this.onEnterFrame;
  28.         }
  29.         updateAfterEvent();
  30.     };
  31. }
  32.  
  33.  
  34.  
  35. next.onPress = function() {
  36.     if(_root.fotonr <= 1) {
  37.         fotonr++;
  38.     } else {
  39.         _root.fotonr = 0;
  40.     }
  41.     _root.path = "gallery/" add directory add "/foto" add fotonr add ".jpg";
  42.    
  43.     _root.picCont.loadMovie(path);
  44.  
  45.     _root.loadVariables("filesize.php", "POST");
  46.    
  47.     borderScal();
  48. };

Ist es sinnd voll alle Bilder-Größen vorher einzulesen, damit ich dieses Problem übergehen kann? Oder kann ich soeswas einbauen, das zB XML.onLoad = funciton(success) {}; entspricht?
Angehängte Dateien
Dateityp: zip bildersize.zip (31,0 KB, 2x aufgerufen)
__________________
Mediendesign-Student

Geändert von johanness (06-04-2004 um 14:11 Uhr)
johanness ist offline   Mit Zitat antworten
Alt 06-04-2004, 14:37   #2 (permalink)
agedoubleju
Gast
 
Beiträge: n/a
loadVariables ist in der Ausführung zu langsam und du bekommst keine Rückmeldung, dass das Laden auch durchgeführt wurde. Nimm besser das loadVars-Objekt:
ActionScript:
  1. function geladen(erfolgreich) {
  2.         if(erfolgreich) {
  3.                
  4.                 trace("erfolgreich");//hier weitermachen
  5.    
  6. //Beispiel zum Übernehmen einer Variable:   meineNeueVariable=LadeObj.irgendeineTextVariable;
  7.  
  8. //Beispiel zum Einlesen eines Arrays        meinNeuesArray=LadeObj.irgendeineKommaseparierteVar.split(",");
  9.         }
  10.         else {
  11.                 trace("Fehler beim Laden");
  12.         }
  13. }
  14. LadeObj = new LoadVars();
  15. LadeObj.onLoad = geladen;
  16. LadeObj.sendAndLoad("meineDatei.php",LadeObj,"POST");
  Mit Zitat antworten
Alt 06-04-2004, 14:50   #3 (permalink)
Flash & TYPO3
 
Registriert seit: Oct 2003
Ort: Bayern
Beiträge: 2.700
hm... Danke.
__________________
Mediendesign-Student

Geändert von johanness (06-04-2004 um 16:07 Uhr)
johanness ist offline   Mit Zitat antworten
Alt 06-04-2004, 15:39   #4 (permalink)
Flash & TYPO3
 
Registriert seit: Oct 2003
Ort: Bayern
Beiträge: 2.700
Jetzt geht gar nichts mehr. Ich versteh das mit den LoadVars einfach nicht!

Könnte mir keiner das hier so umschreiben, dass berücksichtigt wird, ob die daten geladen wurden oder nicht?
DAAANKE!

ActionScript:
  1. // ------------ Pfad erstellen ------------ //
  2. directory = "coca-cola";
  3. fotonr = 0;
  4. path = "gallery/" add directory add "/foto" add fotonr add ".jpg";
  5. // ------------ Bild einladen ------------ //
  6. this.picCont.loadMovie(path);
  7. // ------------ Höhe und Breite des eingeladenen JPGs holen ------------ //
  8. this.loadVariables("filesize.php", "POST");
  9.  
  10.  
  11.  
  12. borderScal = function() {
  13.     this.onEnterFrame = function() {
  14.        
  15.         this.borderCont._width += (pic_w - this.borderCont._width)/10;
  16.         this.borderCont._height += (pic_h - this.borderCont._height)/10;
  17.        
  18.         hDiff = Math.abs((Math.ceil(this.borderCont._height) - pic_h));
  19.         wDiff = Math.abs((Math.ceil(this.borderCont._width) - pic_w));
  20.        
  21.         if(wDiff <= 1  && hDiff <= 1) {
  22.             delete this.onEnterFrame;
  23.         }
  24.         updateAfterEvent();
  25.     };
  26. }
  27.  
  28.  
  29.  
  30. next.onPress = function() {
  31.     (fotonr <= 2) ? fotonr++ : fotonr = 0;
  32.     path = "gallery/" add directory add "/foto" add fotonr add ".jpg";
  33.     this._parent.picCont.loadMovie(path);
  34.     this._parent.loadVariables("filesize.php", "POST");
  35.     borderScal();
  36. };
__________________
Mediendesign-Student

Geändert von johanness (06-04-2004 um 16:03 Uhr)
johanness ist offline   Mit Zitat antworten
Alt 06-04-2004, 16:12   #5 (permalink)
Flash & TYPO3
 
Registriert seit: Oct 2003
Ort: Bayern
Beiträge: 2.700
Hier noch die derzeitige "langsame" Version.
Angehängte Dateien
Dateityp: zip bildersize_ohneonload.zip (29,1 KB, 2x aufgerufen)
__________________
Mediendesign-Student
johanness ist offline   Mit Zitat antworten
Alt 06-04-2004, 17:00   #6 (permalink)
Neuer User
 
Registriert seit: Apr 2002
Ort: Altwarmbrooklyn
Beiträge: 9
Nabend

Das ist ne gute Idee, was du gebastelt hast.
Hab das jetzte mit dem loadVars Zeug umgebaut.

ActionScript:
  1. borderScal = function() {
  2.     // _root = this
  3.     this.picCont._alpha = 30;
  4.     this.onEnterFrame = function() {
  5.        
  6.         this.borderCont._width += (pic_w - this.borderCont._width)/10;
  7.         this.borderCont._height += (pic_h - this.borderCont._height)/10;
  8.        
  9.         hDiff = Math.abs((Math.ceil(this.borderCont._height) - pic_h));
  10.         wDiff = Math.abs((Math.ceil(this.borderCont._width) - pic_w));
  11.        
  12.         if(wDiff <= 1  && hDiff <= 1) {
  13.             this.borderCont._height = pic_h;
  14.             this.borderCont._width = pic_w;   
  15.             this.picCont._alpha = 99;
  16.             delete this.onEnterFrame;
  17.         }
  18.         updateAfterEvent();
  19.     };
  20. }
  21.  
  22.  
  23.  
  24. next.onPress = function() {
  25.     // _root = this._parent
  26.     if(fotonr <= 1) {
  27.         fotonr++;
  28.     } else {
  29.         fotonr = 0;
  30.     }
  31.     path = "gallery/" add directory add "/foto" add fotonr add ".jpg";
  32.    
  33.     this._parent.picCont.loadMovie(path);
  34.     LadeObj.onLoad = function() {
  35.         pic_h=LadeObj.pic_h;
  36.         pic_w=LadeObj.pic_w;
  37.         borderScal();
  38.        
  39.     }
  40.     LadeObj.sendAndLoad("filesize.php",LadeObj,"POST");
  41.  
  42.    
  43.    
  44.    
  45. };
  46.  
  47. // ------------ Pfad erstellen ------------ //
  48. directory = "coca-cola";
  49. fotonr = 0;
  50. path = "gallery/" add directory add "/foto" add fotonr add ".jpg";
  51. // ------------ Bild einladen und 'alphan' ------------ //
  52. this.picCont._alpha = 30;
  53. this.picCont.loadMovie(path);
  54. // ------------ Höhe und Breite des eingeladenen JPGs holen ------------ //
  55.  
  56.  
  57. LadeObj = new LoadVars();
  58.  
  59.     LadeObj.onLoad = function() {
  60.         pic_h=LadeObj.pic_h;
  61.         pic_w=LadeObj.pic_w;
  62.         borderScal();
  63.     }
  64. LadeObj.sendAndLoad("filesize.php",LadeObj,"POST");

Ich habe die Funktionen nur mal nach oben gepackt, damit das erste Bild nach dem Laden auch schon angepasst wird.
Das mit dem LoadVars ist eigentlich so ähnlich wie mit XML. Du hast das loadVars Objekt, in diesem Falle LadeObj und nach dem laden stehen da alle Variablen aus der php Datei drin.
Musst du dann einfach über LadeObj.Variablenname ansprechen.

Gruß
McClane
John McClane ist offline   Mit Zitat antworten
Alt 06-04-2004, 22:38   #7 (permalink)
Flash & TYPO3
 
Registriert seit: Oct 2003
Ort: Bayern
Beiträge: 2.700
Hi, vielen Dank für das Script!
Nur... Bei mir geht das so nicht. Der borderContainer wird dann immer auf Null scalliert, weil in flash die Werte nicht ankommen.
Ich habe jetzt mal meine Version so drangehangen...
Vielleicht könntest du sie dir ansehen ?
Danke!
Angehängte Dateien
Dateityp: zip bildersize2.zip (31,0 KB, 10x aufgerufen)
__________________
Mediendesign-Student

Geändert von johanness (07-04-2004 um 12:33 Uhr)
johanness ist offline   Mit Zitat antworten
Alt 07-04-2004, 12:33   #8 (permalink)
Flash & TYPO3
 
Registriert seit: Oct 2003
Ort: Bayern
Beiträge: 2.700
findet keiner den/die Fehler ?
__________________
Mediendesign-Student
johanness ist offline   Mit Zitat antworten
Alt 07-04-2004, 16:58   #9 (permalink)
Neuer User
 
Registriert seit: Apr 2002
Ort: Altwarmbrooklyn
Beiträge: 9
Nabend

Ich hab dir aus Versehen den falschen Code hinkopiert. Sorry.
Da fehlte noch die Übergabe der zu postenden variablen an das LadeObj.
Mit dem hier sollte alles problemlos funzen:

ActionScript:
  1. borderScal = function() {
  2.         // _root = this
  3.         this.picCont._alpha = 30;
  4.         this.onEnterFrame = function() {
  5.                
  6.                 this.borderCont._width += (pic_w - this.borderCont._width)/10;
  7.                 this.borderCont._height += (pic_h - this.borderCont._height)/10;
  8.                
  9.                 hDiff = Math.abs((Math.ceil(this.borderCont._height) - pic_h));
  10.                 wDiff = Math.abs((Math.ceil(this.borderCont._width) - pic_w));
  11.                
  12.                 if(wDiff <= 1  && hDiff <= 1) {
  13.                         this.borderCont._height = pic_h;
  14.                         this.borderCont._width = pic_w;
  15.                         this.picCont._alpha = 99;
  16.                         delete this.onEnterFrame;
  17.                 }
  18.                 updateAfterEvent();
  19.         };
  20. }
  21.  
  22.  
  23.  
  24. next.onPress = function() {
  25.         // _root = this._parent
  26.         if(fotonr <= 1) {
  27.                 fotonr++;
  28.         } else {
  29.                 fotonr = 0;
  30.         }
  31.         path = "gallery/" add directory add "/foto" add fotonr add ".jpg";
  32.         LadeObj.path = path;
  33.         this._parent.picCont.loadMovie(path);
  34.         LadeObj.onLoad = function() {
  35.                 pic_h=LadeObj.pic_h;
  36.                 pic_w=LadeObj.pic_w;
  37.                 borderScal();
  38.                
  39.         }
  40.         LadeObj.sendAndLoad("filesize.php",LadeObj,"POST");
  41.        
  42.        
  43.        
  44.        
  45. };
  46.  
  47. // ------------ Pfad erstellen ------------ //
  48. directory = "coca-cola";
  49. fotonr = 0;
  50. path = "gallery/" add directory add "/foto" add fotonr add ".jpg";
  51. // ------------ Bild einladen und 'alphan' ------------ //
  52. this.picCont._alpha = 30;
  53. this.picCont.loadMovie(path);
  54. // ------------ Höhe und Breite des eingeladenen JPGs holen ------------ //
  55.  
  56.  
  57. LadeObj = new LoadVars();
  58. LadeObj.path = path;
  59. LadeObj.onLoad = function(success) {
  60.     if(success) {   
  61.         trace("ERFOLG");
  62.         pic_h = LadeObj.pic_h;
  63.         trace(pic_h);
  64.         pic_w = LadeObj.pic_w;
  65.         trace(pic_w);
  66.         borderScal();
  67.     } else {
  68.         trace("FEHLER");
  69.     }
  70. }
  71.  
  72. LadeObj.sendAndLoad("filesize.php",LadeObj,"POST");

Man muss, wenn man ein loadVars Objekt erstellt hat, auch die Variablen, die mitgesendet werden sollen an das Objekt weitergeben. Das passiert mit LadeObj.path=path;
So haut´s hin.

Gruß
John McClane
John McClane ist offline   Mit Zitat antworten
Alt 07-04-2004, 21:50   #10 (permalink)
Flash & TYPO3
 
Registriert seit: Oct 2003
Ort: Bayern
Beiträge: 2.700
Vielen Dank! Das ist echt prima. Und ich hatte das einen ganzen Tag vergebens versucht! Danke!
__________________
Mediendesign-Student
johanness 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:41 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele