Sunday, April 14, 2013

Getting Flash to Talk to UDK - part 2

I've been planning out and outlining this for a while, not that it will make it much better, but I've spent so much time on projects, that I haven't had a chance to write out all the steps. I ended up breaking the steps out even further.


The Flash File

Planning Ahead -



It's always a good idea to know what you want to do already. Your GDD should have very precise requirements out of the HUD that you'll be working with, and as such, you can better plan, and prepare for the set up of the Flash file with a good GDD or goal in mind.

Now, my current project involved creating a HUD that would keep track of inventory, as well as display status messages, be the main menu and be an alternative to player interference and surprise. 

Animation -


It is best to have each MovieClip in the Flash file have its own animation. You'll be calling that animation using: with.

with (ExampleMovieClip)
{
     ExampleMovieClip.gotoAndPlay("ExampleMovieClipPlay");
}

To call a movie object inside a movie object:

with (ExampleMovieClip.SecondMovieClip)
{
     ExampleMovieClip.SecondMovieClip.gotoAndPlay("ExampleMovieClipPlay");
}

This is what you will include in any function that will require animating ExampleMovieClip or any movie clip you make. Note that "ExampleMovieClip" is the name of the instance of a movie clip, and that "ExampleMovieClipPlay" is a label inside that movie clip.

This code is telling Flash to find that specific instance of a movie clip, and find the label "ExampleMovieClipPlay" and to play that movie clip from there.

The way you use this depends on the situation, so I'll bring up what I did.

1) Scary Face

The concept is simple. Have a scary face show up when they don't expect it.

Execution: create a movie clip. Label the instance of it (click on the movie clip after placing it), as RightFace (or whatever, I used RightFace, to keep track of where it was). 




On the first frame put the actionscript

stop();


Change the alpha to 0 in the beginning, animate it however you want (start from the 2nd frame, leave the first frame as a stop with alpha 0. Have the alpha reset to 0 at the end of the animation.




Setting up for the function: Label the 2nd frame of animation as something that you will use for the other animations like this one, such as, "Scare" or "Play".






Create a function:

function ScaryFace()
{

     with (RightFace)
     {
          RightFace.gotoAndPlay("Scare");
     }

}

Now whenever you want to use ScaryFace(), just call it, and it will animate! You can call it from UDK, from a key press, randomly through a timer! Whatever!

This technique will be used throughout the project, so keep it in mind!

No comments:

Post a Comment