?
Solved

Advanced Flash ActionScript 2.0 Load video/audio control question.

Posted on 2007-09-27
16
Medium Priority
?
1,253 Views
Last Modified: 2008-01-24
I am loading two external Flash SWF files into my present Flash movie. The first one that loads is a music player. The second movie I am loading upon the click of a button and it is a external SWF that contains a
Flash video.

Right now I am simply loading the video SWF movie into the same layer as the music player so that it will stop the playback of the music so the viewer can see the video AND hear it's audio.

Unfortunately when the video ends it just sits there on the last frame.

I would like to have suggestions as how to:
       a.) Unload the SWF Flash video that has just completed playback and..
       b.) resume the playback of the audio that was last playing.

I am loading the Flash SWF music with the following:
-------------------------------------------
on(release) {
      
            loadMovieNum("/motion/flash/music/music2.swf",1);
            _root.soundstatus="on";
            _parent.equalizer.gotoAndStop(1);
            _parent.gotoAndStop(1);
}
------------------------------------------
I am loading the external SWF Flash video with:
------------------------------------------
on(release) {
      
            loadMovieNum("/motion/flash/video/kirklandPSA.swf",1);
            _root.soundstatus="on";
            _root.equalizer.gotoAndStop(1);
            _parent.gotoAndStop(1);
            
      
}
-----------------------------------------------

Suggestions and help appreciated.

Thanks in advance,

Rip
0
Comment
Question by:ripnoel
  • 9
  • 7
16 Comments
 
LVL 23

Expert Comment

by:Zeffer
ID: 19976408
on last frame of the video swf..
stop();
unloadMovieNum(1);

Z
0
 

Author Comment

by:ripnoel
ID: 19977940
No this just unloads the video as soon as the frame has been hit. I think we need to listen for some sort of movie complete event.

Rip
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 19981441
yes it unloads the video..but it's at the end why do you need a movie complete listener?
If you want the music player to kick back in you will need to leave it in the player..at the moment it is being replaced by the video on layer 1
if you loaded the music to layer1 and the video to layer2..you could stop the music player..
_level1.stop();
_level.._visible = false;
load and play the video as you are now
and on the last frame
stop();
unloadMovieNum(2);
_level1._visible = true;
_level1.play();

Z
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ripnoel
ID: 19982672
I don't want to make the length of my timelines as long as the flash videos I am loading into them AND in some cases with long videos this is not possible because of the timeline length limitation in Flash.

That is why I need  a listener. I am real new to working with FLV files. Your help and suggestions are appreciated.

Can you share some code that will listen for the Flash Video to stop or end. I'm using the flash video component to playback the external FLV file.

Thanks again for this help!

Rip
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 19982881
I presume you are using the standard method of loading an flv..there are a several of ways to detect the ending..here's a couple

myNetconnection = new NetConnection();
myNetconnection.connect(null);
myStream = new NetStream(myNetconnection);
myStream.setBufferTime(10);
my_video.attachVideo(myStream);
myStream.play(someflv.flv);
//..............
myStream.onStatus = function(info) {
      if (info.code == "NetStream.Play.Stop") {
            //your code here
        }
}

or

var myListener = new Object();
myListener.complete = function(eventObject){
         //your code here
};
muStream.addEventListener("complete", myListener);

Z


 
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 19982885
sorry typo..
muStream.addEventListener("complete", myListener);
should be
myStream.addEventListener("complete", myListener);

Z

0
 

Author Comment

by:ripnoel
ID: 19983788
Hi Z,

As I mentioned in my last post I am loading my Flash videos using the built in flash video component (in CS3) so... what code should I use in this case to code a listener to unload the video once it has played (I am using Actionscript 2.0).

Thanks,

Rip
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 19985250
there are two methods in my last post from the dotted line down
the second one is a listener

var myListener = new Object();
myListener.complete = function(eventObject){
         unloadMovieNum(1);    
};
myStream.addEventListener("complete", myListener);

again.. put it on frame 1 of kirklandPSA.swf
when the video has completed the function will fire.

Z
Z
0
 

Author Comment

by:ripnoel
ID: 19987832
Tried this on my actionscript layer over the first frame of the Flash video and it did not do anything:
---------------------------------------------
var myListener = new Object();
myListener.complete = function(eventObject){
         unloadMovieNum(1);    
};
myStream.addEventListener("complete", myListener);
-----------------------------------------------
I next tried clicking the object and adding the code there and nothing there either...

Why is this not working?

Rip
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 19987878
try it in an onEnterFrame function

this.onEnterFrame = function(){
var myListener = new Object();
myListener.complete = function(eventObject){
         unloadMovieNum(1);
     }  
};
myStream.addEventListener("complete", myListener);

Z
0
 

Author Comment

by:ripnoel
ID: 19988060
nope... just sits on last frame when completed...
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 19988216
where have you put the code?
and are you putting the name of your player where it says (eventObject)?
try it on the last frame where it sits stopped

Z
0
 

Author Comment

by:ripnoel
ID: 19988416
I put this actionscript on a blank keyframe in my "actions" layer:
-------------------------------------
this.onEnterFrame = function(){
var myListener = new Object();
myListener.complete = function(mainVideo){
         unloadMovieNum(1);
     }  
};
myStream.addEventListener("complete", myListener);
----------------------------------
my video component is named (mainVideo) I double checked it.

0
 
LVL 23

Expert Comment

by:Zeffer
ID: 19988500
show me your complete loading code for the video
and I assume this is on frame 1 of kirklandpsa.swf ..is it?

Z

0
 

Author Comment

by:ripnoel
ID: 19988539
I don't have any loading code.... as I told you in an earlier post I am using the Flash CS3 built it component for FLVPlayBack. I have named the instance mainVideo.
0
 
LVL 23

Accepted Solution

by:
Zeffer earned 1500 total points
ID: 19993503
did you choose "actionscript controlled" when you created the video component from the drop-down menu  in the library?
I suspect you didn't as you would have some code like the code I wrote above for creating the NetStream connection.
Z



0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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 last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
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.
Suggested Courses

809 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