Where is the actual function?

You cant store a function in XML, on the name. You can then use that name to construct a call to the function. Where is the function?

mike chambers

[EMAIL PROTECTED]

mike chambers

[EMAIL PROTECTED]

On Sep 6, 2008, at 7:40 AM, Gerry wrote:

Mike,
Neither of these options are working.

-Gerry
Here's what my XML looks like:

       <steps>
               <step>
                       <text>NEW TEXT.</text>
                       <funct>testFunction</funct>
                       <pausev>1.5</pausev>
               </step>
               <step>
                       <text>NEXT TEXT to display .</text>
                       <funct>testFunctionOne</funct>
                       <pausev>2.5</pausev>
               </step>
       </steps>

I have a button that is named mentorNext with this event listener..
mentorNxt.addEventListener(MouseEvent.CLICK,playNextSection);

the function "playNextSection" looks like this...

private function playNextSection(e:MouseEvent):void{
                       //
                       var val:Number = stepArray[stepCount].pv;
                       //stepArray[stepCount].fnct(val);
                       stepArray[stepCount]["fnct"](val);
textwindow.captionTxt.text = stepArray[stepCount].txt;
                       stepCount++
               }


If I remove the line for the stepArray function the
textwindow.captionText line works.
The data is there the array is populated properly but I can't get the
function to act like a function.
I get this error message:

TypeError: Error #1006: value is not a function.
       at MainIntro/::playNextSection()


Thanks,

-Gerry





On Sep 6, 2008, at 12:47 AM, Mike Chambers wrote:

if fnct is a function:

stepArray[0].fnct();

if it is a string:

stepArray[0]["fnct"]();

The 0 is the index from the array you want to retrieve.

mike chambers

[EMAIL PROTECTED]

On Sep 5, 2008, at 8:30 PM, Gerry wrote:

I have an array built from and XML file that I want to step through
and one of the nodes will have
a function to call. I thought I did this in AS2 before but can't find
my code.
I'm stuffing my array with the function string cast as an object
but I
can't seem to find any hints on
how I should be calling that function.
My array is built like this...
[code]
//this works fine
     for each (var step:XML in xmlData..step) {
             var step_text:String = step.text;
             var stepFunc:String = step.funct;
             var stepPause:Number = step.pausev;

stepArray.push({txt:step_text,fnct:stepFunc,pv:stepPause});
     }

[/code]
I want to call the stepArray.fnct but can't seem to get it to work
nor
can I find an example of how I should go about this.
Any help or link would be greatly appreciated.


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to