PDA

Volledige versie bekijken : textformat


jonnekke
%Europe/Berlin %681 %2008, 16:21
Hallo,

ik creeer op de volgende manier een txtvlak in mijn swf:


this.createTextField("titel",903,60,510,290,40);
this["titel"].html = true;
this["titel"].type = "dynamic";
this["titel"].border = false;
this["titel"].background = false;
this["titel"].multiline = true;
this["titel"].wordWrap = true;
this["titel"].autoSize = true;
this["titel"].antiAliasType = "advanced";

var my_fmt:TextFormat = new TextFormat();
my_fmt.color = 0xff0000;
my_fmt.underline = false;
my_fmt.font = "Verdana";
my_fmt.leading = 8;
my_fmt.size = 10;

titel2 = "<b>Dit is de Titel!</b>";

this["titel"].htmlText = this.titel2;
this["titel"].setTextFormat(my_fmt);


Nu wil ik aan deze tekst een link koppelen.
Echter is dit geen URL maar een "verwijzing in flash"

Hoe koppel ik de volgende functie aan deze link: gotoPage(1, true); ??

Dit heb ik gevonden: my_ft.url
maar dit is voor echte url (www.site.com)

_j

Jan
%Europe/Berlin %697 %2008, 16:43
asfunction...
var titel2:String = "<a href=\"asfunction:gotoPage,1,1 \"><b>Dit is de Titel!</b></a>";
this["titel"].htmlText = titel2;
function gotoPage(str:String)
{
trace("gotoPage:" + str);
var args:Array = str.split(",");
trace("frame:"+ Number(args[0]));
trace("flag:" + Boolean(args[1]));
}
En dus ook je Booleans omvormen van true en false naar 1 en 0 want:
trace(Boolean("true")); // true
trace(Boolean("false")); // true
Je kan ook checken op de String "true" of "false" met een if:
if(args[1]=="true")//String
{
trace (true);//Boolean
}
else if(args[1]=="false")//String
{
trace(false);//Boolean
}


Wat is hier het nut van? :S
this.createTextField("titel",903,60,510,290,40);
this["titel"].html = true;
this["titel"].type = "dynamic";
this["titel"].border = false;
this["titel"].background = false;
this["titel"].multiline = true;
this["titel"].wordWrap = true;
this["titel"].autoSize = true;
this["titel"].antiAliasType = "advanced";
Dat kan toch gewoon met:
this.createTextField("titel",903,60,510,290,40);
titel.html = true;
titel.type = "dynamic";
titel.border = false;
titel.background = false;
titel.multiline = true;
titel.wordWrap = true;
titel.autoSize = true;
titel.antiAliasType = "advanced";
Of nog korter:
this.createTextField("titel",903,60,510,290,40);
with(titel)
{
html = true;
type = "dynamic";
border = false;
background = false;
multiline = true;
wordWrap = true;
autoSize = true;
antiAliasType = "advanced";
}

Groeten,
Jan