Affichage des articles dont le libellé est Director. Afficher tous les articles
Affichage des articles dont le libellé est Director. Afficher tous les articles

09 novembre 2006

Comparing Lingo and ActionScript

"... Loops

Director uses script-like syntax for loops. The key word is repeat. A typical loop will look like this:

repeat with i = 1 to 10
  -- do something
end repeat

In Flash, you use the more common for keyword, along with syntax like you would use in C.

for (var i = 1; i <= 10; i++) {
    // do something
}

..."

From :
 
 

et Hammers Within Hammers: Dynamic Hierarchical Structures in Flash

Méthode Call de Director

Sending messages to specific behaviors only

The call method sends an event to specific behaviors. Unlike the sendSprite method, the call method does not pass the message to frame scripts, scripts of the cast member, or movie scripts.

Before sending a message to a specific behavior, check the scriptInstanceList sprite property to find a behavior script reference to use with the call method.

The scriptInstanceList property provides a list of references for the behaviors attached to a sprite while a movie is playing.

For example, this handler displays the list of references for all behaviors attached to the same sprite as this behavior's handler:

--Lingo syntax  on showScriptRefs me   put sprite(me.spriteNum).scriptInstanceList end  // JavaScript syntax  function showScriptRefs() {    trace(sprite(spriteNum).scriptInstanceList); } 

This handler sends the message bumpCounter to the first script reference attached to sprite 1 (the getAt method identifies the first script reference in the scriptInstanceList):

--Lingo syntax  on mouseDown me    xref = getAt(sprite(1).scriptInstanceList, 1)    call (#bumpCounter, xref, 2) end  // JavaScript syntax  function mouseDown() {    xref = sprite(1).scriptInstanceList.getAt(1);    bumpCounter (xref, 2); } 

Note: The symbol (#) operator must precede the message in the call method.

To remove all instances of a sprite while the movie is playing:

  • Set the sprite's scriptInstanceList property to an empty list([]). For more information about this property, see the Scripting Reference topics in the Director Help Panel.
 
from :