this small bit of code creates 100% CPU load

looping video code breaks simple video reel demo

Page 1 of 1

1 Replies - 1367 Views - Last Post: 12 July 2007 - 04:59 PM

#1 apslavin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-July 07

this small bit of code creates 100% CPU load

Posted 12 July 2007 - 01:37 AM

hi, and thanks in advance for any help available. the usual caveats apply: new to actionscript coding, just figuring it out by brute force. etc.

my application is a fairly simple and straightforward graphics reel demo -- the SWF has three frames, a few text buttons, two linked FLV videos, one short audio loop.

now i've added a small bit of code -- to use a video loop on frame 1 loader page instead of a still image -- and this reliably sends CPU use to 100% (tested on several browsers, several machines, locally and online). this effectively breaks the playback of the progressive downloading FLVs. even though download stays ahead of playback, the video stutters and jumps (i presume because of high CPU use).

CPU load for the EXACT same SWF, without the looping video code, is between 35 - 40%.

my two FLVs are fairly large and heavy (512 x 340, 15fps, 700kbps, 15 - 25MB), but they play beautifully without this code. the video loop i've added is only 5 seconds, so it can't be the overhead of this particular piece.

i have a few other questions, but i'd like to cross this hurdle first. even though i'm new to FLASH, i can't believe that adding a simple bit of code to add and remove a video loop can scotch the whole deal. maybe i'm just doing it improperly? i'm using "removeChild" to get the video loop off the stage before navigating to other frames/FLVs.

i'd be very grateful for any advice out there on this problem.

frame 1 code below. looping video code that kills playback is commented out. all other code still in play.

thanks again in advance.

======================================================
gotoAndStop(1);

import flash.events.MouseEvent;
import flash.events.IEventDispatcher;
import fl.video.*;
import flash.media.Sound
import flash.media.Video


var loop:Sound = new loopcopy ();
var volume:SoundTransform = new SoundTransform(0.4, 0);

loop.play(0,500,volume)

/*
var videoloop = new FLVPlayback();
videoloop.width = 512;
videoloop.height = 340;
videoloop.x = 188.9;
videoloop.y = 114.7;
addChild(videoloop);
videoloop.source = "hypnosloop.flv";


function completeHandler(event:VideoEvent):void
{
   videoloop.seek(0);
   videoloop.play()
}
videoloop.addEventListener(VideoEvent.COMPLETE, completeHandler);
*/


playPart1.addEventListener(MouseEvent.MOUSE_DOWN,goPage2);
playPart2.addEventListener(MouseEvent.MOUSE_DOWN,goPage3);

function goPage2(e:MouseEvent):void {
	 SoundMixer.stopAll()
//	 removeChild(videoloop);
	 gotoAndStop (2);
	 }
function goPage3(e:MouseEvent):void {
	 SoundMixer.stopAll()
//	 removeChild(videoloop);
	 gotoAndStop (3);
	 }




Is This A Good Question/Topic? 0
  • +

Replies To: this small bit of code creates 100% CPU load

#2 DilutedImage  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 14
  • View blog
  • Posts: 646
  • Joined: 20-November 06

Re: this small bit of code creates 100% CPU load

Posted 12 July 2007 - 04:59 PM

The loop portion of your code (commented out) works fine on my system. Got a file we can look at?

I'm curious as to why you're starting your frame with a gotoAndStop. ??

Also, you should add/remove some semi-colons. They're not required in AS3, but you should still be consistent with your use/lack of them.

2
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1