Copy link to clipboard
Copied
Hi all,
I am a Flash coding novice. I have been trying to make an MPU ad with a trailer hosted on another server, I managed to do that fine but no matter what I did, I couldnt get the file size to be under 50k, the imported FLVplayback component was 58k on its own.
So I then tried to import the video using AS3 netStream, I managed to do that, but the video size was filling the stage size.
I basically want to import a streaming video onto half of the stage (stage size is 300x250), be able to play/pause it, and keep the exported SWF smaller than 50k
any suggestions would be great
Thanks again
'vid' is the reference to your video instance. why are you trying to size 'video"?
use:
...
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
ns.play("RTS-TRAILER.flv");
ns.client=this;
function asyncErrorHandler(event:AsyncErrorEvent):void
{
// ignore error
}
var vid:Video = new Video();
vid.attachNetStream(ns);
addChild(vid);
pauseBtn.addEventListener(MouseEvent.CLICK, pauseHand
Copy link to clipboard
Copied
show your code that's sizing your video instance.
Copy link to clipboard
Copied
well, my code just didnt work at all! but here it is in all its shame!
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
ns.play("RTS-TRAILER.flv");
function asyncErrorHandler(event:AsyncErrorEvent):void
{
// ignore error
}
var vid:Video = new Video();
vid.attachNetStream(ns);
addChild(vid);
pauseBtn.addEventListener(MouseEvent.CLICK, pauseHandler);
playBtn.addEventListener(MouseEvent.CLICK, playHandler);
//togglePauseBtn.addEventListener(MouseEvent.CLICK, togglePauseHandler);
function pauseHandler(event:MouseEvent):void
{
ns.pause();
}
function playHandler(event:MouseEvent):void
{
ns.resume();
}
function stopHandler(event:MouseEvent):void
{
// Pause the stream and move the playhead back to
// the beginning of the stream.
ns.pause();
ns.seek(0);
}
function ns_onMetaData(item:Object):void {
trace("metaData");
// Resize video instance.
video.width = item.width;
video.height = item.height;
// Center video instance on Stage.
video.x = (stage.stageWidth - video.width) / 2;
video.y = (stage.stageHeight - video.height) / 2;
}
//function togglePauseHandler(event:MouseEvent):void
//{
// ns.togglePause();
//}
Copy link to clipboard
Copied
'vid' is the reference to your video instance. why are you trying to size 'video"?
use:
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
ns.play("RTS-TRAILER.flv");
ns.client=this;
function asyncErrorHandler(event:AsyncErrorEvent):void
{
// ignore error
}
var vid:Video = new Video();
vid.attachNetStream(ns);
addChild(vid);
pauseBtn.addEventListener(MouseEvent.CLICK, pauseHandler);
playBtn.addEventListener(MouseEvent.CLICK, playHandler);
//togglePauseBtn.addEventListener(MouseEvent.CLICK, togglePauseHandler);
function pauseHandler(event:MouseEvent):void
{
ns.pause();
}
function playHandler(event:MouseEvent):void
{
ns.resume();
}
function stopHandler(event:MouseEvent):void
{
// Pause the stream and move the playhead back to
// the beginning of the stream.
ns.pause();
ns.seek(0);
}
function onMetaData(item:Object):void {
trace("metaData");
// Resize video instance.
vid.width = item.width; // <- this won't resize to 1/2 the stage. use vid.width=stage.stageWidth/2 etc if that's what you want
vid.height = item.height;
// Center video instance on Stage.
vid.x = (stage.stageWidth - vid.width) / 2;
vid.y = (stage.stageHeight - vid.height) / 2;
}
//function togglePauseHandler(event:MouseEvent):void
//{
// ns.togglePause();
//}
Copy link to clipboard
Copied
LIFESAVER!!!! I am kinda getting this now,
I managed to change the position of the video, but having trouble trying to stop the video autoplaying
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
ns.play("RTS-TRAILER.flv");
ns.client=this;
function asyncErrorHandler(event:AsyncErrorEvent):void
{
// ignore error
}
var vid:Video = new Video();
vid.attachNetStream(ns);
addChild(vid);
pauseBtn.addEventListener(MouseEvent.CLICK, pauseHandler);
playBtn.addEventListener(MouseEvent.CLICK, playHandler);
//togglePauseBtn.addEventListener(MouseEvent.CLICK, togglePauseHandler);
function pauseHandler(event:MouseEvent):void
{
ns.pause();
}
function playHandler(event:MouseEvent):void
{
ns.resume();
}
function stopHandler(event:MouseEvent):void
{
// Pause the stream and move the playhead back to
// the beginning of the stream.
ns.pause();
ns.seek(0);
}
function onMetaData(item:Object):void {
trace("metaData");
// Resize video instance.
vid.width = item.width; // <- this won't resize to 1/2 the stage. use vid.width=stage.stageWidth/2 etc if that's what you want
vid.height = item.height;
// Center video instance on Stage.
vid.x =15;
vid.y =15;
// vid.x = (stage.stageWidth - vid.width) / 2;
// vid.y = (stage.stageHeight - vid.height) / 2;
}
//function togglePauseHandler(event:MouseEvent):void
//{
// ns.togglePause();
//}
Copy link to clipboard
Copied
pause your video:
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
ns.play("RTS-TRAILER.flv");
ns.pause();
ns.client=this;
Copy link to clipboard
Copied
You are amazing!!! Thankyou so much for all your help, I was really struggling with this, its a whole new world!
as a little cheeky plug, be cool if you could check out my little social art/design project I run aside to my day job a designer in London
Copy link to clipboard
Copied
you're welcome.
(and nice website!)