WN

WN (https://www.wn.se/forum/index.php)
-   Klientsidans teknologier, design och grafik (https://www.wn.se/forum/forumdisplay.php?f=12)
-   -   Flash; netStream Loader (https://www.wn.se/forum/showthread.php?t=14783)

blipplopp 2006-06-22 00:06

Så, jag försöker, eller ja jag har codat så att en media fil öppnas och spelas upp i min flash, sen skulle jag lägga till en laddnings bar som visade inladdning och sedan startade mediafilen, då blev det galet, någon som et vad jag gör för fel?

Hela kod exemplet nedan.

Kod:

// Create a NetConnection object:
var netConn:NetConnection = new NetConnection();
// Create a local streaming connection:
netConn.connect(null);
// Create a NetStream object and define an onStatus() function:
var netStream:NetStream = new NetStream(netConn);
netStream.onStatus = function(infoObject) {
        status.text += "Status (NetStream)"+newline;
        status.text += "Level: "+infoObject.level+newline;
        status.text += "Code: "+infoObject.code+newline;
};
// Attach the NetStream video feed to the Video object:
my_video.attachVideo(netStream);
// Set the buffer time:
netStream.setBufferTime(5);
//Load
onEnterFrame = function () {
        percent = Math.floor((netStream.bytesLoaded/netStream.bytesTotal)*100);
        trace(netStream.bytesTotal);
        _root.loadbar._xscale = percent;
        _root.loadtxt.text = percent;
        if (percent == 100) {
 delete onEnterFrame;
 // Being playing the FLV file:
 netStream.play("data.flv");
        }
};


blipplopp 2006-06-22 00:53

Oh well, löste det hela själv. Rätt lösning är som följer om någon har intresse;

Kod:

// Create a NetConnection object:
var netConn:NetConnection = new NetConnection();
// Create a local streaming connection:
netConn.connect(null);
// Create a NetStream object and define an onStatus() function:
var netStream:NetStream = new NetStream(netConn);
trace(netStream.bytesTotal);
netStream.onStatus = function(infoObject) {
        status.text += "Status (NetStream)"+newline;
        status.text += "Level: "+infoObject.level+newline;
        status.text += "Code: "+infoObject.code+newline;
};
// Attach the NetStream video feed to the Video object:
my_video.attachVideo(netStream);
// Set the buffer time:
netStream.setBufferTime(5);
// Being playing the FLV file:
netStream.play("data.flv");
//Load
percent = 0;
onEnterFrame = function () {
        if (percent != 100) {
 percent = Math.floor((netStream.bytesLoaded/netStream.bytesTotal)*100);
 _root.loadbar._xscale = percent;
 _root.loadtxt.text = percent;
        } else {
 delete onEnterFrame;
        }
};

VA! säger du? nu laddar den juh inte in skiten och startar när mätaren är 100%. Nä, visst fan,, det är juh så att man streamar FLA :P jag som inte tänkte mig för.


Alla tider är GMT +2. Klockan är nu 13:29.

Programvara från: vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Svensk översättning av: Anders Pettersson