Share Posted September 24, 2012 // create video loader var video:VideoLoader = new VideoLoader(VIDpath, { name: "video", container: this, alpha: 0, bgColor: backgroundsColor, width: vW, height: vH, scaleMode: "proportionalInside", centerRegistration: true, alternateURL: videoURL, onComplete: initVideo, onError: errorCatch, onProgress: updateDownloadProgress }); For example i got code like this, and i want the black background to be seen and be 'ready' before i call video.load(); to actually load video...(coz i simply don't want to unnecessary load whole video into ram, before it actually used, but i want background to be seen) Or it woulb be cool if there are any way to preload just small portion of video, like first frame only, without loading whole video, so you would get black background + preview for the first frame, is it possible, and if it is - how to do it? Link to comment Share on other sites More sharing options...
Share Posted September 25, 2012 The reason you are not seeing the bgColor is because you have alpha set to 0 in the constructor. I am not exactly sure what the best method is for loading enough of the video just to grab the first frame. A solution may arise. Stay tuned. -c 1 Link to comment Share on other sites More sharing options...
Share Posted September 25, 2012 Due to the way Flash's NetStream works, there isn't a simple solution for only loading a portion of the video to get the first frame and then pausing the download. You could, however, wait for a BUFFER_FULL event and then create a BitmapData yourself, draw() the VideoLoader's content into a Bitmap, and then cancel() the VideoLoader after placing that Bitmap where the content was on the stage (like swapping it in). Visually you'd get the effect you're after. Cumbersome, yes. I wish I had a simple solution for you. 1 Link to comment Share on other sites More sharing options...
Author Share Posted September 26, 2012 carl schooff haha, i've just noticed that i forgot about some sneaky tween addresing for content, not for rawContent, that's why i have problems with background remained unseen GreenSock Hell, that's indeed sounds pretty hard and not so stable... I'm also not sure how to actually implement this with BUFFER_FULL, can you give me any short example? P.S. Do you guys know a cool and fast a way to draw a few pixel border around container, or make a glow (or shadow effect), that wouldn't change it's own color, when alpha or color of container have been changed? I was trying to use glow, but if alpha of container is not 1, than glow apply it's own color to the background...which is totally not cool Link to comment Share on other sites More sharing options...
Share Posted September 26, 2012 for any of the effects you are looking to accomplish (glow, stroke) you can create a container Sprite for your loader's content. This container Sprite would then hold -item 1: some background shape or stroke that you dynamically create based on the width and height of the loader's content -item 2: the loader's content For item 1 you could use the drawing API to draw a rectangle and optionally stroke it, or you could just use a pre-exisiting movie clip from your library that you resize to be 1 or 2 pixels wider or taller than the content of the loader. You could then apply a glow filter to item 1 without effecting the color of item 2. do some google searches for "add border or stroke to movieclip as3" or similar. Something like this should get you on the right path with some slight adjustments: http://www.parorrey.com/blog/flash-development/as3-dynamically-create-border-around-movieclips-in-flash-using-actionscript/ Link to comment Share on other sites More sharing options...
Share Posted September 26, 2012 Basic example: yourVideoLoader.addEventListener(VideoLoader.VIDEO_BUFFER_FULL, swapBitmap); function swapBitmap(event:LoaderEvent):void { var bd:BitmapData = new BitmapData(yourVideoLoader.content.width, yourVideoLoader.content.height, false, 0x000000); bd.draw(yourVideoLoader.content); var bitmap:Bitmap = new Bitmap(bd); bitmap.transform.matrix = yourVideoLoader.content.transform.matrix; yourVideoLoader.content.parent.addChildAt(bitmap, yourVideoLoader.content.parent.getChildIndex(yourVideoLoader.content)); yourVideoLoader.content.parent.removeChild(yourVideoLoader.content); yourVideoLoader.cancel(); } 2 Link to comment Share on other sites More sharing options...
Author Share Posted September 26, 2012 GreenSock hmm...this gives me Scene 1, Layer 'actions', Frame 1, Line 303 1046: Type was not found or was not a compile-time constant: BitampData.Scene 1, Layer 'actions', Frame 1, Line 305 1046: Type was not found or was not a compile-time constant: Bitamp. Ideas? ' carl schooff yeah, i already have made something similar to this example, but problem is that i have dynamic resize, so i have to .clear and .drawRect with all of those calculations...pretty much intensive process. But seem that there are no options, and i'm very disappointed that in flash it is impossible to have alpha < 1 rectangle with glow / shadow instead border, it woule make our life sooo much easier! Link to comment Share on other sites More sharing options...
Share Posted September 26, 2012 It should be BitmapData (not BitampData) and Bitmap (not Bitamp). 1 Link to comment Share on other sites More sharing options...
Author Share Posted September 26, 2012 haha, haven't noticed, sorry Well, it works...But whole thing seem to be kind of pointless, coz with my test HD video which is 239 mb size, memory load reports exactly same, so it still loads whole video... Or could i miss something else? Well, anyway it's interesting to know, thx Link to comment Share on other sites More sharing options...
Share Posted September 26, 2012 Did you try calling unload() on the VideoLoader instead of cancel()? Link to comment Share on other sites More sharing options...
Author Share Posted September 27, 2012 // create video loader var video:VideoLoader = new VideoLoader(VIDpath, { name: "video", container: this, alpha: 0, bgColor: backgroundsColor, width: vW, height: vH, centerRegistration: true, scaleMode: "proportionalInside", alternateURL: videoURL, onComplete: initVideo, onError: errorCatch, onProgress: updateDownloadProgress }); video.load(); video.addEventListener(VideoLoader.VIDEO_BUFFER_FULL, swapBitmap); function swapBitmap(event:LoaderEvent):void { var bd:BitmapData = new BitmapData(video.content.width, video.content.height, false, 0x000000); bd.draw(video.content); var bitmap:Bitmap = new Bitmap(bd); bitmap.transform.matrix = video.content.transform.matrix; video.content.parent.addChildAt(bitmap, video.content.parent.getChildIndex(video.content)); video.content.parent.removeChild(video.content); video.unload(); // reset video playing flag videoPlaying = false; // pause video video.pauseVideo(); // switch play / pause visibility videoControls.btnPause.visible = false; videoControls.btnPlay.visible = true; } Nope, but now i had, so it gives same result ~204mb, which doesn't seem like unloading Link to comment Share on other sites More sharing options...
Share Posted September 27, 2012 Are you expecting the Flash Player to immediately perform a garbage collection routine? That's not typically how it works - sometimes it takes a little while for memory to be cleared. Unfortunately we have almost no control over the gc collection routines of the player. Link to comment Share on other sites More sharing options...
Author Share Posted September 27, 2012 I have waiting for more than a minute, well, there is nothing perfect i know, worth trying though )) But the whole concept will be huge overload if there is like more than 2 players on one page...So i guess i have to drop the idea. Link to comment Share on other sites More sharing options...
Share Posted September 27, 2012 Yes, it may take well over a minute. Sometimes MANY minutes. Sorry, I wish there was more we could to to help. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now