Macromedia Flash Professional 8 UNLEASHED [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Macromedia Flash Professional 8 UNLEASHED [Electronic resources] - نسخه متنی

David Vogeleer, Eddie Wilson, Lou Barber

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید
aaa

Cross-Object Events


I305 forms, when a user has finished entering data, he or she can click the submit button or press the Enter key while in the last text field. Well, Flash, by default, does not have the capability for users to simply press the Enter key and move on through an application or form. So how does a Flash developer overcome this dilemma? Use a Key object listener with the TextField object.

This example will create a text field that will listen for the Enter key to be pressed:


1.

Create a new Flash document.

2.

Draw an input text field on the stage.

3.

Give the text field an instance name of

input_txt and make sure the border option is selected (so that you can see it on the stage).

4.

Create a new layer and name it

actions .

5.

In the actions layer, open the actions panel and place these actions in it:


//create the listener with the text field
input_txt.onKeyDown = function(){
//check to make sure its the ENTER key being pressed
if(Key.isDown(Key.ENTER)){
//send a message to the output panel
trace("I detect an ENTER");
}
}
//add the text field as a listener
Key.addListener(input_txt);


The preceding code uses an event-handling method on a text field with a Key object event. Inside the event, it uses a conditional to check to see which key has been pressed and whether it is in fact the Enter key, and then a message is sent to the Output panel. And finally, it adds the text field as a listener to the Key object.

/ 318