# In class A call a method from class B

**URL:** <https://forum.kirupa.com/t/in-class-a-call-a-method-from-class-b/298005>\
**Category:** flash\
**Created:** [October 12, 2009, 8:32am UTC](https://forum.kirupa.com/t/in-class-a-call-a-method-from-class-b/298005 "2009-10-12T08:32:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephsh](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@stephsh](https://forum.kirupa.com/u/stephsh)\
**Post date:** [October 12, 2009, 8:32am UTC](https://forum.kirupa.com/t/in-class-a-call-a-method-from-class-b/298005/1 "2009-10-12T08:32:10Z")

</div>

Hello,  
From my LoadXML class I am trying to call a method, named onBackgrLoad, which sits inside the Main class. I made the method onBackgrLoad public. Inside the LoadXML class in the method ParseData I added an event listener. This is supposed to call onBackgrLoad but it doesnt work :ogre:

Here is my ParseData method:

```php

private function ParseData(dat: XML) : void
       {
         // Number of products
  numOfProducts = xmlData.*.length();
  trace("Number of Products (LoadXML class): " + numOfProducts);
 
  // Max products as specified by the user
  maxProducts = xmlData.produkte.max.attributes();
 
  trace("Step 3: Parsing data.");
 
   for (var i: uint = 0; i < numOfProducts; i++)
   {
    kategorie* = dat.produkte.produkt.kategorie.attributes()*;
    website* = dat.produkte.produkt.website.attributes()*;
    uebersicht* = dat.produkte.produkt.uebersicht.text()*;
    hintergrund* = dat.produkte.produkt.bild.hintergrund.attributes()*;
    titel* = dat.produkte.produkt.bild.titel.text()*;
    pfad* = dat.produkte.produkt.bild.pfad.attributes()*;
 
    trace("
 Data Parsed for Array " + i);
   }
   trace("LoadXML class completely loaded now");
 
   // When LoadXML class loaded, load test function from the Main class
   addEventListener(Event.COMPLETE, Main.onBackgrLoad);
   //OR onBackgrLoad(new Event(Event.COMPLETE));
       }

```
