Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 23-06-2005, 21:41   #1 (permalink)
Neuer User
 
Registriert seit: Mar 2003
Beiträge: 8
[noob] Film per Taste vor / zurück statt Timer

Hallo,

bastele gerade an einer Bildergalerie... Das Original-Teil hab ich bei Flashkit gesaugt, und ein wenig angepasst. Funzt auch prima. Nur habe ich noch die Anforderung, daß das Ganze auch per Pfeiltasten links / rechts zu bedienen sein soll, und nicht nur per Timer abläuft.

Ich hoffe ich habe mich verständlich ausgedrückt... Flash + Actionscript gehören nicht gerade zu meinen Spezialitäten.

Mein Kram ist der, der unter :ADDED: steht.

Der Codeblock aus dem entspr. Frame:

Code:
// Loop through all the images that have been loaded into the
// slideshow

Key.addListener(_root.image_dropzone);

for(var i=1; i<=numImages; i++){
	
	// Check to see if see if 'i' matches the current image to be shown
	if(i == _root.currentImage){
		
		// Check to see if the image to be shown is loaded or not
		if(_root["image_dropzone" + _root.currentImage].getBytesLoaded() >= _root["image_dropzone" + _root.currentImage].getBytesTotal()){
			
			// Check to see if the image to be shown is to high for the slideshow
			if(this["image_dropzone" + _root.currentImage]._height > (_root.movie_height - 20)){
				
				// Resize the image, by measuring height, to fit the slideshow
				var percent = 100 * ((_root.movie_height - 20) / this["image_dropzone" + _root.currentImage]._height);
				this["image_dropzone" + _root.currentImage]._xscale = percent;
				this["image_dropzone" + _root.currentImage]._yscale = percent;
			}
			
			// Check to see if the image to be shown is to wide for the slideshow
			if(this["image_dropzone" + _root.currentImage]._width > (_root.movie_width - 20)){
				
				// Resize the image, by measuring width, to fit the slideshow
				var percent = 100 * ((_root.movie_width - 20) / this["image_dropzone" + _root.currentImage]._width);
				this["image_dropzone" + _root.currentImage]._xscale = percent;
				this["image_dropzone" + _root.currentImage]._yscale = percent;
			}
			
			// Check to see if the image has been shown yet
			if(_root.imageShown == 0 && _root.currentImage != _root.oldImage){
				
				// Show the image and prep it for fading
				this["image_dropzone" + _root.currentImage]._visible = true;
				this["image_dropzone" + _root.currentImage]._alpha = 0;
				_root.imageShown = 1;
				
			// If the image has already been shown and preped
			} else {
				
				// Check to see if the images needs to be faded in
				if(_root.currentImage != _root.oldImage && _root.fade > 0){
					
					// Fade in the image
					this["image_dropzone" + _root.currentImage]._alpha = 100 * (_root.counter / (_root.fade * _root.second));
					
				// If the image does not need to be faded in
				} else {
					
					// Show the image
					this["image_dropzone" + _root.currentImage]._alpha = 100;
				}
				
				// Move the image to the middle of the slideshow screen
				this["image_dropzone" + _root.currentImage]._x = (_root.movie_width - this["image_dropzone" + _root.currentImage]._width) / 2;
				this["image_dropzone" + _root.currentImage]._y = (_root.movie_height - this["image_dropzone" + _root.currentImage]._height) / 2;
				
				// Check to see if captions should be shown
				if(_root.captions == true || _root.captions == "true"){
					
					// Make the captions box visible and load the caption text for the current image
					_root.caption._visible = true;
					_root.caption.tb_caption.text = xmlData.slideshow[1].images[i-1].image[1].caption.value;
					
				// If captions should not be shown
				} else {
					
					// Hide the captions box
					_root.caption._visible = false;
				}
				
				// Swap depths of caption box to make sure its on top of the current image shown
				_root.caption.swapDepths(numImages + 3);
			}
			
		// If the current image has not been fully loaded, hide it
		} else {
			this["image_dropzone" + i]._visible = false;
		}
		
	// Check to see if 'i' is the old image
	} else if(i == _root.oldImage && _root.fade > 0){
		
		// Fade the old image out
		this["image_dropzone" + _root.oldImage]._alpha = 100 - (100 * (_root.counter / (_root.fade * _root.second)));
		
	// If 'i' is not the current image or the old image, hide image 'i'
	}  else {
		this["image_dropzone" + i]._visible = false;
	}	
}

// Increment the counter
_root.counter++;

// Check to see if the counter has exceeded the fade and time to show the image
if(_root.counter > ((_root.time + _root.fade) * _root.second)){

	//:ADDED:
	_root.stop();
	
	if (Key.isDown(Key.RIGHT)){
		_root.playing = true;
		_root.play();
	}
	if (Key.isDown(Key.LEFT)){
		_root.currentImage--;	
		_root.playing = true;
		_root.play();
	}
	
	// Reset the counter
	_root.counter = 0;
	
	// Set the current image as the old image
	_root.oldImage = _root.currentImage;

	// Increment the current image
	_root.currentImage++;
	
	// Check to see if the current image exceeds the number of images in the slideshow
	if(_root.currentImage > numImages){
		
		// Check to see if the slideshow should be repeated
		if(_root.repeat){
			
			// Set the current image back to the beginning
			_root.currentImage = 1;
			
		// If the slideshow is not to be repeated, hold on the last image
		} else {
			_root.currentImage = _root.numImages;
		}
	}
	
	// Set the current image as not shown
	_root.imageShown = 0;
}
Und hier die FLA dazu:

http://www.flashkit.com/downloads/mo.../Slideshow.zip

Geändert von -Novalis- (23-06-2005 um 21:42 Uhr)
-Novalis- ist offline   Mit Zitat antworten
Alt 23-06-2005, 21:50   #2 (permalink)
robo kalkühl
Gast
 
Beiträge: n/a
brainstorming:
ActionScript:
  1. // Check to see if the counter has exceeded the fade and time to show the image
  2. if((_root.counter > ((_root.time + _root.fade) * _root.second)) || Key.isDown(Key.RIGHT) || Key.isDown(Key.LEFT)){
  3.  
  4.    
  5.     // Reset the counter
  6.     _root.counter = 0;
  7.    
  8.     // Set the current image as the old image
  9.     _root.oldImage = _root.currentImage;
  10.  
  11.     // Increment the current image
  12.     _root.currentImage++;
  13.    
  14.     // Check to see if the current image exceeds the number of images in the slideshow
  15.     if(_root.currentImage > numImages){
  16.        
  17.         // Check to see if the slideshow should be repeated
  18.         if(_root.repeat){
  19.            
  20.             // Set the current image back to the beginning
  21.             _root.currentImage = 1;
  22.            
  23.         // If the slideshow is not to be repeated, hold on the last image
  24.         } else {
  25.             _root.currentImage = _root.numImages;
  26.         }
  27.     }
  28.    
  29.     // Set the current image as not shown
  30.     _root.imageShown = 0;
  31. }
...nicht getestet, keine garantie, hab mir nichtmal diene fla runtergeladen, war halt das erste was mir einfiel


edit: seh grad, das er so immer nur in eine richtung weitergeht, egal welche taste gedrügt wird, aber das zu beheben schaffste selber, oder?

Geändert von robo kalkühl (23-06-2005 um 21:52 Uhr)
  Mit Zitat antworten
Alt 23-06-2005, 21:59   #3 (permalink)
Neuer User
 
Registriert seit: Mar 2003
Beiträge: 8
Hm, immerhin tut sich jetzt was

Nur leider ist die Abfrage oben wichtig, damit das Bild rein und raus fadet... und die Keypress-Abfrage dürfte erst danach kommen. Ausserdem muss der Film auch dann stoppen, was er bei der Lösung halt nicht tut. Ich will die Fading-Effekte UND Tastenreaktion

Trotzdem danke, zur Not mache ich es so... aber lieb wäre mir halt o.g.

Gruß,
Nov
-Novalis- ist offline   Mit Zitat antworten
Alt 23-06-2005, 22:14   #4 (permalink)
robo kalkühl
Gast
 
Beiträge: n/a
die fla is nicht deine oder?

lade mal deinen versuch hoch (abgespeckt), und dann können wir weiter sehen...
  Mit Zitat antworten
Alt 23-06-2005, 22:57   #5 (permalink)
Neuer User
 
Registriert seit: Mar 2003
Beiträge: 8
Jep, das ist ne andere. Meine ist aber wirklich nur marginal angepasst... im wesentlichen habe ich nur paar MC gelöscht, und die XML angepasst.

Danke für deine Hilfe :-)

Gruß,
nov

Geändert von -Novalis- (23-06-2005 um 23:30 Uhr)
-Novalis- ist offline   Mit Zitat antworten
Alt 23-06-2005, 23:15   #6 (permalink)
robo kalkühl
Gast
 
Beiträge: n/a
du,
es tut mir ja echt leid,
aber das ding ist mir ein bischen zu groß, um es mal eben durchzugucken.
sorry.

ich mag aber auch den stil nicht, in dem das programmiert ist,
wegschmeißen...

ich erlaube mir einfach mal zu vermuten, das für das was du vorhast, viel weniger code nötig ist...
  Mit Zitat antworten
Alt 23-06-2005, 23:29   #7 (permalink)
Neuer User
 
Registriert seit: Mar 2003
Beiträge: 8
kein ding, muss ich wohl selbst nachdenken ^^

Trotzdem Danke - und dann wünsch' ich dir mal Durchhaltevermögen beim Nicht-Rauchen ;-) Ich hab schon paar Jährchen hinter mir inzwischen.

Gruß,
Nov
-Novalis- ist offline   Mit Zitat antworten
Alt 24-06-2005, 00:01   #8 (permalink)
Neuer User
 
Registriert seit: Mar 2003
Beiträge: 8
Tjo, manchmal... sind es nur zwei Zeichen:

Code:
if ((_root.counter > ((_root.time + _root.fade) * _root.second))) _root.counter = ((_root.time + _root.fade) * _root.second+1);

if((_root.counter > ((_root.time + _root.fade) * _root.second)) && (Key.isDown(Key.RIGHT) || Key.isDown(Key.LEFT))) {......
Danke & Gruß,
Nov
-Novalis- 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 02:04 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele