Hello all,

I'm try'n to extract data from a glyph to create a pathAnimation in
the shape of given character.
What I did so far is mostly based on code from the vectorText.as,
Edge.as and a few other related classes.
Arial font is imported using a swf file.

It seem to me as if I am missing a vital part. The outcome of the
animation is not at all related to the character in question, not even
if ya drunk.

Maybe I don't understand what a glyph is correctly. Shouldn't the sum
of the edges of a glyph for a given character 't' be a path?
Am I looking at this  the wrong way? Any pointers?



private function CreateLetterAnimations(message:String,
animObject:Object3D):void
{
        var pArray:Array = new Array();
       //the line below should return the vector array representing a
't' in this case
        pArray =
CreateLetterPath(VectorText.getFontDefinition("Arial").glyphs['x]);
       //then create a path animation. From here the code should be
ok, I use it in other parts, no trouble
        var pInit:Object = {
                duration:2000,
                lookat:false,
                aligntopath:true,
                targetobject:null,
                offset:new Vector3D(0,0,0),
                rotations:null,
                fps:24,
                easein:false ,
                easeout:false
        };
        var myPath:Path = new Path(pArray);
        myPath.smoothPath();
        this.pathanimator = new PathAnimator(myPath, animObject, pInit);
        this.pathanimator.loop = false;
        this.pathanimator.addOnCycle(onPathanimatorCycle);
        this.pathanimator.update(0.0);
}


//this is part of the vectorText.write() methode
public function CreateLetterPath( shape:ShapeRecord, scale:Number =
1.0, offsetX:Number = 0.0,
                                                offsetY:Number =
0.0):Array//:Path
{
        var pathArray:Array = new Array();
        var elems:Array = shape.elements;
        var elemNum:int = -1;
        var elemLen:int = elems.length;
        var dx:int = 0;
        var dy:int = 0;
        scale *= .05;

        while ( ++elemNum < elemLen ) {
                if ( elems[elemNum] is Edge )  {
                var edge:Edge = elems[elemNum];
                        if ( dx != edge.sx || dy != edge.sy ) {
                                if (edge.type==0){ //curve has center point data
                                        pathArray.push(new 
Vector3D(offsetX+edge.sx * scale, offsetY +
edge.sy * scale, 0));
                                        pathArray.push(new 
Vector3D(offsetX+edge.cx * scale, offsetY +
edge.cy * scale, 0));
                                        pathArray.push(new 
Vector3D(offsetX+edge.x * scale, offsetY +
edge.y * scale, 0));
                                }
                                else{//line has no center point data, calculate 
 its value from
start & end point
                                        pathArray.push(new 
Vector3D(offsetX+edge.sx * scale, offsetY +
edge.sy * scale, 0));
                                        pathArray.push(new Vector3D(
                                                ((offsetX + edge.sx * scale) + 
(offsetX + edge.x * scale))/2,
                                                ((offsetY + edge.sy * scale) + 
(offsetY + edge.y * scale))/2,
                                                0));
                                        pathArray.push(new Vector3D(offsetX + 
edge.x * scale, offsetY +
edge.y * scale, 0));
                                }
                        }
                        dx = edge.x;
                        dy = edge.y;
                }
                else if ( elems[elemNum] is FillStyle )
                {
                }
        }
        return pathArray;
}

Reply via email to