Ajax and Ajax Frameworks

I have been a developer for nearly 20 years and a web developer for about 10 years. Over the years, I have considered creating a blog to share the things I have learned (and am learning) about web design and development, but I never seemed to have the time. When I began learning about web development using Ajax and Ajax Frameworks, I decided to take the time to create this blog.

My intention for this blog is to focus primarily on Ajax Frameworks, but since web development requires knowledge of many technologies, I will occasionally write about things such as CSS, Javascript, PHP, MySQL, Flash, etc.

Lately, I have been using JQuery as my primary Ajax tool. Although I have used other Ajax Frameworks in the past (Dojo Toolkit, Yahoo! User Interface Library, Scriptaculous/Prototype), JQuery has thus far been the easiest to learn. In my first few posts I will discuss some of the JQuery Plugins that I have created. Some of these include: a plugin for Google Maps (jquery.imGoogleMaps), Form validation and submission  (jquery.imValidateForm), Page Populater (jquery.imPagePopulate), and a plugin to create lists (jquery.imList).

While I am still learning about some of the other Ajax Frameworks, I hope that what I have learned will be helpful to others. Just remember, “When you can pull the pebbles from my hand…”

Share

gpAS3Library – Part 2a: gpColorSchemes

Monday, June 21st, 2010

When I converted the gpShapes class from AS2 to AS3, I wanted to be able to create shapes with web 2.0 type color schemes, but I did not want to hand code each color scheme in an XML file every time that I wanted to use one. So I created the gpColorSchemes class by duplicating a set of web 2.0 styles that I have in Photoshop. The gpColorSchemes contains 34 preset color schemes that can be used with any Flash/ActionScript application. I named this post Part 2a because I created this class to be used with the gpShapes class (Part 2), but the gpColorSchemes class can be used separately from the gpShapes class.

Using gpColorSchemes With gpShapes

As stated in previous posts, the gpAS3Library uses XML data to dynamically create all UI within a Flash/ActionScript application.

The gpShapes class provides a number of options to create shapes within an application (see gpShapes). To use the gpColorSchemes class with the gpShapes class, simply remove the bgColor, borderColor, and borderSize options from the XML attributes and replace them with color scheme preset name of your choice.

<pStyles cType="shape1" nW="200" nH="100" shape_type="rectangle" corners="7,7,7,7" colorSchemeName="gpLimeGreen4" />
<pStyles cType="shape2" nW="200" shape_type="circle" colorSchemeName="gpPink3" colorSchemeReverse="true" />

colorSchemeName: The preset name of the of color scheme. I named these rather arbitrarily, but I tried to include the primary color and the number of gradient colors within the name. So gpPink3 has 3 hues of pink.

colorSchemeReverse: This option will tell the gpColorSchemes class to reverse the order in which the gradient is drawn.

Using the gpColorSchemes class separately

To use the gpColorSchemes class without the gpShapes class, instantiate the class using the color scheme name and the reverse option:

?View Code ACTIONSCRIPT
import flash.display.Sprite;
import com.grasshopper.utils.*;
 
var cScheme:gpColorSchemes = new gpColorSchemes('gpDarkGrey4', false);
var colorScheme:Object = cScheme.getColorScheme();

The getColorScheme method returns an object:

bgColor: The background color (or background multiple colors).
brdrColor: The border color.
brdrSize: The border size.
cAlphas: Fill alphas for each color (an array).
ratio: The gradient ratios.

Once I have these values, I can then create a shape:

?View Code ACTIONSCRIPT
var sp:Sprite = new Sprite();
addChild(sp);
sp.x = 100;
sp.y = 100;
 
var matrix = new Matrix();
matrix.createGradientBox(100, 50, Math.PI/2, 0, 0);
 
sp.graphics.beginGradientFill(GradientType.LINEAR, colorScheme.bgColor, colorScheme.cAlphas, colorScheme.ratio, matrix);
sp.graphics.lineStyle(colorScheme.brdrSize, colorScheme.brdrColor, 1.0);
sp.graphics.drawRect(0, 0, 100, 50);

That’s it. the gpColorSchemes class is fairly simple to use. You can download it as part of the gpAS3Library that is stored on GitHub. You can view a demo (and view each color scheme) on the demo section.

Share

CommentLuv badge