Stage3D Error #3694: The object was disposed by an earlier call of dispose() on it - actionscript-3

Using Flare3D, i run into error #3694 when the player (when compiling within flash) is resized, or when i run it in a browserpage and then lock wy (windows) machine and unlock it again.
The error is: "The object was disposed by an earlier call of dispose() on it."
I did some searching and found some suggestions to check on context3D.driverInfo and skip rendering if that string equals 'Disposed', but this doesnt seem to work. In my case, that string is either 'Software (embedded)' (when running in flash ide) or 'DirectX9 (Direct blitting)' when running in a standalone player.
Does anyone know what the error is and how to avoid it?

I had the same problem, googled, found your question... and it helped me figure out the answer :)
You probably have a resize handler that is called when the anything resizes the stage. And it tries to change the size of the stage3D back buffer.
While the stage is being resized the context3D.driverInfo == "Disposed". When you finish resizing it goes back to normal.
So instead of something like this:
context3D.configureBackBuffer(stageW(), stageH(), 0, false);
Try:
public function onResizeStage(event:Event) {
if (stage3D == null) {
return;
}
if (context3D == null) {
return;
}
if (context3D.driverInfo == "Disposed") {
return;
}
context3D.configureBackBuffer(stageW(), stageH(), 0, false);
}

Related

Videojs-swf - rtmp connect without publishing stream or disconnect

How can I set waiting when the stream is not published.
When unpublish (NetStream.Play.UnpublishNotify) set to waiting, and on publish (NetStream.Play.PublishNotify) continue play
I don't use Video-JS so I don't know what their code setup is doing.
Normally (without Video-JS) it's done something like this.
yourNS.addEventListener(NetStatusEvent.NET_STATUS, streamEventsHandler);
private function streamEventsHandler(evt:NetStatusEvent):void
{
//trace(evt.info.code); //if you need to check event status as text
if (evt.info.code == "NetStream.Play.UnpublishNotify") { yourNS.pause(); }
if (evt.info.code == "NetStream.Play.PublishNotify") { yourNS.resume(); }
}
So now in the Video-JS code, find the part that handles NetStream events, and edit the function to pause(); or resume();.
If unsure of the real NetStream name (I just called it yourNS for example) you can try :
Instead of : yourNS.pause(); try as evt.target.pause(); or evt.target.pause();
(PS: I use evt because of the name in function parameter is (evt:NetStatusEvent):void... Check your own Video-JS function)

What's code sequence in the below cocos2dx code?

I'm new to cocos2dx. In the below code, _nextProjectile is added to the children of "this" in the callback function which is executed after _nextProjectile->runaction (since "finish shoot" is always printed after "run action"). However, I print the position of _nextProjectile in finishShoot(), which is exact the same with that I set when I created the _nextProjectile.
So my question when does the _nextProjectile->runAction is executed actually?
Thank you.
{
_player->runAction(Sequence::create(RotateTo::create(rotateDuration, cocosAngle), CallFuncN::create(CC_CALLBACK_0(HelloWorld::finishShoot, this)), NULL));
// Move projectile to actual endpoint
printf("run action\n");
_nextProjectile->runAction(Sequence::create(MoveTo::create(realMoveDuration, realDest), CallFuncN::create(CC_CALLBACK_1(HelloWorld::spriteMoveFinished, this)), NULL));
}
void HelloWorld::finishShoot()
{
// Ok to add now - we've finished rotation!
printf("finish shoot\n");
this->addChild(_nextProjectile);
// Add to projectiles vector
_projectiles.pushBack(_nextProjectile);
_nextProjectile = NULL;
}
Both actions run simultaneously. The player rotates for rotateDuration before calling the callback, at the same time nextprojectile (if not null) already starts moving.
It seems like you may want to move the nextprojectile runaction in the finishShoot method instead.

Parameter child must be non-null error in AS3

I have a code to pause the game, and it runs the pause function as shown:
public function onKeyPress(keyboardEvent:KeyboardEvent) :void
{
//Check for pause
if(keyboardEvent.keyCode == Keyboard.P)
{
//If the timer is still running
if(gameTimer.running)
{
gameTimer.stop();
Mouse.show();
pauseText = new PauseText();
pauseText.x = 150;
pauseText.y = 100;
addChild(pauseText);
//If the player is using the mouse, resume by clicking on the player
if(mouseControl)
{
player.addEventListener(MouseEvent.CLICK, resumeGame);
pauseText.pauseInformation.text = "click on yourself";
}
else
{
pauseText.pauseInformation.text = "press 'p'";
}
}
else
{
//Only allow the player to resume with P IF he is using the keyboard
//This prevents cheating with the mouse.
if(!mouseControl)
{
gameTimer.start();
removeChild(pauseText);
pauseText = null;
}
}
}
}
The game runs perfectly fine. On my first playthrough, the pause functions work. However, if later I die and restart the game, then pause it, I get the following message:
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/removeChild()
at Game/onKeyPress()
The game still runs fine though. However, everytime I pause, or unpause, this error appears. If I die again, restart, then pause, TWO of these errors appears. From what I can gather it seems as if it attempts to remove the pauseText…but I’ve been removing it just fine on the first playthrough, I’ve used removeChild() then set as null for other parts of my code and it works fine. Additionally, if I add a trace(“a”); statement right after the function header, I get the error before the “a” appears on the output panel.
What’s wrong?
Additional notes:
If I don’t use the pause function at all for my first playthough, there is no error when I call it up on my second playthrough.
put removeChild into 'if' ,this will solve error :
if(pauseText.parent){
pauseText.parent.removeChild(pauseText);
}
but You should anyway check what is the source of problem , maybe 'gameTimer.running' is false on beggining ?
You probably instantiate another Game object (the one that contains the whole game) while not removing the previous game's event listener. That would explain such behavior, since you have more than one KeyboardEvent.KEY_DOWN listener active, and note that when you're stopping the game, you most likely stop the timer in it, so the "else" clause of your "if (gameTimer.running)" statement is executed, but the timer was effectively stop without pauseText to be generated. So, you miss a
removeEventListener(KeyboardEvent.KEY_DOWN,onKeyPress);
in your game destruction code.
if (!mouseControl) {
gameTimer.start();
if (pauseText && contains(pauseText)) {
removeChild(pauseText);
pauseText = null;
}
}

Adobe Cirrus Error on Direct Connect"Property startTransmit not found on flash.net.NetStream"

The error:
ReferenceError: Error #1069: Property startTransmit not found on flash.net.NetStream and there is no default value.
I've played around with cirrus plenty of times before and have yet to see this error before. But now I cant get it to go away.
My p2p Direct connect works great just fine. But every single time i see this error pop up. It throws an exception. I can't figure out where it's exactly happening.
Has anyone encountered this before? Any ideas where I should look?
Every client object needs to have the following functions defined.
client.stopTransmit=function($p1:*,$p2:*):void{
trace("stopTransmit called",$p1,$p2);
}
client.startTransmit=function():void{
trace("startTransmit called");
}
For example, set these in the onPeerConnect function:
sendStream.client = new Object();
sendStreamClient.onPeerConnect = function(subscriber:NetStream): Boolean{
var client:Object=new Object();
client.stopTransmit=function($p1:*,$p2:*):void{
trace("stopTransmit called",$p1,$p2);
}
client.startTransmit=function():void{
trace("startTransmit called");
}
subscriber.client=farStreamClient;
}
Additionally these need to be set on your sendStreamClient's client property:
sendStreamClient.client.stopTransmit=function($p1:*,$p2:*):void{
trace("stopTransmit called",$p1,$p2);
}
sendStreamClient.client.startTransmit=function():void{
trace("startTransmit called");
}
And they need to be set on your recieveStreamClient's client property.
On the server side script, you probably (or somebody else) have set up the application, so that it calls back a function -this time it is startTransmit-, and it isn't handled on the client side.
Remove the code from the server, or add a default value, or add a function to your code.
In my similar program, i had to add the function to my code (in my case it was not 'startTransmit') :
if ("NetConnection.Connect.Success" == e.info.code) {
netConnection.client=new Object();
netConnection.client.startTransmit=startTransmit; //no columns!
}
where startTransmit is
private function startTransmit():Boolean{
return true;
}
Are you sending h264 videos? I think it is to do with that...
If you add
public function startTransmit($p1:*,$p2:*):void{
}
public function stopTransmit():void{
}
where you have your media server connection it should work fine, at least it does for me :)
There is another netstream other than receiveStream and sendStream. You should set startTransmit and stopTransmit functions on the callerns netstream, something like this:
sendStreamClient.onPeerConnect = function(callerns:NetStream): Boolean{
var farStreamClient:Object=new Object();
farStreamClient.stopTransmit=function($p1:*,$p2:*):void{
trace("-------------farStream stopTransmit called!",$p1,$p2);
}
farStreamClient.startTransmit=function():void{
trace("-------------farStream startTransmit called!");
}
callerns.client=farStreamClient;
}
The problem is not on AMS or Red5 server. Even transmitting a video on P2P from an Android device triggers the same error.
The solution worked.
Actually the stopTransmit() sends a Boolean and an integer.
It would be amazing to know what they mean.
I have opened a bug on adobe bugbase in order to have it documented or removed.
Please vote:
https://bugbase.adobe.com/index.cfm?event=bug&id=3844856

Debug AS3 in Flash CS4, how to watch a variable?

I am debugging AS3 in Flash CS4, a variable becomes NULL but I don't know who changes it at when. Is it possible to watch this variable and when the value changes to null, it stops?
Thanks.
Bin
This is a wild guess, because I've never thrown an error (on purpose) in AS3. Can you change the property to as setter and then insert:
public var function set myVar(v:*):void{
if(v == null){
throw new Error("Its null!")
}
_myVar = myVar;
}
from top menu: window > debug panels > variables.
That should make a huge list of variables visible.