The last text feature that we discuss is the new Flash 5 Selection Object. The Selection Object is similar to the Mouse Object you don’t create instances of the Selection Object, as there can only be one active text field at any given time. In Flash 4 movies, we had no way of checking which text field was active. You could turn off a focus rectangle for Flash 4 text fields and Button instances, but you couldn’t control tab order or automatically set a text field active.
Either Input or Dynamic Text fields can use the Selection Object. The Selection Object uses a string reference to the text field’s variable name to perform its methods. We discuss the methods of the Selection Object in the following sections.
This method detects and returns the starting position of a highlighted selection in a text field. The method returns –1 if there is no active text field and/or there is no selection inside the text field. As with the Array Object, selection indexes start position values at 0. You do not need to specify a target path for this method only one text field can have a selection at any given point. Therefore, as a variable startIndex, the getBeginIndex() method would look like:
In the Output window, the trace action would reveal startIndex = -1 until you made a selection within a text field in the movie, as shown below.
A text field with a starting selection index of 3
Similar to the getBeginIndex() method, this method returns a number indicating the index position at the end of a highlighted selection in a text field, as shown below. If there is no active selection, then a value of –1 will be returned.
A text field with a starting selection index of 5 and an ending index of 9
This method of the Selection Object returns the current cursor position (as an index value) within an active text field, as shown below. As with the two previous methods, if you use the getCaretIndex() method when there is no active cursor in a text field, it will return a –1.
A text field with a caret index of 5
This method returns the current active text field’s name, as an absolute path; that is, if you have selected or inserted the cursor position inside a text field named myOutput on the Main Timeline, then Selection.getFocus()returns _level0.myOutput. If there is no active text field, then this method returns null.
Perhaps the best enhancement to controlled text field activity is the setFocus() method. This method enables you to make a text field active automatically the user doesn’t need to click the mouse cursor inside the text field to start typing. To use this method, simply indicate the setFocus() method of the Selection Object, and the absolute path to the text field as its argument:
This code, when used on an empty Movie Clip instance, sets the current focus to the testOutput text field. If any text exists in the text field, it will be highlighted as a selection. You can only use string data types as the setFocus() argument. If you try the following:
The setFocus() method will not work. Why? The first line of code sets myTextField equal to the value of _root.testOutput, not to the text field’s name itself. To remedy the situation, simply refer to the text field’s name in quotes:
The last method available for the Selection Object is setSelection(). This method enables you make a specific selection within an active text field. The method takes two arguments: a start index and an end index. Using the same index numbering as getBeginIndex() and getEndIndex(). Note that this method will not work unless a text field is already active. The following code creates a selection span from index 5 to 9 of the testInput text field:
Flash Related Interview Questions
|Adv Java Interview Questions||J2EE Interview Questions|
|Adobe Flex 3 Interview Questions||Dreamweaver Interview Questions|
|3D Animation Interview Questions||Adobe Flash CS6 Interview Questions|
|Dreamweaver CS3 Interview Questions||Adobe Flex Interview Questions|
|Adobe Flex Actionscript Interview Questions||Gif Animation Interview Questions|
|Adobe Fireworks Interview Questions|
Understanding The Flash Framework
Exploring The Interface: Panels, Settings, And More
Using Tools For Navigation And Viewing
Working With Selections And The Pen Tool
Working With The Drawing And Painting Tools
Working With Text
Exploring The Timeline
Checking Out The Library: Symbols And Instances
Drawing In Flash
Animating In Flash
Using Bitmaps And Other Media With Flash
Designing Interfaces And Interface Elements
Understanding Sound For Flash
Importing And Editing Sounds In Flash
Optimizing Flash Sound For Export
Understanding Actions And Event Handlers
Navigating Flash Timelines
Controlling Movie Clips
Sharing And Loading Assets
Planning Code Structures
Creating Subroutines And Manipulating Data
Understanding Movie Clips As Complex Objects
Sending Data In And Out Of Flash
Understanding Html And Text Field Functions In Flash
What Is Generator?
Revving Up Generator
Working With Third-party, Server-side Applications
Working With Raster Graphics
Working With Vector Graphics
Working With Audio Applications
Working With 3d Graphics
Working With Quicktime
Working With Realplayer
Creating Full-motion Video With Flash
Creating Cartoon Animation With Flash
Planning Flash Production With Flowcharting Software
Working With Authoring Applications
Publishing Flash Movies
Integrating Flash Content With Html
Using Players, Projectors, And Screensaver Utilities
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.