Digestive Health & Nausea > Prilosec 10mg Pills (Generic) > 60 Pills > $102.00

ActionScript 3.0 Flash

Digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 This article can be considered a sequel to “How to Load External Flash Video (FLV) Files (AS2).”  The code suggested here is nothing more than the ActionScript 3.0 way to accomplish the same goal achieved earlier; namely, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 to load an external Flash video (FLV) file at runtime — without using the FLVPlayback component.  To be sure, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 there’s nothing wrong with FLVPlayback.  Its skins are customizable (all the more so in Flash CS3, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 which is the first version of Flash to support AS3) and it provides plenty of built-in widgets, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 such as play/pause, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 a volume slider, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 mute button, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 and the like.  But to get those features, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 even if you choose a non-skinned component, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 you pay a 49KB price in an ActionScript 3.0 document.  If you go without the component, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 it costs you less than 1KB.  That means site visitors can spend their bandwidth on your video content itself, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 rather than the video player. 

An answer, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 short and sweet

Digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 As described in the AS2 version of this article, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 you’re going to use an instance each of the NetConnection and NetStream classes in addition to a Video object.  In ActionScript 3.0 — this is really neat — you can even create your Video instance via ActionScript.  This is new.  If you like, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 though, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 you can also still use the Library panel to create a video asset beforehand and drag it to the Stage.  We’ll look at both approaches.  First, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 the completely programmatic way:

var vid:Video = new Video(320, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 240);
addChild(vid);

var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);
vid.attachNetStream(ns);

var listener:Object = new Object();
listener.onMetaData = function(evt:Object):void {};
ns.client = listener;

ns.play("externalVideo.flv");

How it works

Digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 An arbitrarily named variable, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 vid, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 is declared and set to an instance of the Video class.  To specify the size of this video, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 two parameters are passed into the constructor:  a width and height of 320 and 240 pixels.  As it turns out, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 this is the default, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 so you can leave those numbers out completely and your video will show as 320×240.  If you want something bigger or smaller, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 or if your video’s dimensions are some other aspect ratio, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 specify the relevant numbers.  The line immediately following, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 addChild(vid), digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 invokes the DisplayObjectContainer.addChild() method on the timeline in which this code appears.

Digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 Why the timeline?  Because the method stands alone, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 doesn’t have an object reference prefixed to it.  (In contrast, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 other methods in the above snippet are preceded by object references.)  What’s a DisplayObjectContainer?  Well, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 it’s just another class, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 like the others we’re using here.  DisplayObjectContainer is inherited by a number of everyday classes, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 such as MovieClip.

Digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 The timeline in which this code appears (i.e., digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 the main timeline) actually is a MovieClip instance, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 which means it has access to the addChild() method thanks to the fact that DisplayObjectContainer is a grandparent in its family tree.  By “adding the child” vid, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 you’re simply making the Video object visible.  You’re adding it to the display list of the main timeline, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 which means it’ll show up visually (even though it exists before then and would even if you failed to add it to the list — in which case it just wouldn’t show).

Digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 So now we have a Video object to display the video.  Now we need to hook it up.  Another arbitrarily named variable, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 nc, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 is declared and set to an instance of the NetConnection class, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 then the NetConnection.connect() method is called on it and passed a null parameter.  Why null?  All that means is that we’re requesting a progressive download FLV file; that is, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 one that isn’t streamed via Flash Media Server.

Digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 With this connection established, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 a third arbitrarily named variable, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 ns, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 is declared and set to an instance of the NetStream class.  This instance is associated with the net connection, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 and the Video.attachNetStream() method is invoked on vid to associate it with the net stream.  This may be a bit tedious, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 but it’s not too bad, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 and certainly pretty straightforward.

Digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 The next three lines merit a bit of explanation.  Here they are again:

var listener:Object = new Object();
listener.onMetaData = function(evt:Object):void {};
ns.client = listener;

Digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 This is one of the very few exceptions to how event handing is done in ActionScript 3.0.  Normally, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 the task is done as described in this excellent article by Trevor McCauley, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 “Introduction to event handling in ActionScript 3.0.”  Here, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 the NetStream.onMetaData event is taken care of by a sort of liaison — a generic Object instance — the way it’s often done in AS2.  Why are we even handling onMetaData?  Strictly speaking, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 you don’t have to.  If your FLV doesn’t have metadata embedded in it, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 the onMetaData event won’t be dispatched when the video starts playing.  Most FLV encoders, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 however (including the native Flash Import Video Wizard), digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 do embed metadata, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 and if you don’t handle the dispatched event, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 you’ll see an error message in the Output panel.  The above three lines simply create a dummy stand-in function (that doesn’t do anything) and associate it with an onMetaData property of the Object instance, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 arbitrarily named listener.  This object is then connected with the NetStream instance by way of its client property.

Digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 Finally, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 NetStream.play() is invoked on ns and told which FLV to play.

What if I prefer a made-by-hand Video object?

Digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 If you remember the AS2 version of this article and prefer your older workflow, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 drop the first two lines of the above code sample.  Instead, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 right-click / Command-click in an open space in your Library panel, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 choose New Video… from the context menu, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 hit OK to accept the default values — this gives you an ActionScript-controllable Video object with an asset name of Video 1 — then drag that asset to the Stage.  Size it to the dimensions of your video content, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 then use the Property inspector to give the object an instance name, digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 such as videoPlayer.  That instance name will be your key to associating this Video object with the NetStream instance:

var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);
videoPlayer.attachNetStream(ns);

var listener:Object = new Object();
listener.onMetaData = function(evt:Object):void {};
ns.client = listener;

ns.play("externalVideo.flv");

Digestive health & nausea > prilosec 10mg pills (generic) > 60 pills > $102.00 And there you have it.  See how most of that code overlaps?

Average Rating: 5 out of 5 based on 170 user reviews.

Leave a Reply