Jump to content
Search Community

nchung

Members
  • Posts

    7
  • Joined

  • Last visited

nchung's Achievements

0

Reputation

  1. I have a simple setup of a videoloader. All seems to be working well except for my seekbar (movieclip instance: scrubber, and the seekbar = scrubber.slider): package { import flash.display.MovieClip; import com.greensock.loading.*; import com.greensock.loading.display.*; import com.greensock.*; import com.greensock.events.LoaderEvent; import flash.events.MouseEvent; import flash.events.Event; import flash.geom.Rectangle; public class VideoPlayer extends MovieClip { public var scrubber:MovieClip = new MovieClip ;// the seekbar public var playPause:MovieClip = new MovieClip ; // check whether you are displaying the time or changing the time private var seeking:Boolean = false; private var video:VideoLoader; public function VideoPlayer ():void { init (); } public function init ():void { //create a VideoLoader video = new VideoLoader("song.flv",{name:"myVideo",container:this,width:400,height:300,scaleMode:"proportionalInside",bgColor:0x000000,autoPlay:false,volume:1,requireWithRoot:this.root}); //start loading video.load (); //add a CLICK listener to a button that causes the video to toggle its paused state. playPause.addEventListener (MouseEvent.CLICK, togglePause); scrubber.slider.buttonMode = true; scrubber.slider.addEventListener (MouseEvent.MOUSE_DOWN, scrubToTime); stage.addEventListener (MouseEvent.MOUSE_UP, stopScrubToTime); addEventListener (Event.ENTER_FRAME, updateVideoTime, false, 0, true); //scrubber.addEventListener(MouseEvent.CLICK, onSeekToClick, false, 0, true); } private function updateVideoTime (e:Event):void { // moves the seeker and progress together if (! seeking) { scrubber.slider.x = (video.videoTime /video.duration)*scrubber.width; } else { seekToPoint (); trace("seek to point" + scrubber.slider.x); } } private function seekToPoint ():void { var c:Number = (scrubber.slider.x); var value:Number = Math.abs(c / scrubber.width); video.gotoVideoTime (value*video.duration, true); } private function scrubToTime (e:Event):void { // constrain to rectangle scrubber.slider.startDrag (false, new Rectangle(0,0,scrubber.width - scrubber.slider.width, 0)); seeking = true; } private function stopScrubToTime (e:Event):void { scrubber.slider.stopDrag (); seeking = false; } private function togglePause (event:MouseEvent):void { if (video.videoPaused) { video.playVideo(); playPause.gotoAndStop("pause"); } else { video.pauseVideo(); playPause.gotoAndStop("play"); } } private function onSeekToClick(e:MouseEvent):void { var seekPoint:Number = this.mouseX; if (seekPoint < scrubber.x + scrubber.width) { removeEventListener(Event.ENTER_FRAME, updateVideoTime); seeking = true; scrubber.slider.x = seekPoint; seekToPoint(); seeking = false; addEventListener(Event.ENTER_FRAME, updateVideoTime, false, 0, true); } } } } I think there is something I don't understand about VideoLoaders methods...especially in my updateVideoTime function. The seekbar/scrubber seems to scrub around my video fairly well until I reach near the end of the video (either by playing to that point or seeking/scrubbing to that point). When the seekbar reaches the end, it suddenly just slides off screen/stage and never returns. I would like the seekbar to just stop at the end of my bar when the video stops...
  2. Hi I was just wondering if there is a built-in way to have a kind of random, "vibrating" effect using TweenMax. Right now I have something moving in a diagonal line with a nice ease (great!). But is there a way to have it kind of move a bit side-to-size without using the bezier tween?
  3. That helps SO much, thanks! It turned out I had another Tween in another class that wasn't removing items properly. So It was my class structure, but I wouldn't have found it without help...thanks!
  4. I have the following code: var i:uint = this.numChildren; while (i--) { var target:DisplayObject = getChildAt(i); TweenLite.to(target, 2, {alpha: 0, onComplete: removeThis, onCompleteParams: [target]}); } private function removeThis(target:DisplayObject) { removeChild(target); } I get the error message: ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller. However when I write this instead: var i:uint = this.numChildren; while (i--) { removeChild(getChildAt(i)); } My error is gone...but then so is my tween. What am I doing incorrectly?
  5. I am using the following code to fade and remove all the children of an object: var i:uint = this.numChildren; while (i--) { var target:DisplayObject = getChildAt(i); TweenLite.to(target, 2, {alpha: 0, onComplete: removeThis, onCompleteParams: target}); } private function removeThis(target:DisplayObject) { removeChild(target); } Everything fades out, but on the remove, I am getting the following error message, can anyone advise? TypeError: Error #1116: second argument to Function.prototype.apply must be an array. at Function/http://adobe.com/AS3/2006/builtin::apply() at com.greensock.core::TweenCore/complete() at com.greensock::TweenLite/renderTime() at com.greensock.core::SimpleTimeline/renderTime() at com.greensock::TweenLite$/updateAll()
×
×
  • Create New...