PDA

View Full Version : [MX] Cannot acces to variable i'v load in my own component


flapflap
10-24-2003, 11:36 AM
Hi,

I've juste create a component that create a textfield with a rounded rectangle draw behind...

It's works well with a text put in the variable interface of the component but now I want to load the text from a external text file (.txt)

Here's my code...

#initclip
Bulle = function () {
this.creerbulle();
};
Bulle.prototype = new MovieClip();
Object.registerClass("idBulle", Bulle);
Bulle.prototype.creerbulle = function() {
this.objData = new LoadVars();
this.objData.ignoreWhite = true;
this.objData.load(this.lefichier);
this.objData.obj = this;
var letexte = eval("this.objData."+this.lavariable);
trace(this.lavariable+" : "+letexte);
var monFormat = new TextFormat();
with (monFormat) {
font = this.texte_police;
size = this.texte_taille;
multiline = true;
bold = this.texte_gras;
italic = this.texte_italique;
embedFonts = true;
align = this.texte_alignement;
color = this.texte_couleur;
}
// Attributs du texte de la bulle
// marge = La marge entre le texte et la bulle
var marge = this.marge;
var arrondi = this.bulle_arrondi;
var cible = "clip"+this._name;
_root.createEmptyMovieClip(cible, i++);
// La largeur du texte ll est définie pas l'utilisateur
// La longueur du texte
var longueur_texte = letexte.length;
// Alors là...
var cali = (this.ll-marge)/7;
// Apparement ceci fonctionne
// Regle n°1 : Si ça marche, ne touche à rien même si tu ne sais pas pourquoi...
var hh = (longueur_texte/cali)*marge+marge;
with (eval("_root."+cible)) {
createTextField("monTexte", 3, 0, 0, this.ll, hh);
// creation du texte
with (monTexte) {
wordWrap = true;
border = false;
autoSize = true;
selectable = this.texte_selectionnable;
html = true;
htmlText = letexte;
// On applique le format
setTextFormat(monFormat);
}
// recupère la hauteur de champ de texte
// nn est la hauteur de la bulle
// ll2 sa hauteur
var nn = monTexte._height+2*marge;
var ll2 = this.ll+marge;
// la bulle
createEmptyMovieClip("fond", 2);
with (fond) {
// couleurs du dégradé (on laisse tomber pour l'instant)
// couleurs = [0xFFF4A6, 0xFFC54A];
// alphas = [100, 100];
// rapports = [0, 0xFF];
// matrice = {a:0+800, b:0, c:0, d:0, e:0+400, f:0, g:0+50, h:0+50, i:1};
// beginGradientFill("radial", couleurs, alphas, rapports, matrice);
// Le fond couleur et transparence
beginFill(this.bulle_fond_couleur, this.bulle_fond_transparence);
// couleur, épaisseur de bordure
lineStyle(this.bulle_trait_epaisseur, this.bulle_trait_couleur, this.bulle_trait_transparence);
// arrondi = rayon de l'arrondi
// On trace la bulle
moveTo(0, arrondi);
lineTo(0, nn-arrondi);
curveTo(0, 0+nn, arrondi, nn);
lineTo(ll2-arrondi, 0+nn);
curveTo(ll2, nn, ll2, nn-arrondi);
lineTo(ll2, arrondi);
curveTo(ll2, 0, ll2-arrondi, 0);
lineTo(arrondi, 0);
curveTo(0, 0, 0, arrondi);
endFill();
}
// On place le texte et la bulle par rapport au clip
fond._x = this._x;
fond._y = this._y;
monTexte._x = this._x+marge;
monTexte._y = this._y+marge;
}
};
#endinitclip


The trace give me only a (name : )
And when I look with the deboger the variable are shown In my component clip instance...

Arrgh I've look some component that load variable from a outside text file but the code is very complicate for me and for a simple loadvariables...

Please help me.

Sorry for my bad english I'm french

hangalot
10-27-2003, 10:25 AM
plz place your code inside [ as ] [ /as ] tags to make it human readable.

flapflap
10-27-2003, 10:47 AM
Finally it works... In my component.

But I cannot load variable in my live preview...