dcsimg
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: noob Trying to instantiate classes

  1. #1

    noob Trying to instantiate classes

    Hi, hopefully this seems obvious-

    I have two active-element classes (files?)- they appear as separate elements. One defines a toy class called COne, the other defines CTwo. I was trying to test if 3dfa can handle circular references (can it?) but now when I do
    var One = new COne();
    I get the following error:
    Unknown type 'CTwo' cannot be created on line 691 var Twoer = new CTwo()
    What am I doing wrong?

    class CTwo
    {
    Integer myothernum = 5;

    function CTwo()
    {
    trace (myothernum);
    }

    function TestMe()
    {
    //var Oner = new COne();
    }
    }

    the other defines COne-
    class COne
    {
    Integer mynum;

    function COne()
    {
    mynum = 4;
    var Twoer = new CTwo();
    }

    }

  2. #2
    Senior Member
    Join Date
    Dec 2006
    Posts
    274
    It seems to be class visibility problem.. I'm not sure is it bug or just normal way things work in actionscript?!?

    Simply changing
    var Twoer = new CTwo();
    to
    var Twoer = new root.CTwo();

    removes error message but then trace() wont print anything in to console (while running in 3dfa...) so I imagine CTwo is newer instantiated.. -> bug?

  3. #3
    Hmmm... that gets rid of the error, but it doesn't actually create the class.

    Try
    var Twoer = new root.CTwo();

    and check the value of Twoer. (Twoer==Null)

  4. #4
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681
    There was a bug, which is now fixed in 4.9.7.3
    Cheers,
    kusco
    (3DFA Support Team)

  5. #5
    I installed version 4.9.7.3. It crashes as soon as I try to preview.

  6. #6
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681
    [revised]

    Your original test was to see what would happen if a class created a class that recreated the first class, and so on, infinitely. And yes, you are right, 3DFA runs out of memory and crashes.

    Thankyou for being such a malicious tester. There will be a circular dependency error checker in the next release.

    Don't worry about sending in a movie file.

    [original]

    Nothing that we can do with this sample will crash the program

    Can you please send an email to the website contact address with an attached copy of the .movie that causes the crash.

    It is especially important that as soon as anybody sees a crash they immediately send a copy of the crashing movie to the contact address. A description is not enough, we need the exact movie. Crashes are not something that we ever want to allow.
    Last edited by kusco; 11-27-2007 at 08:36 PM.
    Cheers,
    kusco
    (3DFA Support Team)

  7. #7
    Ok. The two class test I described before does work in 4.9.7.3. It turns out the crash is happening later in the code (I will do future tests in separate files).

    I don't think those classes have a circular dependency, just a circular reference. It would only spiral out of control if both constructors created the other class.

    But meanwhile, my movie is still crashing. Is there a way to step through the code to isolate the crash point? Or trace to a text file where I can see how far it got. This program has >1000 lines of code. And thank you for your help so far.

  8. #8
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681
    3DFA's internal step-by-step debugger is not quite finished yet, so you'll need to use strategically placed 'trace' functions to determine the last line of code before the crash.

    The fastest and easiest way to solve the problem is always to let us run the code in our debug environment. The problem will be found within seconds, and we can make sure that you never have this problem again, and nobody else will ever have to suffer it.

    But if you are able to isolate the problem code through tracing, then make sure you let us know what you find.

    [addition]

    Another debug option is to export as Flash 9 or Flex source code to check that your code is well formed and properly parsed.
    Last edited by kusco; 11-27-2007 at 11:04 PM.
    Cheers,
    kusco
    (3DFA Support Team)

  9. #9
    Update: I found the bug-
    Put this in a class element-
    The semicolon after the function declaration causes a crash when it tries to compile. Outside of a class or if the function has no return type then it just reports a syntax error.

    class CCrasher
    {
    function Cra****():Integer;
    {
    //wont get here
    }
    }

  10. #10
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681
    Fantastic work, sparky. You move straight into our "favorite bugfinder" hall of fame.

    On a more interesting point, "Integer" is neither an Actionscript nor a C# variable type. It is a Visual Basic variable type.

    If it was possible to allow all VB syntax then we would have. Unfortunately, it was just too incompatible with Actionscript.
    Cheers,
    kusco
    (3DFA Support Team)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center