Adobe Dreamweaver Forums



Last 10 THreads :         DW CS4 - Internet Explorer - Tables (Last Post : billhdz - Replies : 0 - Views : 1 )           »          Property inspector (Last Post : Murray *ACE* - Replies : 1 - Views : 2 )           »          Mail form not working (Last Post : Gary White - Replies : 4 - Views : 5 )           »          How do I change the order the pictures are in when doinga web photo album? (Last Post : Nancy O - Replies : 1 - Views : 2 )           »          Hacked Possible through local machine (Last Post : Coldstream - Replies : 15 - Views : 40 )           »          Re: Robohelp HTML Not Compiling and not responding (Last Post : glennito - Replies : 0 - Views : 1 )           »          datagrid in a datagrid (Last Post : nickname118 - Replies : 4 - Views : 7 )           »          special chars in XML (Last Post : ilux - Replies : 0 - Views : 1 )           »          TextArea: Interface for user selection is deficient (Last Post : ericbelair - Replies : 2 - Views : 3 )           »          Lost resorce on Adobe.com (Last Post : tweaked_eye - Replies : 1 - Views : 2 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flash
 
Tags: ,



Reply
  #1 (permalink)  
Old 08-26-2008, 07:41 PM
necie
 
Posts: n/a
Diggs:
Default CuePoint help

I have a progresive flv with an instance name of myVideo which is already on
the stage and set to autoplay via the component parameters tab. When the video
plays and gets to a cue point I want the flv to pause. Can anyone help me with
my code? Is there a better way to do it? Here is what I have so far:



var listener:Object = new Object();

listener.cuePoint = function(eventObject:Object):Void
{
if (eventObject.info.name == "cp1")
{
myVid.gotoAndStop("cp1");
}

if (eventObject.info.name == "cp2")
{
myVid.gotoAndStop("cp2");
}

if (eventObject.info.name == "s3")
{
myVid.gotoAndStop("cp2");
}

vid.addEventListener("cuePoint", listener);



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-26-2008, 08:07 PM
necie
 
Posts: n/a
Diggs:
Default Re: CuePoint help


Sorry, I thought I was in the Actionscript 1 & 2 forum. I moved this question to that forum.
Reply With Quote
  #3 (permalink)  
Old 08-26-2008, 08:07 PM
David Stiller
 
Posts: n/a
Diggs:
Default Re: CuePoint help

necie,

> When the video plays and gets to a cue point I want the flv
> to pause. Can anyone help me with my code?


Sure thing.

> var listener:Object = new Object();
>
> listener.cuePoint = function(eventObject:Object):Void
> {
> if (eventObject.info.name == "cp1")
> {


So far, so good. You're checking for the cue point name as it was
supplied by you.

> myVid.gotoAndStop("cp1");
> }


Here's a significant problem. When you're dealing with video, you're
either dealng with the NetConnection and NetStream classes, or you're
dealing with the FLVPlayback class. Since you mentioned components, I'm
guessing you're using FLVPlayback.

It helps to understand that everything in ActionScript can be described
in terms of an object. In this case, you're dealing with an FLVPlayback
object. Objects are defined by their (usually namesake) classes. Think of
a class as a recipe. Movie clips are defined by the MovieClip class; text
fields by the TextField class; sounds by the Sound class, and so on. If
you're formatting text, you'll want the TextFormat class, and so on. You
get the idea.

Classes generally describe one or more of the following three
categories: properties (characteristics of the object), methods (things the
object can do), and events (things the objectg can react to). You're using
gotoAndStop(), which is an active term, basically a "verb." That means
you're describing what the object can do ... in other words, a method. If
you look up the FLVPlayback class, you'll find that the Methods heading does
not contain a gotoAndPlay() method. That's a MovieClip method, which means
it's something you can only instruct a movie clip to do.

You will find a pause() method, though, and that's your ticket here.

Obviously, when the video pauses, the cue points will stop, because they
depend on the video actually rolling. So somewhere, you'll need to provide
a mechanism for playing the video again. Maybe a button?


David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design."


Reply With Quote


  #4 (permalink)  
Old 08-26-2008, 09:18 PM
necie
 
Posts: n/a
Diggs:
Default Re: CuePoint help

Wow, I'm reading your blog right now about FLV cue points. I get an email from
the adobe forum and it's you with some info to help me out. You are an
incredible educator. I used the NetStream instead of FLVPlayback. I used your
code from your blog and tweaked it for my files and I added the pause(). It
worked great. Now to get to that play button. I need to add a keyboard event.
The desired result is the end user can continue to play the video by pressing
the right arrow button. I'm trying to NOT use buttons. Here's what I have so
far and the playing of the netStream isn't working.

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 {};
listener.onCuePoint = function(evt:Object):void {
ns.pause();
};
ns.client = listener;

ns.play("CPVideo.flv");


stage.addEventListener(KeyboardEvent.KEY_DOWN, playVideo);
function playVideo(event:KeyboardEvent):void
{
trace(event.keyCode);
ns.play();
}

Reply With Quote
  #5 (permalink)  
Old 08-26-2008, 09:18 PM
necie
 
Posts: n/a
Diggs:
Default Re: CuePoint help

Wow, I'm reading your blog right now about FLV cue points. I get an email from
the adobe forum and it's you with some info to help me out. You are an
incredible educator. I used the NetStream instead of FLVPlayback. I used your
code from your blog and tweaked it for my files and I added the pause(). It
worked great. Now to get to that play button. I need to add a keyboard event.
The desired result is the end user can continue to play the video by pressing
the right arrow button. I'm trying to NOT use buttons. Here's what I have so
far and the playing of the netStream isn't working.

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 {};
listener.onCuePoint = function(evt:Object):void {
ns.pause();
};
ns.client = listener;

ns.play("CPVideo.flv");


stage.addEventListener(KeyboardEvent.KEY_DOWN, playVideo);
function playVideo(event:KeyboardEvent):void
{
trace(event.keyCode);
ns.play();
}

Reply With Quote
  #6 (permalink)  
Old 08-26-2008, 10:16 PM
David Stiller
 
Posts: n/a
Diggs:
Default Re: CuePoint help

necie,

> Wow, I'm reading your blog right now about FLV
> cue points. I get an email from the adobe forum and
> it's you with some info to help me out.


Heh, it's pretty neat when it works out that way.

> You are an incredible educator.


Thanks, necie!

> I used your code from your blog and tweaked it for my
> files and I added the pause(). It worked great. Now to
> get to that play button. I need to add a keyboard event.


Keyboard makes good sense; just keep in mind, the SWF won't respond to
keyboard input (I think!) unless the SWF has focus. Test that to make sure.

> Here's what I have so far and the playing of the netStream
> isn't working.


> stage.addEventListener(KeyboardEvent.KEY_DOWN, playVideo);
> function playVideo(event:KeyboardEvent):void
> {
> trace(event.keyCode);
> ns.play();
> }


The structure of your code is fine, but that play() method is the
culprit here. It needs at least one parameter, which tells the NetStream
instance what file to play. Without that parameter -- as you've seen --
Flash doesn't know what you're asking for.

The solution is to use the optional Boolean parameter of the pause()
method. In your cue point handler, use ns.pause(true); ... then, in your
keyboard handler, use ns.pause(false); -- that should do it!


David Stiller
Contributor, How to Cheat in Flash CS3
http://tinyurl.com/2cp6na
"Luck is the residue of good design."


Reply With Quote


  #7 (permalink)  
Old 08-27-2008, 04:06 PM
necie
 
Posts: n/a
Diggs:
Default Re: CuePoint help

First of all please allow me to say thanks for helping me out. I've switched
the code using your suggestions but am getting errors on the ns.pause(true);
and the ns.pause(flase); methods. Here is what I have:

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 {};
listener.onCuePoint = function(evt:Object):void {
ns.pause(true);
};
ns.client = listener;

ns.play("CPVideo.flv");


stage.addEventListener(KeyboardEvent.KEY_DOWN, playVideo);

function playVideo(event:KeyboardEvent):void
{
trace(event.keyCode);//i'm using this to see if I can get the number for the
Right arrow key, not sure where to put that info yet but will deal with that
later//
ns.pause(false);
}

Reply With Quote
  #8 (permalink)  
Old 08-27-2008, 04:14 PM
David Stiller
 
Posts: n/a
Diggs:
Default Re: CuePoint help

necie,

> First of all please allow me to say thanks for helping me out.


Sure thing.

> I've switched the code using your suggestions but am getting
> errors on the ns.pause(true); and the ns.pause(flase); methods.


I see why, too -- and I should have taken better care with my previous
reply! When you mentioned, in a previous post, you thought you were in the
Actionscript 1 & 2 forum, I got it stuck in my head that you were using AS2,
so my code suggestion was for the AS2 version of the NetStream class.

The fact that your stage reference is lowercase (AS3), and that your
keystroke event handlers use the KeyboardEvent class (AS3), should have
reminded me that you're actually using ActionScript 3.0.

So ... the Boolean parameter no longer applies. For AS3, use pause() --
no true/false parameter -- to pause your NetStream instance. Use
resume() -- again, no parameter -- to resume it.


David Stiller
Co-author, ActionScript 3.0: The Quick Answer Guide for Flash Professionals
http://tinyurl.com/2s28a5
"Luck is the residue of good design."


Reply With Quote
  #9 (permalink)  
Old 08-27-2008, 06:43 PM
necie
 
Posts: n/a
Diggs:
Default Re: CuePoint help

That worked just fine. Finally have a working video with cue point and keyboard
control. Kinda feel like Tom Hanks in Cast Away after he makes fire. Thanks so
much for your help. And thanks for explaining the details so well.

Perhaps one more question. I used the trace(event.keyCode); so that when I hit
a key I could tell what number to use in the code. But where, and with what
special syntax might I put these numbers. The space bar (39) will ns.pause();
at any time, while the cue points are predetermined pauses. The right arrow
(32) will ns.resume(); the video. this is where I thought it would go, but it's
not working:

stage.addEventListener(KeyboardEvent.KEY_DOWN, <32>, playVideo);

Am I on the right track?


Reply With Quote


  #10 (permalink)  
Old 08-27-2008, 07:17 PM
David Stiller
 
Posts: n/a
Diggs:
Default Re: CuePoint help

necie,

> Kinda feel like Tom Hanks in Cast Away after he makes
> fire. Thanks so much for your help.


Ha, that's a great image! Sometimes I feel like he did when he had to
knock out his tooth with the ice skates.

> I used the trace(event.keyCode); so that when I hit a key
> I could tell what number to use in the code. But where, and
> with what special syntax might I put these numbers.


You'll do that inside the event handler (your playVideo() function), and
when you see how, it'll make perfect sense.

> stage.addEventListener(KeyboardEvent.KEY_DOWN, <32>, playVideo);
>
> Am I on the right track?


Wrong track. But check it out:

function playVideo(event:KeyboardEvent):void {
if (event.keyCode == 32) {
// do the space bar thing
}
if (event.keyCode == whatever) {
// do the whatever thing
}
}

As an alternative to using a series of if() statements, you could use a
switch() statement:

function playVideo(event:KeyboardEvent):void {
switch (event.keyCode == 32) {
case 32:
// do the space bar thing
break;
case whatever:
// do the whatever thing
break;
case whatever2:
// do the whatever2 thing
break;
}


David Stiller
Co-author, ActionScript 3.0: The Quick Answer Guide for Flash Professionals
http://tinyurl.com/2s28a5
"Luck is the residue of good design."


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 05:13 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk