Video class in Actionscript 3
February 10th, 2009
Hi again for all, well think you creating a simple video player in max one minute. ”Yes, We Can”. Using the videoPlayer class from asDataLibs. The videoPlayer is a simple way to make your video player or video gallery using less time than the normal process. Bellow some features:
• Support HD (h.264)
• Play and Pause button together;
• Mute button;
• Seek bar and loaded bar;
• Time played and total time of video.
In final of this post you will see the link to download the sample video player and the source code demonstrated in this article. See the sample of video Bellow.
video by Flasher Magazine
Create the video is so simple like show these actionscript line ahead:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | package { import flash.display.MovieClip; import flash.events.MouseEvent; import com.dLibs.video.videoPlayer; public class main extends MovieClip { private var videoObject:videoPlayer; private var videoURL:String = "http://adobe.edgeboss.net/download/adobe/adobetv/flasher_magazine/issue_1/issue1.mp4"; private var videoWidth:uint = 700; private var videoHeight:uint = 400; private var videoStart:Boolean = false; public function main():void { videoObject = new videoPlayer(videoURL,700,400,false); videoObject.addBuffer = newBuffer; videoObject.addPlayPause = playPause; videoObject.addMuteSound = muteIcon; videoObject.addDuration = seekControll.theTime; videoObject.addSeek = {progress:seekControll.seekProgress, loader:seekControll.seekLoader}; newVideo.addChild(videoObject); // @ Change status of playPause Button playPause.addEventListener(MouseEvent.CLICK, changePlayPause); } private function changePlayPause(m:MouseEvent):void { if ( m.currentTarget.currentFrame == 1 ) { m.currentTarget.nextFrame(); } else { m.currentTarget.prevFrame(); } } } } |
In resume the videoPlayer object receive three variables:
• URL of video, width and height of video.
By default this video will play when buffer is full, but can change it sending ‘false’ withe the fourth variable that is if the video will start or not on load buffer complete. Other optional variable is buffer time. The complete object is:
new videoPlayer(videoURL:String,videoWidth:uint, videoHeight:uint, videoStart:Boolean = true, videoBuffer:uint = 10)
Now you can put the playpause button, mute button and seek too:
19 20 21 22 23 | videoObject.addBuffer = newBuffer; videoObject.addPlayPause = playPause; videoObject.addMuteSound = muteIcon; videoObject.addDuration = seekControll.theTime; videoObject.addSeek = {progress:seekControll.seekProgress, loader:seekControll.seekLoader}; |
After that you need add this object in your stage and now see your video into Flash using Actionscript 3 easy.





July 9th, 2009 at 23:43
I also made an as3 video class, but yous class looks cleaner..
check out:
http://www.blog.diogolean.com/
October 13th, 2009 at 07:03
Can you resize the video object once it has been created and while it is playing?
I havent been able to find the attribute to set
width does not work.
October 13th, 2009 at 09:29
If you download the repository will se a new class path: novesfora. Inside novesfora have other folder ‘video’ and have two classes, the base classe is VideoPlayer.as and with this you can resize your video, width or height, all the time.
Create your videoPlayer object and set the config data
var video:VideoPlayer = new VideoPlayer();
video.config(width,height);
Its easy. Tryit
June 2nd, 2010 at 23:25
Oh yea, what a great evil plan to get followers. And I like it
June 4th, 2010 at 15:40
Worst. Teaser. Evar.
January 28th, 2011 at 16:38
Im glad I located this web page, I couldnt obtain any knowledge on this matter prior to. Also manage a website and for anyone who is ever interested in a little bit of visitor writing for me please feel free to let me know, i’m always look for people to check out my web site. Please stop by and leave a comment sometime!