-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError while using with Starling #71
Comments
I guess you're using new buggy compiler and having issue with ||= operator.
|
Hey fljot, I am getting: Tryed everything on this thread you mentioned with no luck. |
@Pablocabana whaaaat, no, that's something new. Error stack trace maybe? Give me something. |
This stack bellow is what I get as soon as I call //// TypeError: Error #1034: Type Coercion failed: cannot convert Function to org.gestouch.core.GestureState. |
@Pablocabana apparently new compiler surprises. Can you try to rewrite this loop somehow differently? |
@fljot Ok, it made it. It is a type conversion error. I changed the function from this: private function setValidNextStates(...states):void
{
for each (var state:GestureState in states)
{
validTransitionStateMap[state] = true;
}
} To this: private function setValidNextStates(...states):void
{
for each (var state:* in states)
{
trace(state)
validTransitionStateMap[state] = true;
}
} This stack below is what the trace call returned. Im using the GestureState.RECOGNIZED btw, thanks for the quick reply. My first time using the lib and was stucked on this wall. |
@Pablocabana hmm state machine inside gesture might not work correctly now. Please try removing tracing the state, but rather trace states rest argument in the beginning. Just to ensure that it is something with the class static initialization and not something else. |
@fljot ok, done that. A new trace: GestureState.RECOGNIZED,GestureState.BEGAN,GestureState.FAILED Than i tried to do this: private function setValidNextStates(...states):void
{
trace(states);
trace("states.length outside the loop: " + states.length);
for each (var state:* in states)
{
trace("states.length inside the loop: " + states.length);
validTransitionStateMap[state] = true;
}
} Oddly, got this: GestureState.RECOGNIZED,GestureState.BEGAN,GestureState.FAILED |
And if you rename "states" to "args"? |
Same thing: GestureState.RECOGNIZED,GestureState.BEGAN,GestureState.FAILED |
This is how I am using now and it is working fine: private function setValidNextStates(...states):void
{
for each (var state:* in states)
{
if(state is Function == false)validTransitionStateMap[state] = true;
}
} |
@Pablocabana no-no, this is totally not cool. Better try regular |
all right, all right! ;) |
@Pablocabana it works as expected this way, right? Should I commit fix? |
@Pablocabana what compiler are you using (e.g. mxmlc --version)? (EDIT: i found the version text above) i cannot reproduce this with multiple AS3.0 compilers (e.g. from recent AIR SDK). |
what if you update your Apache Flex SDK to the latest one - 4.13.0 is from july 2014? EDIT: ^ scratch the above. 4.13.0 is the latest from Apache... also, if you create a simple HelloWorld project (i.e. just a simple Sprite class without Starling etc) does it still occur? |
@Pablocabana then used AIR's ADL 15.0.x to launch it, but cannot reproduce the issue. i suggest you try the HelloWorld idea, so that we can confirm that this issue only occurs for larger projects. and also confirm to fljot if this loop works: @fljot if this is some sort of a crazy VM stack bug, i'd suggest you remove setValidNextStates() and unroll the validTransitionStateMap[x] calls. |
I will try to isolate everything later. Busy now. But for a quick test: private function setValidNextStates(...states):void
{
for (var i:uint = 0; i < states.length; i++)
{
validTransitionStateMap[i] = true;
}
} Throws an error as soon as douple tap the object: But this works fine: private function setValidNextStates(...states):void
{
for each (var state:* in states)
{
validTransitionStateMap[state] = true;
}
} |
i think it should be: because it's a Dictionary? |
oops! my bad. Tried too quickly. So, my tests: 1 - That does not happen on a simple hello world without starling. |
you could make the bug go away even if you change the simplest of things in your project and that's because it triggers for a specific stack frame state. even if you get it stable - that's no good of a solution. and BTW for(...i < length) is much safer than "for each (x in y)" or "for (x in y)", because if the compiler has made it so that the inbound Object becomes corrupted via something like stack frame re-alignment it can in theory receive more elements that will be just assigned as key [n]...[n+x] - but as i implied earlier - varargs is a can of worms (because it's a bit difficult to implement in a compiler) and given the function is private and the number of calls is not big - unrolling the loop and inlining the function body will be the best way to solve the issue. |
@neolit123 thanks for the participation) |
glad if i can help, pablocabana hinted that it works, but i'm not sure he meant it (?). |
Yeah, it works 100% fine with I don't have enough knowledge on the internals either and I couldnt figure it out exactly what was the cause of the problem. :/ |
Hi any progress on this issue? If I add this code Gestouch.inputAdapter=new NativeInputAdapter(this.stage);
var doubleTap:TapGesture=new TapGesture(appMediator);
doubleTap.numTapsRequired=2;
doubleTap.addEventListener(GestureEvent.GESTURE_RECOGNIZED, onDoubleTap); then my error is code there is: protected function onStageAvailable(stage:Stage):void
{
_stage = stage;
Gestouch.inputAdapter ||= new NativeInputAdapter(stage);
Gestouch.addTouchHitTester(new NativeTouchHitTester(stage));
} |
I changed this line in the function onStageAvailable(stage:Stage):void Gestouch.inputAdapter||=new NativeInputAdapter(stage); and its working for me The weird thing is that the objects i drag around, scale or rotate If I comment out that code then the jump isn't as wild but it is still there |
@slaymantis I've create branch with the fix https://github.com/fljot/Gestouch/tree/features/71-fix-initialization And in changelog you can see see how you should initialize stuff: https://github.com/fljot/Gestouch/blob/features/71-fix-initialization/CHANGELOG.md Please try and tell me if everything works) |
@slaymantis that was about automatic initialization (that stuff in |
Hi,
I am getting the following error when initializing GesTouch in my Starling project:
TypeError: Error #1034: Type Coercion failed: cannot convert to org.gestouch.core.IInputAdapter.
Any idea what might be the issue?
The text was updated successfully, but these errors were encountered: