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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:12:39+00:00 2026-05-30T22:12:39+00:00

I’ve got a block of code that’s doing what I want – it generates

  • 0

I’ve got a block of code that’s doing what I want – it generates a grid of MC’s.

As soon as I put something like function blah() around it, it starts generating errors indicating lines of code I don’t have e.g.

TypeError: Error #1010: A term is undefined and has no properties.
at flightCellMaker_fla::MainTimeline/myXMLtrace() [flightCellMaker_fla.MainTimeline::frame1:87]
at flightCellMaker_fla::MainTimeline/processFPBxml() [flightCellMaker_fla.MainTimeline::frame1:52]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()

When I take the function out, it does what I want it to do. What’s up with that?

var testXML:XML;
var myFPBxml:XML;

// Initialise a URLLoader to get XML data from XML file
var myFPBLoader:URLLoader = new URLLoader();
myFPBLoader.load(new URLRequest("flightPlannerBoard.xml"));


 // Check XML data fully loaded
 myFPBLoader.addEventListener(Event.COMPLETE, processFPBxml);


// Once the flight board planning data is loaded, save it to a variable
function processFPBxml(e:Event):void {
myFPBxml = XML(e.target.data);
myXMLtrace();
 }  


// Grab the XML data load completed and make it available elsewhere
function myXMLtrace(){
testXML = XML(myFPBxml);
}
trace("***********************" + testXML.*); This throws an error (not within myXMLtrace tho)

OK, so here’s the rest of the code that will run correctly on it’s own but not in a function:

// Create and place all the flight cells for planning and drag and drop 

// Setup 2 loops: j for columns and i for Rows
for (var j:Number =0; j < rowNum; j++){

for (var i:Number =0; i<9; i++){

    // Create copies of flightCell for board grid
    var my_mc = new flightCell();
    my_mc.name = "mc"+i+j;

    addChild(my_mc);

    // Set event Listeners on all Child objects
    my_mc.myDragShape.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler);
    my_mc.myDragShape.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler);
    my_mc.myDragShape.addEventListener(MouseEvent.MOUSE_DOWN, fl_MouseDownHandler);
    my_mc.myDragShape.addEventListener(MouseEvent.MOUSE_UP, fl_MouseUpHandler);

    Object(this).my_mc.yellowHiLite.visible = false;


    //cellPos[j] = myXML.cellPosX[j];
    //trace(stage.myXML.*);

    //trace(my_mc.name);
        my_mc.x = (100 + colWidth);
        my_mc.y = myRowHeight;

    colWidth = colWidth + 155;

    //trace(myXML.*);

    cellArray[arrayCount] = [my_mc.x, my_mc.y];
    trace("CellArrayCount = " + cellArray[arrayCount]);
    arrayCount = arrayCount + 1;
}

myRowHeight = myRowHeight + 105;
colWidth = 50;
}
  • 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-30T22:12:40+00:00Added an answer on May 30, 2026 at 10:12 pm

    Your trace is throwing an error because it is being executed before the XML is loaded.

    ActionScript is asyncronous, which means that while the XML is being loaded, the program execution carries on going, and looks something like this:

    1. Declare testXML:XML and myFPBxml:XML
    2. Create loader and start loading
    3. Add a listener for load completion
    4. Trace testXML
    5. Execute processFPBxml when the XML is loaded

    If you move your trace into the myXMLTrace function then it will work correctly.


    With the newly added code, the problem is with this line:

    Object(this).my_mc.yellowHiLite.visible = false;
    

    There is no need to use the this keyword at all here. This will work inside or outside a function:

    my_mc.yellowHiLite.visible = false;
    

    The reason your code fails inside a function is because inside and outside the function this will be the scope of the object in which this code resides. However, when you put the code into a function, the reference you create – my_mc – is scoped locally to the function, not to the parent object, and so this.my_mc is undefined, because this is not the function scope.

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I
I am doing a simple coin flipping experiment for class that involves flipping a
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.