Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6345527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:50:26+00:00 2026-05-24T20:50:26+00:00

I followed the example from a previous question and I am loading an external

  • 0

I followed the example from a previous question and I am loading an external swf using a loader and inside the loader event handler I am trying to cast the loader.content as my custom class PanelReferenceClip which extends MovieClip

When I publish I receive a this error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

Just to make sure and test that the swf location was correct and the swf was actually being loaded, I changed the type of the content to as MovieClip and it worked fine.

EDIT: I also wanted to add that these swfs are being stored locally and not being pulled across the internet, multiple networks or servers.

I am not sure if I did something quirky in my class so I am providing the source to my custom class PanelReferenceClip

package com.components 
{
    import com.UI.DevicePanel;
    import flash.display.MovieClip;

    /**
     * ...
     * 
     * used to store the loaded swf inside the panel
     * 
     * *parentPanel is set so that it is able to access it's parent Panel when needing
     * to set parameters.
     */

    public class PanelReferenceClip extends MovieClip 
    {
        private var _parentPanel:DevicePanel;
        private var _bg_mc:MovieClip;
        private var _oldY:Number = 0;
        private var _oldX:Number = 0;
        private var _IsDragging:Boolean = false;

        public function PanelReferenceClip() {
            super();
        }

        /*--------------------------------------------------------------------------
         * GETTERS AND SETTERS
         * -----------------------------------------------------------------------*/

        public function set parentPanel(p:DevicePanel):void {
            _parentPanel = p;
        }

        public function get parentPanel():DevicePanel {
            return _parentPanel;
        }

        public function get bg_mc():MovieClip {
            try {
                return getChildByName("bg_mc") as MovieClip;
            } catch (e:Error) {
                trace("could not find bg_mc in " + _parentPanel.DeviceName + " panel");
            }

            return null;
        }

        public function set oldY(n:Number):void {
            _oldY = n;
        }

        public function get oldY():Number {
            return _oldY;
        }

        public function set oldX(n:Number):void {
            _oldX = n;
        }

        public function get oldX():Number {
            return _oldX;
        }

        public function set IsDragging(b:Boolean):void {
            _IsDragging = b;
        }

        public function get IsDragging():Boolean {
            return _IsDragging;
        }
    }

}

Here is the part of another class that is loading the swfs and then trying to assign them as the class prop _reference which is of type PanelReferenceClip . I am doing this so I am able to get ahold of the swf and it’s children because when you import a swf you do not get to set the instance name of the imported swf. So I am assigning it a custom class that extends MovieClip so I can store have some custom properties.

        private function handleLoad(e:Event):void
        {
            e.target.removeEventListener(Event.COMPLETE, handleLoad, false);
            // keep reference to the content
            _reference = e.target.content as PanelReferenceClip;
                    //  ** BREAKS ON THE NEXT LINE **/
            trace(_reference.numChildren);

            // add loader to the display list so we can see the external SWF.
            addChild(e.target.loader);

            // signal the sim engine that the swf has loaded 
            // and to go ahead and wire up the components
            dispatchEvent(new DataEvent(DataEvent.COMPLETE));

            initPanel();
        }

Here is the method used to load the swf. I added in the application context part to try it out but I am still not getting anywhere.

    public function loadSWF(theSWF:String):void
    {
        var url:String = theSWF;
        var urlReq:URLRequest = new URLRequest(url);
        _urlError = url;
        _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleLoad);
        _loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
        var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
        _loader.load(urlReq,context);
        _loader.mouseEnabled = false;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:50:27+00:00Added an answer on May 24, 2026 at 8:50 pm

    This might be caused by converting between types that can’t be typecast. Instead of an error occurring when performing someVariable as OtherClass, the variable will just become null. (Example Shown)

    I would store a reference to the original movieclip as one of the properties in PanelReferenceClip, and just use that reference when you need to access things like .numChildren

    //MovieClips are subclasses of Sprites... this conversion works
    var originalMC:MovieClip = new MovieClip();
    var sprite:Sprite = originalMC as Sprite; 
    trace("sprite: " + sprite); //defined
    
    //Sprites are not subclasses of MovieClips... this conversion wont work
    var originalSprite:Sprite = new Sprite();
    var mc:MovieClip = originalSprite as MovieClip; 
    trace("mc: " + mc); //null
    
    //MovieClips are not subclasses of PanelReferenceClips (quite the opposite)
    //this conversion wont work, just as the one before
    var panelRef:PanelReferenceClip = originalMC as PanelReferenceClip;
    trace("panelRef: " + panelRef); //null
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just followed this example from Wordpress and I have successfully added an extra
I am trying to follow this example from MSDN: http://msdn.microsoft.com/en-us/library/a1hetckb.aspx I think i'm doing
I am trying to learn CorePlot. I found a code example from codejunkster that
I'm attempting to do basic auth with Apache HTTPClient 4.x using the example from
Hi i have a problem with recursion. i followed this example from wc3 http://www.w3schools.com/jsref/met_win_settimeout.asp
I followed the example: http://arunranga.com/examples/access-control/credentialedRequest.html from this page: http://arunranga.com/examples/access-control/ The example work in Firefox,
I have followed the onTouch example from google located here . However, I get
I've followed the NetscapeCocoaPlugin example from the nightly Webkit build, and I'm able to
I'm trying to compile a simple example from thrust graph. At the moment I
I followed an example from Beginning iPhone 3 Development which puts the code for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.