• 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

1.2K

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 Expert ,
Jul 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

i don't see why you'd get that error though you have two other obvious errors:

 

input is undefined

input_txt is not input_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 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

kglad, when I begin to type import, then type  fl.events. i can see a list of all the available packages, component event isn't there! Neither when using flash.events.

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

copy and paste here a screenshot of your stage with the textinput component selected also showing the properties panel.

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

DEMONSTR.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 Expert ,
Jul 19, 2024 Jul 19, 2024

Copy link to clipboard

Copied

that's not an input text component.  it's just an input textfield.

 

either adjust your code and remove that textfield and replace with a textinput  component.

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

wowwwwwwwwwww i have never heard of that.  i dont know how to add one

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 20, 2024 Jul 20, 2024

Copy link to clipboard

Copied

open your component panel (window > components) and drag a textinput component to the stage.

 

though it would be better (imo) to continue with an input textfield and fix your code.

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 22, 2024 Jul 22, 2024

Copy link to clipboard

Copied

Help me please. This is confusing. I would like to just use input textfield that I originally planned. My problem is that when pressing enter,  the string returned adds the unncessary blank line " ". how do I prevent the addition of a break line when the user presses 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 22, 2024 Jul 22, 2024

Copy link to clipboard

Copied

do you want to use a component (less flexibility but some additional styling) or an input textfield (which you're now using and has less styling but needs different code)?

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 22, 2024 Jul 22, 2024

Copy link to clipboard

Copied

Hehe I would like to know how to do it with input textfield. Do you want a video of me show you what i mean or do you think you know what i mean? Ok obviously they type a little, press enter, the text box should empty and what they type should occupy in the first space directly above. However what ends up occupying is 

"

"

or 

"

the 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 Expert ,
Jul 22, 2024 Jul 22, 2024

Copy link to clipboard

Copied

if your textfield is ti, use:

 

//////////////////////////////////

ti.addEventListener(Event.CHANGE, readInput);
ti.text = "";
 
function readInput(e:Event):void {
trace(e.currentTarget.text);
/////////////////////////////////
 
then describe how you want the trace output to appear, if it's not what you want currently.
}

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

OKAY. Alas, when I use the code 

 

 

usertext.addEventListener(Event.CHANGE, readInput);
usertext.text = "";

function readInput(e:Event):void
{
if (e.keyCode==13) //enter
{
trace ("keycode is 13");
usertext.text = "";
trace(input);
chathistoryline19.text=chathistoryline18.text;

chathistoryline18.text=chathistoryline17.text;
chathistoryline17.text=chathistoryline16.text;
chathistoryline16.text=chathistoryline15.text;
chathistoryline15.text=chathistoryline14.text;
chathistoryline14.text=chathistoryline13.text;
chathistoryline13.text=chathistoryline12.text;
chathistoryline12.text=chathistoryline11.text;
chathistoryline11.text=chathistoryline10.text;
chathistoryline10.text=chathistoryline9.text;
chathistoryline9.text=chathistoryline8.text;
chathistoryline8.text=chathistoryline7.text;
chathistoryline7.text=chathistoryline6.text;
chathistoryline6.text=chathistoryline5.text;
chathistoryline5.text=chathistoryline4.text;
chathistoryline4.text=chathistoryline3.text;
chathistoryline3.text=chathistoryline2.text;
chathistoryline2.text=chathistoryline1.text;
chathistoryline1.text=input;
}
}

 

 

 

it throws error Access of undefined property keyCode thru a reference with a static type  flash: events

and when i leave it as function readInput(event:Event):void and not function readInput(e:Event):void it says Access of undefined property e

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

use a keyboardevent if you want keycodes.

 

ti.addEventListener(KeyboardEvent.KEY_DOWN, f);
 
function f(e:KeyboardEvent):void{
trace(e.keyCode)
}

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

Okay. Sgh. Now we are back to where we started. Where it enters a blank line and it copies the text to the text history with a blank line above it. I'm trying to avoid that. I want to let them write a line of text and when they hit enter is when i want the text in the text box to move to the text history fields. 

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

this code is not effective

 

addEventListener(KeyboardEvent.KEY_DOWN, readInput);
usertext.text = "";

function readInput(e:KeyboardEvent):void
{
if (e.keyCode==13) //enter
{
trace ("keycode is 13");
usertext.text = "";
trace(input);
chathistoryline19.text=chathistoryline18.text;
chathistoryline18.text=chathistoryline17.text;
chathistoryline17.text=chathistoryline16.text;
chathistoryline16.text=chathistoryline15.text;
chathistoryline15.text=chathistoryline14.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 Expert ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

if you want to remove line breaks from a string use string.split("\r").join("").split("\n").join("")

 

ti.addEventListener(KeyboardEvent.KEY_DOWN, f);
 
function f(e:KeyboardEvent):void{
if(e.keyCode==13){
saveTextF();
}
}
function saveTextF():void{
// do whatever you like with (ti.text.split("\r").join("").split("\n").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

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

what's that trying to show and how's that related to the code suggested?

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

What this is showing is how it is adding a line and coming to be a blank line above every line the user enters. I dont know how to prevent the blank line. Its supposed to be just singlelines of entries

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

i infer that you want users to input text and then you want to do something with that text, but what exactly are you tryig 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 Beginner ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

im going to tajke their answer and comapre it to some other variables to see whether it is 'correct' or not and push it up one line into histry

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

do you know how determine if their input text is "correct"?

do you know how to "push it up one line into histry"?

 

if either answer is no, th info you've given is insufficient to help you encode correctly.  ie, explain more carefully.

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

Heh heh, yes. Later on I will have arrays wth correct responses and be implementing further code to determine whether the code matches is correct. The problem here and today is about getting that little blank line to stop injecting everywhere once they hit enter. Also, the code to push the line of text into history is already functional in the youtube video shown previosuly

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

i already showed you how to do that using 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