I ran into this again today and had to think it out, so figured it might help some folks.
If you are looking for the fl.controls.ComboBox or other fl.controls code in Flash Builder, you will find it conveniently absent. The easiest way I have found to make available the code for the controls I want to use in a Flash project built in Flex Builder is to create a Components.fla file and then compile it out to a .swc. You can then include the
1. Create an empty flash file called Components.fla
2. In the publish settings of your flash file, click the Flash tab, then check the Export SWC box.
3. Drag the components you want to use in your project to the stage (don’t worry, you can come back later and add more if you need to).
4. Save your file, then File>Publish.
5. In Flex Builder, right click on your project folder and go to Properties.
6. Click Actionscript Build Path on the left column, then the Library Path tab.
7. On the library path tab, click Add SWC and browse to the SWC file you just created.
Poof, now you have Flash Component code available in your Flex environment for code hinting, etc.
So many people have this wrong, I have to post something right about this. I’m going to show you the example below and explain to you why it’s WRONG, and the simple change in logic required to make true random number generation happen for you.
THIS IS WRONG
var myRandomNumber:Int = Math.floor(Math.random()*(High-Low))+Low;
For example, if you wanted a number between 2 and 10:
var myRandomNumber:Int = Math.floor(Math.random()*(10-2))+2;
You will never get 10 as an answer.
Here is why:
The Math.random() function in AS3 returns a pseudo-random number, where 0 <= n < 1. This means you will never get 1 as your result of calling Math.random(). Without 1, you will never get any number greater than 10 to round down to 10. Everybody and their mom has the above formula as the 'correct' way to get a ranged integer number out of the Math.random() function.
So why not use Math.ceil, or Math.round? Math.ciel will give you the same problem, but at the beginning of your number range. Math.round sounds great, except you'll be left with 50% less chances to receive either your top or bottom number.
So what's the solution?
Easy. Add 1 inside your Math.floor call before you multiply with your random number. Then everything will have the same odds.
THIS IS RIGHT
var myRandomNumber:Int = Math.floor(Math.random()*(1+High-Low))+Low;
Think about it. Use it. And if there is a better way to do this, let me know. If I’m wrong, please tell me. I love to know when I’m wrong.
Why this isn’t set up to work by default for Actionscript Projects is beyond me, but I found a need to use the fl.color Class this week in Flash and it sure was a challenge to get the fl.* libraries to work natively within Flex Builder 3 for Mac.
Here is how you do it:
1. Right click on your project folder in Flex, click “Properties.”
2. Click on the “Actionscript Build Path” menu item.
3. Click “Add Folder”
4. Navigate to: /Applications/Adobe Flash/Common/Configuration/Actionscript 3.0/projects/Flash/src/
5. Click “Choose” to select the /src/ folder and “Ok” to add this to your source path.
You can do the same thing for Windows based Flex Builder as well, the file path should be similar to this:
C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\ActionScript 3.0\Classes
P.S. Speaking of fl.color, fl.color.setTint() is a great trick to tinting without having to deal with the more complex colorTransform class.
Apparently Internet Explorer is REALLY smart. It knows that .Gadget files are REALLY .zip files. And since by default the Apache web server doesn’t know what kind of MIME headers to send for a .Gadget file, it doesn’t send any and IE has to figure it out. (More than likely IIS takes care of this automagically, so this fix is for all Apache based sites)
This generally results in a customer downloading a .zip file that they have no idea what to do with.
And apparently there isn’t much if any documentation on how to get around this problem. It is easy.
Create an .htaccess file, put it in the root of your website folder, and add the following line of text:
A few weeks ago I was working on an interesting text typing widget for our new website (that isn’t up yet, still in the works). I came to find that there was a Keyboard.CharCodeStrings Array Constant in the AS3 Language reference–but it was only available within the AIR 1.0 runtime. Bummer.
So like many folks out there, I needed to roll a homegrown solution to match up CharCode result numbers with their character counterparts. Essentially a singleton class that you can use when you catch your event and turn the resulting CharCode into a literal string character.
If this may be useful to you, there is a download link below. I built this to do what I needed for the project I was working on, so the character codes returned are for US English–but you could easily substitute another language by using the included sample app and replacing the characters. If you do set this up for use in another language feel free to shoot me the file and I will link it here.
(Hint, when testing from within the Flash IDE turn off Keyboard Shortcuts when you run your movie to test or the preview window may not receive keyboard input. It is in the Control menu when your swf is playing.)
There is an interesting article up today about what major changes will be made in the upcoming release of PHP V6. Most of the changes won’t affect anybody developing with the current standards established with recent PHP V5 releases
Namespaces – Should be great for integrating libraries with third party code.
Soap – Now Standard instead of an optional compile-in feature.
XML – Now Standard instead of an optional compile-in feature.
These items are going to make a lot of standard open-source apps fall apart.