all groups > flash actionscript > april 2005 >
You're in the

flash actionscript

group:

createTextField not working from swf in swf?


createTextField not working from swf in swf? mcpalmer
4/1/2005 11:38:28 PM
flash actionscript:
I've got a problem getting some code to work when a swf is loaded from another
a swf - the code is in a little content management section of a site that uses
textfields created at runtime with data loaded into them. Here is a sample of
the code:

wintext.loadTitle = function(){

var loader=new LoadVars();
loader.onLoad=function(done){
if(done){
titleFileLoaded();
} else{
trace("notloaded");
}
};
titleFileLoaded=function(){
wintext.createTextField("wTitle1", 10, 0, 0, 200, 20);
wintext.wTitle1.multiline = false;
wintext.wTitle1.wordWrap = false;
wintext.wTitle1.embedFonts = true;
wintext.wTitle1.text=loader.tTitle;
wintext.wTitle1.setTextFormat(tfmt);
wintext.loadBody();
};
loader.load(title1);
}

The swf works fine by itself but when loaded from another swf - an intro swf -
there are major problems with text display. its as if the the runtime code does
not want to work - creatTextField is not working properly. There is something
loaded because the cusrsor changes when rolled over parts of the text area. The
text is loaded into a masked custom scroll window and and its like what
happens if the font is not embedded.

Is there a known problem with running certain code in a swf loaded from
another swf? Anyone got any ideas?
Re: createTextField not working from swf in swf? kglad
4/2/2005 1:08:24 AM
when you declare you TextFormat() specify the movieclip where the exported font can be found. for example:

Re: createTextField not working from swf in swf? mcpalmer
4/2/2005 5:20:15 PM
Thanks for the reply, I tried this and it didn't work. Its definitely something
to with embedded fonts though. This is my code:

var tfmt = new TextFormat(this);
tfmt.color = 0x6f9c12;
tfmt.font = "helv45";
tfmt.bold = true;
tfmt.size=14;
tfmt.underline = false;

The "helv45" font is not held in a clip but as a font in the librairy. I think
the problem might lie in the fact that the font does not work when the swf is
loaded from another swf because it cannot be found? Flash may be looking in the
original swf for the font but cannot find it cos its in the second one? Could
this be the case? If it is, I do not have access to the original swf source so
can the font be exported in some way to be visible and work? There are some
linkage options available in flash - could any of these be of use?
Re: createTextField not working from swf in swf? kglad
4/2/2005 9:35:19 PM
the font can be found. that's why you're using "this" in your TextFormat()
declaration. it tells your main movie where to look for that TextFormat()
linkage.

is there a depth() collision? ie, is depth() of your textfield (10) taken by
the target movieclip into which you're loading that swf?
Re: createTextField not working from swf in swf? mcpalmer
4/3/2005 10:45:20 AM
No , no depth collision problems, i checked this. Like i said, the swf works
perfectly fine when loaded by itself, what is happening is, when the swf is
live on the site its loaded from an intro swf. In this situation, embedded
fonts just don't want to work with a textfield created at runtime. They will
work with an authored dynamic textfield but this is no good for me because the
textfields need to be at different sizes and different positions depending on
the text loaded into them so therefore needed to be created at runtime.

I even tried creating a textfield at authortime with embedded fonts and then
getting the textFormat object from it and putting it in the runtime textfield
but this did not work either. Arrrggghh! This is drivin me crazy!
Re: createTextField not working from swf in swf? kglad
4/3/2005 5:26:33 PM
Re: createTextField not working from swf in swf? mcpalmer
4/3/2005 6:00:22 PM
AddThis Social Bookmark Button