Archive for the 'Classes' Category

Box3D Class for Papervision3D

Reynaldo May 20th, 2008

Hi All!

Today I found myself with the need to create a cube, but in my case, I wanted to have all the sides of the cube treated as if they were planes. Also, I wanted to have more control over the inner workings of my cube hence the birth of the Box3D class.
All this class does is create a cube out of 6 planes primitives. It works very much like the EnhancedPlane class mentioned in an earlier post .

This is the result:

This movie requires Flash Player 9

You can get the source and example files here!

Tags: , , , , , ,

EnhacedPlane and PlaneGrid PV3D classes

Reynaldo May 4th, 2008

Hi!

It’s been a really long time since I posted anything and there are a ton of reasons for that including moving to New York, getting a new job and finding a new place. But you can trust that I will be posting on a more regular basis from now on ;)

I decided to come back with a couple of classes I cerated for use with the Great White branch of PaperVision3D.

EnhancedPlane
This class allows you to create a Plane primitive with two dynamic faces to which you can add different materials. In other words, it’ll have two unique sides!

Use:

var frontMaterial:ColorMaterial = new ColorMaterial(0x00FFFF);
var backMaterial:ColorMaterial = new ColorMaterial(0xFFFF00);

var materials:MaterialsList = new MaterialsList({front:frontMaterial,	back:backMaterial});

var myEnhancedPlane:EnhancedPlane = new EnhancedPlane(materials, 250, 250, 16);
this.scene.addChild(myEnhancedPlane);

The first argument the class accepts is a MaterialList with the “front” and “back” materials specified. After that, the class accepts 4 optional arguments: width, height, segments and name.

PlaneGrid
This class allows you to create a grid of (same width, same height) planes real easily!

Use:

var planesArray:Array = new Array();
for(var a:Number = 0; a<18; a++){
     var material:ColorMaterial = new ColorMaterial(0x00FFFF);
     var plane:Plane = new Plane(material, 320, 480);
     planesArray.push(plane);
}
var planeGrid:PlaneGrid = new PlaneGrid(planesArray, 6, 3, 5, 320, 480, "left");
this.scene.addChild(planeGrid);

The first argument is an array holding the planes you would like to be in the grid, the rest of the parameters are columns, rows, spacing, plane width, plane height, and alignment respectfully. The alignment can either be: “left”, “right” or “center”.

Both of the classes extend the DisplayObject3D so you can treat them like any other 3D display object/primitive.

You can get the classes here

[EDIT]

Thanks to my good friend Matt, I fixed a small error in the the EnhancedPlane class. Thanks dude! I also uploaded an example on how to set up your EnhancedPlane to have interactivity on both sides. You can find the example here.

Managing Context Menus in AS3 with the Reyco1 AS3 Tools

Reynaldo February 3rd, 2008

Hi all:

A context menu is a menu for a display object that pops up when right-clicking on it; also called a short-cut menu.

Using the Reyco1 Framework makes managing context menus really easy and very fast. First we need to import the necessary files:

1
2
import com.reyco1.manager.ContextMenuManager;
import com.reyco1.events.ContextMenuManagerEvent;

Now we create two instances of the ContextMenuManager class. One for the stage and one for a box movieclip on the stage.

3
4
var stageCM:ContextMenuManager = new ContextMenuManager(this);
var boxCM:ContextMenuManager = new ContextMenuManager(mcBox);

Now, using the addMenuItem method, we add a few menu items to each instances of the ContextMenuManager we just created. The addMenuItem method accepts 3 arguments: a string to represent the menu label, a boolean specifying if there should be separator before the menu item or not and another boolean specifying if the menu item is enabled.

5
6
7
8
9
stageCM.addMenuItem("Hello World!");
stageCM.addMenuItem("Hello Moon!");
stageCM.addMenuItem("Hello Star!", true);
 
boxCM.addMenuItem("Move to 0,0")

We then have each of the ContexMenuManager instances listen to the ContextMenuManagerEvent.MENU_SELECTED event which is fired each time a context menu item is selected.

10
11
stageCM.addEventListener(ContextMenuManagerEvent.MENU_SELECTED, handleMenuSelection);
boxCM.addEventListener(ContextMenuManagerEvent.MENU_SELECTED, handleBoxMenuSelection);

Finally, we create the event handler functions. Every ContextMenuManagerEvent event carries along with it a params object. This object contains two values “label” and “target”.

12
13
14
15
16
17
18
19
20
21
22
23
24
function handleMenuSelection($event:ContextMenuManagerEvent):void
{
	output.text = "the selected menu is: "+$event.params.label
}
 
function handleBoxMenuSelection($event:ContextMenuManagerEvent):void
{
	if($event.params.label == "Move to 0,0"){
		output.text = "moving "+$event.params.target.name+" to 0,0.";
		$event.params.target.x = 0;
		$event.params.target.y = 0;
	}
}

That’s it! There are other properties and methods that you can use, but basically these are all you need to get started. The sample fla can be found in the samples folder of the Reyco1 Framework.

Reyco1 AS3 Tools, Release 1

Reynaldo February 2nd, 2008

Hi All:

I added a few classes to the framework and decided that it was time to let it loose out into the wild. As I stated before, the classes in the framework are a compilation of classes I had written in AS2 and had ported over to AS3 along with others.

Out of the whole framework, my favorite classes are:

ContextMenuManager
Found in the “manager” package.
This class allows you to easily add and manage Right Click context menu’s to any display object, including the stage.

PayPalCart
Found in the “tool” package.
The PaypalCart is a class which allows you to build and customize your very own flash PayPal shopping cart.

QueryUtil
Found in the “util” package.
Using the new Dictionary class in AS3 along with the ExternalInterface class, this class allows you to grab any and all parameters in the url of the html page holding your swf.

FullBrowserExtension
Found in the “extension” package.
Any document class that extends the FullBrowserExtension is full browser ready and all you need to do is just have a bitmap tile in the library with “Tile” as the class name (linkage id).

These are just a few of the classes in the ever growing framework as I will be adding more and more in the near future. Some of the classes in the pipeline for the following weeks are a “FormValidator” which will use regular expressions to make sure the entries in a field are valid, a “LayoutManager which will be responsible the visual organization of your sites/application and a “VideoController” for easily controlling flv files.

You can see the documentation at http://www.reynaldocolumna.com/Reyco1FrameworkDocumentation and you can grab the files using subversion from http://reyco1.googlecode.com/svn/trunk.

There are examples for all the major classes in the “samples” folder. I would start there and crack open the fla’s and document files to see how to get started.

ENJOY!

Tags: , ,

Reyco1 Framework almost ready!!

Reynaldo January 30th, 2008

Hi All:

I have been making lots of cool additions to the framework and it should be out within the next week or so!

Some of the new classes are:

  • QueryUtil: places all the url parameters into an easy to manage object
  • RSSParser: nice little class which reads rss feeds, formats them for display
  • DepthManager: manages all the depths in a display object
  • PayPalCart: this is my favorite! Its a sweet little PayPal api, really easy to use.

Finally I was able to get the ASDoc command line tool in Flex working and have the documentation ready and good to go. I still have to add a few other classes but stay tunned!

Tags: , , ,

Next »

  • Friends

  • Props

  • Donations

  • website counter
  • Archives

  • Feedburner