SandyCooke
asked on
Scripting the creation of a New Video object?
I can't find this documented anywhere...
This works just fine:
1) With the document open in the Flash authoring tool, in the Library panel (Window > Library) select New Video from the Library options menu to create a video object.
2) Drag a video object from the Library panel onto the Stage. This creates a video object instance.
3) With the video object selected on the Stage, in the Property inspector (Window > Properties) enter myVideo in the Instance Name text box.
4) Add this code:
myUrl = "example.flv";
//
var myNetConnection:NetConnect ion = new NetConnection();
myNetConnection.connect(nu ll);
//
var netStream:NetStream = new NetStream(myNetConnection) ;
//
myVideo.attachVideo(netStr eam);
netStream.play(myUrl);
But I want to replace steps 1-3 with something like:
_root.myVideo = new Embedded Video ("myVideo", 1, 20, 20, 320, 240);
Is this possible?
This works just fine:
1) With the document open in the Flash authoring tool, in the Library panel (Window > Library) select New Video from the Library options menu to create a video object.
2) Drag a video object from the Library panel onto the Stage. This creates a video object instance.
3) With the video object selected on the Stage, in the Property inspector (Window > Properties) enter myVideo in the Instance Name text box.
4) Add this code:
myUrl = "example.flv";
//
var myNetConnection:NetConnect
myNetConnection.connect(nu
//
var netStream:NetStream = new NetStream(myNetConnection)
//
myVideo.attachVideo(netStr
netStream.play(myUrl);
But I want to replace steps 1-3 with something like:
_root.myVideo = new Embedded Video ("myVideo", 1, 20, 20, 320, 240);
Is this possible?
ASKER
I'm using a for loop to dynamically create menu items with thumbnails.
I had hoped to use flvs instead of swfs for the thumbs, so that where I would say:
var thumb = this.createEmptyMovieClip( "thumb"+i etc.
thumb.loadMovie("thumb"+i+ ".swf");
I could instead say:
var thumb = this.createNewVideoObject( "thumb"+i etc.
thumb.attachVideo("netStre am"+i);
but from what you say it looks like I'll have to use swfs for the thumbs after all...?
I had hoped to use flvs instead of swfs for the thumbs, so that where I would say:
var thumb = this.createEmptyMovieClip(
thumb.loadMovie("thumb"+i+
I could instead say:
var thumb = this.createNewVideoObject(
thumb.attachVideo("netStre
but from what you say it looks like I'll have to use swfs for the thumbs after all...?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have been obsessed with the idea of the entire site being generated by one page of actionscript... now I'll have to load in a swf and that makes me feel just dirty, dammit.
1) a VideoStreamHead tag is inserted into the timeline;
2) it is placed on a stage with the name you assigned for it.
As for a programmical creation of a video object -- nothing is easier. Just define a VideoStreamHead tag with some predefined width and hight parameters and place it to the stage with the PlaceObject2 tag providing a name for the VideoStreamHead tag. It is very easy to create an SWF using any open-source Flash SDK available on the Net.
As for scripting (using ActionScript) I doubt it is possible, at least at present. Unfortunately video is not a component, therefore you have no way to setup its width and height (which are just readonly in runtime, but you can adjust them in designtime).
Why you need to _create_ it in a script? Do you need to change its dimensions?