Monday, April 15, 2013

Getting Flash to Talk to UDK - part 2 - addendum

You may have noticed how I set up the movie file in the previous part. This is just to clear up some of the set up.

A) Create layers for each element of your UI. This will allow you to animate them, and lock them down later as you finish them.

B) Create a layer for actionscript. This makes it easy to find, and easy to label without arrows and what not getting in the way. I usually label it "as" in the movies inside the file, and "as_root" for the main one in the file.

C) Unless you want something to play or loop for ever, put a quick stop(); on the first line.

We're going to move on, implementing the one singular feature for now. Then we'll come back and look at spawning in new things.

I figured that you have some experience with Flash, so I'll assume you understand this. If you have questions, please ask it here.

If you have suggestions to clarify something or a better way of doing something, then please do so in the addendum. Thank you.

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!