Archive for the 'Tips & Tricks' Category

Setting Up Flash Media Server Developer Edition For Newbs

A couple of weeks ago I had the honor of doing a little Flash Media Server work for the first time in my life. I had never worked with FMS nor did I know a lick about it, but I Googled it to a frenzy and found some useful little things. Without having access to Flash Media Server, which will cost you an arm and a leg, you can download the free developer edition to test your stuff locally. I normally work on a Mac but I had to do this on my PC laptop as I'm not very good with server-side stuff and I don't know how to run FMS developer edition on the Mac. Keep in mind, this is for newbies only and probably not the way that an FMS pro would set up their work, but this served me well in my trials and tribulations.

Anyway, you can grab the developer edition here. After you've got it downloaded, go ahead and go through the installation. The default installation directory is located at C:\Program Files\Macromedia\Flash Media Server 2. In there you will find an applications folder which is where all your projects will sit (and by projects I mean your .FLV file streams as you can put your working FLA anywhere on your computer).

The first thing you should do is create a folder inside of the applications folder that will hold your videos. I cleverly titled mine "videos". Inside of the videos folder, lets create a "streams" folder. This streams folder is the key as this is where your files will sit. Without this folder, nothing will function properly. GUARD IT WITH YOUR LIFE! Inside of the streams folder, I then created a folder for my actual streams to go into. I named mine "fmstest". Finally, in the fmstest folder, I have my FLV file, let's call it "dance.flv".

Now, to play this file, you'll need to establish a connection to the server. You'd do so like this:

Actionscript:
  1. var nc:NetConnection = new NetConnection();
  2. var ns:NetStream = new NetStream(nc);
  3.  
  4. vid.attachVideo(ns);
  5.  
  6. nc.onStatus = function($info:Object):Void
  7. {
  8.     if ($info.code == "NetConnection.Connect.Success")
  9.     {
  10.         playStream();
  11.     }
  12. };
  13.  
  14. function playStream():Void
  15. {
  16.     ns.play("dance");
  17. }
  18.  
  19. nc.connect("rtmp://localhost/videos/fmstest");

We have a couple of things to note here. The first thing to make sure of is that you have a video object on the stage with an instance name of "vid". This is the object we'll use to load our movie into.

The second is to note the path that you're connecting to in the NetConnection. I'm using localhost because we are running this locally, but you would replace this with whatever the IP or address would be to your server. Also in the path, notice that I do not define my applications folder. FMS will know that your files are in the applications folder by default. Lastly, the path avoids the streams folder. I've still yet to figure out why you don't need to define the streams folder in the connection path, but that's how it works and I wasn't about to question it. :)

Also note that when you write the filename of the file you are going to play, you do not add the .flv extension. Again, something that works and I have no explanation for.

This is the barebones that you need to run the video locally through FMS. I also found this Flash Media Server Eclipse plugin but I found it after I had finished up my FMS experiments and have yet to use it so use at your own risk.

I really wish I could offer more help on FMS but unfortunately my knowledge is limited to only the tests I have run. If you'd like some more information, two resources to research that were vital in my own experiments would be the "Ask an FMS Guru" series and FlashComGuru. Good luck!

Tags: , , , , ,

Allocate More Memory For Eclipse

The other day I had updated to the new FDT 3.0.1 build 1002 and I restarted Eclipse like you usually do when you make software updates. When I restarted Eclipse I got an error saying that I don't have enough startup memory and to change it in eclipse.ini to be set to -Xmx512m. Of course, my first reaction to this was "English please..." and I couldn't find the eclipse.ini file on my HD. After some swift Google work I found the solution for OSX.

Go to your Applications/eclipse folder (or wherever you installed Eclipse). Right click on Eclipse.app and go to Show Package Contents. From there, go into the Contents folder and then the MacOS folder. This is where eclipse.ini lives and you can open it up in a text editor. Change the line that reads -Xmx256m to -Xmx512m (just like the cryptic message told us!).

Basically, this allows 512MB to be used in the heap for the JVM which gives you more maximum memory to play with (wow that was nerdy, and no, I didn't make that up, I don't talk like that, I just found that on Google :P). Hope this helps!

Tags: , ,

Saving Eclipse/FDT Preferences

I usually make a new workspace for every project that I create in Eclipse/FDT and I have to save out my preferences (as you can see on the downloads page) because every time you create a new workspace it resets the preferences to the default. When I originally wanted to do this I found that it wasn't as easy as I expected so here is a quick rundown of exporting and importing your preferences in Eclipse.

To export, go to File > Export > General > Preferences. Type in your file name (I usually append a .prefs extension to mine, I think I saw that somewhere and just started to use that as a convention) and click Finish. The default settings should be fine.

To import, go to File > Import > General > Preferences. Click Browse to find your preferences file on your hard drive and then click Finish. Voila, all your preferences are loaded!

You'd think this would be as simple as a button in the preferences panel but it was kind of buried in this mess.

Tags: , ,

Find Corresponding Library Item

Download Find Corresponding Library Item.jsfl

This JSFL script will allow you to click on a movie clip on the stage, run the script, and you'll get the library item that clip is associated to. It's great for working on projects that you may not have made or if you don't remember which folder the clip is buried into.

For anyone that doesn't know how to install a JSFL script, or create one for that matter, simply go to File > New > Flash JavaScript File. Then, write your code and save it somewhere on your hard drive with a name you will recognize later (I named mine Find Corresponding Library Item.jsfl). Put this file in one of these folders (depending on your platform):

Windows:
boot drive\Documents and Settings\user\Local Settings\Application Data\Macromedia\Flash 8\language\Configuration\

Mac OS X:
Macintosh HD/Users/userName/Library/Application Support/Macromedia/Flash 8/language/Configuration/

Restart Flash and the command should now be available in the Commands menu up top. I found all this out a very easy way: it (along with a lot more about JSFL) is in the Flash help files. Just do a search for JSFL and there you go!

Tags: ,

fl.* Package .swc

Last night I was working on something in Eclipse/FDT 3 where I needed to use the fl.transitions package. I proceeded to import it and got an error saying that the fl.* package could not be found. After some investigation I realized that I needed an .swc file for the fl.* package but I don't have Flex Builder so I couldn't create one. This is where my good friend Samuel Agesilas stepped in and created one for me. The thing is, if you go ahead and add the folder that is in Applications/Adobe Flash CS3/Configuration/ActionScript 3.0/Classes (which is where the fl.* package sits on a Mac) to your Linked Libraries in FDT, you're going to get a duplicate of the playerglobal.swc that is already in your Linked SWCs in Eclipse. That is really messy to me as I like to keep my workspace as tidy as possible so Sam making that .swc for me really helped me out. I've posted the .swc on the downloads page or you can get it directly from here.

Tags: , , ,

Automatically Declare Stage Instances

I was doing some work today in Eclipse/FDT 3 and I kept running into something that I wasn't expecting. In FDT 1.5 I would normally create a movie clip symbol in the Flash IDE and maybe have more clips inside of it, like say a bg_mc and a title_txt. Then, in FDT, I would define the variable at the top of my class so that I could use it in the code later on:

Actionscript:
  1. public var bg_mc:MovieClip;

Now, coming over to AS3 and FDT 3, I expected the same behavior. I went about my business in defining my variable at the top of my class and then using it later on in the class somewhere. I went back to Flash to compile the project and got the following in the output panel:

1151: A conflict exists with definition bg_mc in namespace internal.

After some quick fiddling around and Google searching I realized the problem. If you don't want FDT 3 to give you errors and want to be able to declare your instances in the class itself, go into File > Publish Settings > Flash > Settings and uncheck "Automatically declare stage instances". This will prevent the Flash IDE from throwing the error in the output panel and will make Eclipse/FDT happy because you aren't trying to use an instance that you never defined. YAY!

Tags: , ,

« Previous Page