Archive for category ‘Flex’

2009
05
May
Category: Flex

I’m not going to go into all of the properties of the Alert component. I am going to concentrate on the modal of the Alert. If you don’t know what a modal is, a modal is the translucent overlay underneath the Alert component. This can be customized using CSS, but many people simply overlook it. A basic example of an Alert looks like this:

Alert.show(“My Title”, “This is the message of the Alert component”);

This creates an Alert with default properties. So now lets play with it a little:

Alert{
modalTransparencyBlur: .4;
modalTransparency: 0.5;
modalTransparencyColor: red;
modalTransparencyDuration: 500;
}

Or you can get a little fancy and make the CSS global:

global{
modalTransparencyBlur: .4;
modalTransparency: 0.5;
modalTransparencyColor: red;
modalTransparencyDuration: 500;
}

2009
05
May
Category: Actionscript, Flex

It’s amazing how many people still don’t know about …rest. On the other hand I think I have only played with it but never actually used it. Basically what …rest does it allows you to pass, or not pass, parameters to a function. …rest parameters are passed just like all variables but in the function it will be an Array. Here is an example:


function myFunction(required:Number, ...optionalArgs):void
{
trace(required); // 1
trace(optionalArgs); // [2, 3, 4]
}
myFunction(1, 2, 3, 4);

The same functionality can be achieved a couple other ways. This next example you set a default value for each variables you pass. But this isn’t an undetermined number of arguments.


function myFunction(option1:Number=0, option2:Number=null):void
{
trace(option1); // 1
trace(option2); // null
}
myFunction(1);

Another way is similar to the way jQuery does it plugins. I don’t have an example of it but you pass all of your variables that you want in an object to the function. You can have any number of items in the object. Inside the function you have default values in case the variables aren’t passed. Then the variables that were passed overwrite the default values.

2009
04
May
Category: Actionscript, Flex, Links

I found a great resource today called the ActionScript Error Repository. Let’s say you are working in Flash, Flex, or AIR and you get a fun error message: Error #2032: Stream Error. You can search for the error code and it will explain the cause and how to fix it. It will give an example of bad that that will cause a similar error and it will also give you an example of good code that you can copy/paste.

2008
27
Jul
Category: Actionscript, Flex
Tags: ,

Let’s say you are loading in an image. The image is a little to big to fit in the area it is supposed to go in or maybe too small so you have to scale it up a little. The problem is, if you scale it, it will end up looking absolutely horrible. All is not lost. Adobe has an article by Ben Longoria on creating a component called SmoothImage which basically takes your image and once it is loaded in, it casts it as a bitmap in order to apply bitmap smoothing to it. Ok, granted, the article is a little dated. It was created April 6, 2007. It can be used as a basis for your own custom MXML component. Maybe you are the type of person that likes to use Actionscript components instead of MXML components. This basically does the same thing. Once the image is loaded in, it calls this function which casts it as a bitmap and applies smoothing.

[Updated July 28, 2008] Here is an example of an Actionscript classes bases example.