Prozac 40mg Pills $118.00

ActionScript 2.0 ActionScript 3.0

Prozac 40mg pills $118.00 Half a year ago, prozac 40mg pills $118.00 I wrote a brief article on “How to Play Sound Files Sequentially” (AS2).  Recently, prozac 40mg pills $118.00 a reader was asking how to apply the same principle to video.  In his case, prozac 40mg pills $118.00 Paul had to play a commercial first, prozac 40mg pills $118.00 then follow it with a longer content video — and the user controls (buttons, prozac 40mg pills $118.00 scrubber, prozac 40mg pills $118.00 etc.) needed to be disabled wile the commercial was playing.  As it turns out, prozac 40mg pills $118.00 Paul worked out a solution of his own, prozac 40mg pills $118.00 partly based on some of the other articles here, prozac 40mg pills $118.00 but I thought it would be fun to do a quick version too.  That way, prozac 40mg pills $118.00 he can compare notes and anyone else can look on. 

An answer, prozac 40mg pills $118.00 short and sweet

Prozac 40mg pills $118.00 To my thinking, prozac 40mg pills $118.00 the key is to reuse as much code as possible.  Even though we’re playing two (or any number) of videos, prozac 40mg pills $118.00 we only need a single instance of Video, prozac 40mg pills $118.00 NetConnection, prozac 40mg pills $118.00 and NetStream apiece.  That’s if we’re going with a non-component approach, prozac 40mg pills $118.00 like the one described in “How to Load External Video (FLV)” (AS2).  We’ll start with that one, prozac 40mg pills $118.00 to get the basic idea across, prozac 40mg pills $118.00 then I’ll also show how to accomplish the same thing with the FLVPlayback component.  The operative mechanism, prozac 40mg pills $118.00 in all cases, prozac 40mg pills $118.00 is to detect when the current video has ended, prozac 40mg pills $118.00 then automatically start playing the next one, prozac 40mg pills $118.00 until the list of videos is complete.

Prozac 40mg pills $118.00 Let’s start with ActionScript 2.0.  Here’s the chunk of code:

ActionScript 2.0

var videos:Array = new Array("a.flv", prozac 40mg pills $118.00 "b.flv", prozac 40mg pills $118.00 "c.flv");
var currentVideo:Number = 0;
var duration:Number = 0;
var ready:Boolean = true;

var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
videoPlayer.attachVideo(ns);
ns.play(videos[currentVideo]);

ns.onMetaData = function(evt:Object):Void {
  duration = evt.duration;
  ready = true;
};
ns.onStatus = function(evt:Object):Void {
  if (ready && this.time > 0 && this.time >= (duration - 0.5)) {
    ready = false;
    currentVideo++;
    if (currentVideo < videos.length) {
      ns.play(videos[currentVideo]);
    } else {
      delete this.onStatus;
    }
  }
}

How it works

Prozac 40mg pills $118.00 The first line declares an arbitrarily named variable, prozac 40mg pills $118.00 videos, prozac 40mg pills $118.00 and sets it to an instance of the Array class.  This Array instance is populated with three strings, prozac 40mg pills $118.00 “a.flv”, prozac 40mg pills $118.00 “b.flv”, prozac 40mg pills $118.00 and “c.flv”.  Arrays are just lists, prozac 40mg pills $118.00 and this is a list of three FLV files.  The second line declares another variable, prozac 40mg pills $118.00 currentVideo, prozac 40mg pills $118.00 which is a number, prozac 40mg pills $118.00 and sets its value to zero.  Arrays start at zero, prozac 40mg pills $118.00 so in a moment, prozac 40mg pills $118.00 you’ll see this variable used to pull the first video from the list.

Prozac 40mg pills $118.00 The third line declares a variable named duration, prozac 40mg pills $118.00 which will be updated later from its initial value of zero in response to the NetStream.onMetaData event, prozac 40mg pills $118.00 as described in “How to Determine the Completion of a Flash Video (FLV) File.”  Finally, prozac 40mg pills $118.00 a Boolean (true/false) variable named ready is declared and set to true.  This will be used to ensure that the onStatus event handler doesn’t perform its tasks too often in a row.

Prozac 40mg pills $118.00 The next few lines — starting with var nc:NetConnection — use the approach suggested in “How to Load External Video (FLV)” to load the first video.  In fact, prozac 40mg pills $118.00 the videos array already makes its entrance:

Prozac 40mg pills $118.00 ns.play(videos[currentVideo]);

Prozac 40mg pills $118.00 Remember, prozac 40mg pills $118.00 currentVideo is 0, prozac 40mg pills $118.00 so the preceding line is effectively the same as saying videos[0], prozac 40mg pills $118.00 which pulls the first element from the videos array (the string “a.flv”, prozac 40mg pills $118.00 or whatever the name of your own video is; for Paul, prozac 40mg pills $118.00 this would be his commercial).  Ultimately, prozac 40mg pills $118.00 this expression resolves to ns.play("a.flv");.

Prozac 40mg pills $118.00 The onMetaData event handler is explained in the “How to Determine” article, prozac 40mg pills $118.00 which leaves the NetStream.onStatus event handler.  Most of what it does is covered in the same onMetaData article, prozac 40mg pills $118.00 but in a nutshell, prozac 40mg pills $118.00 the onStatus event is dispatched whenever the video does something interesting, prozac 40mg pills $118.00 like start, prozac 40mg pills $118.00 download data, prozac 40mg pills $118.00 stop, prozac 40mg pills $118.00 etc.  It fires a couple times near the beginning and the end of FLVs, prozac 40mg pills $118.00 so the if statement checks if its current position (NetStream.time, prozac 40mg pills $118.00 represented by the expression this.time) is greater than zero and (&&) is greater than half a second less than the video’s full duration.  The very first item in the if condition, prozac 40mg pills $118.00 ready &&, prozac 40mg pills $118.00 adds one more filter level, prozac 40mg pills $118.00 so to speak.  Because onStatus fires so often, prozac 40mg pills $118.00 it can be triggered more than once even while the other two portions of the condition are true.  For this reason, prozac 40mg pills $118.00 ready is set to false as soon as the whole condition evaluates to true.

Prozac 40mg pills $118.00 If all three sub-conditions are true, prozac 40mg pills $118.00 the ready variable is set to false.  This keeps onStatus from perfroming the next part too many times in a row.  The currentVideo variable is incremented by one (currentVideo++), prozac 40mg pills $118.00 which changes it from 0 to 1.  Next, prozac 40mg pills $118.00 a second if statement checks of currentVideo (now 1) is less than the Array.length property of videosArray.length returns the number of items in an array (we have three strings, prozac 40mg pills $118.00 so the property returns 3 in this case).  1 is less than 3, prozac 40mg pills $118.00 so the following line is executed:  ns.play(videos[currentVideo]);.  That’s the same line we saw earlier, prozac 40mg pills $118.00 but this time, prozac 40mg pills $118.00 the value of current Video has changed, prozac 40mg pills $118.00 and the second video plays.  When it does, prozac 40mg pills $118.00 the onMetaData handler will again set ready to true, prozac 40mg pills $118.00 which re-allows onStatus to do its thing.

Prozac 40mg pills $118.00 This procedure will occur again at the end of the second video, prozac 40mg pills $118.00 at which point currentVideo will increment to 2.  2 is still less than 3, prozac 40mg pills $118.00 so eventually, prozac 40mg pills $118.00 the third video will also play.  At that point, prozac 40mg pills $118.00 currentVideo will increment to 3.  Obviously, prozac 40mg pills $118.00 3 is not less 3, prozac 40mg pills $118.00 so the else clause will execute, prozac 40mg pills $118.00 which simple shuts down the onStatus event handler.

Prozac 40mg pills $118.00 To fulfill the requirement of disabling user controls (see “How to Build a Basic Slider Widget (AS2)” and “How to Build a Basic Toggle Button (AS2)”), prozac 40mg pills $118.00 the same area of the NetStream.onStatus event handler could be used:

ns.onStatus = function(evt:Object):Void {
  if (ready && this.time > 0 && this.time >= (duration - 0.5)) {
    ready = false;
    currentVideo++;
    if (currentVideo > 0) {
      toggleButton.enabled = true;
      sliderKnob.enabled = true;
    }
    if (currentVideo < videos.length) {
      ns.play(videos[currentVideo]);
    } else {
      delete this.onStatus;
    }
  }
}

Prozac 40mg pills $118.00 All that has changed is the addition of a new if statement, prozac 40mg pills $118.00 which checks if currentVideo is greater than zero.  If it is, prozac 40mg pills $118.00 then we’re obviously past the first video, prozac 40mg pills $118.00 which was the commercial.  At that point, prozac 40mg pills $118.00 any user controls can be turned on (they would have been disabled earlier by default).  Re-enabling your user controls will, prozac 40mg pills $118.00 of course, prozac 40mg pills $118.00 depend on how they were made.  If you’re using UI Components that ship with Flash, prozac 40mg pills $118.00 you’ll have to consult their respective APIs in the ActionScript 2.0 (or 3.0) Language Reference or Components Reference.  In Paul’s case, prozac 40mg pills $118.00 the controls were made from movie clips, prozac 40mg pills $118.00 which means the MovieClip class entry is what he’d need to consult.  In ActionScript 2.0, prozac 40mg pills $118.00 the MovieClip class happens to feature _visible and enabled properties.

ActionScript 3.0

Prozac 40mg pills $118.00 Here’s the same basic outline in AS3:

import flash.events.NetStatusEvent;
var videos:Array = new Array("a.flv", prozac 40mg pills $118.00 "b.flv", prozac 40mg pills $118.00 "c.flv");
var currentVideo:uint = 0;
var duration:uint = 0;
var ready:Boolean = true;

var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
videoPlayer.attachNetStream(ns);
ns.play(videos[currentVideo]);

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

ns.addEventListener(
  NetStatusEvent.NET_STATUS, prozac 40mg pills $118.00
  nsHandler
);

function nsHandler(evt:NetStatusEvent):void {
  if (ready && ns.time > 0 && ns.time >= (duration - 0.5)) {
    ready = false;
    currentVideo++;
    if (currentVideo < videos.length) {
      ns.play(videos[currentVideo]);
    } else {
      ns.removeEventListener(
        NetStatusEvent.NET_STATUS, prozac 40mg pills $118.00
        nsHandler
      );
    }
  }
};

How it works

Prozac 40mg pills $118.00 Must of the syntax overlaps.  I’ve replaced the Number type with uint in the first few lines (see “Mind Your ints and uints”).  The onMetaData event handler is structured differently — one of the rare cases in which AS3 requires a liaison listener Object instance — but the same basic activity takes place.  The NetStatusEvent.NET_STATUS event handler replaces AS2’s onStatus.  The NetStream instance (ns) is associated with a custom function, prozac 40mg pills $118.00 nsHandler, prozac 40mg pills $118.00 by way of the addEventListener() method.  The nsHandler function repeats what we’ve already seen, prozac 40mg pills $118.00 except that instead of using delete to unhook the event handler, prozac 40mg pills $118.00 it uses removeEventListener().

How About the FLVPlayback Component?

Prozac 40mg pills $118.00 If you’re using the FLVPlayback component, prozac 40mg pills $118.00 fewer lines of code are needed.  You’ll simply drag an instance of FLVPlayback to the Stage, prozac 40mg pills $118.00 use the Property inspector to associate it with the first of your FLVs, prozac 40mg pills $118.00 then employ the following:

ActionScript 2.0

var videos:Array = new Array("a.flv", prozac 40mg pills $118.00 "b.flv", prozac 40mg pills $118.00 "c.flv");
 var currentVideo:Number = 0;
videoPlayer.skin = "";
var listener:Object = new Object();
listener.complete = function(event:Object):Void {
  currentVideo++;
  if (currentVideo > 0) {
    videoPlayer.skin = "MojaveOverPlaySeekMute.swf";
  }
  if (currentVideo < videos.length) {
    videoPlayer.contentPath = videos[currentVideo];
    videoPlayer.play();
  }
};
videoPlayer.addEventListener("complete", prozac 40mg pills $118.00 listener);

Prozac 40mg pills $118.00 Note that the skin part is a different approach toward disabling user interface.  Because skins are actually separate SWF files, prozac 40mg pills $118.00 we would need a way to access the MovieClip instance in the main SWF that represents the loaded skin in order to disabled it via, prozac 40mg pills $118.00 say, prozac 40mg pills $118.00 MovieClip.enabled.  Rather than hassle with that, prozac 40mg pills $118.00 I’ve chosen to set the FLVPlayback.skin property to an empty string at first (""), prozac 40mg pills $118.00 then set it to the file name of an existing skin later (obviously, prozac 40mg pills $118.00 that skin must be present, prozac 40mg pills $118.00 or it won’t show).

ActionScript 3.0

var videos:Array = new Array("a.flv", prozac 40mg pills $118.00 "b.flv", prozac 40mg pills $118.00 "c.flv");
 var currentVideo:uint = 0;

videoPlayer.addEventListener(
  Event.COMPLETE, prozac 40mg pills $118.00
  completeHandler
);

videoPlayer.mouseChildren = false;

function completeHandler(evt:Event):void {
  currentVideo++;
  if (currentVideo > 0) {
    videoPlayer.mouseChildren = true;
  }
  if (currentVideo < videos.length) {
    videoPlayer.source = videos[currentVideo];
    videoPlayer.play();
  }
}

Prozac 40mg pills $118.00 In AS3, prozac 40mg pills $118.00 the DisplayObjectContainer.mouseChildren property, prozac 40mg pills $118.00 inherited by FLVPlayback, prozac 40mg pills $118.00 is enough to disable the optional skin controls, prozac 40mg pills $118.00 then re-enable them later.

Average Rating: 4.7 out of 5 based on 188 user reviews.

Leave a Reply