PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
How to access a function from another AS file? - Page 2
A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 25 of 25

Thread: How to access a function from another AS file?

  1. #21
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    I said it was a bare sketch, you're going to have to fill in some blanks.

    In this case, change LibPage to extend MovieClip instead of Sprite, and import flash.display.MovieClip.

    Also, I expected you to put the Main code in the timeline. Not because it's better, but because I thought that would seem more intuitive to you. You can put it in a class, but you'll need to put in all the class features like package, class, constructor, and public/private markers

  2. #22
    Member
    Join Date
    Jan 2010
    Posts
    40
    Ah ok, thanks for the help so far.

  3. #23
    Member
    Join Date
    Jan 2010
    Posts
    40
    Hi again, I'm sure the answer to this is probably easy but I'm getting the following error.

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at LibPage/useMysteryNumber()

  4. #24
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You are almost certainly calling useMysteryNumber before setting mainRef.

  5. #25
    Member
    Join Date
    Jan 2010
    Posts
    40
    Ok, so I've abandoned OOP for the moment. I've just put everything inside the Main class and it's working fine so far.

    Here's what I've done to make each room load up
    Actionscript Code:
    function onLibButtonClick(event:MouseEvent):void
    {
        if (1 == mysteryNumber){
        addChild(libPage1);
        removeChild(mapPage);
        }
        if (2 == mysteryNumber){
        addChild(libPage2);
        removeChild(mapPage);
        }
    }

    And here's what I'm using to back out of the room.

    Actionscript Code:
    function onMapButtonClick(event:MouseEvent):void
        {
        addChild(mapPage);
        removeChild(this);
        }

    Although it does work I'm getting this error:
    ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
    at flash.display:isplayObjectContainer/removeChild()
    at Main/onMapButtonClick()

    Help?

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