Cannot compare Dynamic and Unknown, for Lists


  • Posts: 4
Hi there,

Stencyl project:

I have an event that:
1. Compiled fine when it was in 2.2
2. Compiles fine when tested again with only local attributes
3. Compiles fine when one of the list values is put into a local attribute (see Event "But no error here" in linked Stencyl)

Just run the linked Stencyl project to see the error as per the screenshot. Logs are attached.
This really shouldn't be a problem,  but I decided to put this here in case it has larger ramifications.

I'm happy with my workaround, but any way I can help and contribute would make me happier. Hope this helps!

Best regards,
Johann Lim


  • Posts: 2693
You should just explain the problem as best you can here on the forums, because depending on the problem its easier than having to download the project (I don't have the fastest internet, for example.) Typically I only ask for .stencyl files if I'm not sure how to troubleshoot a problem via posting.

1.) Are you certain that the item at slot 0 for scrapboost is a number?
2.) Can you just post a screenshot of the workaround?
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!


  • Posts: 4
My apologies, just realised that I didn't actually describe the problem.

The game simply does not compile, showing the error on the previous screenshot (Cannot compare Dynamic and Unknown). It worked in Stencyl 2.2, and works when the value is held in an intermediary attribute.

1) Yes, I am certain that item #0 for scrapboost is a number.

2) Will attempt to attach the workaround screenshot here. If I cannot, I'll edit the original post to include it.

Many thanks.


  • *
  • Posts: 9472
Apparently trying to access an element of a Dynamic variable (game attribute) results in the variable being considered an Unknown type.  And it seems that Dynamic (your other game attribute) can't be compared with Unknown, so you get that compile error.  The problem is a part of the Haxe language and isn't going to change.

Solution: wrap that "get item #4 from ScrapBoost1" block in the "___ as number" block so the compiler will know that it's a number.


  • Posts: 64
Thank you rob1221. I had the same problem and it's working now :)


  • Posts: 206
Thanks, rob1221! I encountered the same issue. Your solution with 'as number' block is perfect!