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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:14:03+00:00 2026-05-24T10:14:03+00:00

I’ve got an object declared and instantiated in my Flex application’s singular MXML file:

  • 0

I’ve got an object declared and instantiated in my Flex application’s singular MXML file:

public var CDN:CDNClass = new CDNClass;

I would like to access this same CDN object (and its public methods and properties) in another class declared in a separate .as file as such:

package my.vp
{
    import my.media.CDNClass;

    public class SyncConnectorManager
    {

        private function syncMessageReceived(p_evt:SyncSwfEvent):void
        {
            switch (p_evt.data.msgNm)
            {
                case "startStream" :
                    // Play a stream
                    CDN.parsePlayList(p_evt.data.msgVal);
                    break;

But when I try to access the public method parsePlayList in the CDN object in a method in the class defined in the .as file, I get the following error:

Access of undefined property CDN

The reason I want to do this is to break up the logic of my application into multiple AS files and have minimal MXML files, probably only one.

Thanks – any help is much appreciated. Perhaps my OOD/OOP thinking is not correct here?

  • 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-24T10:14:04+00:00Added an answer on May 24, 2026 at 10:14 am

    Yes, your OOP thinking is not correct here. You should take in mind differences between classes and instances. This line declares a filed in a current class and initiates it with an instance:

    public var CDN:CDNClass = new CDNClass;
    

    So current instance of your MXML class (you can think about it as usual AS class with some other notation) has public field. To operate with CDN instance you need something from the following:

    • Read the value of CDN (as far as it is public) from the instance of your MXML class. You need some reference to it for that.
    • The instance of your MXML class can have a reference to the instance of SyncConnectorManager and SyncConnectorManager should have a way to inject the value of CDN there. Something like:

    Your class:

    package my.vp
    {
        import my.media.CDNClass;
    
        public class SyncConnectorManager
        {
            private var CDN:CDNClass;
    
            public function SyncConnectorManager(CDN:CDNClass)
            {
                 this.CDN = CDN;
            }
    
            private function syncMessageReceived(p_evt:SyncSwfEvent):void
            {
                switch (p_evt.data.msgNm)
                {
                    case "startStream" :
                        // Play a stream
                        CDN.parsePlayList(p_evt.data.msgVal);
                        break;
    

    In your case SyncConnectorManager class hasn’t CDN declared (the problem of the compiler error you mentioned) and instantiated (the problem of NPE even if you just declare field).

    As the bottom line I can suggest you to follow ActionScript naming and coding conventions to talk other people and team members about your code 🙂

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

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
i got an object with contents of html markup in it, for example: string
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i want to parse a xhtml file and display in UITableView. what is the
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;

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.