Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Video coding...

Community Beginner ,
Sep 09, 2009 Sep 09, 2009

Hello everyone. I have some questions about video and AS3. I am coding in some video and need it to loop. I am new to this so my set up may be wrong. Feel free to give suggestions on fixes. Right now I have an FLVPlayback component on the first frame of a movie clip. In my main time line I call up the movie clip:

var AL_mc:AL = new AL();

addChild(AL_mc);

There are 2 things I would like to know about this. First, how can I make this loop. I figured I could extend the timeline of the movie clip containing the FLVPlayback to the length of the video, but its a long video and I would rather code it so it is exact. I tried just making the movie clip 2 frames and this sort of worked, but the video got very choppy on the second time around. Second, I need to remove the video on an event. In AS3, how do I completely remove the movie clip until I call it again?

Thanks!

TOPICS
ActionScript
5.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 13, 2009 Sep 13, 2009

The following code works perfectly for me. I commented out mm_clear() an width/height settings - they move video outside the stage when width and height are as in your code.I think you need to play with other parameters like registrationX, scaleMode, etc.

Read about it here:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlayback.html

Naturally, I used different video.

import fl.video.*;
import flash.events.*;

var myVideo:FLVPlayback = new FLVPlayback();

myVideo.source = "mTOR Attract Loop_ESMO_0.1.f4v";

addChild(myVideo);
myVideo.y = 0;
myVideo.x = 0;

//myVideo.width = 1080;
//myVideo.height = 1920;
//mm_clear();

stage.addEventListener(MouseEvent.MOUSE_DOWN, ALbtnClicked);

function ALbtnClicked(event:MouseEvent):void{
     if(MovieClip(root).contains(myVideo)) {
          myVideo.stop();
          removeChild(myVideo);
     }
     stage.removeEventListener(MouseEvent.MOUSE_DOWN, ALbtnClicked);
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 13, 2009 Sep 13, 2009

The problem is that doesn't work in fullscreen mode, which is what the original question is about.

In fullscreen mode, somehow the video is reparented (I guess) and is no longer a child of the main timeline, which is why you get an error when trying to remove it.

I have no idea what the exact parent of the video is when in fullscreen mode and don't think it's documented either (allthough I haven't really looked it up).

If you can't find the video's parent, best bet is probably to exit fullscreen mode, remove the video and then jump back to fullscreen mode.

Something like this:


function ALbtnClicked(event:MouseEvent):void {
stage.displayState = StageDisplayState.NORMAL;
myVideo.stop();
removeChild(myVideo);
stage.displayState = StageDisplayState.FULL_SCREEN;
stage.removeEventListener(MouseEvent.MOUSE_DOWN, ALbtnClicked);
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 13, 2009 Sep 13, 2009

Flash will not go to fullscreen mode without explicit click.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 13, 2009 Sep 13, 2009

Well, he's removing the video in response to a mouse event..

You sure you actually read the question?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 13, 2009 Sep 13, 2009

I am sure I understand what he is trying to do.

My comment to you was that your suggestion will not work because in your code it does go to normal screen on click but it will not go back full screen because there is another click needed for that.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 13, 2009 Sep 13, 2009

Why don't you try it first

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 13, 2009 Sep 13, 2009

Maybe because I read documentation and thus don't need to try what doesn't work. Why don't you give documentation a chance? 🙂

http://www.adobe.com/devnet/flashplayer/articles/full_screen_mode.html

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 13, 2009 Sep 13, 2009

Muzak - Thanks for the suggestion. I tested it and it does indeed seem to work. The only issues is that I am worried the transition from Full Screen to not full screen may not look clean enough. I am going to do some further testing to see how it functions on the actual monitor set up.

Andrei - I tried that last code you posted and it still doesnt seem to work. The video comes up and plays fine, but nothing happens when I click, full screen or not.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 13, 2009 Sep 13, 2009
Maybe because I read documentation and thus don't need to try what doesn't work. Why don't you give documentation a chance? 🙂

No need for that, I know them by heart by now..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 13, 2009 Sep 13, 2009

I am having second thoughts about it. Since the normal screen and full screen are invoked within the same method that, in turn, is invoked by mouse click - your suggestion actually may work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 13, 2009 Sep 13, 2009

It does work. The issue is that it may not be very elegant. The program is portrait and my current setup is landscape so I need to test it further to know how it will actually look. 

Also, say I wanted that video to loop. What is the best way to make that happen?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 13, 2009 Sep 13, 2009
It does work. The issue is that it may not be very elegant. The program is portrait and my current setup is landscape so I need to test it further to know how it will actually look. 

On my PC I don't really notice the jump from fullscreen to normal and back to fullscreen. Unless someone knows how to reach the video while in fullscreen mode, you're stuck with this solution.

Also, say I wanted that video to loop. What is the best way to make that happen?

Listen for the complete event on the FLVPlayback and start the video again.

http://help.adobe.com/en_US/AS3LCR/Flash_10.0/fl/video/FLVPlayback.html#event:complete

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 13, 2009 Sep 13, 2009

And here's a more elegant solution

Add the video to the stage, rather than the main timeline.

When you add it to the main timeline and jump to fullscreen, the video is reparented to the stage, so you miight as well add it to the stage right away. You can then remove it as you like.

var myVideo:FLVPlayback = new FLVPlayback();
myVideo.source = "your-video";
stage.addChild(myVideo);

stage.addEventListener(MouseEvent.MOUSE_DOWN, ALbtnClicked);

function ALbtnClicked(event:MouseEvent):void {
myVideo.stop();
stage.removeChild(myVideo);
stage.removeEventListener(MouseEvent.MOUSE_DOWN, ALbtnClicked);
}

Sorry for all the posts.. should have thought of this sooner..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 14, 2009 Sep 14, 2009
LATEST

This is the code I am using now and it is working great! Thank you both for your help!

import fl.video.*;

import flash.events.*;

var myVideo:FLVPlayback = new FLVPlayback();

myVideo.source = "mTOR Attract Loop_ESMO_0.1.f4v";

stage.addChild(myVideo);

stage.addEventListener(MouseEvent.MOUSE_DOWN, ALbtnClicked);

mm_clear();

myVideo.autoRewind = true;

myVideo.addEventListener( VideoEvent.AUTO_REWOUND, videoPlayAgain, false, 0, true );

function videoPlayAgain( event:VideoEvent ):void

{

event.target.play();

}

function ALbtnClicked(event:MouseEvent):void {

myVideo.stop();

stage.removeChild(myVideo);

stage.removeEventListener(MouseEvent.MOUSE_DOWN, ALbtnClicked);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines