Highlighted

Variable value differ while tracing it.

Community Beginner ,
Sep 15, 2014

Copy link to clipboard

Copied

Hi, I am having a really annoying problem with my mobile air project.

I have variable that value is updated every enterFrame (gyroscope roll value) and every thing is ok when I trace it like:

private function update(event:EnterFrame):void

{

     trace(roll);

     _onUpdate(roll);

}

but when I remove "trace(roll)" line my value seems to to contain some really random data, once it is refreshed other time it is not. Can anybody tell me what is going on ? how trace statement can do anything ?

TOPICS
Performance issues

Views

241

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Variable value differ while tracing it.

Community Beginner ,
Sep 15, 2014

Copy link to clipboard

Copied

Hi, I am having a really annoying problem with my mobile air project.

I have variable that value is updated every enterFrame (gyroscope roll value) and every thing is ok when I trace it like:

private function update(event:EnterFrame):void

{

     trace(roll);

     _onUpdate(roll);

}

but when I remove "trace(roll)" line my value seems to to contain some really random data, once it is refreshed other time it is not. Can anybody tell me what is going on ? how trace statement can do anything ?

TOPICS
Performance issues

Views

242

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 15, 2014 0
Adobe Employee ,
Sep 15, 2014

Copy link to clipboard

Copied

Hi,

Could you please share the sample code ?

Thanks

Govinda Gupta

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 15, 2014 0
Community Beginner ,
Sep 15, 2014

Copy link to clipboard

Copied

I'm not in front of code right now but the flow is like that :

USing adobe ane gyroscope

1. Initial gyroscope instance

2. Set interval to 100

3. Add event listener gyroscopeEvent.update

4. In listener function set roll variable to event.x

5. On enter frame function trigger my function with roll parameter.

nothing else is going here there is no any other code just what I wrote. When I debug on device and trace "roll" var everything is just great, but when I remove the trace line I have some really no constant data According to my device position.

I have changed code to use adobe accelerometer class without using any ane, and it work quite ok but I have strange delay after let say 10 seconds of receiving data, after this time when I move my device accelerometer gives me data about that movement after 2 seconds and delay is bigger with more time. (The interval in this case is set to 0) it is very similar situation to this whith gyroscope ane but in this case data is more stable.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 15, 2014 0
Participant ,
Sep 15, 2014

Copy link to clipboard

Copied

Not sure but the code you pasted has a few things

Are you passing a global var named roll into a function which maybe having conflicts between local and global?

Also if roll is a getter you maybe having a RACE issue.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 15, 2014 0
Community Beginner ,
Sep 16, 2014

Copy link to clipboard

Copied

It's not an answer for the topic question (why trace call was doing anything with traced variable using gyroscope ane) but i got my code working.


here is the class that works ok. It seems that setting interval to accelerometer cause some problems with delaying data. without setting interval (letting it be default set by device, according to adobe api doc) everything is ok. didn't tryied it with gyroscope ane but maybe there is the same problem.

Conclusion: do not use setRequestedUpdateInterval() method. As it is described in api doc it should set update interval not delay

private var _onUpdate:Function;

  private var acc:Accelerometer = new Accelerometer();;

  public function GyroscopeStering()

  {

  }

  public function Start(onUpdate:Function):void

  {

  _onUpdate = onUpdate;

  if(Accelerometer.isSupported && !acc.muted)

  {

  acc.addEventListener(AccelerometerEvent.UPDATE, accUpdate);

  StarlingView.Instance.addOnUpdateListener(update);

  NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;

  }

  }

  public function Stop():void

  {

  acc.removeEventListener(AccelerometerEvent.UPDATE, accUpdate);

  StarlingView.Instance.removeOnUpdateListener(update);

  NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.NORMAL;

  }

  private static const rollMultipler:Number = 1.5;

  private var _roll:Number = 0;

  protected function accUpdate(event:AccelerometerEvent):void

  {

  if(Core.STAGE.orientation == StageOrientation.UPSIDE_DOWN)

  {

  _roll = -event.accelerationX * rollMultipler;

  }

  else

  {

  _roll = event.accelerationX * rollMultipler;

  }

  }

  private function update(dl:Number):void

  {

  _onUpdate(_roll * dl);

  }

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 16, 2014 0
Community Beginner ,
Oct 16, 2014

Copy link to clipboard

Copied

Ehhhhhh. updated to iOS 8.0.2 and now when using accelerometer class after locking iPad and returning to home screen auto orients no longer work, i mean the iPad native auto orients not the Air app one. It seems like accelerometer make some bug that impact autoorient feature outside of the Air sandbox.

Reported this bug to Apple but no response, what should I do ?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 16, 2014 0