• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Why??? Definition 1172:  Definition fl events.ComponentEvent could not be found.

Community Beginner ,
Jul 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

I am trying to ask for input in an input textfield and the way Im doing it is using

 

 

import fl.events.ComponentEvent;
input_text.addEventListener(ComponentEvent.ENTER, readInput);
input_text.addEventListener(Event.CHANGE, changeHandler);

var clearing:Boolean=false;

function readInput(event:Event):void
{
    input = input_txt.text;
    trace(input);

    clearing=true;

}

function changeHandler(event:Event)
{
if(clearing)
{
  input_text.text="";
  clearing=false;
}
}

 

 

in my code, however am getting a Definition 1172:  Definition fl events.ComponentEvent could not be found.

I am only doing all of this junk instead of a simple input_text="" on a keycode=13 event listener; because when i do that it adds a blank return line "

 "to the input when they hit enter and I dont want that. They told me i could do this and it would solve the blank extra return line problem (when i ask a person hit enter to submit the text) but they didnt mention that there would be this error. What do i do

TOPICS
ActionScript , Error

Views

911

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 23, 2024 Jul 23, 2024

You'll have problems by using multiple text fields if the user inserts a text that takes up more than one line, I think.

Anyway, here is an approach to make the text move from bottom to top.

import flash.events.KeyboardEvent;
import flash.ui.Keyboard;

var i:int;

function keyDownHandler(e:KeyboardEvent)
{
	if (e.keyCode == Keyboard.ENTER)
	{
		chathistory.appendText(e.currentTarget.text + "\n");
		chathistory.scrollV = chathistory.maxScrollV;
		e.currentTarget.text = "";
	}
}

for (i = chathisto
...

Votes

Translate

Translate
Community Beginner ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

So if I wanted to stop an undesired blank line from being added to the string that is going from the text input box to the chat history I would have to write something like chathistoryline1.text= (/n)textInput.text

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

Take a look at this video.. This video while it demonstrates the problem I am having it also shows the functionality.  Each response is populating a new box above it as a new line is written. That's great! But the text box isn't behaving normal. When you and I type in messenger windows, how does it behave? It deletes the line, populates it at the bottom because, that's closest to where your typing. But Adobe is acting such a stupid fool by thinking I want a blank line there already there for the next response. Why would anyone want that, I don't even recall text boxes anywhere behaving like that. Also when you delete it, it adds it again next time you press enter. The thing still shows that the text properly translates up the window. Just having this line addition crap.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

whatever string you want to clean of line breaks, use

 

clean_string = old_string.split("\n).join("").split("\r").join("");

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

I will try this. And how can i stop/delete the return line that adds to the input box when they hit enter, you know, so they stop beginning from line 2 every time they hit enter?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

show your code that uses split/join

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

LATEST

Sure. Here is the code and how it ends up. 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 19, 2024 Jul 19, 2024

Copy link to clipboard

Copied

DEMONSTRA2.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 19, 2024 Jul 19, 2024

Copy link to clipboard

Copied

Can you help me

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

You should only need one text field for the chat history.

 

import flash.events.KeyboardEvent;
import flash.ui.Keyboard;

function keyDownHandler(e:KeyboardEvent)
{
	if (e.keyCode == Keyboard.ENTER)
	{
		chathistory.appendText(e.currentTarget.text + "\n");
		e.currentTarget.text = "";
	}
}

usertext.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);


https://drive.google.com/file/d/1UjJawavDM0cxOBsXJAVX-nYljTqgwUgf/view?usp=sharing

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

Hello. I executed the code. Three things are undesirable.

1. Chat is not starting directly above the text input, nor is it bottom-aligned like I wanted.

2   Responses are not ascending as they are later.  My original method of "chathistoryline1/2/3/4" is fine and it beats this because it allows to push most latest responses upward and out of the chat history

3. Still getting undesired break line after hitting enter, and the cursor proceeds to line 2 undesired, and you have to backspace to delete the break line

6, Pressing backspace and typing and hitting enter will either place new text directly beside the previous line or on a new line

https://youtu.be/9E0kEFKI_SY

 

I have my little method I just need to know how to stop and ive been also reading the other users response on how to split and join but i just cant figure out what to do

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

You'll have problems by using multiple text fields if the user inserts a text that takes up more than one line, I think.

Anyway, here is an approach to make the text move from bottom to top.

import flash.events.KeyboardEvent;
import flash.ui.Keyboard;

var i:int;

function keyDownHandler(e:KeyboardEvent)
{
	if (e.keyCode == Keyboard.ENTER)
	{
		chathistory.appendText(e.currentTarget.text + "\n");
		chathistory.scrollV = chathistory.maxScrollV;
		e.currentTarget.text = "";
	}
}

for (i = chathistory.numLines - 1; i > -1; i--)
	chathistory.appendText("\n");

usertext.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);


https://drive.google.com/file/d/1LXBpsccYXIk_uUYAeigxhJjufnxCMHv0/view?usp=sharing

Please note that this is just a simple template for you to get started. This is not gonna solve all challenges required to develop a chat application.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

Lol. Its funny how you basically said somethnig that is not raelly intentionally designing to shut anyone dreams down but it is calling everythnig I am trying to accomplish in two words (chat application). lol. Uhhh. I guess its what it is. I was going to do it cheapy-cheap coding wise and just go as far as i can in complexity and the bit you gave me is definitely something i would have never come up with in my own mind. I will test it out

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

https://youtu.be/EHfBT_T6mLc

There is a blank line, that, if i choose to ignore, will only affect the very first response.  If i move up to line 1, if there is a empty break line, and put words there, its weird- they will come along side the last response line, or they will appear on a new line. This makes it behave further behave weird, when dropping down to write on line two manually once again. The enter line there, its still undesirable, leaving you to wonder, do I write on line 1 or 2.  I did a test showing the results. Still another problem with this implementation is, I want the chat how I want it, with chathiistorylines, where the first line starts directly above the type box, and the second line will push the first line upward away from the textbox.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 19, 2024 Jul 19, 2024

Copy link to clipboard

Copied

Hi.

 

Make sure you have a TextInput added to the stage because by default Animate doesn't know where to look for components' code if you don't have any in your project or if you don't set the paths in the AS3 settings.

Regards,

JC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines