Solved

Scripting the creation of a New Video object?

Posted on 2004-03-24
4
313 Views
Last Modified: 2006-11-17
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:NetConnection = new NetConnection();
myNetConnection.connect(null);
//
var netStream:NetStream = new NetStream(myNetConnection);
//
myVideo.attachVideo(netStream);
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?
0
Comment
Question by:SandyCooke
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:abb1
ID: 10715150
In fact what is done while you perform these steps are:

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?

0
 
LVL 2

Author Comment

by:SandyCooke
ID: 10715979
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("netStream"+i);

but from what you say it looks like I'll have to use swfs for the thumbs after all...?

0
 
LVL 3

Accepted Solution

by:
abb1 earned 250 total points
ID: 10720502
Sorry, what is the problem? Are your thumbs of the same (width x height)? if so, nothing is easier! Just create a template "video.swf", containing such video object, load it into every thumb and play with all them. You can even stretch videos (create thumbs of various sizes) though I'm not sure how fast it will work for a couple of thumbs.

Please note that you may access the video by its instance name, though it is not a movieclip. This is very useful exception!

OK?
0
 
LVL 2

Author Comment

by:SandyCooke
ID: 10722452
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.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question