Posted by robert | Filed under ActionScript 3
Recently I’ve been working on building a AS3 streaming video player and ran into an error with onBWDone and wanted to share my findings. I am streaming (RTMP) my video files from Amazon CloudFront which uses Adobe’s Flash Media Server to power its streaming distributions.
You may have seen this error before:
Error #1069: Property onBWDone not found on flash.net.NetConnection and there is no default value.
I will describe three different ways you can fix the onBWDone issue. First one is a fast fix:
_netConnection.client = { onBWDone: function():void{ trace("onBWDone") } };
The second version is to create a public function within the same class and make the NetCennection client equal this. Make sure the function is public! Below is the code:
_netConnection.client = this; public function onBWDone(...rest):void { var p_bw:Number; if (rest.length > 0){ p_bw = rest[0]; } trace("bandwidth = " + p_bw + " Kbps."); }
The server calls the onBWDone() function when it finishes measuring the bandwidth. It takes four arguments. The first argument it returns is the bandwidth measured in Kbps. The second and third arguments are not used. The fourth argument is the latency in milliseconds.
The third code example I will show involves creating a custom class which I called NetConnectionClient. I placed the public function onBWDone and also the onBWCheck function in the class.
The onBWCheck() function is required by native bandwidth detection. It takes an argument, …rest. The function must return a value, even if the value is 0, to indicate to the server that the client has received the data. You can call onBWCheck() multiple times.
_netConnection.client = new NetConnectionClient();
Below is our custom client class
package { public class NetConnectionClient { public function NetConnectionClient() { } public function onBWCheck(...rest):Number { return 0; } public function onBWDone(...rest):void { var p_bw:Number; if (rest.length > 0){ p_bw = rest[0]; } trace("bandwidth = " + p_bw + " Kbps."); } } }
If there is interest from viewers, I will show code examples of my finished streaming AS3 video player. Last thing is if you wanted to call your onBWDone to get the client side bandwidth you can use the following code in your application.
_netConnection.call("checkBandwidth", null);
Let me know if this post has helped anyone
Comments (4) |
October 13th, 2010
Leave a Reply
06-01-2011, 10:29 AM
#1
Junior Member
ReferenceError: Error #1069: Property 3 not found on flash.utils.Timer and there is n
Hi everyone, I’m building a page that uses an array to deploy a series of timers that do a variety of things. The problem is at any point the user needs to be able to navigate away from the page and when they do they get a timer tick error. To stop this, I have been trying to write a function that stops all the timers which I can do when I write all the timers out the long way, but I’m failing when trying to stop the timers created with the array. I’m getting the following error:
ReferenceError: Error #1069: Property 3 not found on flash.utils.Timer and there is no default value.
Here is the code:
Code:
var timerRepeats:Number = 1; var currentTimerLength:Array = [1500, 4500, 500, 1500, 1500]; var i:Number = 0; var timerCount:Number = 0; var totalTimers:Number = 3; for (i = 0; i<totalTimers; i++){ var newTimer:Timer = new Timer(currentTimerLength[i], timerRepeats); newTimer.addEventListener(TimerEvent.TIMER, timerHandler); newTimer.start(); } function timerHandler(e:TimerEvent):void{ timerCount ++; trace(timerCount); if(timerCount <= 3){ trace('a timer completed'); } if (timerCount > 3){ trace('too many timers!!!'); } } stopTimerBtn.addEventListener(MouseEvent.CLICK, stopTimers); function stopTimers(e:MouseEvent):void{ newTimer[i].reset(); }I assume that this relates to my attempt to use the variable i to identify each of the various timers and stop them (apparently flash is not actually creating an instance name for each of the timers like it would for a movieclip). But I’ve tried a few different ways and I’m getting nowhere. Any ideas?
I have same reference error #, but with different file:
http://www-cs-students.stanford.edu/~amitp/_test/
spaceship-world.swf 09-Oct-2012 15:16 108K
guest@slax:/dev/shm/lightspark/x86_64/Release/bin$ LANG=C ./lightspark spaceship-world.swf
INFO: Lightspark version 0.8.1-198-gff8878a6 Copyright 2009-2013 Alessandro Pignotti and others
nv50_screen_get_param: unhandled cap 44
nv50_screen_get_param: unhandled cap 44
nv50_screen_get_param: unhandled cap 44
nv50_screen_get_param: unhandled cap 44
nv50_screen_get_param: unhandled cap 44
nv50_screen_get_param: unhandled cap 44
INFO: RenderThread this=0x8f25a08
INFO: Creating input thread
INFO: Running in local-with-filesystem sandbox
INFO: zlib compressed SWF file: Version 13
INFO: FrameRate 60
INFO: Creating VM
nv50_screen_get_param: unhandled cap 44
nv50_screen_get_param: unhandled cap 44
INFO: Fragment shader compilation
INFO: Vertex shader compilation
INFO: throwing exception:1069 Property loadCompressedDataFromByteArray not found on flash.media::Sound and there is no default value.
at Class/init()
at Class/main()
at boot_8ebf/init()
at boot_8ebf/start()
at boot_8ebf/()
ERROR: Unhandled ActionScript exception in VM ReferenceError: Error #1069: Property loadCompressedDataFromByteArray not found on flash.media::Sound and there is no default value.
INFO: dynamic cast:ReferenceError
ERROR: Unhandled ActionScript exception in VM ReferenceError: Error #1069: Property loadCompressedDataFromByteArray not found on flash.media::Sound and there is no default value.
at Class/init()
at Class/main()
at boot_8ebf/init()
at boot_8ebf/start()
at boot_8ebf/()
INFO: ~RenderThread this=0x8f25a08
So i have been stuck on this for about 2 weeks and i have no idea how to progress.
I have an array of movie clips called «_main.speederArray» and i’m trying to make it so that if they collide with each other then they are both destroyed. Here is my code in the «Speeder class» to detect collision.
private function detectionHandler():void{
//trace("array length", _main.speederArray.length);
detectionID = _main.gameCounter;
for ( var i:int = _main.speederArray.length -1; i >= 0; i--){
var speeder:Speeder = _main.speederArray[i];
if(speeder.destroyMe) continue;
if(speeder.detectionID == this.detectionID) continue;
if (boxIntersect(this, speeder)){
trace("collision");
destroyMe = true;
speeder.destroyMe = true;
}
}
}
Here is the boxIntersect function this code refers to. It’s in the same class
private function boxIntersect ( speeder1:Speeder, speeder2:Speeder):Boolean{
if(speeder1.x + speeder1.distRight < speeder2.x + speeder2.distLeft) return false; //checking for overlap on X axis
if(speeder1.x + speeder1.distLeft > speeder2.x + speeder2.distRight) return false;
if(speeder1.y + speeder1.distBot < speeder2.y + speeder2.distTop) return false; // checking for overlap on Y axis
if(speeder1.y + speeder1.distTop > speeder2.y + speeder2.distBot) return false;
return true;
}
And then here is where i think the problem is. I have a class called «spawner» and this is where i was going to handle the objects being created and destroyed. Here is the code where i am trying to splice objects from the array depending on whether the destroyMe bool is set to true. At this stage i have confused the shit out of myself so any help would be greatly appreciated!
private function updateArray(e:Event):void{
for(var i:int = _main.speederArray.length - 1; i>=0; i--){
var speeder:Speeder = _main.speederArray[i];
if(speeder.destroyMe){
//trace("hello");
removeChild(speeder[i]); // take it off the stage
_main.speederArray[i] = null;
_main.speederArray.splice(i, 1); //remove it from the array
}
}
}
Now, the game runs however as soon as the 2 objects within the same array collide, i get the collision trace in the output window but straight after i get this :
ReferenceError: Error #1069: Property 1 not found on com.game.Speeder and there is no default value.
at com.game::Spawner/updateArray()
No idea what it means
Any help appreciated thanks guys!