PDA

View Full Version : [AS3] simple pathing question..


caseyctg
12-12-2008, 10:39 PM
ok, I have built a datagrid, and I am using a custom cell renderer. The cell renderer is located within the folder along with the FLA. Here is how I am referencing it...which works:

speakingListing_dg.setStyle("cellRenderer", CustomCellRenderer);

what I am trying to do is clean up my folder structure a bit. So I created a folder "as" to place my CustomCellRenderer.as file into. BUT i am having problems referencing the file. I've tried:

speakingListing_dg.setStyle("cellRenderer", as.CustomCellRenderer);

speakingListing_dg.setStyle("cellRenderer", as/CustomCellRenderer);

and

speakingListing_dg.setStyle("cellRenderer", as\CustomCellRenderer);

anyone know how I would reference the .as packaged file??

caseyctg
12-12-2008, 10:44 PM
p.s., here is the code in the CustomCellRenderer.as file

package {
import fl.controls.listClasses.CellRenderer;
import flash.text.TextFormat;
import flash.filters.BevelFilter;
import flash.filters.GlowFilter;

public class CustomCellRenderer extends CellRenderer {
public function CustomCellRenderer() {
var format:TextFormat = new TextFormat("Verdana", 10);
setStyle("textFormat", format);
}
}
}

caseyctg
12-23-2008, 07:30 PM
this was an easy solution:

I had two problems.

A) I shouldn't have been using "as" as a folder name, just in case it is used in internal namespace. So I changed the folder name to custom. So the folder structure is:

Root/com/custom/CustomCellRenderer.as

B) I needed to add an import statement to the .fla, and the .as file.

CustomCellRenderer.as:
package com.custom
{
import fl.controls.listClasses.CellRenderer;
import flash.text.TextFormat;

public class CustomCellRenderer extends CellRenderer {
public function CustomCellRenderer() {
var format:TextFormat = new TextFormat("Verdana", 10);
setStyle("textFormat", format);
}
}
}

and to the beginning of the .fla actions:
import com.custom.*