crusy.net

  • home.
  • photos.
  • about.

 

29
Apr

Streamen von SWFs

By crusy|Coding, Flash|Be the first to comment!

Grundsätzlich können SWFs streamen. Viele Preloader basieren darauf: Auf dem ersten Frame (der bereits verfügbar ist) dreht sich die Sanduhr, während der zweite Frame mit der Anwendung noch geladen wird.

So kann man zB mit LoaderMax ein SWF streamen, in dem ein Video und ein Sound auf der Zeitleiste liegen:

private var _loader:SWFLoader;
private var _loadedSWF:MovieClip;
private const MIN_PERCENTAGE_LOADED:Number = 0.2; // between 0 and 1

_loader = new SWFLoader( 'video_chaptera.swf', { auditSize:false, autoPlay:false, onProgress:_onLoaderProgress } );
_loader.load();

private function _onLoaderProgress(event : Event) : void
{
   trace( 'loaded: ' + _loader.progress );

   if( _loader.rawContent )
   {
      // do not address it twice, for garbage collection:
      if ( _loadedSWF == null && _loader.progress >= MIN_PERCENTAGE_LOADED )
      {
         _loadedSWF = _loader.rawContent as MovieClip;

         // maybe it was no MovieClip?
         if( _loadedSWF )
         {
            // the volume was set to 0 by {autoPlay:false}
            var st:SoundTransform = _loadedSWF.soundTransform;
            st.volume = 1;
            _loadedSWF.soundTransform = st;

            addChild( _loadedSWF );
            _loadedSWF.gotoAndPlay( 1 );
         }
      }
   }
}

Leider kann man das Laden nicht pausieren:

It’s actually impossible to do a true pause/resume on a single loader in Flash. When you pause() an individual loader, it basically cancels it and then when you resume(), it starts over. You might be wondering why have pause/resume then at all, right? It’s primarily useful in a LoaderMax queue. Imagine you have 20 loaders in a LoaderMax queue and after 12 of them, you pause() while the 13th one is loading. It would technically just cancel that 13th one, but when you resume(), the 12 that had already loaded are still there – it resumes the queue at 13 and picks up from there.

Quelle

Trotzdem nice: Streaming, und trotzdem Zugriff auf einzelne Frames.

Wichtig dabei:

  • autoPlay:false. Das verhindert, dass das SWF “im Hintergrund” schon startet, während man es eigentlich noch buffert
  • die Zeilen mit “SoundTransform”. “autoPlay:false” setzt das Volume des SWF auf 0, damit man es im Hintergrund nicht hört. Das wird zwar automatisch wieder auf 1 gesetzt, aber erst, wenn das SWF fertig geladen ist!
  • Der Sound muss auf der Hauptzeitleiste liegen! Wird er in einen MC verschachtelt, muss dieser parallel zu _loadedSWF.gotoAndPlay(1) ebenfalls auf Frame 1 zurückgesetzt werden
Tagged as: Greensock, LoaderMax, preloader, Preloading, Streaming, SWF, Video
Add your comment →

0 Comments

Leave your comment below! Cancel Reply

View More Posts:
  • ←
  • →

Suche:

Schubladen:

  • Apropos (62)
  • Computer (222)
    • Arduino (4)
    • Coding (166)
      • CSS (5)
      • Flash (88)
      • Java (4)
      • Javascript (17)
      • PHP (6)
    • Firefox (19)
    • OS X (19)
  • Lustig (90)
  • Musik (52)
  • Photo (30)
    • Photoshop (16)
  • Video (58)
  • Web (95)
  • Werbung (29)

@crusy:

Lord Helmchen! (Der war bestimmt schon, oder?) #cl
20 hours ago from Twitter for Windows Phone
Fußball gucken ist ein bisschen wie Al Bundy gucken: Der Sprecher ist zwar unlustig, aber das Publikum klatscht trotzdem.
20 hours ago from Twitter for Windows Phone
Wenn man heiratet, ist man dann ent-ledigt?
1 day ago from web
Sach ich doch
3 days ago from Twitter for Windows Phone
SHER
3 days ago from Twitter for Windows Phone

Kommentare:

  • Christian on WSDL2Java: Axis2 in Eclipse Indigo
  • crusy on Deutschlandweite Verteilung Deines Namens
  • Jotteh on Deutschlandweite Verteilung Deines Namens
  • Fogwulf on Abgerundete Ecken
  • crusy on Van Gogh meets Monkey Island (und mehr!)

Tags:

Actionscript Actionscript 3 Addon Adobe AIR Ant Apple AS AS3 Coding Comment Cover CSS Design Eclipse Facebook FDT Film Firefox Flash Flex Google Internet iOS iPad iPhone Java Javascript Kommentar Mac music Musik Obama OSX OS X Photoshop PHP Plugin Star Wars Video Web Werbung Wordpress XML Youtube

Projekte

  • Bent Larsen
    DAS Film Noir Point-and-Click-Adventure
  • crusy goes sf
    Photoblog aus San Francisco
  • Insignia
    Aufbau. Handel. Herrschaft.
  • nerdeln.de
    Nörgeln für Nerds
  • Photos
    Mein Photoblog
  • Tourtagebuch
    Von sechs Menschen, einer Stadt und keiner Wohnung

Powered by the inLine Minimal WordPress Theme