tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/9162-inject-doesnt-work-on-one-pcRobotlegs: Discussion 2014-10-29T11:41:55Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/343554532014-08-27T14:54:11Z2014-08-27T14:54:33Z[Inject] doesn't work on one PC<div><p>In addition here the comparison of the debugging outputs</p>
<p>PC1 (working)<br>
sound initialisiert<br>
play sound<br>
play sound<br>
play sound<br>
play sound<br>
play sound</p>
<p>PC2 (not working)<br>
sound initialisiert<br>
sound initialisiert<br>
sound initialisiert<br>
sound initialisiert<br>
sound initialisiert<br>
sound initialisiert</p></div>iamabletag:robotlegs.tenderapp.com,2009-10-18:Comment/343554532014-08-27T15:10:03Z2014-08-27T15:10:03Z[Inject] doesn't work on one PC<div><p>Hey,</p>
<ul>
<li>First thing to clear up: are you compiling against the source
of robotlegs? If so, have you added the compiling arguments needed?
Like so:</li>
</ul>
<p>-keep-as3-metadata+=Inject -keep-as3-metadata+=PostConstruct</p>
<p>Have you tried to run a release build of your application on the
computer where it was working? Or was it a debug version that
worked?</p>
<ul>
<li>
<p>Then, are you keeping a reference to your context? Can you post
the code where you initialize your context. What is the scope of
the variable holding the IContext?</p>
</li>
<li>
<p>Are you using modules in your app? Is everything ok with the
ApplicationDomain?</p>
</li>
</ul>
<p>Please answer these questions, so we can narrow down the
issue.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/343554532014-08-27T15:18:13Z2014-08-27T15:18:13Z[Inject] doesn't work on one PC<div><ol>
<li>
<p>no I am using the .swc library. and I didn't added the compiling
arguments</p>
</li>
<li>
<p>yes I have the compilied release running on my machine.</p>
</li>
</ol>
<p>3.package<br>
{ [SWF(frameRate="30", height="540",
width="1440",backgroundColor="#000000")]</p>
<pre>
<code>public class Main extends Sprite
{
private var mainContext:MainContext;
public function Main()
{
mainContext = new MainContext(this);
}
}</code>
</pre>
<p>}</p>
<ol>
<li>no I don't think I am using modules. How do you define
modules?<br>
But everything seems fine besides the sound. everything is
displayed and working pretty well</li>
</ol></div>iamabletag:robotlegs.tenderapp.com,2009-10-18:Comment/343554532014-08-27T15:40:32Z2014-08-27T15:40:32Z[Inject] doesn't work on one PC<div><p>In this case I think of race conditions of some sort.<br>
Or, maybe the PostConstruct method is the culprit.</p>
<blockquote>
<p>On the other PC (where it doesn't work) the service is
instatiated once at the beginning and every command is instatiating
the service again and not calling playSound()</p>
</blockquote>
<p>Do you mean that init() is called every time?</p>
<p>Or, is the service null in your command?</p>
<p>If you comment out this line:<br>
var soundMachine:SoundMachine =
injector.getInstance(SoundMachine);</p>
<p>and you try to run your app again on the 'good' PC, does it
work?</p>
<p>Would it be possible to attach the app ( making the discussion
private for the time being) , so I can take a look at it?</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/343554532014-08-27T16:00:41Z2014-08-27T16:00:41Z[Inject] doesn't work on one PC<div><p>yes the init() is called every time.</p>
<p>before I tried without the line: var soundMachine:SoundMachine =
injector.getInstance(SoundMachine);<br>
--> same problem. (on one PC working, on the other not)</p>
<p>I will try without [PostConstruct] and calling init() at first
instance in context</p>
<p>Unfortunately attaching the app is not possible.</p></div>iamabletag:robotlegs.tenderapp.com,2009-10-18:Comment/343554532014-08-27T16:03:38Z2014-08-27T16:04:59Z[Inject] doesn't work on one PC<div><p>You have this in your service class:<br>
possibleSoundTimer.addEventListener(TimerEvent.TIMER_COMPLETE,
setPossibleSendingFree);</p>
<p>I can't see how you use the timer, but maybe it is initiating an
async process which may be the cause of race conditions?</p>
<p>Or this:<br>
SoundEngineExt.loadBank( "Init" );<br>
Is it an async process?</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/343554532014-08-27T16:12:51Z2014-08-27T16:12:51Z[Inject] doesn't work on one PC<div><p>So, the Service gets injected into your commands.</p>
<p>Try to replace your SoundMachine with a very simple class,
having just the init() and a playStaticSound methods, that do
nothing (just having trace statements) and see what happens. If it
works, then you'll have to refactor your service class...</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/343554532014-08-27T16:21:22Z2014-08-27T16:21:22Z[Inject] doesn't work on one PC<div><p>Also, is it possible to compile your application on the 'bad'
PC? If yes, does it work?</p>
<p>Is the 'good' PC slower or faster than the other one? Do you
have the same FlashPlayer installed?</p>
<p>Is it a desktop or a browser application?</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/343554532014-08-27T17:57:04Z2014-08-27T17:57:04Z[Inject] doesn't work on one PC<div><p>OK I figured out whats going wrong here.<br>
Within the service I am triggering some loading from a native
extension and I am getting the error #3500. Some googling tells me
within that extension is missing a method.<br>
But I don't understand why this problem is only on one machine.<br>
I will ask the supplier of the ANE whats going wrong here.<br>
Do you know anything about native extensions? Are there any methods
which have to be implemented in every native extension?</p>
<p>But OK. Like expected: robotlegs is running perfectly ;-)<br>
With calling init() once in context the calls to play sound are
working too.<br>
Only [PostConstruct] seems to be buggy.</p>
<p>Thank you :-)</p></div>iamabletag:robotlegs.tenderapp.com,2009-10-18:Comment/343554532014-08-28T08:59:29Z2014-08-28T08:59:29Z[Inject] doesn't work on one PC<div><p>You're welcome!</p>
<p>I'm afraid I can't help you with ANE.</p>
<p>I wish you luck in finding a solution :)</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/343554532014-08-28T10:17:39Z2014-08-28T10:17:39Z[Inject] doesn't work on one PC<div><blockquote>
<p>With calling init() once in context the calls to play sound are
working too. Only [PostConstruct] seems to be buggy.</p>
</blockquote>
<p>Not saying it's impossible there's a bug there, but I'm pretty
certain the repeated calls are due to reinstantiating the service.
Could it be the service instance is tore down due to the error
thrown by the ANE? Hence if the service is declared as a dependency
in two other components it will be reinstantiated twice.</p></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/343554532014-08-28T10:18:49Z2014-08-28T10:18:49Z[Inject] doesn't work on one PC<div><p>And regarding the ANE: probably the error thrown has something
to do with a failing connection to the sound card?</p></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/343554532014-08-28T10:26:44Z2014-08-28T10:26:44Z[Inject] doesn't work on one PC<div><p>"Could it be the service instance is tore down due to the error
thrown by the ANE?"</p>
<p>I don't know what happens when a service throws an error<br>
this is the init function</p>
<p>public function init() : void<br>
{ vehicleModel.debuggerMessage = "sound wird initialisiert";</p>
<pre>
<code> possibleSoundTimer.addEventListener(TimerEvent.TIMER_COMPLETE, setPossibleSendingFree);
var relativeFile:File = File.applicationDirectory;
relativeFile = relativeFile.resolvePath("SoundBank");
var nativePath:String = relativeFile.nativePath;
nativePath = nativePath.replace(/\\/g, "\\\\");
nativePath += "\\\\";
vehicleModel.debuggerMessage = nativePath;
try
{
SoundEngineExt = new SoundEngine();
SoundEngineExt.setBasePath( nativePath );
SoundEngineExt.loadBank( "Init" );
SoundEngineExt.loadBank( "Proreta3" );
SoundEngineExt.registerGameObj(gO_static, "static");
SoundEngineExt.registerGameObj(gO_dynamic_comet, "dynamic");
SoundEngineExt.registerGameObj(gO_dynamic_obstacle, "dynamic");
SoundEngineExt.registerGameObj(gO_dynamic_warning, "dynamic");
}
catch(e:Error)
{
vehicleModel.debuggerMessage = e.name;
vehicleModel.debuggerMessage = e.message;
vehicleModel.debuggerMessage = e.getStackTrace();
}
}</code>
</pre>
<p>"And regarding the ANE: probably the error thrown has something
to do with a failing connection to the sound card?"</p>
<p>Hmm maybe. But Windows sounds are playing</p></div>iamabletag:robotlegs.tenderapp.com,2009-10-18:Comment/343554532014-08-28T12:39:05Z2014-08-28T12:39:05Z[Inject] doesn't work on one PC<div><p>OK we fixed the issue.<br>
It was a problem within the native extension while setting the base
path.</p>
<p>Thank you so much for the support.<br>
Very good forum here</p></div>iamable