ciao ragazzi, spero di non annoiarvi con le mie piccole (ma per me "enormi") domande.
ho un video (dream.swf) che voglio caricare con AS in un contenitore_mc che viene creato ad hoc per visualizzare questo video.
allora (dream.swf) è perfetto da solo, i controlli funzionano, l'audio è perfettamente in sync,ecc.. ma quando vado a caricarlo nel contenitore_mc i controlli anzichè agire sul filmato dream.swf, interagiscono con _root sulla quale è creato contenitore_mc. so che è un problema di percorsi, ma il codice che vi allego di seguito è troppo complicato per il mio piccolo cervellino e dopo alcuni tentativi non a buon fine ho deciso di postarlo a voi, così capisco i passi che devo fare ed imparare ancora....![]()
grazie da ora
function playFLV()
{
return (g_flvVariable != undefined || g_flvURL != undefined);
} // End of the function
function initPlayer()
{
if (g_initilized == undefined)
{
g_flvLoaded = false;
g_isPlaying = false;
g_isEnd = false;
g_soundObj = new Sound();
g_soundVolume = g_soundObj.getVolume();
g_soundMute = false;
if (g_flvVariable != undefined)
{
g_flvURL = eval(g_flvVariable);
} // end if
if (!playFLV())
{
g_currentFrame = _currentframe;
g_seekStep = int(_totalframes / 20);
if (g_seekStep < g_fps * 5)
{
g_seekStep = g_fps * 5;
} // end if
_root.onEnterFrame = function ()
{
if (!control.vt.isDragging)
{
g_isPlaying = g_currentFrame != _currentframe;
g_currentFrame = _currentframe;
} // end if
var _loc2 = g_isEnd;
g_isEnd = _currentframe == _totalframes;
if (g_isEnd)
{
if (g_endURL != undefined && !_loc2 && g_isEnd)
{
getURL(g_endURL, _root.g_endURLTarget == undefined ? ("") : (_root.g_endURLTarget));
} // end if
} // end if
if (g_isEnd && !control.vt.isDragging)
{
if (g_isPlaying)
{
if (!(g_autoRewind || g_repeat))
{
g_isPlaying = false;
stop ();
}
else
{
changeCurrentFrame(1);
if (!g_repeat)
{
g_isPlaying = false;
stop ();
}
else
{
play ();
} // end if
} // end if
} // end else if
} // end else if
updateControls();
};
if (!g_autoPlay)
{
g_autoPlay = true;
stop ();
} // end if
}
else
{
if (g_flvURL != undefined)
{
control.vt.time.text = "Streaming...";
g_currentTime = 0;
g_netConnection = new NetConnection();
g_netConnection.connect(null);
g_netStream = new NetStream(g_netConnection);
g_videoObj.attachVideo(g_netStream);
g_netStream.setBufferTime(5);
g_netStream.play(g_flvURL);
g_netStream.onStatus = function (infoObj)
{
switch (infoObj.code)
{
case "NetStream.Play.Start":
{
g_flvLoaded = true;
g_videoObj._width = g_videoWidth;
g_videoObj._height = g_videoHeight;
if (!g_autoPlay)
{
g_netStream.pause(true);
g_netStream.seek(0);
g_isPlaying = false;
}
else
{
g_isPlaying = true;
} // end else if
break;
}
case "NetStream.Buffer.Full":
{
break;
}
case "NetStream.Play.Stop":
{
break;
}
case "NetStream.Seek.InvalidTime":
{
g_netStream.seek(infoObj.details);
break;
}
case "NetStream.Play.StreamNotFound":
{
control.vt.time.text = "Stream not found.";
var _loc1 = new TextFormat();
_loc1.color = 16711680;
control.vt.time.setTextFormat(_loc1);
break;
}
} // End of switch
};
g_netStream.onMetaData = function (infoObj)
{
g_totalTime = Math.floor(infoObj.duration);
g_seekStep = g_totalTime / 20;
if (g_seekStep < 5)
{
g_seekStep = 5;
} // end if
};
}
else
{
control.vt.time.text = "\"" + g_flvVariable + "\" not defined.";
var fmt = new TextFormat();
fmt.color = 16711680;
control.vt.time.setTextFormat(fmt);
} // end else if
_root.onEnterFrame = function ()
{
if (g_totalTime != undefined)
{
var _loc2 = g_isEnd;
g_isEnd = g_netStream.time >= g_totalTime;
if (g_endURL != undefined && !_loc2 && g_isEnd)
{
getURL(g_endURL, _root.g_endURLTarget == undefined ? ("") : (_root.g_endURLTarget));
} // end if
} // end if
if (g_isEnd && !control.vt.isDragging)
{
if (g_isPlaying)
{
if (!(g_autoRewind || g_repeat))
{
g_isPlaying = false;
g_netStream.pause(true);
}
else
{
changeCurrentFrame(0);
if (!g_repeat)
{
g_isPlaying = false;
g_netStream.pause(true);
}
else
{
g_netStream.pause(false);
} // end if
} // end if
} // end else if
} // end else if
updateControls();
};
} // end else if
g_initilized = true;
} // end if
} // End of the function
function changeCurrentFrame(pos)
{
if (!playFLV())
{
if (!(g_isPlaying && !control.vt.isDragging && pos < _totalframes))
{
g_currentFrame = pos;
gotoAndStop(pos);
}
else
{
g_currentFrame = 0;
gotoAndPlay(pos);
} // end else if
}
else
{
g_netStream.seek(pos);
} // end else if
} // End of the function
function updateControls()
{
control.b_play._visible = !g_isPlaying;
control.b_pause._visible = g_isPlaying;
control.vt.syncIndicatorWithVideo();
} // End of the function
var g_fps = 25;
var g_autoPlay = true;
var g_autoRewind = false;
var g_repeat = false;
var g_skinColor = 0;
var g_skinColorSaturation = 100;
var g_videoWidth = 400;
var g_videoHeight = 275;
var g_initilized;
var g_flvLoaded;
var g_netConnection;
var g_netStream;
var g_videoObj;
var g_totalTime;
var g_seekStep;
var g_soundObj;
var g_soundVolume;
var g_soundMute;
var g_currentFrame;
var g_isPlaying;
var g_isEnd;
initPlayer();
gotoAndStop(1);

Rispondi quotando
