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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:26:59+00:00 2026-05-12T10:26:59+00:00

Ok here is what I am currently trying to do. I have a class

  • 0

Ok here is what I am currently trying to do. I have a class called vdata.as which takes 2 paramaters both are strings sent from the main stage. Parameter one is the location for an XML file that I need to open and read. The second parameter is the name of the video I am currently looking for.

Now I can get the data from the XML file and display it with out any issue if its called from my class but when I try to access any of it from the stage I get undefined.

import flash.net.*;
import flash.display.*;
import flash.events.*;

public class videoData
    {
      private var mName:String;
  private var mLink:String;
  private var mCategory:String;
      public static var elementArray:Array;

      // Constructor
  public function videoData(xmlPath:String,xmlVidSrc:String,pMC:MovieClip)
  {
        pXmlPath = xmlPath;
    pXmlVidSrc = xmlVidSrc;
    xmlloader = new URLLoader();
            elementArray = new Array();
  }

      public function getXML()
  {
    XMLData();
      }

      private function XMLData()
  {
        xmlloader.load(new URLRequest(pXmlPath));
    xmlloader.addEventListener(Event.COMPLETE,parseXMLData);

      } 

      private function parseXMLData():void
  {
    var x:XML = new XML(xmlloader.data);
        Init(x);    
  }

      private function Init(m:XML):*
  {
        var i:Number;
    for(i=0; i<m.videos.videoname.length(); i++)
    {
        if(m.videos.videoname[i].@name == pXmlVidSrc)
        {
        videoData.elementArray.push(m.videos.videoname[i].@name);
        videoData.elementArray.push(m.videos.videoname[i].@category);
        videoData.elementArray.push(m.videos.videoname[i].link.@url);
                 }
    }
}           

}

When I call it from the main stage the code is as follows.

var xData:videoData = new videoData(xmlPath,vidSrc,this);
xData.getXML();

then when I try to access any elements of videoData.elementArray they come up undefined…
Im just smacking my head on my desk trying to figure this out any help would be great.

  • 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-12T10:26:59+00:00Added an answer on May 12, 2026 at 10:26 am

    “addEventListener” doesn’t “fire”…the event does. You’ll need to add a boolean to state for the stage that elementArray has been populated and set that after the init function.

    Is elementArray something that needs to be true across all instances of videoData? If not, it shouldn’t be static. You can use MovieClip(this.root).xData to access that instance of the video class from one of your other classes.

    If the event has completed and the array is still empty – then it wasn’t populated by your parser. You can also do checks to see if the elementArray.length > 0.

    EDIT in response to comment:

    as a public member or preferably a read-only property make a boolean variable:

    var parseComplete:Boolean;
    

    Set it to false in your constructor.

    Then, after your call to “Init” in your Event.COMPLETE callback set:

    parseComplete=true;
    

    Then make sure parseComplete == true before you ever access elementArray. If you’re waiting for the parser to complete you might want to set a timeout or some sort of try/catch mechanism just in case there are any unforeseen errors that would cause some sort of:

    while( !xData.parseComplete ) { }
    

    To loop indefinitely. It all depends on the usage. Personally I’d probably add a callback from the event listener to the stage to trigger whatever is supposed to happen next.

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

Sidebar

Related Questions

I'm not sure if this is even possible but here goes: Currently I have
Currently I am trying to parse an xml string that I already have (no
I currently have three methods which I want to collapse into one: def send_email(contact,email)
I'm trying to add some functionality from a plugin I have made into a
Here is the code currently used. public String getStringFromDoc(org.w3c.dom.Document doc) { try { DOMSource
Here is how our Tomcat webserver is currently setup. We are using jsp for
Here's an easy one for you: I'm currently logging request duration via an HttpModule
I'm currently working through the excercises in 'The C Programming Language'. Here's one of
Here's my current SQL statement: SEARCH_ALBUMS_SQL = SELECT * FROM albums WHERE title LIKE
I'm currently trying to get one of my unit tests to work, but there

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.