473,386 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Actionscript class member function calling problem

Hi All, I have problem with subject .(
The code seems like good.

For example:
cmenu.as
Expand|Select|Wrap|Line Numbers
  1. class cmenu
  2. {
  3.   public var menuitemarray;
  4.  
  5.   public function cmenu{menuitemarray=new Array;}
  6.  
  7.   public function loadxml() {
  8.     var omenuitem = new cmenuitem();
  9.     this.addmenuitem(omenuitem);
  10.      }
  11.  
  12.   public function addmenuitem(omenuitem_param:cmenuitem){
  13.      this.menuitemarray.push(omenuitem_param);
  14.    }
  15.  
  16. }
  17.  
  18. cmenuitem.as
  19. class cmenuitem{}
  20.  
  21. maintimeline
  22. var omenu = new cmenu();
  23. omenu.loadxml();
  24.  
--------------------------------------
The addmenuitem doesnt get called , why ?
Are there any notable thing in class member function calling ?

PS:I use Flash 8
Thanks in advance!
Csaba
Feb 22 '07 #1
3 3470
As I see I need to qutation the original code

class CMenu {
public var aoMMCollection;//array for MM - main menu items
...
...
public function LoadXML(sXML_:String)
{
aoMMCollection = new Array();
...
...
var oMMtmp = new CMM();
trace(typeof(oMMtmp)); // outputbject
trace("before push"); // output:before push
AddMainMenu(oMMtmp);
...
...
}// end of public function LoadXML(sXML_:String)
...
...
public function AddMainMenu(oMM_:CMM)
{
trace("push MM"); // output:nothing .......................!
this.aoMMCollection.push(oMM_);
}
}//end CMenu class

maintimeline .......................................
var oMenu:CMenu = new CMenu("logtext");
oMenu.LoadXML("./menu.xml");

result .........................................
AddMainMenu doesn't get called


That is all I know about this
Feb 22 '07 #2
I am having the same kind of problem.

One class in my project has member functions which are callable from within
other member functions in that class.
Another class in my project has member functions that seem unaccessible from functions within that particular class.

I really have no idea why.
Aug 20 '07 #3
I'm beginning to get a clue: the method from which I'm trying to call 'sibling' member functions is used as an eventhandler.
Apparently it's context is lost when it is called.

To make things more clear: I'm working on a scorm course (the learning interactions stuff) I've extracted some of the code of the MultipleChoice library object and moved it into a class in an actionscript file. Including the onMCButton function. This onMCButton function seems to be used as an eventhandler; anyway the function is passed as an argument:
router.initControlButton(onMCButton). Since I've created a MultipleChoice class instance myMC this 'registration ' has become router.initControlButton(myMC.onMCButton)
From within the onMCButton function the reference to the class instance is gone, subsequent calls to other functions like evalMC etc fail.
To be able to get things working I'm using a static member var to hold the data, and I recreate the MultipleChoice object within the onMCButton function. Might have made all functions static too...
Aug 20 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: gustav04 | last post by:
hi all i have a question: what is the difference between a c-function and an c++ class method (both do exactly the same thing). lets say, i have a function called print2std() and a class...
4
by: WittyGuy | last post by:
Hi all, Though I know the concepts of both abstract class & virtual function (like derived class pointer pointing to base class...then calling the function with the pointer...), what is the real...
9
by: baumann | last post by:
hi all, to implement a singleton class, one has define a static function in the singleton class, class A{ public: static A* getInstance() { static A a; return &a;
9
by: tropostropos | last post by:
On Solaris, using the Sun compiler, I get annoying warnings from the following code. The problem is that I am passing a C++ member function pointer to the C library function qsort. Is there a...
43
by: Tony | last post by:
I'm working with GUI messaging and note that MFC encapsulates the message loop inside of a C++ class member function. Is this somehow inherently less robust than calling the message loop functions...
3
by: drummond.ian | last post by:
Hello Everyone, This problem's been causing me a lot of trouble and I'm hoping somebody can help me out!! I have a dialog-based MFC application in visual studio 2003. I want to call a...
0
by: gabrielk43 | last post by:
Hi I am new to Flex and I use Flex Builder 2 to make a web service client. So I have a web service in .NET(c#) with a simple web method that returns a string(no arguments). It works, I tested it...
6
by: Gaijinco | last post by:
I'm trying to do a template class Node. My node.hpp is: #ifndef _NODE_HPP_ #define _NODE_HPP_ namespace com { namespace mnya { namespace carlos { template <typename T>
2
by: NitinSawant | last post by:
Hello, I'm beginner to actionscript, I've defined following function in script tag of page <script type="text/javascript"> function showMessage(){ alert("javascript says: Hello...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.