Check For Certain Key-press In A Textfield..
Howdy all..
I have a lil prob here..
I want to let flash execute a set if external functions (ASP) as soon as a user presses the ENTER-key (chr(13),chr(10)..?) inside an Input field. I tried on(something) and some other stuff, but to no avail. Cos this script only seems to work in button instances. Calling the external ASP scripts is no problem, but getting flash to respond on pressing the ENTER key inside that field seems a lil trickier..
Any support would be greatly appreciated.
thanks lots in advance
FlashKit > Flash Help > Flash ActionScript
Posted on: 10-07-2001, 08:11 PM
View Complete Forum Thread with Replies
Sponsored Links:
[textfield] How To Check If Input Text Is More Than Textfield Height?
Hi guys, Is there a way to check if the text that has been input into the textfield is more than the height of the textfield.
I have set the scrollbar hidden and it will become unhidden once the text is greater the the textfield height.
I did try to count the input text and set the visiblity of the scrollbar against that count. Unfortunatly this is unreliable.
Anyone got a better idea?
Cheers
Paul
View Replies !
View Related
[textfield] How To Check If Input Text Is More Than Textfield Height?
Hi guys, Is there a way to check if the text that has been input into the textfield is more than the height of the textfield.
I have set the scrollbar hidden and it will become unhidden once the text is greater the the textfield height.
I did try to count the input text and set the visiblity of the scrollbar against that count. Unfortunatly this is unreliable.
Anyone got a better idea?
Cheers
Paul
View Replies !
View Related
Using An Array To Check For Button Press
I have six buttons on a frame. When a user presses a button they are sent to a new frame with information - then they click another button and return to the first frame with the six buttons. I want to be able to check that each button has been pressed, and if it has, I want to set the alpha (since they are MC's) set to 50%. I have done some research on this and have found that using an array is helpful. But how would I set this up?
buttons = ["btn1", "btn2", "btn3", "btn4", "btn5", "btn6"];
But what AS would I use to check which button is pressed and where whould I put this code..on the first frame?
Thanks
Kirk
View Replies !
View Related
TextField On Return Press
hey there, i am trying to make a text field where you can store strings into an array when you press enter. The page will have multiple text fields so the key press of return must only apply to the currently selected text field.
_root.createTextField("_txt", 0, 0, 0, 100, 20);
_txt.border = true;
_txt.type = "input";
var text2:Array = new Array;
_txt.onChanged = function() {
text2.push(this.text);
for (i=0; i<text2.length; i += 1) {
trace(text2[i]);
}
};
i want to change this onChanged to a onKeyPress(Key.ENTER) or something. i have no idea of the correct syntax.
thanks in advance
View Replies !
View Related
How To Validate TextField When ENTER Is Press
i want to validate the value entered in textField.
I will assign a function to onKillFocus event to the textField. However, i would like to invoke the function when the user hit ENTER after entering the value. How to do that?
My take will use Selection.getFocus & Key.getCode. But it makes the code ugly -- the onKillFocus is attached to the textField, whereas Selection.getFocus methods will need another if-else statement.
View Replies !
View Related
TextField Population From A .TXT File On Button Press..
Hi,
I have developed a browser page in Flash , with Buttons say A, B, C, D on the left side. I need to display different Text matters from external Files,
say A.TXT, B.TXT, C.TXT, D.TXT in a Textfield ( with scrolling Texts), on this Page, when the corresponding Buttons are pressed/clicked by user.
I purposely do not want another HTML page to be displayed at the Click of these buttons, but only want all these to happen just on this single browser page, created in Flash8.
This could be a very simple solution.... but am unable to design one !!...
Thanks.
View Replies !
View Related
Trigger TextField OnChanged Handler Without Key Press?
Maybe you can do this and I am jus missing it but can you fire off the textField.onChanged event handler without physically giving focus to the textfield and then typing in it?
Here is a small script I am using to test this:
Code:
//set the scrollbar component to be invisible
text_sb._visible = 0;
//create event handler to hide/show scrollbar component
text_txt.onChanged = function(){
if(text_txt.scroll > 1){
text_sb._visible = 1;
}else{
text_sb._visible = 0;
}
trace(text_txt.scroll);
}
//create setInterval to fire off typing function
typer = setInterval(doTyping, 300);
//function to type one character and a soft return
function doTyping(){
text_txt.text += "X" + newline;
}
My goal with this is, at run-time (or compile time...whatever) to have this text field that is on the Stage with the scrollbar component already attached to have text inserted into programmatically (function doTyping) and once the text bumps the scroll property up past 1, then hav ethe scrollbar component appear and start adjusting itself automatically.
This works if I hand enter text when I test the movie.
So there it is. In all it's glory. Any ideas?
View Replies !
View Related
Textfield Check
I wonder how I can check the content of a textfield. For now I've got
Quote:
if (_root.name.inputname=="") {
_root.resultname ="empty"
} else {
_root.resultname = _root.name.inputname;
}
but it won't do...
robin
View Replies !
View Related
Check If Changed On More Than One Textfield...?
Hi,
I have this code to trigger different alpha settings on some buttons, depending on the content of a dynamic text field
Code:
function checkIfChanged(field,txt, a, b, c, d){
if (field == txt) {
trace("text has changed");
aq1._alpha = a;
aq2._alpha = b;
aq3._alpha = c;
aq4._alpha = d;
}
};
a.onRelease = function (){
str = "black";
my_txt = str;
checkIfChanged(my_txt,str,20,100,30,90);
};
b.onRelease = function (){
str = "blue";
my_txt = str;
checkIfChanged(my_txt,str,50,10,70,100);
};
and so on....
But there are two textfields on the stage.
And I want something like this to happen:
If "textfield 1" says "Blue" and "textfield 2" says "Green" then put following alpha settings.
I tried it many ways but nothing seems to work.
Can I give the second text-field an name like "str2" and if yes what else would I have to put in my CheckIfChanged function?
I'm really lost....
Thanks!
View Replies !
View Related
Check If TextField Is Selelcted
Hey guys,
How can i check if the user selected a certain TextInput TextField, I don't mean highlighting the text, just that the typing cursor (the vertical blinking line) is in that certain TextField.
And after the user selected it, how can i set that typing cursor to another TextField?
//Thanks, Tilpo
View Replies !
View Related
Dynamic Textfield Check
Hey,
How can I check whether a dynamic textfield is empty or not?
When it is NOT empty I want to display a buton above it with an getURL action with the url from the textfield.
How can I do that ?
thx in advance.
View Replies !
View Related
[as] How To Check Size Of An Autosize Textfield?
Ok here is the situation.
I have a movieclip in my library that is linked as article_MC.
In this movieclip I have a title_txt textfield and a article_txt textfield.
My title_txt textfield is just a normal textfield on a single line. My article_txt textfield (multi line) is set to wordWrap = true and autosize = true so that it always stays the same width yet can change in height depending on how much text I have.
I loop through an XML file that has some news articles that are different sizes. Everytime the loop reaches a new article it attaches my article_MC movieclip to the stage and sets title_txt to the attribute called title and article_txt to the nodeValue of the article.
Now what I would like to have is to position each new article at a _y coordinate that is the height of the last article + the _y of the last article, but the _height of the last article still has the value it had initially before text was entered into it.
so is there a way to find out the real height of this movieclip while still looping through my XML file?
here are the ressources:
http://konstructs.com/news.zip
View Replies !
View Related
Indexof - Valid Email Adress Check In Textfield
this is my code to check whether all fields have been filled out or the email adress is valid or not.
Code:
on (release) {
if (antwort eq "" or betreff eq "" or inhalt eq "" or von eq "" or iantwort.indexOf('@') < 0
or iantwort.indexOf('@') != iantwort.lastIndexOf('@')) {
stop();
check.text = "Invalid adress or empty fields";
} else {
loadVariables("http://XXXXX.XXXX.XXXXX/mail.cgi", "_root.home_container", "POST");
gotoAndStop(23);
}
}
it does check for the empty fields, but not if theres an @ in it. can u maybe help me? maybe there are other conditions that need to be met to have a valid email adress that i could check for..thanks!
Chris
View Replies !
View Related
Check Whether Characters In Input Textfield Are Numbers Or Letters?
I just can't get this right.
I have two textfields:inputTxt (INPUT)
statusTxt (DYNAMIC)
I have a button, which when pressed should check whether the characters entered into the input field are numbers or letters.
I have tried:
Code:
private function onMouseUp(evt:MouseEvent):void {
if (isNaN(inputTxt.text)) {
statusTxt.text = 'You have not entered a number';
}else {
statusTxt.text = 'You have entered a number';
}
}
I realise now that isNAN() only checks a variable value rather than a string value.
How does one do this?
View Replies !
View Related
Check Whether Characters In Input Textfield Are Numbers Or Letters?
I just can't get this right.
I have two textfields:
1. inputTxt (INPUT)
2. statusTxt (DYNAMIC)
I have a button, which when pressed should check whether the characters entered into the input field are numbers or letters.
I have tried:
private function onMouseUp(evt:MouseEvent):void {
if (isNaN(inputTxt.text)) {
statusTxt.text = 'You have not entered a number';
}else {
statusTxt.text = 'You have entered a number';
}
}
I realise now that isNAN() only checks a variable value rather than a string value.
How does one do this?
View Replies !
View Related
On "press" Check 1st If Hel.mc Reached Frame222 And Then Load The New Mc...(plz Read)
i need to do something ,i know that it can be done but i don't have any clue how..
i have at my main movie a mc that ALLWAYS plays a loop of 222frames and then continue again from the 1st frame
whatever happen to the main stage (_level0) this mc will never unload or move etc etc
let's say that this mc is a helicopter that i made in a 3d animation app and allways flying to a loop
what i need to do is:
when i will press a button somehow what needs to load will w8 until the helicopter .mc is at 222frame (last frame) because this will be the only way to know that the loop has finished
i need to load exactly at the last frame another animation of the helicopter ...i guess you got my point ..right?
for example i will create another animation that will start from the 222 frame and for another 222 frames length
if i press the button and the new helicopter will load ,if the 1st will be at frame 150 for example the user will understand it like frame skip and worst
i need to press the button...flash movie listen if helicopter1 reached frame 222,unload it and then load the helicopter2 and the user will not understand nothing
then this helicopter will also loop until i reverse the call
so how can this happen??
View Replies !
View Related
Button Press + Key Press Together In Perfect Harmony?
Well, i have been trying now for a while to get my buttons to display the corresponding number in a text box. I have achieved it so that if you click on the button with the mouse cursor it will happen. I can also do this for a keypress, but sadly they will not work as an either/or option. What actually happens is that the keypress is disabled until the mouse has activated the on release.
Here is the code:
on (release){
if (password == "") {
password = "1";
} else {
password += "1";
}
}
on(keyPress "1"){
if (password == "") {
password = "1";
} else {
password += "1";
}
}
Any suggestions will be greatly welcomed.
Thanks
Yoda
View Replies !
View Related
Combo Key Press, Double Key Press Ect
HELLO, this is common code for action "when u press key go to "frame""
Code:
if (Key.isDown(Key.UP)) {
_parent.gotoAndPlay("frame");}
i want to ask if any1 know code for actions:
1. when u press combo key UP and then key DOWN(down after up in like 0,5 sec or smth) goto "frame"
2. when u press 2 keys AT once (f.e. up+down arrows)
3. when u press key very fast twice - goto "frame"
GREETINGS !
View Replies !
View Related
[F8] Key Press To Mouse Press
The code below is a sample i want to change to onMousePress from keyPress. my attempts have not worked. come someone give me some pointers?
rat
PHP Code:
fscommand ("fullscreen", "true");
fscommand ("allowscale", "false");
Stage.scaleMode = "noscale";
stop();
// use spacebar to re-draw screen
var canvasArray = new Array();
for (var p in this) {
var curCanvas = this[p];
if (curCanvas instanceof MovieClip) {
canvasArray.push(curCanvas);
}
}
pressSpacebar = new Object();
pressSpacebar.onKeyDown = function() {
if (Key.isDown(Key.SPACE)) {
for (var i=0; i<canvasArray.length; i++) {
var curCanvas = canvasArray[i];
curCanvas.drawCanvas();
}
}
}
Key.addListener(pressSpacebar);
View Replies !
View Related
Reality Check: Flash CS3/AS3 Check Syntax
I need a quick reality check. I've finally started playing around in CS3/AS3 on my Mac. Whenever I click "check syntax" I get a very limited error response: specifically, I get actual syntactical errors (e.g., a missing brace or paren), but I get NO COMPILER ERRORS (e.g., use of an undefined method or property). These compiler errors trigger at runtime, but not having them during authoring makes coding and debugging unnecessarily difficult.
Is this really how it's supposed to work?
In Flash8/AS2, we had compile-checking right in the AS file. If I attempted to access an undefined method or property, the error-checker would catch that right away. No time-consuming compile was necessary to catch these obvious errors (see example below). But AS3 doesn't seem to be as clever.
Am I missing something?
Thanks much!
-------------EXAMPLE---------------
Attach Code
import flash.display.BitmapData;
class myClass{
var _bmp:BitmapData;
function myClass(){
_bmp = new BitmapData(500,300);
_bmp.methodNotDefined();//unknown method of BitmapData triggers an error
myVar = 5;//unknown property of myClass triggers an error
}
}
View Replies !
View Related
On Press Start Drag, On Press Stop Drag. How?
Hello i have an object that i want to drag and drop with the same event.
Something like on press start drag and on press again stop drag.
Anyone can help me?
I'm sure it's pretty simple with and if and else statment but i can't find how to do that...
The best i have done so far was this:
ActionScript Code:
on (press) {
startDrag(this);
}
on (release) {
stopDrag();
}
But i want to on press start drag then on press again stop drag.
anyone can help?
thanks
View Replies !
View Related
On Press Start Drag, On Press Stop Drag. How?
Hello i have an object that i want to drag and drop with the same event.
Something like on press start drag and on press again stop drag.
Anyone can help me?
I'm sure it's pretty simple with and if and else statment but i can't find how to do that...
The best i have done so far was this:
Code:
on (press) {
startDrag(this);
}
on (release) {
stopDrag();
}
But i want to on press start drag then on press again stop drag.
anyone can help?
thanks
View Replies !
View Related
Add A Movieclip On Button Press, Remove On Another Button Press...
Sounds a little confusing maybe, but the idea is rather simple... I'm trying to figure out a way to have a + and a - button. When a user hits the + button, a movieclip appears. If they hit it again, another duplicate movieclip appears next to the first, etc... basically adding movieclips along the x-plane. Now, when the user hits the - button, the movieclip on the furthest right-hand side is removed, when hit again the next movieclip furthest on the right-hand side is removed, etc until there are no more movieclips.
It's basically an add and subtract movieclip function but I have no idea how to set this up. Any tips or advice would be greatly appreciated! thanks in advance!
View Replies !
View Related
Loading Text & JPG Nito TextField Makes Textfield White
Hi guys !
Does anyone know, why a textfield may become white when loading text + JPGs into it? Sometimes it happens to me, sometimes not. I haven't figured out why.
If you have any clues... I'd be really thankful
The AS I'm using:
_target.container.t.html = true
_target.container.t.condenseWhite = true
_target.container.t.autoSize = "left";
_target.container.t.htmlText = _data.texto
The String ( &HTML ):
"Text lorem ipsum bla bla ..... <img style='WIDTH: 154px; HEIGHT: 59px' height='298' width='856' alt='' src='http://www.spacilong.com/arq/img/AlcatelLucent_Hor_2col_sm.jpg' />
View Replies !
View Related
Textfield Woes, How To Anti-Alias A Dynamic Textfield?
this is driving me nuts, even if i have it marked so that my dynamic textfield is anti aliased, it still looks as if its text is aliased. And if i simply make that textfield Static, the text all of a sudden looks amazingly crisp and anti aliased.
How can i fix this?! I am attempting to load xml data into my text fields but its wasted if the text looks like crap..
So can anyone enlighten me on how to do this? i tried searching Flashs help, all i came out with was "Textfield._quality" but i do not understand what the description means exactly.. And i tried coding my textfield to _quality = "BEST";, with no avail.
Please help, i'v seen other websites with what i am sure is dynamically loaded fields, and smooth looking text... so what gives?
Thanks!
View Replies !
View Related
Link In Dynamic Textfield To Jump To Section Of Same Textfield
Howdy all,
I know you've all seen this before - you are on a website and you click a link and you stay on the same page but jump down to a different section of the page. Like an FAQ page or something where all the questions are listed above but you click on one and jumps down to the answer below.
Is it possible to do this in a dynamic (scrollable) textfield with externally loaded text files in Flash? I don't have DW and I know that there are limited html tags available but if anyone knows an easy way to do this please let me know!
thanks!
View Replies !
View Related
Link In Dynamic Textfield To Jump To Section Of Same Textfield
Howdy all,
I know you've all seen this before - you are on a website and you click a link and you stay on the same page but jump down to a different section of the page. Like an FAQ page or something where all the questions are listed above but you click on one and jumps down to the answer below.
Is it possible to do this in a dynamic (scrollable) textfield with externally loaded text files in Flash? I don't have DW and I know that there are limited html tags available but if anyone knows an easy way to do this please let me know!
thanks!
View Replies !
View Related
Masking Dynamic Textfield When The Textfield Has A Stylesheet
ok... i have a movieClip containing dynamic textfields, which i'm trying to mask. the textfields are linked to a stylesheet. i understand that, for the masking to work, i have to embed the font. so i've placed the font in the library, given it a linkage name and set embedFonts = true for the dynamic textfields.
what do i do next? and does the fact that i'm embeding the font override the effect of the stylesheet?
(sorry if i sound confused over this. that's because i am.)
thanks in advance for any help
View Replies !
View Related
Textfield In ScrollPane > Textfield Only Accessible With Clicking Twice
hi!
i have a scrollPane on the stage which contains an editable textfield.
unfortunately i can only access the textfield in the pane when i click on it twice. it seems that the first click goes for the activation of the pane and then comes the textfield.
does anybody have an idea how to solve that problem?
// Text Field
var myTextField:TextField = new TextField();
myTextField.text = "Please insert text";
myTextField.selectable = true;
myTextField.type = TextFieldType.INPUT ;
// ScrollPane
var myScrollPane:ScrollPane = new ScrollPane();
myScrollPane.source = myTextField;
addChild(myScrollPane);
View Replies !
View Related
Masking Dynamic Textfield When The Textfield Has A Stylesheet
ok... i have a movieClip containing dynamic textfields, which i'm trying to mask. the textfields are linked to a stylesheet. i understand that, for the masking to work, i have to embed the font. so i've placed the font in the library, given it a linkage name and set embedFonts = true for the dynamic textfields.
what do i do next? and does the fact that i'm embeding the font override the effect of the stylesheet?
(sorry if i sound confused over this. that's because i am.)
thanks in advance for any help
||| O ^ | + O ¬
View Replies !
View Related
Masking Dynamic Textfield When The Textfield Has A Stylesheet
ok... i have a movieClip containing dynamic textfields, which i'm trying to mask. the textfields are linked to a stylesheet. i understand that, for the masking to work, i have to embed the font. so i've placed the font in the library, given it a linkage name and set embedFonts = true for the dynamic textfields.
what do i do next? and does the fact that i'm embeding the font override the effect of the stylesheet?
(sorry if i sound confused over this. that's because i am.)
thanks in advance for any help
||| O ^ | + O ¬
View Replies !
View Related
Return TextField From Extended TextField Class
Hi
I'm trying to return a TextField from a class and then display it on stage... but I'm having problem to get it to show up on stage?
Help appreciated!
TFCreator.as:
Code:
import flash.display.*;
import flash.text.*;
public class TFCreator extends TextField
{
// TextField
private var tf:TextField;
// Properties
private var txt:String;
private var instancename:String;
private var color:Number;
private var autosize:String;
private var multilinee:Boolean;
private var wordwrap:Boolean;
// Default TextFormat
private var dfrmt:TextFormat;
private var dfrmt_font:String;
private var dfrmt_color:Number;
private var dfrmt_size:Number;
// External TextFormat
private var efrmt:TextFormat;
public function TFCreator(txt:String = "Text", instancename:String = "Instance", color:Number = 0x333333, autosize:String = "LEFT", multilinee:Boolean = false, wordwrap:Boolean = false, dfrmt_font:String = "Arial", dfrmt_size:Number = 11, dfrmt_color:Number = 0x333333):void
{
// Init Properties
this.txt = txt;
this.instancename = instancename;
this.color = color;
this.autosize = autosize;
this.multilinee = multilinee;
this.wordwrap = wordwrap;
// Init Default Textformat
this.dfrmt_font = dfrmt_font;
this.dfrmt_size = dfrmt_size;
this.dfrmt_color = dfrmt_color;
// Create TextField
createTextfield();
}
private function createTextfield():TextField
{
// New TextField
this.tf = new TextField();
// Set Default TextFormat
setDefaultTextformat();
// Set Properties
this.tf.text = this.txt;
this.tf.name = this.instancename;
this.tf.textColor = this.color;
setAutosize(this.autosize);
setMultiline(this.multilinee);
setWordwrap(this.wordwrap);
trace("Textfield created");
// Add TextField to Displaylist
//addChild(this.tf);
return this.tf;
}
// Getters & Setters......
}
}
and test on timeline:
Code:
import TFCreator;
var ttxt:String = "Halloooo?";
var t1:TFCreator = new TFCreator(ttxt,"inst1",0x666666,"LEFT",false,false,"Arial",13,0x333333);
addChild(t1);
t1.x = 200;
t1.y = 300;
//t1.selectable = false;
t1.setText("Baaaaa");
trace(t1.getText());
//t1.setAutosize("CENTER");
trace(t1.getAutosize());
trace(t1);
getChildByName("inst1");
It seems to work ok it just wont show up on stage.
View Replies !
View Related
Masking Dynamic Textfield When The Textfield Has A Stylesheet
ok... i have a movieClip containing dynamic textfields, which i'm trying to mask. the textfields are linked to a stylesheet. i understand that, for the masking to work, i have to embed the font. so i've placed the font in the library, given it a linkage name and set embedFonts = true for the dynamic textfields.
what do i do next? and does the fact that i'm embeding the font override the effect of the stylesheet?
(sorry if i sound confused over this. that's because i am.)
thanks in advance for any help
||| O ^ | + O ¬
View Replies !
View Related
TextField: Can We Embed HTML In Textfield?
Hello all,
I know that textfield can embed HTML like:
Code:
createTextField("noteText", 1, 100, 100, 300, 30);
noteText.type = "dynamic";
noteText.wordWrap = true;
noteText.border = true;
noteText.html = true;
noteText.htmlText = '<font color="#FF0000">This is HTML</font>';
I wonder if we embed button, HTML input field int Flash textfield?
Code:
noteText.htmlText = '<input name="txtTest" type="text">';
Thanks,
View Replies !
View Related
Cant Get Textfield Height From AutoSized Textfield
Afternoon guys.
I am creating a new nwe3s blogger. Instead of relying on a scrollbar to scroll the news story i thought i would use
code: textField.autosize="left"
This works fine...
At present i am loading x amount of news into flash at any one time. I am placing the news story underneath each other using
code:
holder.attachMovie ("newsMc", "news" + i, i);
holder['news' + i]._y = nextY;
nextY += Math.ceil (holder['news' + i]._height) + 2;
this is fine...
But when i use
code: textField.autosize="left"
nextY retains it's orginal height even though some of the news stories have made for higher textfields.
I thought i could pull the height from the previuosly created news holder
code:
if (i > 0) {
j = i - 1;
trace (j + " text height=" + holder['news' + j].newsStory._height);
if (holder['news' + j].newsStory._height > 184) {
nextY += Math.ceil (holder['news' + j]._height) + 2;
} else {
nextY += Math.ceil (holder['news' + j]._height) + 2;
trace ("nextY=" + nextY);
}
But this still returns the intial height
Here is the complete code
code:
for (i = 0; i < this.newsCount; i++) {
holder.attachMovie ("newsMc", "news" + i, i);
holder['news' + i]._y = nextY;
holder['news' + i].newsTitle.text = this['news' + i + 'newsTitle'];
holder['news' + i].newsDate.text = "Submitted: " + this['news' + i + 'newsDate'];
holder['news' + i].newsStory.htmlText = this['news' + i + 'newsStory'];
nextY += Math.ceil (holder['news' + i]._height) + 2;
if (i > 0) {
j = i - 1;
trace (j + " text height=" + holder['news' + j].newsStory._height);
if (holder['news' + j].newsStory._height > 184) {
nextY += Math.ceil (holder['news' + j]._height) + 2;
} else {
nextY += Math.ceil (holder['news' + j]._height) + 2;
trace ("nextY=" + nextY);
}
}
unloadMovie (dtLoader);
viser._visible = 0;
}
View Replies !
View Related
Cant Get Textfield Height From AutoSized Textfield
Afternoon guys.
I am creating a new nwe3s blogger. Instead of relying on a scrollbar to scroll the news story i thought i would use
ActionScript Code:
textField.autosize="left"
This works fine...
At present i am loading x amount of news into flash at any one time. I am placing the news story underneath each other using
ActionScript Code:
holder.attachMovie ("newsMc", "news" + i, i);
holder['news' + i]._y = nextY;
nextY += Math.ceil (holder['news' + i]._height) + 2;
this is fine...
But when i use
ActionScript Code:
textField.autosize="left"
nextY retains it's orginal height even though some of the news stories have made for higher textfields.
I thought i could pull the height from the previuosly created news holder
ActionScript Code:
if (i > 0) {
j = i - 1;
trace (j + " text height=" + holder['news' + j].newsStory._height);
if (holder['news' + j].newsStory._height > 184) {
nextY += Math.ceil (holder['news' + j]._height) + 2;
} else {
nextY += Math.ceil (holder['news' + j]._height) + 2;
trace ("nextY=" + nextY);
}
But this still returns the intial height
Here is the complete code
ActionScript Code:
for (i = 0; i < this.newsCount; i++) {
holder.attachMovie ("newsMc", "news" + i, i);
holder['news' + i]._y = nextY;
holder['news' + i].newsTitle.text = this['news' + i + 'newsTitle'];
holder['news' + i].newsDate.text = "Submitted: " + this['news' + i + 'newsDate'];
holder['news' + i].newsStory.htmlText = this['news' + i + 'newsStory'];
nextY += Math.ceil (holder['news' + i]._height) + 2;
if (i > 0) {
j = i - 1;
trace (j + " text height=" + holder['news' + j].newsStory._height);
if (holder['news' + j].newsStory._height > 184) {
nextY += Math.ceil (holder['news' + j]._height) + 2;
} else {
nextY += Math.ceil (holder['news' + j]._height) + 2;
trace ("nextY=" + nextY);
}
}
unloadMovie (dtLoader);
viser._visible = 0;
}
View Replies !
View Related
INPUT TextField Within An HTML TextField Via <img>
I'm trying to extend an HTML TextField to include an INPUT TextField control as an <img> tag. This I can do. The problem is that mouse and keyboard events are not being seen by the inner TextField. I created a test case to demonstrate the situation. My guess is that <img> tags are treated like AS2 events and because the outer TextField is trapping text events, they are not propagated to the inner TextField. Is there anyway around this problem? Mouse events to other DisplayObjects work fine. I'm using Flash CS3.
The test case contains two classes. TextImgTest is the document class for TextImgTest.fla. TestImg implements the <img> loaded by TestImgTest. To run this. Just create an empty TextImgTest.fla and set the document class to TextImgTest. Then publish and run.
Attach Code
package
{
import flash.display.MovieClip;
import flash.events.TimerEvent;
import flash.text.TextFieldAutoSize;
import flash.text.TextField;
import flash.text.StyleSheet;
import flash.utils.Timer;
import TestImg;
public class TextImgTest extends MovieClip
{
public var textField: TextField;
public var styleSheet: StyleSheet;
public var img: TestImg;
public var timer: Timer;
public function TextImgTest(): void
{
// render directly
img = new TestImg();
addChild(img);
// render within a TextField as an <img> tag.
styleSheet = new StyleSheet();
styleSheet.setStyle("p", {fontFamily:"sans-serif", fontSize:"10"});
textField = new TextField();
textField.styleSheet = styleSheet;
textField.multiline = true;
textField.autoSize = TextFieldAutoSize.LEFT;
textField.wordWrap = true;
textField.border = true;
textField.borderColor = 0x0000FF;
textField.background = true;
textField.backgroundColor = 0xFFCCFF;
textField.width = 190;
textField.x = 5;
textField.y = 120;
textField.htmlText = "<p>TextField with an <img src='TestMsg' id='rmk'> tag:<br><img src='TestImg' id='rmk'></p>"
addChild(textField);
textField.selectable = true;
textField.mouseEnabled = true;
// Give it a little time to render then get a reference to it.
timer = new Timer(3000, 1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimeout);
timer.start();
}
public function onTimeout(evt: TimerEvent): void
{
var freeText: TestImg = textField.getImageReference("rmk") as TestImg;
freeText.tField.mouseEnabled = true;
freeText.tField.selectable = true;
freeText.tField.appendText(" Got ImageReference for 'rmk'.");
}
}
}
===================================================
package
{
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.display.Sprite;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
import flash.text.TextField;
import flash.text.TextFieldType;
public class TestImg extends MovieClip
{
static public const MSG_WIDTH: int = 170;
static public const MSG_HEIGHT: int = 100;
static public const MSG_MARGIN: int = 8;
public var tFmt: TextFormat;
public var tField: TextField;
public var sBut: SimpleButton;
public function TestImg(): void
{
super();
this.tabEnabled = false;
this.mouseEnabled = false;
// Show this MovieClip
with (this.graphics)
{
clear();
beginFill(0x9999FF);
drawRect(0, 0, MSG_WIDTH, MSG_HEIGHT);
endFill();
}
// Show the INPUT TextField within it.
tFmt = new TextFormat("_sans", 10, 0x000000, true, false,
false, null, null,
TextFormatAlign.LEFT);
tField = new TextField();
tField.type = TextFieldType.INPUT;
tField.height = MSG_HEIGHT - 2*MSG_MARGIN - 16;
tField.defaultTextFormat = tFmt;
tField.multiline = true;
tField.wordWrap = true;
tField.width = MSG_WIDTH - 2*MSG_MARGIN;
tField.border = true;
tField.borderColor = 0xFF0000;
tField.background = true;
tField.backgroundColor = 0xFFEECC;
tField.x = MSG_MARGIN;
tField.y = MSG_MARGIN;
tField.text = "TestImg MovieClip containing an INPUT TextField.";
this.addChild(tField);
tField.selectable = true;
tField.mouseEnabled = true;
// Show the button within this MovieClip
var butGraphics1: Sprite = new Sprite();
with (butGraphics1.graphics)
{
lineStyle(1, 0x000000);
beginFill(0xFF0000);
drawRect(0, 0, 32, 16);
endFill();
}
var butGraphics2: Sprite = new Sprite();
with (butGraphics2.graphics)
{
lineStyle(1, 0x000000);
beginFill(0x00FF00);
drawRect(0, 0, 32, 16);
endFill();
}
sBut = new SimpleButton();
sBut.upState = butGraphics1;
sBut.overState = butGraphics2;
sBut.downState = butGraphics1;
sBut.hitTestState = butGraphics2;
sBut.x = MSG_MARGIN;
sBut.y = MSG_HEIGHT - MSG_MARGIN - 16;
this.addChild(sBut);
}
}
}
View Replies !
View Related
Cant Get Textfield Height From AutoSized Textfield
Afternoon guys.
I am creating a new nwe3s blogger. Instead of relying on a scrollbar to scroll the news story i thought i would use
ActionScript Code:
textField.autosize="left"
This works fine...
At present i am loading x amount of news into flash at any one time. I am placing the news story underneath each other using
ActionScript Code:
</p>
<p>holder.attachMovie ("newsMc", "news" + i, i);</p>
<p>holder['news' + i]._y = nextY;</p>
<p>nextY += Math.ceil (holder['news' + i]._height) + 2;</p>
<p>
this is fine...
But when i use
ActionScript Code:
textField.autosize="left"
nextY retains it's orginal height even though some of the news stories have made for higher textfields.
I thought i could pull the height from the previuosly created news holder
ActionScript Code:
</p>
<p>if (i > 0) {</p>
<p>j = i - 1;</p>
<p>trace (j + " text height=" + holder['news' + j].newsStory._height);</p>
<p>if (holder['news' + j].newsStory._height > 184) {</p>
<p>nextY += Math.ceil (holder['news' + j]._height) + 2;</p>
<p>} else {</p>
<p>nextY += Math.ceil (holder['news' + j]._height) + 2;</p>
<p>trace ("nextY=" + nextY);</p>
<p>}</p>
<p>
But this still returns the intial height
Here is the complete code
ActionScript Code:
</p>
<p>for (i = 0; i < this.newsCount; i++) {</p>
<p> holder.attachMovie ("newsMc", "news" + i, i);</p>
<p> holder['news' + i]._y = nextY;</p>
<p> holder['news' + i].newsTitle.text = this['news' + i + 'newsTitle'];</p>
<p> holder['news' + i].newsDate.text = "Submitted: " + this['news' + i + 'newsDate'];</p>
<p> holder['news' + i].newsStory.htmlText = this['news' + i + 'newsStory'];</p>
<p> nextY += Math.ceil (holder['news' + i]._height) + 2;</p>
<p> if (i > 0) {</p>
<p> j = i - 1;</p>
<p> trace (j + " text height=" + holder['news' + j].newsStory._height);</p>
<p> if (holder['news' + j].newsStory._height > 184) {</p>
<p> nextY += Math.ceil (holder['news' + j]._height) + 2;</p>
<p> } else {</p>
<p> nextY += Math.ceil (holder['news' + j]._height) + 2;</p>
<p> trace ("nextY=" + nextY);</p>
<p> }</p>
<p> }</p>
<p> unloadMovie (dtLoader);</p>
<p> viser._visible = 0;</p>
<p>}</p>
<p>
View Replies !
View Related
Cant Get Textfield Height From AutoSized Textfield
Afternoon guys.
I am creating a new nwe3s blogger. Instead of relying on a scrollbar to scroll the news story i thought i would use
ActionScript Code:
textField.autosize="left"
This works fine...
At present i am loading x amount of news into flash at any one time. I am placing the news story underneath each other using
ActionScript Code:
holder.attachMovie ("newsMc", "news" + i, i);
holder['news' + i]._y = nextY;
nextY += Math.ceil (holder['news' + i]._height) + 2;
this is fine...
But when i use
ActionScript Code:
textField.autosize="left"
nextY retains it's orginal height even though some of the news stories have made for higher textfields.
I thought i could pull the height from the previuosly created news holder
ActionScript Code:
if (i > 0) {
j = i - 1;
trace (j + " text height=" + holder['news' + j].newsStory._height);
if (holder['news' + j].newsStory._height > 184) {
nextY += Math.ceil (holder['news' + j]._height) + 2;
} else {
nextY += Math.ceil (holder['news' + j]._height) + 2;
trace ("nextY=" + nextY);
}
But this still returns the intial height
Here is the complete code
ActionScript Code:
for (i = 0; i < this.newsCount; i++) {
holder.attachMovie ("newsMc", "news" + i, i);
holder['news' + i]._y = nextY;
holder['news' + i].newsTitle.text = this['news' + i + 'newsTitle'];
holder['news' + i].newsDate.text = "Submitted: " + this['news' + i + 'newsDate'];
holder['news' + i].newsStory.htmlText = this['news' + i + 'newsStory'];
nextY += Math.ceil (holder['news' + i]._height) + 2;
if (i > 0) {
j = i - 1;
trace (j + " text height=" + holder['news' + j].newsStory._height);
if (holder['news' + j].newsStory._height > 184) {
nextY += Math.ceil (holder['news' + j]._height) + 2;
} else {
nextY += Math.ceil (holder['news' + j]._height) + 2;
trace ("nextY=" + nextY);
}
}
unloadMovie (dtLoader);
viser._visible = 0;
}
View Replies !
View Related
|