1

I've exported some of the User-Interface components inside of the Adobe Animate into a .swc file to be used at runtime:

public class Main extends Sprite {
    public function Main() {
        var checkbox:CheckBox = new CheckBox(); // fl.controls.CheckBox
        checkbox.label = "Row";
        addChild(checkbox);
    }
}

It's working nice with the Adobe Flash Builder; but using the IntelliJ IDEA, that I do need to go with, only behaves weirdly sometimes, and argues in unexpected ways of:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at fl.controls::CheckBox/drawLayout()
    at fl.controls::LabelButton/draw()
    at fl.core::UIComponent/callLaterDispatcher()

or sometimes, argues with the following message (with a fl.controls.NumericStepper in the following example):

TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/addChildAt()
    at fl.controls::BaseButton/drawBackground()
    at fl.controls::BaseButton/draw()
    at fl.core::UIComponent/drawNow()
    at fl.controls::NumericStepper/drawLayout()
    at fl.controls::NumericStepper/draw()
    at fl.core::UIComponent/callLaterDispatcher()

for the really no rational reason!! I've been searching for solutions (and even reasons!) for many hours and tried what I could've thought of! (e.g: I put the routine in an Event.ADDED_TO_STAGE handler; I tested multiple combinations of the components for the exported file, and I do use the latest versions of the applications and the SDK.)

Please shed some lights on this as it randomly appears with identical code just for the fun of annoyment!! I appreciate any feedback as I'm totally out of ideas!

Thank you in advance :)

Samuel Liew
  • 76,741
  • 107
  • 159
  • 260
  • 1
    Flash components sometimes initialize not immediately, but on the next or second next frame for whatever reason. That could happen, like, to 1 combobox out of 10 on the same class, same contaner, same everything. I've never figures out a cause exactly because it is not rational, I just learned how to live with it. I advise to wait 1-2 frames after you instantiated a component before accessing its properties. – Organis Mar 24 '18 at 21:35
  • @Organis Thanks for the reply :) I don't have any issues with that life-style! The thing is: _It just doesn't work!_ I did wait a fairly redundant amount of time after the instantiating and this time, I didn't access _any_ properties in the code!! I just only mention them when adding them onto the stage (as the argument for the `addChild()` method); again, it _sometimes_ argues the same grumbles!! –  Mar 28 '18 at 15:08
  • I think I have most of the **fl.control** package in this SWC, will that produce the same error for you? https://drive.google.com/file/d/1WYq1zk43C4Dfex4AJVtA_4iUc586ivAJ/view?usp=sharing – Organis Mar 28 '18 at 21:21
  • @Organis I've tested the `.swc` file you provided & _thank you_ for that; but, the error still occurs every now and then!! –  Apr 03 '18 at 06:52
  • Maybe that has to do something with publish settings? Like player target version? I'm out of ideas, actually, sorry. If I were you I'd either stick to compiling with Flash IDE while coding in IntelliJ, or went for someone's else components. – Organis Apr 03 '18 at 07:14
  • @Organis Do you have any suggestions for the _"someone else's components"_? –  Apr 08 '18 at 03:38
  • Ever considered using Flex, for one? Then, there's a full course menu to dig in: http://www.programering.com/a/MjM5YzMwATE.html – Organis Apr 08 '18 at 03:44

0 Answers0