Autoheight of a dynamic textbox
Hi,
I have this script which reads the xml and creates a list of
article titles and descriptions. The problem is that I can't figure
it out how to tell Flash/AS that the distance between two titles
depends on the height of a title textbox and description textbox. I
have this line I'm playing around but I have no idea what to do.
var item_mc =
menu_mc.attachMovie("menu_item","item"+item_count, item_count);
item_mc._y =(item_count * (item_mc.info_txt._height +
item_mc.main_btn._height));
var previtem = item_count-1;
item_mc._y =(previtem._y + previtem._height);
item_count++;
If I use
item_mc.info_txt._height = 100;
it works, but if I use
item_mc.info_txt._height = autoSize;
it's not working
THX
Using getTextExtent() may be helpful in your case. This
method is good for measuring the distance between 2 textfields. In
the livedocs it mentions that this method has deprecated, this is
incorrect, it is still being used today. In Flash hit F1 and search
“getTextExtent”.
Similar Messages
-
using action script 2 how can i send a variable value to a dynamic textbox on a different keyframe?
Thanks for your swift response.
That sounds like a good solution, but the code I have on frame 2 is this
timer = 0;
countup = function(){
timer++;
countupInterval = setInterval(countup,100);
If I added the same actionscript to frame 3 which has a dynamic textbox with a variable timer attached wouldn't it just put the timer back to 0? What I want is the last known value that was given when it was in frame 2.
I am thinking of temple run here, I am trying to caculate the total distance(set in the timer variable) from the previous try.
Hope this makes sense.
Chazwick -
Creating dynamic textbox in JSP
I am trying to create dynamic textbox.when i run this below JS ,I am getting two boxes only and then i nothing getting it displayed.The problem comes in the inner for loop.
function DynamicBox(val)
alert("helloooo");
var d =document.getElementById("bottom");
d.innerHTML = '<table cellpadding="10">';
for(i=0;i<val;i++)
d.innerHTML += '<tr><td><INPUT type="text" name="week'+i+'" size=8 > </td><td><INPUT type="text" name="deliverable'+i+'" size=30> </td>';
for(j=1;j<=<%=parameter.length%>;j++)
<% int m=0;%>
d.innerHTML+='<td><INPUT type="text" name="'+<%=parameter[m]%>+i+'" size=10></td>';
<% m++; %>
d.innerHTML +='</tr><br />';
d.innerHTML+='</table>';
}In the above code,val is the number of rows to be created.Bottom is the id of the <div> tag.parametr is a String array.The values are coming from database.move the <% int m=0;%> out of the loop.. You have place it in the loop, causing it to be initialize to be 0 each time the looping occurs.
Place <% int m=0;%> below the line: d.innerHTML = '<table cellpadding="10">' -
Passing Input Text Data to Dynamic TextBox in Another Scene
Hi everyone there,
I am creating a quiz for my school using flash.
I am wondering if it is possible to pass the answers key in
by students in the input text field to the dynamic textbox at the
end of the entire quiz to show all the ans by the students and all
the model ans of the quiz.
May i know if this can be done?
Or is it better to pass info from text box to text box in
from one frame to another in the same scene?
Also, how do i create a page that will list down the total
number of questions the student has answered correctly and show her
score?
Thank you very much.
FiOh
*^^*An instructor at a summer camp told me to avoid scenes, so
I've been afraid of them ever since.
I'm not sure I quite understand the first post - you want the
students to put in their own answer key?
I made a quiz once. It was about genetics. This first frame
had a "let's go" button that started the quiz. Each consecutive
frame had a question and an oddball amount of input fields. The
frame had each input set to a certain variable. At the end it added
one to the score variable for each textfield that matched my magic
answer. You could do all kinds of things this way. The syntax
looked something like:
if(input3A.text = whatever the answer is) {
++score; //adds to score variable
and it could make a result3A_txt.text = "Bingo";
"input3A" is arbitrary - for problem three, two, etc. the
text field was called "input" and then a number, and then, if there
was more than one text field for that problem, a letter. This is
just the first field in problem three.
The second line in the if statement talks to a field. You put
a static text with the problem number, and next to it,
result3A_txt. If the user answered the problem correctly, the field
will become "Bingo" or something. You would do this for each
problem so that every correct one would say "Bingo."
To get a percent score:
percent_txt.text = Math.round((score / max_score) *
100); -
Dynamic textbox through the Back button
I have created a dynamic textbox in a JSP using Javascript.
When I submit the form in this JSP, the data's validated & a confirmation message is displayed.
On this confirmation message, when the Back button is clicked, I get the original form with the data entered for all the fields except for the dynamic textbox, because there is no dynamic textbox!
The textbox is to be displayed only when a condn is fulfilled. This is coded in a Javascript fn that gets called only when a particular value in the listbox of the form is selected.
How do I display the textbox when the Back button's clicked?Thx for trying to help.
Here's the source code:
<script language="JavaScript">
<!--
function textBox(areaName, submitted)
var spanTxtID = document.getElementById('insertTxtSpan');
var areaNameText=document.createElement('input');
areaNameText.setAttribute('type', 'text');
areaNameText.setAttribute('name', 'areaNameText');
areaNameText.setAttribute('maxLength', 20);
areaNameText.setAttribute('size', '20');
//areaNameText.setAttribute('value', 'Khar');
//alert(areaName.value)
if(areaName.value=="Other")
submitted=false;
while(spanTxtID.hasChildNodes()) spanTxtID.removeChild(spanTxtID.lastChild);
spanTxtID.appendChild(areaNameText);
else { submitted=false; while(spanTxtID.hasChildNodes()) spanTxtID.removeChild(spanTxtID.lastChild); }
-->
</script> -
How to create dynamic Textbox in JSP
I created dynamic Textboxes using javascript in JSP.But i want to give every textbox a unique name..But I dont know how to give unique name to all the textbox which are created dynamically.....Can u help me Please.............
<script code="text/javascript">
function dynam(val)
var d= document.getElementById("Bottom");
d.innerHTML='<table>';
for(i=1;i<=val;i++)
d.innerHTML += '<tr><td>Parameter</td><td><INPUT type="text" name="week"'+i+'size = 15></td>';
d.innerHTML +='</table>' ;
</script>in the above code."val" is the integer value passed while calling this function. "Bottom" is the id of <DIV> tag in my JSP page.
My problem is : when i creating a text box. the Unique name of the textbox in not getting generated.All the text bok has the same name as "week",but i want the name to be as week1,week2,week3,.....etc
Edited by: AnilTcs on Jan 21, 2009 1:31 AMTry this:
d.innerHTML += '<tr><td>Parameter</td><td><INPUT type="text" name="week '+i+' " size = 15></td>';I have just changed the quotes around week. Hope this helps. -
Grab Frame Number, add 6 and display in dynamic textbox
Hey,
I have a gallery that needs numbered images. To do this I
need to grab the current frame number of a parent movie, add 6 and
display in a dynamic textbox. Sounds simple!
The frame number I need to grab is in:
_root.gallery
The dynamic textbox has the var name 'displayNumber' and is
in:
_root.gallery.controlbox
I need this to refresh every time the frame number changes in
the _root.gallery clip. This is a fairly urgent project so swift
help is obviously appreciated!
Thank you in advanceyour code will work if all you state is valid and there's no
other _root.gallery.onEnterFrame overwriting the one you
posted. -
Remove dynamic textbox on loading an image
I'm trying to remove a line of text placed in a dynamic textbox inside a MC after an image loads in the imageloader component.
I've highlighted the line in RED in the code below.
Maybe a timer for this text to disappear or a statuschange function would be helpful. I've been searching extensively but in vain. Any heads-up please?!
Any help would be much appreciated.
Thanks.
Sudarshan
// Import the MX.UTILS so it can be used to set the scope of the listBox listener and the xml onload feature
import mx.utils.Delegate;
// Define default URL to load if no URL is defined in XML attribute
_root.urlLink = "http://www.somesite.com";
// declare variables
var people:Array;
var product:Array;
var update:String;
var dirpath:String;
// set up the XML instance
var peoplexml:XML = new XML();
// initialize items on stage
_global.style.setStyle("fontFamily","Verdana");
_global.style.setStyle("fontSize",11);
// define what should happen when the XML loads
// (read data into update, dirpath, and brand variables)
function onXmlLoaded(success:Boolean)
if (success)
// make a handle to the root node in the xml
var mainnode:XMLNode = peoplexml.firstChild;
update = mainnode.attributes.lastupdate;
dirpath = mainnode.attributes.dir;
// set up an array of all brand nodes
var peoplenodes:Array = peoplexml.firstChild.childNodes;
for (var i:Number = 0; i < peoplenodes.length; i++)
// for each brand node:
var personnode:XMLNode = peoplenodes[i];
people.push({i:i + 1, pname:personnode.attributes.name});
// data is all read and put in the right place -- now setup the screen
// using this data
setup();
else
trace('error reading XML');
function setup()
// set up chooseperson dropdown
choosebrand.labelField = "pname";
choosebrand.dataProvider = people;
choosebrand.addEventListener("change",Delegate.create(this, loadProducts));
function loadProducts(evt:Array)
var thisitem:Array = evt.target.selectedItem;
var productList:Array;
chooseproduct.labelField = "prname";
product = [prname];
var peoplenodes:Array = peoplexml.firstChild.childNodes;
for (var i:Number = 0; i < peoplenodes.length; i++)
// for each brand node:
var personnode:XMLNode = peoplenodes[i];
if (personnode.attributes.name == thisitem.pname)
var productnodes:Array = personnode.childNodes;
for (var j:Number = 0; j < productnodes.length; j++)
// for each product node:
var productnode:XMLNode = productnodes[j];
product.push({i:j + 1, prname:productnode.attributes.title, img:productnode.attributes.photo, url:productnode.attributes.url, txt:productnode.attributes.txt, det:productnode.attributes.det, price:productnode.attributes.price, clck:productnode.attributes.clck});
loader.img.contentPath = "";
loader.clck.text = "";
loader.ldng.text = "";
productTitle.ptitle.text = "";
productTitle.pdet.text = "";
productTitle.prc.text = "";
//initialize the product array
chooseproduct.labelField = "prname";
chooseproduct.dataProvider = product;
chooseproduct.addEventListener("change",Delegate.create(this, loadImage));
function loadImage(evt:Array)
var thisitem:Array = evt.target.selectedItem;
productTitle.ptitle.text = thisitem.txt;
productTitle.pdet.text = thisitem.det;
productTitle.prc.text = 'Rs.'+ thisitem.price;
loader.img.contentPath = thisitem.img;
loader.clck.text = thisitem.clck;
loader.ldng.text = 'Loading Image...';
_root.urlLink = thisitem.url;
function init()
// initialize the brand array
people = [pname];
// set up the xml instance to ignore whitespace between tags
peoplexml.ignoreWhite = true;
// set the scope of the onLoad function to the main timeline, not peoplexml
peoplexml.onLoad = Delegate.create(this, onXmlLoaded);
// start the xml loading
peoplexml.load("bannerxml.php");
init();You can use the setTimeout() function if you want to delay some code from executing
-
Font related issue in dynamic textBox
hi everybody,
i hv a problem. i m loading data from XML file which of UTF-8
encoded and showing it on a dynamic textBox. i m using the font
Arial which is already embaded in the library. the problem is that
the data is not showing n if i chenges the data to that of english
the data shows up. but if i m creating the dynamic textBox at the
_root even chinese data also showing properly.
can any body help me to find out what could be the exact
problem , thanks
can u please PM me top [email protected]well that depends how u are using your text. an XML can be
easiliy shown in Dynamic text box. there are some issues when you
mask it,
although do one thing, if you are using Arial try not to
embed and then see what happens, if it still raises a problem, let
me know -
Why does ' ' kill my dynamic textbox content?
Well... I think it's because Flash sees it as a broken HTML tag, so I guess my real question is how to fix it?
Here's the scoop:
I have a dynamic textbox which is being assigned a variable. The textbox is set to render as HTML and all fonts are loaded.
The following variables appear fine in my textbox:
varText = "This is <b>bold</b>";
varText ="Two is > One.";
but this one
varText ="One is < Two.";
is truncated as soon as it hits the "<". Wrapping everything in <p>variable</p> doesn't help
Any ideas?
Thanks,
- JGOK... I go it solved.
First I realized that inserting a < into the HTML string did display the "<".
But, a mass replace killed all my actual HTML tags of course.
So, I had to write a script to seek out all instances of "<" and leave the actual tags alone (eg <b>, </b>, etc.), but replace the other instances with the character code.
There's probably a better way... but at least this works.
Thanks,
- Jamal -
Looping a dynamic textbox to update its content?
i have a 100 frame movieclip with a dynamic textbox inside that outputs the current frame.
This movieclip gradualy goes from frame 100 - frame 0.
would i need this textbox on 100 frames with code on each or just 1 stretched through the 100 frames? i can get it to say 100, when its on the 100th frame but its doesnt go to 99 98 etc.
atm i tryed:
mc.onEnterFrame = function()
mc.text = _currentframe;
but that doesnt work.If mc is a textfield, textfields do not have an onEnterFrame method. Try using this instead...
this.onEnterFrame = function()
mc.text = _currentframe;
You should only need one instance of the textfield spanning across the timeline. -
JS validation for dynamic textbox
How can i validate dynamic textbox using javascript?.
item_val_#i# is required field.
<cfloop from="1" to="#count#" index="i">
<input type="text" name="item_val_#i#" size="5"
maxlength="5">
</cfloop>use the same cfloop inside your js code (assuming it is IN
THE SAME
PAGE, not in a separate file).
obviously, your #count# variable must be set BEFORE the js
code...
something like [not complete function]:
function validatefields(){
var errstr = "";
<cfloop...>
(document.forms[0].elements["item_val_#i#"].value=="") ?
errstr =
errstr + "\nField Myfield#i# must have a value!" : errstr =
errstr;
</cfloop>
but i would suggest you better validate input server-side...
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com -
Create Dynamic TextBox in LIghtSwitch
Hi Team,
i am developing HTML client LightSwitch Application
My doubt is i need to create textboxes in the screen which will not be bound to any entity. I want to display the aggregate value from the screen.
Department Name - Filter
Actual Effort Sum - TexField - 25
Planned Effort Sum
- TexField - 30
Effort Variance - TexField - 5
Resource Name
Department
Actual Effort
Planned Effort
Srikanth
ABC
10
15
Ashok
ABC
15
15
as shown in the above screen model (Since i cannot able to upload my browse screen snapshot)which is screen for the entity ResourceEfforts and i
have one filter (Department Name) which is not optional, so when use enters the department it will display all the resource names with their efforts in the browse screen (from the ResourceEfforts entity)
those who are comes under that particular department.
My Requirement is, i
want to show the aggregate value from the screen values (sum of Actual Effort, sum of Planned Effort and total Effort variance) in the dynamic text fields for the entered department value in the filter.
i have been thinking of using Linq Query to evaluate the value but i need to pass the entered department filter value in the 'where' condition
of the linq query.
so anyone please tell me if you have suggestions for this scenario, it will be really helpful.
Thanks,
Srikanth AnantharamanHello Srikanth,
You may find the following link helpful:
http://lightswitchhelpwebsite.com/Blog/tabid/61/EntryId/1207/HUY-Volume-III-ndash-Popups-Dirty-Visual-Collections-and-Using-Prototypes-To-Calculate-Child-Collections.aspx
Scroll down the page until you see a section called Using Prototypes To Calculate Child Records.
Another way is to bind your Filter property to the parameter of the dataset on that screen. Click on Edit Query on the right hand side of the Table name, then add a new filter at the top saying something like Where Department equals
, then pick Parameter from the third dropdown and Add new from the final dropdown.
This will create a new Parameter at the bottom of the query screen called "Department" (although you can rename it by clicking on its name, if you like.) If you want to see all Departments if a specific one is not entered, check the
box marked "Is Optional".
Click the link to go back to your screen in the upper left. Select your table again, and now you'll see a new section at the bottom called Query Parameters, and your new parameter should be there. Click on your new parameter, and in the Properties
window, set the Parameter Binding to the name of the screen property you created, DepartmentName, or whatever its name is. Test your program by hitting F5 or clicking Start, and you should see that the table does change whenever you type something into
your Department Name - Filter box.
Once that works, the next thing to do is go to the PostRender event for your DepartmentName box and add a contentItem.dataBind so that you can calculate the display fields immediately when someone puts a department into the box. Something like:
myapp.DepartmentScreen.DepartmentName.PostRender(element,contentItem) {
contentItem.dataBind("value",function(newValue) {
if(newValue != undefined && newValue != null) {
contentItem.screen.getDepartmentTableItems().then(function() {
var actualSum = 0;
var plannedSum = 0;
contentItem.screen.DepartmentTableItems.foreach(function(item) {
actualSum += item.ActualEffort;
plannedEffortSum += item.PlannedEffort;
screen.ActualEffortSum = actualSum;
screen.PlannedEffortSum = plannedSum;
screen.EffortVariance = plannedSum - actualSum; -
I have a textbox in a JSP file that appears only when a particular value is selected in a listbox. This has been done through Javascript.
Now, when the textbox is added, the whole form moves down.
How to eliminate this movement?
Following's the Javascript code:
function textBox(areaName, submitted)
var spanTxtID = document.getElementById('insertTxtSpan');
var txtSpan = document.getElementById('txtSpan');
var areaNameText=document.createElement('input');
areaNameText.setAttribute('type', 'text');
areaNameText.setAttribute('name', 'areaNameText');
areaNameText.setAttribute('maxLength', 20);
areaNameText.setAttribute('size', '30');
areaNameText.setAttribute('height', '21.3');
if(areaName.value=="Other")
submitted=false;
while(errSpan.hasChildNodes()) errSpan.removeChild(errSpan.lastChild);
while(txtSpan.hasChildNodes()) txtSpan.removeChild(txtSpan.lastChild);
while(spanTxtID.hasChildNodes()) spanTxtID.removeChild(spanTxtID.lastChild);
spanTxtID.appendChild(areaNameText);
else
submitted=false;
while(errSpan.hasChildNodes()) errSpan.removeChild(errSpan.lastChild);
while(txtSpan.hasChildNodes()) txtSpan.removeChild(txtSpan.lastChild);
while(spanTxtID.hasChildNodes()) spanTxtID.removeChild(spanTxtID.lastChild);
}Helo Ananth,
What i want is as i press one button i want one textbox object shuld appear on the canvas.I am not talking about the thing like we make one textbox and on click of button it must be visible.so i want to make a textbox dynamically or at runtime it shuld appear.
TQ
Vivek -
How to show an XML doc's node?/element in a dynamic textbox?
Hello!
I would like to show an XML doc's node?/element in a textbox. I am importing the XML data from a PHP page. My code looks like this:
var xmlRequest:URLRequest = new URLRequest("adatatvitel.php");
var xmlLoader:URLLoader = new URLLoader(xmlRequest);
xmlLoader.addEventListener(Event.COMPLETE, init);
function init(e:Event):void{
var xmlDoc:XMLDocument = new XMLDocument();
xmlDoc.ignoreWhite = true;
var datasXML:XML = XML(xmlLoader.data);
xmlDoc.parseXML(datasXML.toXMLString());
This program would be a quiz. First I would like to write out the first data: Question with the appropriate Answers. If the player's answer is correct, the program would show the second set. Thanks in advance!
Here is my PHP code:
<?php
require("db.php");
$sql = "SELECT * FROM kerdesvalasz";
$result = mysql_query($sql) or die(mysql_error());
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
echo "<datas>";
while($row = mysql_fetch_array($result))
echo '<data>';
echo '<question>'.$row['kerdes'].'</question>';
echo '<answer1>'.$row['valasz1'].'</answer1>';
echo '<answer2>'.$row['valasz2'].'</answer2>';
echo '<answer3>'.$row['valasz3'].'</answer3>';
echo '<answer4>'.$row['valasz4'].'</answer4>';
echo '<correct>'.$row['helyes'].'</correct>';
echo '</data>';
echo "</datas>";
?>Hi Taly,
Florian is right, you need to knwo / set a maximum columns ( i assumed he actually mean column) so that content being displayed will be visible on form.
I would suggest you to reaccess to your solution again if this design and think what if you have 999 columns, how do you want to display the content in form .
I would suggest to transpose your content to display as row in form, and let the content to flow.
This should solve your issue.
Hope this helps.
regards,
Xiang Li
Maybe you are looking for
-
"Preview" randomly fails to open files & PDFs
I have a 5k iMac and I have had problems with the Preview app from day one. Sometimes it gets in a rut where it won't open any file including PDFs. When I double click on a document, Preview opens but no document opens. If I go to the "File" menu and
-
NEF unsupported - A3.4 & Cam Raw 4.0
I'm brand new to Mac, Aperature, and photography. Problem: Images taken with Nikon 1 J2 in raw (NEF) format shows as "Unsupported Image Fomat" in Aperture. Both iPhoto and Preview also cannot open the files saying that they are unsupported raw forma
-
My Firefox will not search for websites
My Firefox will not search for websites etc. I put in a parameter and it will not do anything. When I use anything else (such as Yahoo! search) it works fine. I type in a word/website/name etc. into the search box on Firefox and nothing happens. I ha
-
Link Target, Code Snips and Nag-Screens?
I shelled out the cash to buy a copy of iLife '06 so I could get iWeb. I quickly found that it was missing the ability to specify targets in links, this is an incredibly basic feature that iWeb is strangely missing. Without it iWeb sites aren't frame
-
Kicked Out of Response Group When Status is Away
Lync 2010: When switchboard staff enable the Response Group for Main-Line incoming calls and their Lync status changes to "Away," they do not receive the incoming calls. Sometimes the switchboard staff are at their desks but not active on their comp