views:

226

answers:

2

I have a Director project with 3 scripts (2 behaviors and 1 movie script). I have the following code in my movie script:

on startRecording ()
  --do stuff
  _movie.script["script2"].passGrade(75, 3, 4)
end

and in one of my behavior scripts, I have the following:

on passGrade (acc, dur, tim)
  member("Assessment", "Assessment").displayGrade(acc, dur, tim)
end passGrade

where the name of the second behavior script is script2and there is a Flash object on the stage called Assessment which has an ActionScript method called displayGrade which takes 3 numbers as input.

I have 2 questions. First, the call -movie.script["script2"].passGrade(75, 3, 4) does not work, and I can't figure out why. Am I not allowed to call from a movie script to a behavior? Or am I not doing this correctly? The second question is how do I call the ActionScript method? The script is defined as a behavior for the Flash object, which is called Assessment, but Director doesn't seem to be able to locate the method.

I am using Director 11 with HotFix 3, and the Flash object was compiled for ActionScript 2.

A: 

A movie script can't call a behavior script since the bahavior script can be attached to more than one object, and then what?

The movie script is "static" while the behavior is "dynamic". You should refer the behavior functions through the flash object instance/sprite.

Eliram
+1  A: 

The syntax for calling the behavior script should rather be:

script("script2").passGrade(75, 3, 4)

Alternatively you could attach your behavior to the flash sprite (the instance of your flash on the stage), and send the call to the sprite:

sendSprite (flashSpriteNumOrNameOrRef, #passGrade, 75, 3, 4)

About calling a function inside the flash sprite, you do more or less the same, but you send the call to the flash sprite, not the member:

sprite(flashSpriteNumOrNameOrRef).displayGrade(acc, dur, tim)

if the behavior is attached to the sprite: sprite(me.spriteNum).displayGrade(acc, dur, tim)

luna1999