Hello, folks!
I have a hard difficult using classes in Flash. The question is: How can I attach movie clips through classes ?
For example: I have a class to do a clip like an excel table:
So, I have a Cell class (Celula.as), a Columm (Coluna.as) and the final table (Tabela.as).
Here they are:
Cell:
class Celula {
private var superID:Number;
private var grupo:String;
private var texto:String;
private var conteiner:MovieClip;
function Celula() {
superID = new Number();
grupo = new String();
texto = new String();
conteiner = new MovieClip();
}
// setters:
public function setDataProvider(id:Number, g:String, t:String):Void {
this.superID = id;
this.grupo = g;
this.texto = t;
trace("superID: "+this.superID + newline + "grupo: "+this.grupo + newline + "texto: "+this.texto + newline + "--------------");
}
// getters:
public function getSuperID():Number {
return this.superID;
}
public function getGrupo():String {
return this.grupo;
}
public function getTexto():String {
return this.texto;
}
private function getClip():MovieClip {
var mc:MovieClip = this.conteiner.attachMovie("celula_mc", "celula"+superID, superID);
mc.rotulo_txt.htmlText = this.getTexto();
return mc;
}
}
Columm, wich imports the Cell class…
import Celula;
class Coluna {
private var grupo:String;
private var celula:Celula;
private var arrCel:Array;
private var conteiner:MovieClip;
function Coluna() {
this.grupo = new String();
this.celula = new Celula();
this.arrCel = new Array();
}
public function setColuna(g:String, no:XMLNode):Void {
this.createColuna(g,no);
}
public function getCelulas():Array {
return this.arrCel;
}
public function getCelulaAt(i:Number):Celula {
return this.arrCel*;
}
public function getGrupo():String {
return this.grupo;
}
public function getClip():MovieClip {
return this.conteiner;
}
private function createColuna(grupo:String, noColuna:XMLNode):Void {
var count:Number = noColuna.childNodes.length;
for(var i:Number = 0; i < count ; i++){
var celula:Celula = new Celula();
celula.setDataProvider(i, grupo, noColuna.childNodes*.childNodes[0].firstChild.nodeValue)
arrCel.push(celula);
this.conteiner.attachMovie(this.arrCel*.conteiner, "cel"+i, (i));
}
}
}
And, finally, the Table wich imports the Coluna.as Class
import Coluna;
class Tabela {
private var numColunas:Number;
private var larguraMaxima:Number;
private var arrColunas:Array;
private var conteiner:MovieClip;
private var coluna:Coluna;
//
// construtor:
function Tabela() {
numColunas = new Number();
larguraMaxima = new Number();
arrColunas = new Array();
coluna = new Coluna();
}
//
// setters:
public function setTabela(noXML:XMLNode):Void {
var totalColunas:Number = noXML.childNodes.length;
this.numColunas = totalColunas;
this.conteiner = _root.createEmptyMovieClip(noXML.attributes.nome, _root.getNextHighestDepth());
for (var i:Number = 0; i < totalColunas; i++) {
var cl:Coluna = new Coluna();
cl.setColuna(noXML.childNodes*.attributes.grupo, noXML.childNodes*);
this.arrColunas.push(cl);
var mc:MovieClip = this.conteiner.attachMovie("celula_mc", "col"+i, this.conteiner.getNextHighestDepth());
}
}
public function attach():Void {
_root.createEmptyMovieClip("tabela", _root.getNextHighestDepth());
}
public function setLargMax(w:Number):Void {
this.larguraMaxima = w;
}
//
// getters:
public function getNumColunas():Number {
return this.numColunas;
}
public function getTabela():Tabela {
return this;
}
public function getArrColunas():Array {
return this.arrColunas;
}
public function getConteiner():MovieClip {
return this.conteiner;
}
}
So, my problem is: I do not know how to insert the Celula.as movieClip into the Coluna.as movieClip and insert the Coluna.as movieClip into the Tabela.as object.
Some one can help me with this?
Sorry for my poor english.
Tks!
pp