When initializing the creationcomplete event on the flex page, add the focus setting statement: focusmanager. setfocus ("textinput component ID ");
After the page is run, the results are not displayed. Place the focus setting statement in the button event, and textinput is the focus setting.
The main reason is that we embed flash into the HTML page. When opening the HTML page, it is not focused. Therefore, it is best to add a Javascript script on the HTML page to focus on it.
Steps:
1. In the page initialization creationcomplete event, add the focus setting statement: focusmanager. setfocus ("textinput component ID ");
2. Find this page in the bin-DEBUG directory. For example, login.html (the swf id of login is login). Add the js method to the body.
<Body onload = "document. getelementbyid ('swf ID to attach '). Focus ()">
You can use these two steps to initialize the focus.
Similarly, we can also use externalinterface. Call to call and write Js in the As script of flex,CodeAs follows:
Protected function Init (): void {
Focusmanager. setfocus (txtloginname); // txtloginname is the ID of the textinput component.
Externalinterface. Call ("document. getelementbyid ('login'). Focus ()"); // login is the swf id to be loaded.
}