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 1035255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:30:56+00:00 2026-05-16T14:30:56+00:00

this is a follow up question from this one , I don’t want to

  • 0

this is a follow up question from this one, I don’t want to keep going in the comments and preventing people from getting hard-earned reputation… 🙂

In my Cairngorm command class, to get it to compile I needed to tell it what myCanvas was, so I used this line:

var myCanvas : MyCanvas = new MyCanvas;

I’m guessing that’s wrong, though, because although it compiles, if I try to do something like this:

if (myCanvas.subObject.value == 0) { ... }

it’ll throw this error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at com.foo.bar.command::MyCommand/execute()

as if the subObject doesn’t exist. It looks like I might be getting a new instance of MyCanvas, not the instance I want from the main.mxml with an id of myCanvas. Am I right? How do I fix this?

Edit (10:59pm GMT+1): Okay, so it looks like I’ve been way too vague here. Here’s my main.mxml:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:control="com.foo.bar.control.*" 
    xmlns:business="com.foo.bar.business.*"
    xmlns:view="com.foo.bar.view.*"
    applicationComplete="com.foo.bar.util.StartupUtil.init()"
    horizontalScrollPolicy="off"
    verticalScrollPolicy="off"
    borderThickness="0"
    paddingBottom="0"
    paddingLeft="0"
    paddingTop="0"
    paddingRight="0"
>
    <mx:Script>
        <![CDATA[
            import com.foo.bar.model.PlayerModelLocator;

            [Bindable]
            private var model : PlayerModelLocator = PlayerModelLocator.getInstance();
        ]]>
    </mx:Script>

    <!-- ========================================================================== -->

        <!-- the ServiceLocator where we specify the remote services -->
        <business:Services id="services" />

        <!-- the FrontController, containing Commands specific to this application -->
        <control:PlayerController id="controller" />

    <!-- ========================================================================== -->

  <mx:Style source="assets/main.css" />
  <view:MyCanvas id="myCanvas" /> 

</mx:Application>

And here’s my com/foo/bar/command/MyCommand.as:

package com.foo.bar.command {
    /* add to controller
    addCommand( MyEvent.EVENT_CHANGE_VOLUME, ChangeVolumeCommand );
    */
    import flash.net.SharedObject;
    import com.adobe.cairngorm.control.CairngormEvent;
    import com.adobe.cairngorm.commands.ICommand;

    import com.foo.bar.model.PlayerModelLocator;
    import com.foo.bar.event.MyEvent;
    import com.foo.bar.view.*;

    public class ChangeVolumeCommand implements ICommand {
        public function execute(event:CairngormEvent):void {
      var model : PlayerModelLocator = PlayerModelLocator.getInstance();
      var myEvent : MyEvent = MyEvent(event);
      var myCanvas : MyCanvas = new MyCanvas();
      var so:SharedObject = SharedObject.getLocal("fixie.video");
      if (myCanvas.subObject.value == 0) {
        trace("subobject value is 0");
      }
        }
    }
}

Basically, I want to get a handle on the object with ID myCanvas in main.mxml using the myCanvas object in MyCommand.as

  • 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-16T14:30:57+00:00Added an answer on May 16, 2026 at 2:30 pm

    What is the scope of your myCanvas variable? Is it inside a method somewhere? You will need to make it public or give it getter/setter to be able to access it.

    You may also be trying to reference it before it has been added to its parent, using the addChild() method.

    There really isn’t enough code in your examples to determine the problem, but these things should give you somewhere to start looking.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is the follow-up to my question about getting a div's content. the second
Converting a database of people and addresses from ALL CAPS to Title Case will
I have two pages, the parent and from this page I am using: window.open('OrderDetailsFull.aspx?ObjectID='
I have 2 classes Base and Derived (derived publically from Base). When I write
For what reasons would this.InvokeRequired equal False within InitUIState() , as this new thread
I'm stuck with the following bit of code. NSString *gridRef = [[NSString alloc] initWithFormat:
I'm using Castle ActiveRecord which uses NHibernate underneath and I've added a property with
I'm making a simplistic trivial pursuit game . I'm not sure if (and then
I'm using transactions for managing data across several MySQL InnoDB tables in a reasonably

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.