ciao,
ho scaricato un movie che funziona correttamente se aperto su un semplice filmato al livello 0. Però se questo filmato lo carico su un altro livello (nel mio caso il 10) non funziona più. Vi posto il codice:
function charPositions(tFormat,str,depth){
_root.createTextField("temp",depth,0,-300,100,400)
temp.autosize=true
temp.embedFonts=true
temp.setNewTextFormat(tFormat)
var arr=[]
temp.text=str
var totalWidth=temp.textWidth
for(var i=0;i<str.length;i++){
temp.text=str.substr(i)
arr[i]=totalWidth-temp.textWidth
}
return arr
}
function setUpText(str,forma,lineLength){
var positions=charPositions(forma,str,2000)
var currentLine
var lineHeight=forma.getTextExtent(str).height
var finalPositions=[]
for(var i=0;i<positions.length;i++){
if(positions[i]>(lineLength+subtracta)){
subtracta=positions[i]
currentLine++
}
var x=positions[i]-subtracta
var y=lineHeight*currentLine
finalPositions[i]={char:str.charAt(i),x:x,y:y}
}
return finalPositions
}
function drawNext(){
var noo=this.createEmptyMovieClip("lett"+this.count,th is.count)
var nextObj=charPos[this.count]
noo._x=nextObj.x
noo._y=nextObj.y
noo.createTextField("tex",1,0,0,100,100)
noo.tex.text=nextObj.char
noo.tex.embedFonts=true
noo.tex.selectable=false
noo.tex.setTextFormat(mt)
noo._alpha=30
noo.onEnterFrame=function(){
this._alpha+=5
if(this._alpha>=500){
this.onEnterFrame = function(){
if (scompari){ //imposto quando deve scomparire
if(this._alpha>=0){
this._alpha-=5;
}else if(this._alpha<0){
delete this.onEnterFrame;
}
}
}
}
}
this.count++
if(this.count>charPos.length){
delete this.onEnterFrame
}
}
function init(str,tForm,lineLength){
charPos=setUpText(str,tForm,lineLength)
this.count=0
this.onEnterFrame=drawNext
}
mt=new TextFormat()
mt.font="Verdana"
mt.size=14
mt.color=0xffffff
mt.bold=true
str="prova prova prova prova"
init(str,mt,520)
stop();
grazie in anticipo