Copy link to clipboard
Copied
I load external video with playback component (skin over play stop seek mute vol.swf), its working great but when I use
fscommand("fullscreen", "true");
on my first scene (first keyframe in time), and after that when I reach my video scene. I got just black screen


use the netstream class:
var nc:NetConnection=new NetConnection();
nc.connect(null);
var ns:NetStream=new NetStream(nc);
var video:Video=new Video();
addChild(video);
video.attachNetStream(ns);
ns.play("yourvideo.flv");
Copy link to clipboard
Copied
Thx boss u are great. Its working ![]()
But I have some more questions
Can we mention some size (height and width), position(x and y) and control (play, pause, streaming line and volume?)
for the video height and widht i try this, its working but how to get video position and control?
package {
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
public class clickbutton extends SimpleButton {
public function clickbutton() {
this.addEventListener(MouseEvent.CLICK, clickF);
}
private function clickF(e:MouseEvent):void{
var nc:NetConnection=new NetConnection();
nc.connect(null);
var ns:NetStream=new NetStream(nc);
var video:Video=new Video(320, 200);
this.parent.addChild(video);
video.attachNetStream(ns);
ns.play("video_test.flv");
}
}
}
You can see, now its look like this

and also I got output error
Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetStream was unable to invoke callback onMetaData. error=ReferenceError: Error #1069: Property onMetaData not found on flash.net.NetStream and there is no default value.
at clickbutton/clickF()
Copy link to clipboard
Copied
you should check the netstream class to see how to add video controls.
to remove the error and position your video:
l?
package {
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
public class clickbutton extends SimpleButton {
public function clickbutton() {
this.addEventListener(MouseEvent.CLICK, clickF);
}
private function clickF(e:MouseEvent):void{
var nc:NetConnection=new NetConnection();
nc.connect(null);
var ns:NetStream=new NetStream(nc);
var video:Video=new Video(320, 200);
video.x=(stage.stageWidth-320)/2;
video.y=(stage.stageHeight-200)/2;
ns.client=this;
this.parent.addChild(video);
video.attachNetStream(ns);
ns.play("video_test.flv");
}
private function onMetaData():void{
}
}
}
Copy link to clipboard
Copied
Cool its working boss ![]()
package {
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
public class clickbutton extends SimpleButton {
public function clickbutton() {
this.addEventListener(MouseEvent.CLICK, clickF);
}
private function clickF(e:MouseEvent):void{
var nc:NetConnection=new NetConnection();
nc.connect(null);
var ns:NetStream=new NetStream(nc);
var video:Video=new Video(320, 200);
video.x=(stage.stageWidth-320)/2;
video.y=(stage.stageHeight-200)/2;
ns.client=this;
this.parent.addChild(video);
video.attachNetStream(ns);
ns.play("video_test.flv");
}
private function onMetaData():void{
}
}
}
How we can create some control buttons like...... play, pause, volume control, mute and stemming
Copy link to clipboard
Copied
check the netstream class to created controls. it has play() and pause() methods for your play and pause buttons and it has a soundTransform property you can use to control your sound.
package {
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
public class clickbutton extends SimpleButton {
var ns:NetStream;
var previousVolume:Number = 1;
public function clickbutton() {
this.addEventListener(MouseEvent.CLICK, clickF);
}
private function clickF(e:MouseEvent):void{
var nc:NetConnection=new NetConnection();
nc.connect(null);
ns=new NetStream(nc);
var video:Video=new Video(320, 200);
video.x=(stage.stageWidth-320)/2;
video.y=(stage.stageHeight-200)/2;
ns.client=this;
this.parent.addChild(video);
video.attachNetStream(ns);
ns.play("video_test.flv");
controlsF();
}
private function controlsF():void{
play_btn.addEventListener(MouseEvent.CLICK,playF);
pause_btn.addEventListener(MouseEvent.CLICK,pauseF);
muteToggle_btn.addEventListener(MouseEvent.CLICK,muteF);
// add volume listener here. you'll need to decide how you want to control volume.
}
function playF(e:MouseEvent):void{
ns.play();
}
function pauseF(e:MouseEvent):void{
ns.pause();
}
function muteF(e:MouseEvent):void{
if(ns.soundTransform.volume>0){
var st:SoundTransform=ns.soundTransform;
previousVolume=st.volume;
st.volume=0;
ns.soundTransform=st;
} else {
var st:SoundTransform=ns.soundTransform;
st.volume=previousVolume;
ns.soundTransform=st;
}
}
private function onMetaData():void{
}
}
}
Copy link to clipboard
Copied
I make 3 buttons and give him instance name (play_btn, pause_btn, muteToggle_btn) but got some compiler errors
package {
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
public class clickbutton extends SimpleButton {
var ns:NetStream;
var previousVolume:Number = 1;
public function clickbutton() {
this.addEventListener(MouseEvent.CLICK, clickF);
}
private function clickF(e:MouseEvent):void{
var nc:NetConnection=new NetConnection();
nc.connect(null);
ns=new NetStream(nc);
var video:Video=new Video(320, 200);
video.x=(stage.stageWidth-320)/2;
video.y=(stage.stageHeight-200)/2;
ns.client=this;
this.parent.addChild(video);
video.attachNetStream(ns);
ns.play("video_test.flv");
controlsF();
}
private function controlsF():void{
play_btn.addEventListener(MouseEvent.CLICK,playF);
pause_btn.addEventListener(MouseEvent.CLICK,pauseF);
muteToggle_btn.addEventListener(MouseEvent.CLICK,muteF);
// add volume listener here. you'll need to decide how you want to control volume.
}
function playF(e:MouseEvent):void{
ns.play();
}
function pauseF(e:MouseEvent):void{
ns.pause();
}
function muteF(e:MouseEvent):void{
if(ns.soundTransform.volume>0){
var st:SoundTransform=ns.soundTransform;
previousVolume=st.volume;
st.volume=0;
ns.soundTransform=st;
} else {
var st:SoundTransform=ns.soundTransform;
st.volume=previousVolume;
ns.soundTransform=st;
}
}
private function onMetaData():void{
}
}
}


Copy link to clipboard
Copied
1. those 3 buttons don't exist when your code executes.
2. import the soundtransform class, import flash.media.SoundTransform;
Copy link to clipboard
Copied
there's another work-around found recently by another forum user.
use two different flvplayback components. one acts as a parent for the other that plays the flv:
flv_pb_parent.addChild(flv_pb);
Copy link to clipboard
Copied
Sorry to say boss how and where I can use this?
flv_pb_parent.addChild(flv_pb);
Now I use this code and got these complier errors
package {
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.SoundTransform;
public class clickbutton extends SimpleButton {
var ns:NetStream;
var previousVolume:Number = 1;
public function clickbutton() {
this.addEventListener(MouseEvent.CLICK, clickF);
}
private function clickF(e:MouseEvent):void{
var nc:NetConnection=new NetConnection();
nc.connect(null);
ns=new NetStream(nc);
var video:Video=new Video(320, 200);
video.x=(stage.stageWidth-320)/2;
video.y=(stage.stageHeight-200)/2;
ns.client=this;
this.parent.addChild(video);
video.attachNetStream(ns);
ns.play("video_test.flv");
controlsF();
}
private function controlsF():void{
play_btn.addEventListener(MouseEvent.CLICK,playF);
pause_btn.addEventListener(MouseEvent.CLICK,pauseF);
muteToggle_btn.addEventListener(MouseEvent.CLICK,muteF);
// add volume listener here. you'll need to decide how you want to control volume.
}
function playF(e:MouseEvent):void{
ns.play();
}
function pauseF(e:MouseEvent):void{
ns.pause();
}
function muteF(e:MouseEvent):void{
if(ns.soundTransform.volume>0){
var st:SoundTransform=ns.soundTransform;
previousVolume=st.volume;
st.volume=0;
ns.soundTransform=st;
} else {
var st:SoundTransform=ns.soundTransform;
st.volume=previousVolume;
ns.soundTransform=st;
}
}
private function onMetaData():void{
}
}
}


Copy link to clipboard
Copied
add the flvplayback component that plays your video to a parent flvplayback in your original setup that used the flvplayback.
Copy link to clipboard
Copied
Sorry to say, I didnāt get you point
- do I have to add FLV play back component on my scene?
- Do I have to assign this FLV play back component any instance name or give any source file?
- If i use FLV play back component then how we can call this in over video button script?

Copy link to clipboard
Copied
use two different flvplayback components. add a 2nd to your stage at 0,0 and assign it an instance name (eg, flv_pb_parent). then add the following actionscript
flv_pb_parent.addChild(flv_pb);
Copy link to clipboard
Copied
I use 2 FLVPlay back component and assign 1st FLVPlay back component instance name (flv_pb_parent). I didnāt give 2nd component instance name

flv_pb_parent.addChild(flv_pb); this code where I have to use. This is my code which I use
package {
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.SoundTransform;
public class clickbutton extends SimpleButton {
var ns:NetStream;
var previousVolume:Number = 1;
public function clickbutton() {
this.addEventListener(MouseEvent.CLICK, clickF);
}
private function clickF(e:MouseEvent):void{
var nc:NetConnection=new NetConnection();
nc.connect(null);
ns=new NetStream(nc);
var video:Video=new Video(320, 200);
video.x=(stage.stageWidth-320)/2;
video.y=(stage.stageHeight-200)/2;
ns.client=this;
this.parent.addChild(video);
video.attachNetStream(ns);
ns.play("video_test.flv");
controlsF();
}
private function controlsF():void{
play_btn.addEventListener(MouseEvent.CLICK,playF);
pause_btn.addEventListener(MouseEvent.CLICK,pauseF);
muteToggle_btn.addEventListener(MouseEvent.CLICK,muteF);
// add volume listener here. you'll need to decide how you want to control volume.
}
function playF(e:MouseEvent):void{
ns.play();
}
function pauseF(e:MouseEvent):void{
ns.pause();
}
function muteF(e:MouseEvent):void{
if(ns.soundTransform.volume>0){
var st:SoundTransform=ns.soundTransform;
previousVolume=st.volume;
st.volume=0;
ns.soundTransform=st;
} else {
var st:SoundTransform=ns.soundTransform;
st.volume=previousVolume;
ns.soundTransform=st;
}
}
private function onMetaData():void{
}
}
}
Copy link to clipboard
Copied
if there's no flv_pb you should be seeing an error message. if you don't see an error message you're not using the code i suggested.
assign one of the components the instance name, flv_pb.
use the code i suggested.
position the parent where you want your video to appear and position flv_pb at 0,0
Copy link to clipboard
Copied
I assignee 1st FLVplayback component instance name (flv_pb_parent) and 2nd FLVplayback component instance name is (flv_pb)

and i try this code
-------------------------------------------------
package {
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.SoundTransform;
public class clickbutton extends SimpleButton {
var ns:NetStream;
var previousVolume:Number = 1;
public function clickbutton() {
this.addEventListener(MouseEvent.CLICK, clickF);
}
private function clickF(e:MouseEvent):void{
flv_pb_parent.addChild(flv_pb);
var nc:NetConnection=new NetConnection();
nc.connect(null);
ns=new NetStream(nc);
var video:Video=new Video(320, 200);
video.x=(stage.stageWidth-320)/2;
video.y=(stage.stageHeight-200)/2;
ns.client=this;
this.parent.addChild(video);
video.attachNetStream(ns);
ns.play("video_test.flv");
controlsF();
}
private function controlsF():void{
play_btn.addEventListener(MouseEvent.CLICK,playF);
pause_btn.addEventListener(MouseEvent.CLICK,pauseF);
muteToggle_btn.addEventListener(MouseEvent.CLICK,muteF);
// add volume listener here. you'll need to decide how you want to control volume.
}
function playF(e:MouseEvent):void{
ns.play();
}
function pauseF(e:MouseEvent):void{
ns.pause();
}
function muteF(e:MouseEvent):void{
if(ns.soundTransform.volume>0){
var st:SoundTransform=ns.soundTransform;
previousVolume=st.volume;
st.volume=0;
ns.soundTransform=st;
} else {
var st:SoundTransform=ns.soundTransform;
st.volume=previousVolume;
ns.soundTransform=st;
}
}
private function onMetaData():void{
}
}
}
----------------------------------------------------------------------------
I got some compiler errors

I am sure I did some wrong
if you donāt mind can you check my project and solve this problem
Copy link to clipboard
Copied
use:
MovieClip(root).flv_pb_parent.addChild(flv_pb);
Copy link to clipboard
Copied
i try this code

package {
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.SoundTransform;
import flash.display.MovieClip;
public class clickbutton extends SimpleButton {
var ns:NetStream;
var previousVolume:Number = 1;
public function clickbutton() {
this.addEventListener(MouseEvent.CLICK, clickF);
}
private function clickF(e:MouseEvent):void{
//flv_pb_parent.addChild(flv_pb);
MovieClip(root).flv_pb_parent.addChild(flv_pb);
var nc:NetConnection=new NetConnection();
nc.connect(null);
ns=new NetStream(nc);
var video:Video=new Video(320, 200);
video.x=(stage.stageWidth-320)/2;
video.y=(stage.stageHeight-200)/2;
ns.client=this;
this.parent.addChild(video);
video.attachNetStream(ns);
ns.play("video_test.flv");
controlsF();
}
private function controlsF():void{
play_btn.addEventListener(MouseEvent.CLICK,playF);
pause_btn.addEventListener(MouseEvent.CLICK,pauseF);
muteToggle_btn.addEventListener(MouseEvent.CLICK,muteF);
// add volume listener here. you'll need to decide how you want to control volume.
}
function playF(e:MouseEvent):void{
ns.play();
}
function pauseF(e:MouseEvent):void{
ns.pause();
}
function muteF(e:MouseEvent):void{
if(ns.soundTransform.volume>0){
var st:SoundTransform=ns.soundTransform;
previousVolume=st.volume;
st.volume=0;
ns.soundTransform=st;
} else {
var st:SoundTransform=ns.soundTransform;
st.volume=previousVolume;
ns.soundTransform=st;
}
}
private function onMetaData():void{
}
}
}
-----------------------------------------------------------------------------
and in this time i got these compiler errors

Copy link to clipboard
Copied
use MovieClip(root) to reference flv_pb_parent and flv_p:
MovieClip(root).flv_pb
MovieClip(root).flv_pb_parent
Copy link to clipboard
Copied
got compiler errors

Here it the code which I use
package {
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.SoundTransform;
import flash.display.MovieClip;
public class clickbutton extends SimpleButton {
var ns:NetStream;
var previousVolume:Number = 1;
public function clickbutton() {
this.addEventListener(MouseEvent.CLICK, clickF);
}
private function clickF(e:MouseEvent):void{
MovieClip(root).flv_pb;
MovieClip(root).flv_pb_parent;
var nc:NetConnection=new NetConnection();
nc.connect(null);
ns=new NetStream(nc);
var video:Video=new Video(320, 200);
video.x=(stage.stageWidth-320)/2;
video.y=(stage.stageHeight-200)/2;
ns.client=this;
this.parent.addChild(video);
video.attachNetStream(ns);
ns.play("video_test.flv");
controlsF();
}
private function controlsF():void{
play_btn.addEventListener(MouseEvent.CLICK,playF);
pause_btn.addEventListener(MouseEvent.CLICK,pauseF);
muteToggle_btn.addEventListener(MouseEvent.CLICK,muteF);
// add volume listener here. you'll need to decide how you want to control volume.
}
function playF(e:MouseEvent):void{
ns.play();
}
function pauseF(e:MouseEvent):void{
ns.pause();
}
function muteF(e:MouseEvent):void{
if(ns.soundTransform.volume>0){
var st:SoundTransform=ns.soundTransform;
previousVolume=st.volume;
st.volume=0;
ns.soundTransform=st;
} else {
var st:SoundTransform=ns.soundTransform;
st.volume=previousVolume;
ns.soundTransform=st;
}
}
private function onMetaData():void{
}
}
}
Copy link to clipboard
Copied
use the same solution of all display objects on your main timeline. you're out of scope in that class.
MovieClip(root).whateverdisplayobject.
Copy link to clipboard
Copied
Compiler Errors

here is the code
package {
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.SoundTransform;
import flash.display.MovieClip;
public class clickbutton extends SimpleButton {
var ns:NetStream;
var previousVolume:Number = 1;
public function clickbutton() {
this.addEventListener(MouseEvent.CLICK, clickF);
}
private function clickF(e:MouseEvent):void{
MovieClip(root).flv_pb;
MovieClip(root).flv_pb_parent;
var nc:NetConnection=new NetConnection();
nc.connect(null);
ns=new NetStream(nc);
var video:Video=new Video(320, 200);
video.x=(stage.stageWidth-320)/2;
video.y=(stage.stageHeight-200)/2;
ns.client=this;
this.parent.addChild(video);
video.attachNetStream(ns);
ns.play("video_test.flv");
controlsF();
}
private function controlsF():void{
MovieClip(root).play_btn;
MovieClip(root).pause_btn;
MovieClip(root).muteToggle_btn;
play_btn.addEventListener(MouseEvent.CLICK,playF);
pause_btn.addEventListener(MouseEvent.CLICK,pauseF);
muteToggle_btn.addEventListener(MouseEvent.CLICK,muteF);
// add volume listener here. you'll need to decide how you want to control volume.
}
function playF(e:MouseEvent):void{
ns.play();
}
function pauseF(e:MouseEvent):void{
ns.pause();
}
function muteF(e:MouseEvent):void{
if(ns.soundTransform.volume>0){
var st:SoundTransform=ns.soundTransform;
previousVolume=st.volume;
st.volume=0;
ns.soundTransform=st;
} else {
var st:SoundTransform=ns.soundTransform;
st.volume=previousVolume;
ns.soundTransform=st;
}
}
private function onMetaData():void{
}
}
}
Copy link to clipboard
Copied
use:
private function controlsF():void{
MovieClip(root).play_btn.addEventListener(MouseEvent.CLICK,playF);
MovieClip(root).pause_btn.addEventListener(MouseEvent.CLICK,pauseF);
MovieClip(root).muteToggle_btn.addEventListener(MouseEvent.CLICK,muteF);
// add volume listener here. you'll need to decide how you want to control volume.
}
Copy link to clipboard
Copied
I try this its working but having some small problem
When I run the my file first time I got this compiler error


After that when I click on the video button I got this output error (video is playing)

video button, pause button and mute button its working great but play button is not working
- when I click on the play button I got this output error

In the last when video is finished then got this compiler error

This is the code which I use
package {
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.SoundTransform;
import flash.display.MovieClip;
public class clickbutton extends SimpleButton {
var ns:NetStream;
var previousVolume:Number = 1;
public function clickbutton() {
this.addEventListener(MouseEvent.CLICK, clickF);
}
private function clickF(e:MouseEvent):void{
MovieClip(root).flv_pb;
MovieClip(root).flv_pb_parent;
var nc:NetConnection=new NetConnection();
nc.connect(null);
ns=new NetStream(nc);
var video:Video=new Video(320, 200);
video.x=(stage.stageWidth-320)/2;
video.y=(stage.stageHeight-200)/2;
ns.client=this;
this.parent.addChild(video);
video.attachNetStream(ns);
ns.play("video_test.flv");
controlsF();
}
private function controlsF():void{
MovieClip(root).play_btn.addEventListener(MouseEvent.CLICK,playF);
MovieClip(root).pause_btn.addEventListener(MouseEvent.CLICK,pauseF);
MovieClip(root).muteToggle_btn.addEventListener(MouseEvent.CLICK,muteF);
// add volume listener here. you'll need to decide how you want to control volume.
}
function playF(e:MouseEvent):void{
ns.play();
}
function pauseF(e:MouseEvent):void{
ns.pause();
}
function muteF(e:MouseEvent):void{
if(ns.soundTransform.volume>0){
var st:SoundTransform=ns.soundTransform;
previousVolume=st.volume;
st.volume=0;
ns.soundTransform=st;
} else {
var st:SoundTransform=ns.soundTransform;
st.volume=previousVolume;
ns.soundTransform=st;
}
}
private function onMetaData():void{
}
}
}
Copy link to clipboard
Copied
use:
package {
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.SoundTransform;
import flash.display.MovieClip;
public class clickbutton extends SimpleButton {
var ns:NetStream;
var previousVolume:Number = 1;
public function clickbutton() {
this.addEventListener(MouseEvent.CLICK, clickF);
}
private function clickF(e:MouseEvent):void{
MovieClip(root).flv_pb;
MovieClip(root).flv_pb_parent;
var nc:NetConnection=new NetConnection();
nc.connect(null);
ns=new NetStream(nc);
var video:Video=new Video(320, 200);
video.x=(stage.stageWidth-320)/2;
video.y=(stage.stageHeight-200)/2;
ns.client=this;
this.parent.addChild(video);
video.attachNetStream(ns);
ns.play("video_test.flv");
controlsF();
}
private function controlsF():void{
MovieClip(root).play_btn.addEventListener(MouseEvent.CLICK,playF);
MovieClip(root).pause_btn.addEventListener(MouseEvent.CLICK,pauseF);
MovieClip(root).muteToggle_btn.addEventListener(MouseEvent.CLICK,mute F);
// add volume listener here. you'll need to decide how you want to control volume.
}
function playF(e:MouseEvent):void{
ns.resume();
}
function pauseF(e:MouseEvent):void{
ns.pause();
}
function muteF(e:MouseEvent):void{
if(ns.soundTransform.volume>0){
var st:SoundTransform=ns.soundTransform;
previousVolume=st.volume;
st.volume=0;
ns.soundTransform=st;
} else {
st=ns.soundTransform;
st.volume=previousVolume;
ns.soundTransform=st;
}
}
private function onMetaData():void{ // this needs to be in the scope of your loader
}
private function onPlayStatus(eObj:Object):void{
}
}
}
Copy link to clipboard
Copied
Its working boss. U r great
Just 1 output error, is this ignorable?

Copy link to clipboard
Copied
yes, you can ignore it.
but try making it public. i find those messages annoying:
public function onMetaData():void{ // this needs to be in the scope of your loader
}
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more