Skip navigation


Actually our Flash UI is plugged directly in 3dsMax but we do not have any interaction between 3dsMax ans Flash.

In this part we will learn how to send calls from Flash to 3dsMax.

It’s pretty simple to send basics informations using « fscommand ».

In our case i want to click on the animate Button of my Flash UI to Activate Animate mode in 3dsMax.

First we have take a look inside our fla. I added a Listener for the animate button to create an Click Event.

animate_sphere_clip.stop();

var buttonAnimateStatue:Boolean = false;

Animate_toggle_bt.addEventListener( MouseEvent.CLICK, AnimateToggle);

function AnimateToggle(pEvt:MouseEvent ):void
{
if (buttonAnimateStatue == false)
{
animate_sphere_clip.gotoAndStop(2);
buttonAnimateStatue = true;
}
else
{
animate_sphere_clip.gotoAndStop(1);
buttonAnimateStatue = false;
}
}

This line says to stop the playing the swf timeline on opening. The .swf stopped to the first frame. Why Make a stop? I have to do that because inside my Flash UI i added to statues to my button one Green and one Red. First Statue for animate mode disable, second statue Statue for animate mode enable in 3dsMax.

Both statues of the animate button

Both statues of the animate button

var buttonAnimateStatue:Boolean = false;

This is a variable declaration used to know the statue of the button. If false the button is green (animate disable), if true the button is red (animate enable).

Animate_toggle_bt.addEventListener( MouseEvent.CLICK, AnimateToggle);

This is the line used to add the Event listener for the Mouse Click. Animate_toggle_bt. is the name of the animate AnimateToggle is the function that the Click Event will call.

function AnimateToggle(pEvt:MouseEvent ):void
{

}

Here is the function AnimateToggle declaration called by listener describe previously.
pEvt:MouseEvent mean this function is linked to a mouse event, in our case a simple click.

function AnimateToggle(pEvt:MouseEvent ):void
{
if (buttonAnimateStatue == false)
{
animate_sphere_clip.gotoAndStop(2);
buttonAnimateStatue = true;
}
else
{
animate_sphere_clip.gotoAndStop(1);
buttonAnimateStatue = false;
}
}

When the AnimateToggle is called we have to check if the animate mode is enable or disable inside flash that mean if the button is green or red because we do not already have feedback from 3dsMax. A simple if function can do that.

Here is the code translate in simple english with false = green and true = red:

On click If the button statue is green then turn the button to red and let the buttonAnimateStatue variable know the button is now red. Else the button is red turn the button to green and let the buttonAnimateStatue know the button is now green.

Now you know how the actual code is running inside flash. Let says to 3dsMax when to turn animate mode on On or off.

We are in flash we will stay in.
We have to add two lines inside our AnimateToggle toggle function. Those line are simple fscommand for the two cases of the if.

function AnimateToggle(pEvt:MouseEvent ):void
{
if (buttonAnimateStatue == false)
{
animate_sphere_clip.gotoAndStop(2);
buttonAnimateStatue = true;
fscommand(« AnimateToggle », « true »);
}
else
{
animate_sphere_clip.gotoAndStop(1);
buttonAnimateStatue = false;
fscommand(« AnimateToggle », « false »);
}
}

fscommand is to use like that: fscommand( CommandName, Argument);

Publicités

Laisser un commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion / Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion / Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion / Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion / Changer )

Connexion à %s

%d blogueurs aiment cette page :