PDA

View Full Version : class instantiation problem


fdqepd
03-25-2008, 05:48 PM
hello people, back with a new one

i have a class ProjectViewer that loads instances of the Project class to show some thumbs.

i get the thumbs rendered on stage but not on the DisplayObjectContainer i tell i to, how do i fix this?, i need it to check if the thumb is alredy there.

here is te AS

package {

import flash.display.*;
import flash.events.*;
import flash.text.*;

dynamic public class Project extends Sprite {

public var aThumb:Sprite;

private var target:Sprite;

private var myGUI:GUI;

public var pId:Number;
public var pName:String;
public var pName_tf:TextField;
public var pDate:String;
public var pClient:String;
public var pCount:Number;

public var pFace0:String;
public var pFace1:String;
public var pFace2:String;
public var pFace3:String;
public var pFace4:String;
public var pFace5:String;

public var pImgURL:String;
public var pDescription:String;
public var pExtLink:String;

public function Project() {
//constructor


}

public function newProject(myId:Number, myName:String, myCount:int, trgt:Sprite, count:Number){
this.pId = myId;
this.pName = myName;
target = trgt;
myGUI = new GUI();
pCount = count;
buildThumb();
}
public function buildThumb():void {
aThumb = new Sprite();
aThumb.y = pCount*20;
pName_tf = new TextField();
pName_tf.selectable = false;
pName_tf.autoSize = TextFieldAutoSize.LEFT;
pName_tf.defaultTextFormat = myGUI.getFormat('regular');
pName_tf.embedFonts = true;
pName_tf.text = pName;
aThumb.addChild(pName_tf);
target.addChild(aThumb);

}
}

}

parts of ProjectViewer:

public var projectMother:Project;
public var thumbs_holder:Sprite;
public var thumbsArray:Array;



projectMother = new Project();
thumbsArray = new Array();
thumbs_holder = new Sprite();
holder.addChild(thumbs_holder);


addString = activeKeywords.toString();
addRegExp = new RegExp(addString.replace(/,/g, "|"));
addList = new XMLList;
addList = projectsData.children().(addRegExp.test(attribute( 'keywords')));
//trace("addList length(): " +addList.length());
for (var p:int = 0; p< addList.length(); ++p) {
checkIfThere(addList[p].attribute('id'));
if (isThere) {
trace("Project id: " + addList[p].attribute('id') + " alredy there");
trace("");
} else {
var newThumb:Sprite = new Sprite();
newThumb.name = "thumb"+addList[p].attribute('id');
projectMother.newProject(addList[p].attribute('id'), addList[p].NAME, projectCount, newThumb, projectCount);
thumbs_holder.addChild(newThumb);
thumbsArray.push(newThumb);
projectCount ++;
trace("Added id: " + addList[p].attribute('id') + " -- tmpProject: " + newThumb);
trace("thumb_holder children: " + thumbs_holder.numChildren);
trace("");
}
}

any help at all would be great!!