Masking Dynamically Created Textfields?
Hi there,
who can help me out with the following:
I create textfields, set their properties, all works fine. But I want those fields to be masked. It works just fine when I create the fields on the stage, but not when they are created by code. I do use .embedFonts = true the used character is not a systemfont I think the missing thing is a way to embed characters dynamically?
thnx, mark
FlashKit > Flash Help > Flash MX
Posted on: 01-11-2005, 08:15 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Dynamically Created TextFields
Hi
First off I'm sorry this seems to be a very old type of problem. I've spent the last two hours searching the forums for help with this but I just can't get it to work. As far as I can tell I'm doing exactly the same as other threads suggest.
I want to make a list of text items that I can dynamically update at runtime. So I have a MovieClip of a box to hold them and then some AS attached to the MC as follows:
Code:
public function addListItem(itemText:String)
{
var itemHeight = 15;
blackTextFormat = new TextFormat();
blackTextFormat.size = 12;
blackTextFormat.color = 0x000000;
numberOfItems++; // class level variable, starts at 0
this.createTextField("item" + numberOfItems, this.getNextHighestDepth(), 0
((numberOfItems - 1) * itemHeight),
30, itemHeight);
with (["item" + numberOfItems])
{
autoSize = true;
text = itemText;
setTextFormat(blackTextFormat);
trace("The text from with(" + _name + ") = " + text + " and width = " + textWidth + " at " + _x + "," + _y);
} // end with() block for new text item properties
} // end function addListItem()
And then I use it as follows:
Code:
aMenuInstance.addListItem("Barry");
aMenuInstance.addListItem("George");
aMenuInstance.addListItem("Fred");
The containing box is displayed but there is no text on it. The strangest things are that:
1. I have another function that resizes the box around the text once the items have been added - that works perfectly
2. The trace statement in the with() block prints out the text strings (Barry, George & Fred) as expected but the _x, _y, _name & textWidth properties are either 0 or just not printed
What am I doing wrong here? I am using Flash MX 2004 and targeting Flash Player 6
Many thanks
Ross
Problem With Dynamically Created TextFields
i am writing a text scroller where i read in a string of text parse it down and assign each line to a dynamically created text field. i will be using this on a website inside another flash movie that loads it into a movieclip. everything on it works except one problem where i press the down arrow to shift the text and hold it to continue to shift the text. this is done on a movieclip onPress onRelease event where the onPress calls the shiftUp function then sets an interval to continue to repeat the function. the onRelease event then clears the interval. the regular call to the function works just fine but the call from the interval does not. even though it is the same function. here is the code for the creation of the textFields, the shifting of the textFields and the events
//Parses the content of the message and adds date in\
//then creates a number of textFields equal to the number of lines\
//and sets the text equal to the equivelant line of the blog\
function getContent() {
var fieldCounter:Number = 0;
for(var i:Number = 0; i < phpReceiver.n; i++){
var tempArray_arr:Array;
tempStr_str = phpReceiver["date"+i.toString()]+ "~" + phpReceiver["msg"+i.toString()];
tempArray_arr = tempStr_str.split("~");
totalLines += tempArray_arr.length;
for(var j = fieldCounter; j < (tempArray_arr.length+fieldCounter); j++){
var tempName:String = "field"+j+"_txt";
this.createTextField(tempName, this.getNextHighestDepth(), 5, (100 + 20 * j), 350, 20);
//this[tempName].html = true;
this[tempName].text = tempArray_arr[j - fieldCounter];
this[tempName].embedFonts = true;
if(j==fieldCounter){
this[tempName].setTextFormat(dateFormat_fmt);
}else{
this[tempName].setTextFormat(txtFormat_fmt);
}
this[tempName].type = "dynamic";
this[tempName]._xscale = 100 - (j*scaleDifference);
this[tempName]._yscale = 100 - (j*scaleDifference);
}
fieldCounter = totalLines;
}
}
//Shifts the text fields up based on the number of iterations passed through\
//The iterations are multiplied by eight so that the textField shifts up 20 pixels\
function shiftUp(iterations:Number){
test2_txt.text = this[field0_txt] + " " + _parent[field0_txt] + " " + _parent[field0_txt] + " " + _root[field0_txt];
for(var j = 0; j <= iterations * 10; j++){
if(this["field"+(totalLines-1)+"_txt"]._y > 100){
for(var i = 0; i < totalLines; i++){
var tempName:String = "field"+i+"_txt";
if(Math.round(this[tempName]._y) > 390 ){
this[tempName]._visible = false;
this[tempName]._y = this[tempName]._y - 2;
this[tempName]._xscale += scaleDifference / 10;
this[tempName]._yscale += scaleDifference / 10;
}else if(Math.round(this[tempName]._y) > 121 && Math.round(this[tempName]._y) <= 390){
this[tempName]._visible = true;
this[tempName]._y = this[tempName]._y - 2;
this[tempName]._xscale += scaleDifference / 10;
this[tempName]._yscale += scaleDifference / 10;
}else if(Math.round(this[tempName]._y) >= 99 && Math.round(this[tempName]._y) <= 121){
this[tempName]._visible = true;
this[tempName]._y = this[tempName]._y - 2;
this[tempName]._xscale = 100;
this[tempName]._yscale = 100;
}else if(Math.round(this[tempName]._y) < 99 && Math.round(this[tempName]._y) >= 0){
this[tempName]._visible = true;
this[tempName]._y = this[tempName]._y - 2;
this[tempName]._xscale -= scaleDifference / 10;
this[tempName]._yscale -= scaleDifference / 10;
}else if(Math.round(this[tempName]._y) < 0){
this[tempName]._visible = false;
this[tempName]._y = this[tempName]._y - 2;
this[tempName]._xscale -= scaleDifference / 10;
this[tempName]._yscale -= scaleDifference / 10;
}
}
}
}
}
//When arrow line down pressed skips down 1 line of text\
//Sets lineInterval so that if button is held down it continues to reiterate function\
arrowLineDown_mc.onPress = function(){
shiftUp(1);
lineInterval = setInterval(shiftUp, 150, 1);
}
//When arrow line down released clears the lineInterval\
arrowLineDown_mc.onRelease = function(){
clearInterval(lineInterval);
}
Applying CSS To Dynamically Created TextFields?
hi folks.
back again with another quick question!
a quick explanation of what I'm at... I'm working on something at the moment, basically what I have is an external textfile which contains several variables; I am loading these variables into flash using loadVariables().
one of these variables invokes the script to create several buttons on the stage using for() and attachMovie(), and add onRelease() actions for each. when each button is clicked, a new textfield for that button is created on the stage.
the other loaded variables contain appropriately named html-formatted strings of text, which are then loaded into their respective, newly created textFields. pretty straightforward, and everything's working perfectly, the tags are being rendered etc. bold text is turning up bold and links are working correctly.
but, I know nothing about CSS and flash! here's what I'm wondering... although my text is being rendered properly, I currently have no control over the style of my text, so it is rendering as black, times new roman etc. how can I apply CSS styles in order to control font size, type, colour etc.?
does this entail attaching an external stylesheet, or can CSS styles be defined within the movie?
here is my code at the moment:
PHP Code:
// create box for textField for loadingMsg_root.createTextField("loadingMsg", 20, 10, 60, 300, 100);// create empty movie clip to store variables_root.createEmptyMovieClip("myVariables_mc", 1);loadVariables("text.txt", myVariables_mc);function checkVariablesLoaded() { if (myVariables_mc.myVariablesLoaded != "loaded") { trace("variables still loading"); loadingMsg.text = "one moment. loading data..."; } else { trace("variables loaded"); //remove loadingMsg _root.loadingMsg.removeTextField(); for (i=1; i<=myVariables_mc.numberOfButtons; i++) { // attach buttons _root.attachMovie("clicky_mc", i, 3+i, {_x:i*21-20, _y:1}); eval(i).onRelease = function() { // create new textField _root.createTextField("myTextField"+this._name, 2, 1, 30, 300, 100); // define textField properties eval("_root.myTextField"+this._name).multiline = true; eval("_root.myTextField"+this._name).wordWrap = true; eval("_root.myTextField"+this._name).autoSize = "left"; eval("_root.myTextField"+this._name).html = true; // eval("_root.myTextField"+this._name).htmlText = eval(myVariables_mc+".myText"+this._name); trace(this._name); } } clearInterval(myInterval); }}var myInterval:Number = setInterval(checkVariablesLoaded, 100);
and here are the variables, contained in text.txt:
-----
numberOfButtons=3&myText1=<b>hi there</b>. text 1&myText2=hello. <b>text 2</b>&myText3=yo... <b>text three</b> <a href="#">this is a link</a>&myVariablesLoaded=loaded
-----
yeesh... bit long, anyway if anyone has any suggestions as to how I can add a bit of CSS to these textFields I'd be seriously grateful!
thanks for reading! dar
Embedded Fonts In Dynamically Created Textfields
I have a bunch of dynamically created textfields which I set the properties as follows:
with(eval("fieldx" add (scale*xm))){
tempformatx = new TextFormat();
tempformatx.font = "Arial";
tempformatx.size = "10";
tempformatx.bold = true;
type = "dynamic";
selectable = false;
autosize = true;
text = dataarray[0][xm+1];
textColor = "0x000000";
_x = 15 + (colwidth*(xm+1))-(_width/2);
_y =(graphheight-15) + 3
setTextFormat(tempformatx);
}
the problem is that when I insert the line: 'embedFonts = true' the text disapears.
I need the fonts to be embedded so that I can rotate the textfields.
Any ideas.
Embedded Fonts In Dynamically Created Textfields
I have a bunch of dynamically created textfields which I set the properties as follows:
with(eval("fieldx" add (scale*xm))){
tempformatx = new TextFormat();
tempformatx.font = "Arial";
tempformatx.size = "10";
tempformatx.bold = true;
type = "dynamic";
selectable = false;
autosize = true;
text = dataarray[0][xm+1];
textColor = "0x000000";
_x = 15 + (colwidth*(xm+1))-(_width/2);
_y =(graphheight-15) + 3
setTextFormat(tempformatx);
}
the problem is that when I insert the line: 'embedFonts = true' the text disapears.
I need the fonts to be embedded so that I can rotate the textfields.
Any ideas.
Embeding Fonts For Dynamically Created TextFields
I've tried to search for an answer but i've come up empty handed. I know the embedFont for the text format embeds the font, but i can't get it to work. What is that syntax actually doing...? Is it embedding the font from my harddrive when i publish the movie or is it looking for the font from the users hard drive and embedding it from there?
I'm using pixel font's so this is particularly cruciual.
Thanks
How Do I Load Text Into My Dynamically Created Textfields?
Hi again Flashgurus!
I'm using the following code to create a function that creates a dynamic textfield:
function makeText() {
createTextfield("textBox", 50, 4, 3, 371, 43);
textBox.background = true;
textBox.border = true;
textBox.backgroundColor = 0xFFFFFF;
textBox.borderColor = 0x000000;
textBox.multiline = true;
textBox.wordWrap = true;
textBox.autoSize = true;
textBox.variable = "txt";
// formatering
myFormat = new TextFormat();
myFormat.font = "Impact";
myFormat.size = 15;
myFormat.color = 0x666666;
textBox.setNewTextFormat(myFormat);
}
In my different movieclips I call the function like this:
_root.makeText(this);
and the textfield, "textBox" , with the variable "txt" is created.
As there are different texts to be loaded in different textfields (in different movieclips that are loaded by a random script), I can't use the function "makeText" to load the texts. I must load the right, specific text in the right, specific movieclip when that movieclip is loaded (and the textfield is created, ofcourse).
So here's the question:
How do I load text into "textBox" from my external textfiles?!
I know how this works when I make textfields manually, but now I'm stuck. As I'm using about 40 different movieclips and I want to be able to change the formatting of the textbox I really want to use my function.
Please help me, oh, You FlashGurus!
Dynamically Created Textfields Aren't That Dynamic...
Bit of a weird one, but it seems dynamically created text fields don't watch the variable they're assigned.
code: _root.createTextField("txt",1,50,50,50,50);
txt.variable = _root.vari;
_root.vari = "hello";//Text field doesn't change
Is this a known bug?
(I'm in bog standard MX btw...)
Accessing Dynamically Created Input Textfields
Inside a function i dynamically make 10 Input textfields. How do I make them global - that is, how can I access to their .text property from outside the function? The plan is that when a user clicks on a button, the listener function will determine the values in these input textfields, but am stuck in two ways:
1) input textfields are not recognized outside the function (1120: Access of undefined property vnosno.)
2) how to access each of the 10 input textfields, when i create each one with the same variable name (is there a way to create them with successive numbers; e.g. vnosno1,vnosno2,vnosno3...?)
this is how i created the input textfields:
ActionScript Code:
for (var k:int = 0; k < 10; k++) {
var vnosno:TextField = new TextField();
vnosno.type = TextFieldType.INPUT;
vnosno.width = 100;
vnosno.height = 23;
vnosno.x = 100;
vnosno.y = 80 + (k * 30);
addChild(vnosno);
}
Font Embeds With AS - Dynamically Created Textfields
OK, so having some problems again this morning with font embeds (I think) with a dynamically created textfield.
Code I'm using (which is not displaying jack):
ActionScript Code:
var my_fmt:TextFormat = new TextFormat();
my_fmt.color = 0x000000;
my_fmt.size = 12
my_fmt.font = "Rabiohead";
my_fmt.align = "left"
this.createTextField("res_description", 1, 0, 25, 150, 20);
// res_description.multiline = true;
res_description.wordWrap = true;
res_description.autoSize = true;
res_description.embedFonts = true;
res_description.htmlText = true;
res_description.setTextFormat(my_fmt);
res_description.text = "This is a test";
"Rabiohead" is the font. I've tried adding it to the library and setting it's linkage settings to export for AS. tried the Linkage ID in the my_fmt.font = "Rabiohead"; part, but to no avail.
So far, the only way it's working, is if I set embedFonts to false.
Any ideas?
XML Based Banner + Dynamically Created Textfields + Loops
Hello everybody!
I have recently started a task, and have some difficulties with it right now. I literally got stuck with that! I'd appreciate if someone could look at my problem "with fresh eyes" and advise me on possible solution(s).
I am using Flash 8
I need to make XML-based banner. XML file itself will contain from 5 up to 30 tags (childNodes). It is supposed that this XML file gonna be edited by the client, so the client can add/remove or change data (that is, quantity of ChildNodes).
I need to take the data out of XML and then display them (animated!) in a flash banner, five at a time. Firts five, then second five, and so on. If, for example, there will be 13 tags, that should be first 5, then second 5 and then the last 3. After that everything should start from the beginning (first five).
XML-file is like this:
Code:
<?xml version = "1.0" encoding = "Windows-1251" ?>
<tariffs>
<tariff where = "Kaliningrad, Russia" howmuch = "1,5$" />
<tariff where = "Khorezm" howmuch = "0,2$" />
<tariff where = "Moscow" howmuch = "2,5$" />
<tariff where = "Kiev" howmuch = "0,4$" />
<tariff where = "Bobruysk" howmuch = "0,3$" />
<tariff where = "Chirchik" howmuch = "0,3$" />
<tariff where = "Tashkent, mobiles" howmuch = "0,3$" />
<tariff where = "Magadan" howmuch = "0,3$" />
<tariff where = "Almaty" howmuch = "0,3$" />
</tariffs>
actionscript is as following:
first frame:
Code:
var indhold:XML = new XML();
indhold.ignoreWhite = true;
var destinations:Array = new Array();
var prices:Array = new Array();
var Format:TextFormat = new TextFormat();
Format.size = 11;
Format.color = 0xffffff;
Format.font = "tahoma";
Format.bold = true;
indhold.load("tarifi.xml");
second frame:
Code:
indhold.onLoad = function(success) {
if (success) {
var tarifiki:Array = this.firstChild.childNodes;
for (i=0; i<tarifiki.length; i++) {
destinations.push(tarifiki[i].attributes.where);
prices.push(tarifiki[i].attributes.howmuch);
}
} else {
trace("error loading xml");
}
};
third frame:
Code:
import mx.transitions.*;
import flash.filters.*;
for (i=0; i<5; i++) {
_root.createTextField("gde"+i, i+3, 16, 20*i+30, 200, 30);
var ds:DropShadowFilter = new DropShadowFilter(5, 45, 0x000000, 100, 1, 3, 0, 1, false, false, false); //this filter is added just for the sake of alpha tween
// which did not work without that!
_root["gde"+i].filters = [ds];
_root["gde"+i].text = destinations[i];
_root["gde"+i].setTextFormat(Format);
var nashTween = new Tween(_root["gde"+i], "_alpha", Strong.easeIn, 0, 100, 2, true);
}
for (i=0; i<5; i++) {
_root.createTextField("pochem"+i, i+33, 180, 20*i+30, 200, 30);
var ds:DropShadowFilter = new DropShadowFilter(5, 45, 0x000000, 100, 1, 3, 0, 1, false, false, false);
_root["pochem"+i].filters = [ds];
_root["pochem"+i].text = prices[i];
_root["pochem"+i].setTextFormat(Format);
var nashTween = new Tween(_root["pochem"+i], "_alpha", Strong.easeIn, 0, 100, 2, true);
}
var maskClip:MovieClip = _root.createEmptyMovieClip("opa", 200);
with (maskClip) {
// Draw a mask
beginFill(0x667686, 100);
moveTo(0, 30);
lineTo(Stage.width, 30);
lineTo(Stage.width, Stage.height);
lineTo(0, Stage.height);
lineTo(0, 30);
endFill();
}
var myTransitionManager:TransitionManager = new TransitionManager(opa);
myTransitionManager.startTransition({type:Wipe, direction:Transition.OUT, duration:3, easing:None.easeNone, startPoint:9});
var myListener:Object = new Object();
myListener.allTransitionsOutDone = function(eventObj:Object) {
trace("allTransitionsOutDone event occurred."); // added just to catch the moment when transition is finished, though I am not sure that this is right way to do it.
// i tried to begin second-five-items-display here.. and it did not work.
};
myTransitionManager.addEventListener("allTransitionsOutDone", myListener);
stop(); //added just to be able to see that things look like they should.
and now I got stuck..
how to get the next five nodes to be shown?
i did try to do that on allTransitionsOutDone event, removing old textfields and creating new with new .text values, but with no success... :(
another thing that i can't find out is how to check for the quantity of 5-items-sets already shown and how to calculate for the next 5 (or less) to be shown?
and finally, how to arrange that at the end the entire "show" begin again?
please point me out the directions! =)
XML Based Banner + Dynamically Created Textfields + Loops
Hello everybody!
I have recently started a task, and have some difficulties with it right now. I literally got stuck with that! I'd appreciate if someone could look at my problem "with fresh eyes" and advise me on possible solution(s).
I need to make XML-based banner. XML file itself will contain from 5 up to 30 tags (childNodes). It is supposed that this XML file gonna be edited by the client, so the client can add/remove or change data (that is, quantity of ChildNodes).
I need to take the data out of XML and then display them (animated!) in a flash banner, five at a time. Firts five, then second five, and so on. If, for example, there will be 13 tags, that should be first 5, then second 5 and then the last 3. After that everything should start from the beginning (first five).
XML-file is like this:
Code:
<?xml version = "1.0" encoding = "Windows-1251" ?>
<tariffs>
<tariff where = "Kaliningrad, Russia" howmuch = "1,5$" />
<tariff where = "Khorezm" howmuch = "0,2$" />
<tariff where = "Moscow" howmuch = "2,5$" />
<tariff where = "Kiev" howmuch = "0,4$" />
<tariff where = "Bobruysk" howmuch = "0,3$" />
<tariff where = "Chirchik" howmuch = "0,3$" />
<tariff where = "Tashkent, mobiles" howmuch = "0,3$" />
<tariff where = "Magadan" howmuch = "0,3$" />
<tariff where = "Almaty" howmuch = "0,3$" />
</tariffs>
actionscript is as following:
first frame:
Code:
var indhold:XML = new XML();
indhold.ignoreWhite = true;
var destinations:Array = new Array();
var prices:Array = new Array();
var Format:TextFormat = new TextFormat();
Format.size = 11;
Format.color = 0xffffff;
Format.font = "tahoma";
Format.bold = true;
indhold.load("tarifi.xml");
second frame:
Code:
indhold.onLoad = function(success) {
if (success) {
var tarifiki:Array = this.firstChild.childNodes;
for (i=0; i<tarifiki.length; i++) {
destinations.push(tarifiki[i].attributes.where);
prices.push(tarifiki[i].attributes.howmuch);
}
} else {
trace("error loading xml");
}
};
third frame:
Code:
import mx.transitions.*;
import flash.filters.*;
for (i=0; i<5; i++) {
_root.createTextField("gde"+i, i+3, 16, 20*i+30, 200, 30);
var ds:DropShadowFilter = new DropShadowFilter(5, 45, 0x000000, 100, 1, 3, 0, 1, false, false, false); //this filter is added just for the sake of alpha tween
// which did not work without that!
_root["gde"+i].filters = [ds];
_root["gde"+i].text = destinations[i];
_root["gde"+i].setTextFormat(Format);
var nashTween = new Tween(_root["gde"+i], "_alpha", Strong.easeIn, 0, 100, 2, true);
}
for (i=0; i<5; i++) {
_root.createTextField("pochem"+i, i+33, 180, 20*i+30, 200, 30);
var ds:DropShadowFilter = new DropShadowFilter(5, 45, 0x000000, 100, 1, 3, 0, 1, false, false, false);
_root["pochem"+i].filters = [ds];
_root["pochem"+i].text = prices[i];
_root["pochem"+i].setTextFormat(Format);
var nashTween = new Tween(_root["pochem"+i], "_alpha", Strong.easeIn, 0, 100, 2, true);
}
var maskClip:MovieClip = _root.createEmptyMovieClip("opa", 200);
with (maskClip) {
// Draw a mask
beginFill(0x667686, 100);
moveTo(0, 30);
lineTo(Stage.width, 30);
lineTo(Stage.width, Stage.height);
lineTo(0, Stage.height);
lineTo(0, 30);
endFill();
}
var myTransitionManager:TransitionManager = new TransitionManager(opa);
myTransitionManager.startTransition({type:Wipe, direction:Transition.OUT, duration:3, easing:None.easeNone, startPoint:9});
var myListener:Object = new Object();
myListener.allTransitionsOutDone = function(eventObj:Object) {
trace("allTransitionsOutDone event occurred."); // added just to catch the moment when transition is finished, though I am not sure that this is right way to do it.
// i tried to begin second-five-items-display here.. and it did not work.
};
myTransitionManager.addEventListener("allTransitionsOutDone", myListener);
stop(); //added just to be able to see that things look like they should.
and now I got stuck..
how to get the next five nodes to be shown?
i did try to do that on allTransitionsOutDone event, removing old textfields and creating new with new .text values, but with no success... :(
another thing that i can't find out is how to check for the quantity of 5-items-sets already shown and how to calculate for the next 5 (or less) to be shown?
and finally, how to arrange that at the end the entire "show" begin again?
please point me out the directions! =)
XML Based Banner + Dynamically Created Textfields + Loops
Hello everybody!
I have recently started a task, and have some difficulties with it right now. I literally got stuck with that! I'd appreciate if someone could look at my problem "with fresh eyes" and advise me on possible solution(s).
I need to make XML-based banner. XML file itself will contain from 5 up to 30 tags (childNodes). It is supposed that this XML file gonna be edited by the client, so the client can add/remove or change data (that is, quantity of ChildNodes).
I need to take the data out of XML and then display them (animated!) in a flash banner, five at a time. Firts five, then second five, and so on. If, for example, there will be 13 tags, that should be first 5, then second 5 and then the last 3. After that everything should start from the beginning (first five).
XML-file is like this:
<?xml version = "1.0" encoding = "Windows-1251" ?>
<tariffs>
<tariff where = "Kaliningrad, Russia" howmuch = "1,5$" />
<tariff where = "Khorezm" howmuch = "0,2$" />
<tariff where = "Moscow" howmuch = "2,5$" />
<tariff where = "Kiev" howmuch = "0,4$" />
<tariff where = "Bobruysk" howmuch = "0,3$" />
<tariff where = "Chirchik" howmuch = "0,3$" />
<tariff where = "Tashkent, mobiles" howmuch = "0,3$" />
<tariff where = "Magadan" howmuch = "0,3$" />
<tariff where = "Almaty" howmuch = "0,3$" />
</tariffs>
actionscript is as following:
first frame:
var indhold:XML = new XML();
indhold.ignoreWhite = true;
var destinations:Array = new Array();
var prices:Array = new Array();
var Format:TextFormat = new TextFormat();
Format.size = 11;
Format.color = 0xffffff;
Format.font = "tahoma";
Format.bold = true;
indhold.load("tarifi.xml");
second frame:
indhold.onLoad = function(success) {
if (success) {
var tarifiki:Array = this.firstChild.childNodes;
for (i=0; i<tarifiki.length; i++) {
destinations.push(tarifiki[i].attributes.where);
prices.push(tarifiki[i].attributes.howmuch);
}
} else {
trace("error loading xml");
}
};
third frame:
import mx.transitions.*;
import flash.filters.*;
for (i=0; i<5; i++) {
_root.createTextField("gde"+i, i+3, 16, 20*i+30, 200, 30);
var ds:DropShadowFilter = new DropShadowFilter(5, 45, 0x000000, 100, 1, 3, 0, 1, false, false, false); //this filter is added just for the sake of alpha tween
// which did not work without that!
_root["gde"+i].filters = [ds];
_root["gde"+i].text = destinations[i];
_root["gde"+i].setTextFormat(Format);
var nashTween = new Tween(_root["gde"+i], "_alpha", Strong.easeIn, 0, 100, 2, true);
}
for (i=0; i<5; i++) {
_root.createTextField("pochem"+i, i+33, 180, 20*i+30, 200, 30);
var ds:DropShadowFilter = new DropShadowFilter(5, 45, 0x000000, 100, 1, 3, 0, 1, false, false, false);
_root["pochem"+i].filters = [ds];
_root["pochem"+i].text = prices[i];
_root["pochem"+i].setTextFormat(Format);
var nashTween = new Tween(_root["pochem"+i], "_alpha", Strong.easeIn, 0, 100, 2, true);
}
var maskClip:MovieClip = _root.createEmptyMovieClip("opa", 200);
with (maskClip) {
// Draw a mask
beginFill(0x667686, 100);
moveTo(0, 30);
lineTo(Stage.width, 30);
lineTo(Stage.width, Stage.height);
lineTo(0, Stage.height);
lineTo(0, 30);
endFill();
}
var myTransitionManager:TransitionManager = new TransitionManager(opa);
myTransitionManager.startTransition({type:Wipe, direction:Transition.OUT, duration:3, easing:None.easeNone, startPoint:9});
var myListener:Object = new Object();
myListener.allTransitionsOutDone = function(eventObj:Object) {
trace("allTransitionsOutDone event occurred."); // added just to catch the moment when transition is finished, though I am not sure that this is right way to do it.
// i tried to begin second-five-items-display here.. and it did not work.
};
myTransitionManager.addEventListener("allTransitio nsOutDone", myListener);
stop(); //added just to be able to see that things look like they should.
and now I got stuck..
how to get the next five nodes to be shown?
i did try to do that on allTransitionsOutDone event, removing old textfields and creating new with new .text values, but with no success... :(
another thing that i can't find out is how to check for the quantity of 5-items-sets already shown and how to calculate for the next 5 (or less) to be shown?
and finally, how to arrange that at the end the entire "show" begin again?
please point me out the directions! =)
XML Based Banner + Dynamically Created Textfields + Loops
Hello everybody!
I have recently started a task, and have some difficulties with it right now. I literally got stuck with that! I'd appreciate if someone could look at my problem "with fresh eyes" and advise me on possible solution(s).
I need to make XML-based banner. XML file itself will contain from 5 up to 30 tags (childNodes). It is supposed that this XML file gonna be edited by the client, so the client can add/remove or change data (that is, quantity of ChildNodes).
I need to take the data out of XML and then display them (animated!) in a flash banner, five at a time. Firts five, then second five, and so on. If, for example, there will be 13 tags, that should be first 5, then second 5 and then the last 3. After that everything should start from the beginning (first five).
XML-file is like this:
Code:
<?xml version = "1.0" encoding = "Windows-1251" ?>
<tariffs>
<tariff where = "Kaliningrad, Russia" howmuch = "1,5$" />
<tariff where = "Khorezm" howmuch = "0,2$" />
<tariff where = "Moscow" howmuch = "2,5$" />
<tariff where = "Kiev" howmuch = "0,4$" />
<tariff where = "Bobruysk" howmuch = "0,3$" />
<tariff where = "Chirchik" howmuch = "0,3$" />
<tariff where = "Tashkent, mobiles" howmuch = "0,3$" />
<tariff where = "Magadan" howmuch = "0,3$" />
<tariff where = "Almaty" howmuch = "0,3$" />
</tariffs>
actionscript is as following:
first frame:
Code:
var indhold:XML = new XML();
indhold.ignoreWhite = true;
var destinations:Array = new Array();
var prices:Array = new Array();
var Format:TextFormat = new TextFormat();
Format.size = 11;
Format.color = 0xffffff;
Format.font = "tahoma";
Format.bold = true;
indhold.load("tarifi.xml");
second frame:
Code:
indhold.onLoad = function(success) {
if (success) {
var tarifiki:Array = this.firstChild.childNodes;
for (i=0; i<tarifiki.length; i++) {
destinations.push(tarifiki[i].attributes.where);
prices.push(tarifiki[i].attributes.howmuch);
}
} else {
trace("error loading xml");
}
};
third frame:
Code:
import mx.transitions.*;
import flash.filters.*;
for (i=0; i<5; i++) {
_root.createTextField("gde"+i, i+3, 16, 20*i+30, 200, 30);
var ds:DropShadowFilter = new DropShadowFilter(5, 45, 0x000000, 100, 1, 3, 0, 1, false, false, false); //this filter is added just for the sake of alpha tween
// which did not work without that!
_root["gde"+i].filters = [ds];
_root["gde"+i].text = destinations[i];
_root["gde"+i].setTextFormat(Format);
var nashTween = new Tween(_root["gde"+i], "_alpha", Strong.easeIn, 0, 100, 2, true);
}
for (i=0; i<5; i++) {
_root.createTextField("pochem"+i, i+33, 180, 20*i+30, 200, 30);
var ds:DropShadowFilter = new DropShadowFilter(5, 45, 0x000000, 100, 1, 3, 0, 1, false, false, false);
_root["pochem"+i].filters = [ds];
_root["pochem"+i].text = prices[i];
_root["pochem"+i].setTextFormat(Format);
var nashTween = new Tween(_root["pochem"+i], "_alpha", Strong.easeIn, 0, 100, 2, true);
}
var maskClip:MovieClip = _root.createEmptyMovieClip("opa", 200);
with (maskClip) {
// Draw a mask
beginFill(0x667686, 100);
moveTo(0, 30);
lineTo(Stage.width, 30);
lineTo(Stage.width, Stage.height);
lineTo(0, Stage.height);
lineTo(0, 30);
endFill();
}
var myTransitionManager:TransitionManager = new TransitionManager(opa);
myTransitionManager.startTransition({type:Wipe, direction:Transition.OUT, duration:3, easing:None.easeNone, startPoint:9});
var myListener:Object = new Object();
myListener.allTransitionsOutDone = function(eventObj:Object) {
trace("allTransitionsOutDone event occurred."); // added just to catch the moment when transition is finished, though I am not sure that this is right way to do it.
// i tried to begin second-five-items-display here.. and it did not work.
};
myTransitionManager.addEventListener("allTransitionsOutDone", myListener);
stop(); //added just to be able to see that things look like they should.
and now I got stuck..
how to get the next five nodes to be shown?
i did try to do that on allTransitionsOutDone event, removing old textfields and creating new with new .text values, but with no success... :(
another thing that i can't find out is how to check for the quantity of 5-items-sets already shown and how to calculate for the next 5 (or less) to be shown?
and finally, how to arrange that at the end the entire "show" begin again?
please point me out the directions! =)
Dynamically Masking Dynamically Created Text (MX)
I am having trouble dynamically masking dynamically created text... It just doesn't seem to work!! This is what i'm doing.
First i create a movie clip dynamically using attachMovie. On the first frame of that mci create a bunch of text fields, one after the other. When that finishes, i call a function in another mc that creates another mc and draws a box in it and then sets it as the mask of the first mc.
The result should be that only the text that is within that mask should show up, right? Well, the text doesn't mask at all, even if it is entirely beyond the bounds of the mask.
I read that it might be a problem with fonts that aren't embedded, so i set the TextFormat.embedFonts to true...
anyone have any idea??
Problem Masking Dynamically Created Mcs
I'm using a circle to mask two layers, one of which has elements created dynamically (duplicateMovieClip). The problem is, dynamically generated clips are set to depths above zero, and the circle mask begins at depth -16383, the very bottom. I've tried swapping depths of the mc's with the mask, but nothing seems to work. What I'm trying to do is have a completely black screen with the movable mask revealing the mcs and the green background underneath. I've attached the .fla file if anyone would be so kind as to look at it.
Thanks,
aaroneousmonk
Masking A Dynamically Created Movieclip
hi all,
i'm creating an image scrollbar and for some reason i can't get my mask to properly mask the "container" movie clip which holds the dynamically created image holder clips. i only want to display a few images at a time and i'm using setMask to perform the masking but for some reason i can't get it to work. below is the actionscript code and i've attached a zip of the FLA and the images if you want to take a look.
any help would be greatly appreciated! thanks!
Code:
var x_o:Number = 0;
var y_o:Number = 0;
var x_pad:Number = 4;
this.createEmptyMovieClip("container_mc", this.getNextHighestDepth(), {_x:x_o, _y:y_o});
currDepth = this.container_mc.getDepth();
trace("container_mc depth is " + currDepth);
for(i=0; i < 16; i++) {
//this.container_mc.attachMovie("rollover", "rollover" + i, currDepth + 1);
this.container_mc.attachMovie("rollover", "rollover" + i, this.container_mc.getNextHighestDepth());
clipWidth = this.container_mc["rollover" + i]._width;
if(i==0) {
this.container_mc["rollover" + i]._x = x_o;
this.container_mc["rollover" + i]._y = y_o;
clip_x = this.container_mc["rollover" + i]._x;
current_x = clip_x;
currDepth = this.container_mc["rollover" + i].getDepth();
trace(currDepth);
} else {
this.container_mc["rollover" + i]._x = current_x + this.container_mc["rollover" + i]._width + x_pad;
current_x = this.container_mc["rollover" + i]._x;
this.container_mc["rollover" + i]._y = y_o;
currDepth = this.container_mc["rollover" + i].getDepth();
trace(currDepth);
}
this.container_mc["rollover" + i].onRollOver = function() {
trace("Rolling over image " + this._name);
trace("Parent is " + this._parent._name);
}
this.container_mc["rollover" + i].onRollOut = function() {
}
}
// images
for(i=0; i < 16; i++) {
this.container_mc.attachMovie("holder", "holder" + i, this.container_mc.getNextHighestDepth());
if(i==0) {
this.container_mc["holder" + i]._x = x_o + 1;
this.container_mc["holder" + i]._y = y_o + 1;
clip_x = this.container_mc["holder" + i]._x;
current_x = clip_x;
this.container_mc["holder" + i].loadMovie("images/img" + i + ".jpg");
this.container_mc["holder" + i]._xscale = 13.45;
this.container_mc["holder" + i]._yscale = 13.45;
currDepth = this.container_mc["holder" + i].getDepth();
trace(currDepth);
} else {
this.container_mc["holder" + i]._x = current_x + this.container_mc["holder" + i]._width + x_pad + 2;
current_x = this.container_mc["holder" + i]._x;
this.container_mc["holder" + i]._y = y_o + 1;
this.container_mc["holder" + i].loadMovie("images/img" + i + ".jpg");
this.container_mc["holder" + i]._xscale = 13.45;
this.container_mc["holder" + i]._yscale = 13.45;
currDepth = this.container_mc["holder" + i].getDepth();
trace(currDepth);
}
}
totClipWidth = (i*clipWidth) + ((i - 1)*x_pad);
trace(totClipWidth);
trace(this.container_mc._x);
trace(this.container_mc._y);
scroller_x = 50;
scroller_y = 200;
this.container_mc._x = scroller_x;
this.container_mc._y = scroller_y;
//this.container_mc._height = 371;
//this.container_mc._width = totClipWidth;
// mask
this.attachMovie("mask", "mask_mc", this.getNextHighestDepth());
this.mask_mc._x = scroller_x;
this.mask_mc._y = scroller_y;
this.mask_mc._width = totClipWidth;
this.mask_mc._height = clipWidth;
this.container_mc.setMask("mask_mc");
Masking Dynamically Created Movieclips
Hi there!
I've made a "link-menu" populated from an XML-file, where the link is put through dynamic textfield in a movieclip that has a mouseover-effect. It all works smoothly, until I try to mask it. What I want to create is a scrollable area that fits, say 4 links at a time. Hence, I want to mask the dynamically created movieclips listed below (and above, once you start scrolling).
How would I do this? Right now it gets all weird once I use a mask or try to nest the dynamically created movieclips inside a masked movieclip. Like, the actual movieclip works, but the TEXT doesn't get there.
My guess is that it has something to do with depths and levels. I will paste the code parts here and maybe one of you will spot the errors...
So, here is where I create the actual movieclip (these are all made in a for loop, hence the "i"):
ActionScript Code:
_root.quizListContainer.attachMovie("linkArea_mc", "quizBtn" + i, _root.quizListContainer.getNextHighestDepth())
Explanation: I've created linkArea_mc to have a mouseOverbackground turn on and off, and in that _mc I've created a dynamic textfield. I attach it inside the quizListContainer.
Here is when I stack them up below each other:
ActionScript Code:
_root.quizListContainer["quizBtn"+i]._y = (_root.quizListContainer["quizBtn"+i]._height * i);
And here is where i put the text:
ActionScript Code:
_root.quizListContainer["quizBtn"+i].quizTextField.text = _root.quizes[i].attributes.name;
now this works OK, but if I were to put these links inside a dynamically sized movieclip (which I later could move with a scroller) and then mask that movieclip (to get the scroller effect, of course) - how the hell do I go about it?
Any ideas appreciated! Thanks a lot
Masking Dynamically Created MovieClips
Hi Guys,
Quick question,
If I have a movieClip on layer 1 of my timeline, on layer 2 I have a mask for that movieclip - all fine and dandy - but now if I duplicate that movieClip (programatically) the mask has no effect on the duplicated movieClips only the original clip is masked.
Why is this and how do I mask the duplicated clips with the same mask?
I know it has something to do with the stack order, but I can't get my head around it.
Thanks Alot
Roark
Actionscript Created Textfields
I am using Flash 7 and AS 2.0
I have a function as follows that formats a text field
private function setTF():Void {
txf = new TextFormat();
txf.font = "standard 07_55";
txf.bold = false;
txf.size = 8;
}
In another function I have the following code
createTextField("tx"+i, getNextHighestDepth(), 0, 0, 0, 0);
this["tx"+i].setNewTextFormat(txf);
this["tx"+i].embedFonts = false;
this["tx"+i]._y = startY;
this["tx"+i]._x = xspace;
this["tx"+i].selectable = false;
this["tx"+i].border = false;
this["tx"+i].background = false;
this["tx"+i].autoSize = true;
this["tx"+i].text = co[i].label;
this["bg"+i]._alpha = 0;
This code works 100%, however when I code the embedFonts=true then my text disappears in my text box? What is wrong?
Rotate Dynamic Created Textfields - How?
Hello all!
Need help to rotate some dynamic created textfields!
Here is my code:
PHP Code:
for(d = 0; d < runnerCount; d++) {
runnersTF = "runners" + d;
_root.createTextField(runnersTF,d,165+(d*110),20,110,20);
_root[runnersTF].text = runnerName;
_root.runnersTF._rotation = 90;
}
In my actionscript book it says that for the _rotation funtion to work the textfield have to enclose the font. How can I do that dynamically?
Interaction With AS Created Movieclip Containing Textfields
I have a MC called textFieldsMC and it contains three textfields which has instance names, one of them is "tipsNamn", I'm just trying to pass a string to it but I cant get it to work
Code:
var tfMC:MovieClip = new textFieldsMC();
var cDepth:int = 100;
tfMC.name = "tipsFieldsMC" + cDepth;
this.textMoverMC.addChild(tfMC);
// this row is where I want to pass text to one of the textFields inside textFieldsMC100
this.textMoverMC.tipsFieldsMC100.tipsNamn.text = "test";
I just dont quite get the new debugger
On Rollover Fade Dyn. Created Textfields?
Hi all,
Trying to make my dynamic created textfields fade with an onRollOver.
I know the basics i.e. Dyn.
1 -Textfield in a MC and
2 - embed the fonts
So here is a part of my AS
ActionScript Code:
for (child = 3; child < count; child++) {
//mc's holders for the dyn textfields
holder = _root.createEmptyMovieClip ("mcLocationHolder" + child, 10 + child);
.....
.....
.....
//here my dynamic textfields
_root.holder.createTextField (["location" + child], 200 + child, 0, (67.5 * position + 20), 301, 47.5);
with (_root.holder["location" + child]) {
//some format code
multiline = true;
wordWrap = true;
.....
....
}
//onrollover fade FX per holder
_root.holder["location" + child]._alpha = 100;
_root.holder["location" + child].onRollOver = function () {
_root.holder["location" + child]._alpha -= 5;
if (_root.holder["location" + child]._alpha <= 0) {
delete _root.holder["location" + child].onRollOver;
}
};
I have embed the font by New font and linkage.
You guessed it, it ain't working. Any tips???
PS i see my textfield react on
ActionScript Code:
_root.holder["location" + child]._alpha = 100;
when i put embedFonts = true in my with () state
But the onrollover function doesn't work ;(
Grtz,
Dynamic Height In Textfields Created With AS
Hello people
Well, i'm working on a project of my office and need to create a textField with automatic height. You know that textfields need to apply a number on this way:
ActionScript Code:
_root.createTextField(instanceName:String, depth:Number, x:Number, y:Number, width:Number, [b]height:Number[/b]);
But I need that textfield have the same height of the count of lines of text and not a predetermined number.
Do you know if this is possible ???
Best regards and thank you for any help
On Rollover Fade Dyn. Created Textfields?
Hi all,
Trying to make my dynamic created textfields fade with an onRollOver.
I know the basics i.e. Dyn.
1 -Textfield in a MC and
2 - embed the fonts
So here is a part of my AS
ActionScript Code:
for (child = 3; child < count; child++) {
//mc's holders for the dyn textfields
holder = _root.createEmptyMovieClip ("mcLocationHolder" + child, 10 + child);
.....
.....
.....
//here my dynamic textfields
_root.holder.createTextField (["location" + child], 200 + child, 0, (67.5 * position + 20), 301, 47.5);
with (_root.holder["location" + child]) {
//some format code
multiline = true;
wordWrap = true;
.....
....
}
//onrollover fade FX per holder
_root.holder["location" + child]._alpha = 100;
_root.holder["location" + child].onRollOver = function () {
_root.holder["location" + child]._alpha -= 5;
if (_root.holder["location" + child]._alpha <= 0) {
delete _root.holder["location" + child].onRollOver;
}
};
I have embed the font by New font and linkage.
You guessed it, it ain't working. Any tips???
PS i see my textfield react on
ActionScript Code:
_root.holder["location" + child]._alpha = 100;
when i put embedFonts = true in my with () state
But the onrollover function doesn't work ;(
Grtz,
Aliasing TextFields Created With CreateTextField?
I have a clip that uses createTextField, supplies a couple values ::
_x:250,_y:200,_width:250,_height:25,html:true,border:true,font:'Bodoni Bd BT',selectable:false
i then insert the text into the field with htmlText=nameToShow;
problem is, the text is not alised, its jagged.
i've tried the previous solution which was to insert a dynamic textfield on the timeline with the same font and selecting the embedFonts option.
i've tried creating a new Font in the library and linking it to actionscript with the same identifier Bodoni Bd BT
I've tried creating a textFormat and applying it to the textfield
i've tried inserting the text through the text value instead of htmlText.
nothing seems to work, ideas?
Masking Textfields W/ AS
Alright, I'm trying to mask a list of textfields that I dynamically create with AS. The user can choose from a list of main titles, then clicking will load the sublist for that title. However, many sublists have more than 10 entries, and I only want 10 to be seen at a time in the designated box I created, then scroll to the additional selections as the cursor gets to the bottom of the masked area. This can probably be done with scroller components, however, without components will all the textfields have to be contained in an object and then mask the object? If so, then how do I call a function from within an object to dynamically create my textfields?
This is the function that makes the textfields, can someone show me how I would call this function to create the textfields within an object? My attempts haven't had any luck.
ActionScript Code:
function makefields(z, p){
width=293.1;
height=18.6;
x=-147.1;
y=p
chart_y=new Array()
for (j=1; j<z+1; j++){
y=y+18.6;
this.createTextField("tfield"+j, j, x, y, width, height);
chart_y[j]=y;
}
}
something like,
createtext = new Object()
//then in my function that calls makefields()
createtext.makefields(value1, value2)
createtext.setMask(MymaskObject);
??
Thanks,
-Mike
Listing Objects (TextFields, MovieClips Etc) Created In Authoring Time?
Hi!
I am building an application in flash that allows artist to design swiffs containing framebased animation and textfields or movieClips with textfields. The application will load the artists swf and then work as a tool for them to play the animations they created in the swf. It will also be able to fill the (empty) textFields with text.
The main issue here is that the artists know flash but not ActionScript so that is why the application exists. And that is why I need to, in some way, to:
* extract the frameLabels from the swf (I have read some articles on that)
* if the current frame is labeled check if there are any textFields on the stage and store their names in an Array
* if there are any movieClips on the stage check if they contain any textFields, in that case store the names of the textFields and the path in an Array.
If this is impossible I will need to create some application where the artists define all of the frame labels and all of the textFields and outputs it to xml. But this will make the workflow a lot worse for the artists.
Any suggestions or ideas?
/Andreas
Masking Dynamic TextFields?
Hey guys,
I read around the forums and google, and all I could find was to embed the fonts...but I am trying to dynamically mask some dynamic text, and its all janky...the mask messes up. When I change it to static text, it works perfect..
Any ideas? ive embedded the fonts and everything.
Thanks!
Problems With Masking Textfields...
Just come up against a problem and I dont know if it's me being stupid or just something that you can't do in Flash...
I am building a full flash website, and loading the main page (containing content) as an external .swf because it contains an intro loading movie and seemed the logical way to do it.
The problem has occured in the fact that I am masking the area for the main content in the main movie (to prevent any overlap by images in the external file etc.) but this mask seems to be hiding the text held in the loaded file. The scroll bar can still be seen, just not the text itself.
I was hoping someone with more experience could tell me whether this is just Flash and I need to find a way around it, or if I am just making a mistake...
Thanks,
Barney Fox - Redefined Designs
Problems With Masking Textfields...
Just come up against a problem and I dont know if it's me being stupid or just something that you can't do in Flash...
I am building a full flash website, and loading the main page (containing content) as an external .swf because it contains an intro loading movie and seemed the logical way to do it.
The problem has occured in the fact that I am masking the area for the main content in the main movie (to prevent any overlap by images in the external file etc.) but this mask seems to be hiding the text held in the loaded file. The scroll bar can still be seen, just not the text itself.
I was hoping someone with more experience could tell me whether this is just Flash and I need to find a way around it, or if I am just making a mistake...
Thanks,
Barney Fox - Redefined Designs
Masking Dynamic Textfields
hi.
im working on my own scrollpane (isnt a component), but when i add dynamic textfields without embedding the font they arent shown!
i know embedding the font is a solution but it doesnt look good (anti-alias).
my problem is that it must be possible in some way! if i add dynamic textfield to the standard component (scrollpane) its working fine!!!!
thx.
How Dynamically Change The Image In Dynamically Created Row Of Images?
Hi everybody,
I am wondering if someone can help me to find out on how to replace the images in row of dynamically loaded images. I need on Press of an icon from the row of images replace the image of this icon to new one. Below is the code of creating the images row based on array and XMl data. I create an array based on data taking from XML.
Code:
var numOfImages:Number;
var thumbHeight:Number = 8;
var thumbSpace:Number = 100;
var thumbTotalDistance:Number = thumbHeight+thumbSpace;
var xCounter:Number = 5;
var thumbsCollectionHeight:Number;
var currentImage:Number = 0;
var moveOutDist:Number = 10;
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
var IM_Img:Array = new Array();
var IM_Title:Array = new Array();
//==================================================================================================================
//=============================== THUMBS IMAGE LOADER ==========================================================
//==================================================================================================================
var thumbImgLoader2:MovieClipLoader = new MovieClipLoader();
var thumbImgListener2:Object = new Object();
thumbImgListener2.onLoadProgress = function(target:MovieClip):Void {
};
thumbImgLoader2.addListener(thumbImgListener2);
thumbImgListener2.onLoadComplete = function(target_mc:MovieClip):Void {
};
//==================================================================================================================
//=============================== XML ==================================================================================================
//==================================================================================================================
var totalXML:XML = new XML();
totalXML.ignoreWhite = true;
totalXML.onLoad = function(success) {
var TNnode = this.firstChild.childNodes[1].childNodes;
numOfImages = TNnode.length;
//---------------- ATTACHING THUMBS -----------------
//===========================================================================================================
for (i=0; i<numOfImages; i++) {
var mc:MovieClip = imCollection_mc.thumbs_mc.attachMovie("mcThumb_IM", "thumb_" + i, i);
mc._y = 0;
mc._x = xCounter;
xCounter = xCounter+thumbTotalDistance;
thumbImgLoader2.loadClip(TNnode[i].attributes.thumb,mc.loader_mc);
IM_Title.push(TNnode[i].attributes.title);
imCollection_mc.thumbs_mc["thumb_" + i].mc_title.title_txt.text = IM_Title[currentImage];
mc.id = i;
trace (mc.id);
mc.onPress = mc_im_onPress;
mc.xx = mc._x;
mc.yy = mc._y;
}
};
//-------------------------------------------------------------------------
totalXML.load("images.xml");
Here is onPress event where I was thinking to add this functionality:
Code:
function mc_im_onPress() {
mcToSelect = this;
if(this.id==8){
//here I need to tell to replace the image from mc8 to new image from array to image#34 from xml
}
}
Any advice is highly appreciated. Thanks.
Problem With Loading Jpegs Dynamically Into Dynamically Created MC's
hey all. I got a problem with loading jpegs dynamically into dynamically created MC's. I've been using NEIL WEBB's tutorial on dynamic creation with event handling through the LISTENER component, which you can see here http://www.actionscript.org/tutorial...MX_2004_Part2/
I have slightly altered the script to accomodate the fact that I want to attach a movieclip with text fields and image holders within it, but the code aint too different I don't think.
Code:
stop();
myMCL = new MovieClipLoader(); //define MovieClipLoader
myListener = new Object(); //define listener
myListener.onLoadComplete = function(targetMC){ //set the onComplete function on listener
trace("targetMC = " + targetMC._name);
targetMC.onPress = function() { //define onPress within function
}
}
//****************************
function initClips(){
//trace(_global.gallery_cnt);
for (i=1; i<=_global.gallery_cnt; i++){
//trace("Attaching Clip - " + i);
this.gallery_TN_holder.attachMovie("TN_Holder", "TN_Holder" + i, i); //attach the movie
this.gallery_TN_holder["TN_Holder"+i]._x = (i-1)*90; //spacing
this.gallery_TN_holder["TN_Holder"+i].TN_Text.text = _global.gallery_array.description;
[i] [i]myMCL.loadClip(_global.gallery_array.main_thumbnail ,this.gallery_TN_holder["TN_Holder"+i].TN_Image);
//load images into clip
}
play();
}
//****************************
myMCL.addListener(myListener); //associate listerer with MCL object
initClips();
The first line ("trace") in bold outputs
Quote:
targetMC = TN_Image
targetMC = TN_Image
which you can see is resulting from the second bold line.
Basically I need some direction with this as to how to reference the clip target for the loaded JPEG, as my output in the movie shows the attachMovie works, as does the text change within the individual "TN_Holder" clips. What the hell am i doin wrong, cos my eyes are kinda starting to go kinda funny looking at this stuff!!!!!
Thanks for any help!
Only Masking With Dyn. Created Mc:s?
Hey, is there not anyway to have an mc, duplicate it several times and let all the duplications mask the same mc?.
Do you have to dynamiclly create the mask?
I want it to be easy to change the shape of what the mask will look like.
Thanks!
Creating Textfields Dynamically
creating a single textfield dynamically is no problem... what if i want to provide users with an input textfield and create as many textfields as entered by the user... if the user enters 5 .. it shud create 5 textfields! HOW?
thanks~!
aLi
Creating TextFields Dynamically
Hi.
I'm interested to take data from access database and put it in flash using ASP.
My problem is that the access table contains many lines and I would like for every line to create a specific movieclip and in that movie clip to set the textFields that will contain the data (several variables).
I don't know the exact number of lines, so everything must be done dynamically. How can I do this ??
If somebody has done such a thing (and I'm sure they had) please send me a code or give me an idea...
Thanks.
Masking Snow Created By Script
hey,
i've got some snow falling (perfect time of year, huh?) through this:
a small white circle movie clip with this script on it:
onClipEvent (load) {
//specifies the size of the movie stage
movieWidth = 300;
movieHeight = 200;
//variables that will modify the falling snow
i = 1+Math.random()*2;
k = -Math.PI+Math.random()*Math.PI;
//giving each snowflake unique characteristics
this._xscale = this._yscale=50+Math.random()*100;
this._alpha = 75+Math.random()*100;
this._x = -10+Math.random()*movieWidth;
this._y = -10+Math.random()*movieHeight;
}
onClipEvent (enterFrame) {
//putting it all together
rad += (k/180)*Math.PI;
this._x -= Math.cos(rad);
this._y += i;
if (this._y>=movieHeight) {
this._y = -5;
}
if ((this._x>=movieWidth) || (this._x<=0)) {
this._x = -10+Math.random()*movieWidth;
this._y = -5;
}
}
THEN, in the frame I have this script:
for (k=0; k<50; k++) {
duplicateMovieClip(this.snow, "snow"+k, k);
}
I'm trying to seclude the the snow to only a circle within my .fla. I tried masking the frame this script and movie clip are in, but it didn't work.
Any ideas? Thanks!
Dynamically Creating TextFields With Loop...
Hi Everyone, I have a problem that I think should be easy to sort but I just can't figure it out and hope someone can help.
I am trying to create a list of textfields using actionscript which import text from an external text file. To do this i am using a loop and the following script...
Code:
loadVarsText.onLoad = function() {
for (i=0; i<3; i++) {
y = 80+i*120;
trace("y = "+y);//traces the y location of the text field
this.createTextField("priceText_"+i, i+200, 210, y, 200, 300);
trace(["priceText_"+i]);//working fine
["priceText_"+i]text= this["price"+i];
trace(this["price"+i]);//traces the text from the external file
}
If I change ["priceText_"+i]text= this["price"+i];
to say
priceText_1.text=this["price"+i];
then the text field appears (for i=1) in the correct place. ["priceText_"+i] is currently an object which I am still not totally clear on so maybe this is the problem? Everything else seems to be ok though....
Any ideas?
Creating Textfields Dynamically In Movieclips
hi guys,
I'm trying to create 10 empty mc using a for loop, with each mc containing a textfield. Below's how i've done it...
Code:
yPos = 0;
for ( i = 0; i < 10; i++ )
{
this.createEmptyMovieClip( this["hello" + i + "_mc"], this.getNextHighestDepth());
this["hello" + i + "_mc"].createTextField("hello_txt", this["hello" + i + "_mc"].getNextHighestDepth(), 0, yPos, 500, 500 );
this["hello" + i + "_mc"].hello_txt.text = "hahaha" + i;
yPos += 100;
}
for some reasons, it doesn't seems to work. Can any1 help?
Dynamically Track All TextFields On Stage
I have several "page" swfs (Flash 9, AS3) that are loaded at runtime by a "navigation" swf (Flash 9, AS3).
I want to trigger a method in my navigation swf each time that a dynamic TextField is displayed on stage in one of the "page" swfs? These TextFields are put on stage at design time somewere on the fla timeline. So these textFields can be nested in mc's and have whatever instance names.
Is this possible?
Tnx,
Gert
Dynamically Create And Reference TextFields?
I have been working on porting a dynamic text effect generator to Flash 5. Right now it works perfectly in Flash MX. It uses createEmptyMovieClip and createTextField to create TextFields for each character in a given string and then applies a particular effect to the characters. My problem arises in that Flash 5 does not support the createEmptyMovieClip and createTextField methods.
I have attempted to change my code by creating an dummy MovieClip with an empty TextField inside of it, then using duplicateMovieClip to create subsequent MovieClips for each character in the string.
This seems to be working, but I am having trouble referencing the TextField inside of the MovieClip. As I understand it, in Flash 5 you need to assign a TextField a variable name in order change its value. If I have set up the empty TextField inside of the dummy MovieClip, given it the variable name "field" and duplicated the MovieClip, giving it an instance name of "letter," how would I reference the TextField? I have tried letter.field, but the trace merely returns an undefined value.
Or maybe there is a better way I could be doing this?
(I should probably note that I am developing this in the Flash MX environment.)
Creating Textfields Dynamically In Movieclips
hi guys,
I'm trying to create 10 empty mc using a for loop, with each mc containing a textfield. Below's how i've done it...
Code:
yPos = 0;
for ( i = 0; i < 10; i++ )
{
this.createEmptyMovieClip( this["hello" + i + "_mc"], this.getNextHighestDepth());
this["hello" + i + "_mc"].createTextField("hello_txt", this["hello" + i + "_mc"].getNextHighestDepth(), 0, yPos, 500, 500 );
this["hello" + i + "_mc"].hello_txt.text = "hahaha" + i;
yPos += 100;
}
for some reasons, it doesn't seems to work. Can any1 help?
Masking Dynamic Text Created From Actionscript.
I have a whole bunch of dynamic text fields created with the following ActionScript function:
Code:
function Label(x:Number, y:Number, width:Number, text:String)
{
_clip = _root.createEmptyMovieClip("MovieClip" + Gensym.Make(text), _root.getNextHighestDepth())
_clip._x = x
_clip._y = y
_clip.lineStyle(1, 0, 0)
_clip.lineTo(width, height) // Sets _clip's width and height, albeit in a convoluted way.
_text = _clip.createTextField("TextField" + Gensym.Make(text), _clip.getNextHighestDepth(), 0, 0, width, height)
_text.autoSize = "left"
_text.embedFonts = true
}
Label is a class I've written, _clip and _text are members of objects of that class. It works well; everything shows up where I tell it to, in the size and font that I request (so long as I remember to embed those sizes and fonts, that is). But now I'm trying to mask this text I've created, and it's going very badly. I create and apply the mask like so:
Code:
function SetDrawRegion(x:Number, y:Number, width:Number, height:Number)
{
var mask_clip:MovieClip = _root.createEmptyMovieClip(Gensym.Make("LabelMask"), _root.getNextHighestDepth())
mask_clip.lineStyle(1, 0xffffff, 0)
mask_clip.lineTo(width, height)
mask_clip._x = x
mask_clip._y = y
mask_clip._width = width
mask_clip._height = height
_clip.setMask(mask_clip)
}
The trouble is this: whenever I set the mask, my text disappears! It doesn't matter where my mask is or how big it is; the text vanishes even with a mask at (0,0) with width and height 1024 (far larger than my entire movie). I've checked and rechecked the documentation, and I don't see what I'm doing wrong: my fonts are properly embedded, I'm not trying to add transparency or rotate anything, I'm not even fooling around with _*scale. I've used trace statements to check everything's width and height, and nothing is 0, undefined, or in any way unexpected.Does anyone know what I might be missing?
Dynamically Import Fonts For Dynamic Textfields.
OKay here's my question: I want to make an SWF where I can dynamically alter the fonts based on another SWF containing the embedded font movie.
More Specific: I have a movie with dynamic textfields using a particular font (eg. Tahoma), now i want to change the font too another (eg. trebuchet).I don't want to have to recompile an SWF, just have this standard movie and based on Parameters I feed it, it will use 1 font. I'd like to be able to load a movieclip into my parent movie, containing that font embedded into it. This way I can use this movie as a sort of font plug-in.
Is this at all possible using flash?
DO I have to dynamically change the textfield properties first and set it to use a particular font and then load a movie clip wich has that font embedded wich will cause the paretn movie to use this font.?
Hope I don't sound too confusing.
Dynamically Layout Input And Dynamic Textfields
I would like to dynamically layout input and dynamic textfields from external data. The input boxes appear throughout the dynamic (nonselectable) text. Imagine a paragraph with several 'fill-in-the-blanks' throughout. I want to build one function that will automatically parse and populate this.
In dynamic HTML and CFM, this is a simple matter. In Flash, it looks like a huge feat...
What is the best approach to do this? Any ideas/code are welcome.
Note: we have to publish for Flash 6 Player, but are authoring in Flash MX 2004.
Best and thanks,
Sarah
Dynamically Create Multiple Textfields For A Mindmapper
Hi Guys
Any idea what code I need to dynamically create 'thoughtcloud' movie clips
based on an existing MC that contains a dynamic text field when a single button is clicked over and over?
I have a text input box on the screen that will update the text in each thoughtcloud. However at the moment I don't know how to auto increment the instance names of the thoughtclouds and the updater script. Can I use variable names for the textfields to do this and how would I go about it??
At present I have a button that creates a single static textfield which you can enter text into but then it isn't draggable as such. I need to make the text input box switch to updating the newly created textfield inside the thoughtcloud movieclip.
Its for a flash mindmapping tool I'm building for a school. Please help if you can. I've got so far but I need to finish this last bit of the puzzle. If it will help I have uploaded what I've done so far...
Thanks for any help you can give me.
Assign Variable : Dynamically Generated Textfields (createTextField)
Hi,
I was wondering if anyone could help me do this.
I am creating textfields via actionscript and assign them instance names. Now I must assign these fields variables. How do I go about doing that?
Code:
for (i = 0; i < 10; i++){
_root.createTextField("inst"+depth, depth, 10, i*30, 20, 20);
this_txt = this["inst"+depth++];
this_txt.border = true;
this_txt.size = 12;
this_txt.font = "arial";
this_txt.autosize = true;
//this_txt.text = ""+i;
}
inst1.text = "allo";
inst2.text = "duh";
inst3.text = "put a long string of text here";
thanks!
|