philipp37
10-15-2010, 05:47 PM
Hello everyone. Could you please look over my code below to figure out why I'm getting the following two errors:
1061: Call to a possibly undefined method setSelection through a reference with static type mx.core:ITextInput. line 477 Flex Problem
and
1119: Access of possibly undefined property selectionBeginIndex through a reference with static type mx.core:ITextInput. line 419 Flex Problem
Heres the affected portion of my code called AutoComplete.as:
package myWidgets.ParcelNotificationWidget
{
import flash.events.KeyboardEvent;
import flash.events.Event;
import flash.events.FocusEvent;
import flash.net.SharedObject;
import flash.ui.Keyboard;
import mx.core.UIComponent;
import mx.controls.ComboBox;
import mx.collections.ArrayCollection;
import mx.collections.ListCollectionView;
-----------------------------------
/**
* @private
*/
override protected function commitProperties():void
{
super.commitProperties();
if(!dropdown)
selectedIndex=-1;
if(dropdown)
{
if(typedTextChanged)
{
cursorPosition = textInput.selectionBeginIndex;
updateDataProvider();
//In case there are no suggestions there is no need to show the dropdown
if(collection.length==0 || typedText==""|| typedText==null)
{
dropdownClosed=true;
showDropdown=false;
}
else
{
showDropdown = true;
selectedIndex = 0;
}
}
}
}
/**
* @private
*/
override protected function focusOutHandler(event:FocusEvent):void
{
super.focusOutHandler(event)
if(keepLocalHistory && dataProvider.length==0)
addToLocalHistory();
}
/**
* @private
*/
override public function getStyle(styleProp:String):*
{
if(styleProp != "openDuration")
return super.getStyle(styleProp);
else
{
if(dropdownClosed)
return super.getStyle(styleProp);
else
return 0;
}
}
/**
* @private
*/
override protected function keyDownHandler(event:KeyboardEvent):void
{
super.keyDownHandler(event);
if(!event.ctrlKey)
{
//An UP "keydown" event on the top-most item in the drop-down
//or an ESCAPE "keydown" event should change the text in text
// field to original text
if(event.keyCode == Keyboard.UP && prevIndex==0)
{
textInput.text = _typedText;
textInput.setSelection(textInput.text.length, textInput.text.length);
selectedIndex = -1;
}
else if(event.keyCode==Keyboard.ESCAPE && showingDropdown)
{
textInput.text = _typedText;
textInput.setSelection(textInput.text.length, textInput.text.length);
showingDropdown = false;
dropdownClosed=true;
}
else if(event.keyCode == Keyboard.ENTER)
{
if(keepLocalHistory && dataProvider.length==0)
addToLocalHistory();
}
else if(lookAhead && event.keyCode == Keyboard.BACKSPACE
|| event.keyCode == Keyboard.DELETE)
removeHighlight = true;
}
else
if(event.ctrlKey && event.keyCode == Keyboard.UP)
dropdownClosed=true;
prevIndex = selectedIndex;
}
/**
* @private
*/
override protected function measure():void
{
super.measure();
measuredWidth = mx.core.UIComponent.DEFAULT_MEASURED_WIDTH;
}
/**
* @private
*/
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
//An UP "keydown" event on the top-most item in the drop
//down list otherwise changes the text in the text field to ""
if(selectedIndex == -1)
textInput.text = typedText;
if(dropdown)
{
if(typedTextChanged)
{
//This is needed because a call to super.updateDisplayList() set the text
// in the textInput to "" and thus the value
//typed by the user losts
if(lookAhead && showDropdown && typedText!="" && !removeHighlight)
{
var label:String = itemToLabel(collection[0]);
var index:Number = label.toLowerCase().indexOf(_typedText.toLowerCase ());
if(index==0)
{
textInput.text = _typedText+label.substr(_typedText.length);
textInput.setSelection(textInput.text.length,_type dText.length);
}
else
{
textInput.text = _typedText;
textInput.setSelection(cursorPosition, cursorPosition);
removeHighlight = false;
}
}
else
{
textInput.text = _typedText;
textInput.setSelection(cursorPosition, cursorPosition);
removeHighlight = false;
}
typedTextChanged= false;
}
else if(typedText)
//Sets the selection when user navigates the suggestion list through
//arrows keys.
textInput.setSelection(_typedText.length,textInput .text.length);
}
if(showDropdown && !dropdown.visible)
{
//This is needed to control the open duration of the dropdown
super.open();
showDropdown = false;
showingDropdown = true;
if(dropdownClosed)
dropdownClosed=false;
}
}
/**
* @private
*/
override protected function textInput_changeHandler(event:Event):void
{
super.textInput_changeHandler(event);
//Stores the text typed by the user in a variable
typedText=text;
}
THANKS A LOT!!!!!!!!
1061: Call to a possibly undefined method setSelection through a reference with static type mx.core:ITextInput. line 477 Flex Problem
and
1119: Access of possibly undefined property selectionBeginIndex through a reference with static type mx.core:ITextInput. line 419 Flex Problem
Heres the affected portion of my code called AutoComplete.as:
package myWidgets.ParcelNotificationWidget
{
import flash.events.KeyboardEvent;
import flash.events.Event;
import flash.events.FocusEvent;
import flash.net.SharedObject;
import flash.ui.Keyboard;
import mx.core.UIComponent;
import mx.controls.ComboBox;
import mx.collections.ArrayCollection;
import mx.collections.ListCollectionView;
-----------------------------------
/**
* @private
*/
override protected function commitProperties():void
{
super.commitProperties();
if(!dropdown)
selectedIndex=-1;
if(dropdown)
{
if(typedTextChanged)
{
cursorPosition = textInput.selectionBeginIndex;
updateDataProvider();
//In case there are no suggestions there is no need to show the dropdown
if(collection.length==0 || typedText==""|| typedText==null)
{
dropdownClosed=true;
showDropdown=false;
}
else
{
showDropdown = true;
selectedIndex = 0;
}
}
}
}
/**
* @private
*/
override protected function focusOutHandler(event:FocusEvent):void
{
super.focusOutHandler(event)
if(keepLocalHistory && dataProvider.length==0)
addToLocalHistory();
}
/**
* @private
*/
override public function getStyle(styleProp:String):*
{
if(styleProp != "openDuration")
return super.getStyle(styleProp);
else
{
if(dropdownClosed)
return super.getStyle(styleProp);
else
return 0;
}
}
/**
* @private
*/
override protected function keyDownHandler(event:KeyboardEvent):void
{
super.keyDownHandler(event);
if(!event.ctrlKey)
{
//An UP "keydown" event on the top-most item in the drop-down
//or an ESCAPE "keydown" event should change the text in text
// field to original text
if(event.keyCode == Keyboard.UP && prevIndex==0)
{
textInput.text = _typedText;
textInput.setSelection(textInput.text.length, textInput.text.length);
selectedIndex = -1;
}
else if(event.keyCode==Keyboard.ESCAPE && showingDropdown)
{
textInput.text = _typedText;
textInput.setSelection(textInput.text.length, textInput.text.length);
showingDropdown = false;
dropdownClosed=true;
}
else if(event.keyCode == Keyboard.ENTER)
{
if(keepLocalHistory && dataProvider.length==0)
addToLocalHistory();
}
else if(lookAhead && event.keyCode == Keyboard.BACKSPACE
|| event.keyCode == Keyboard.DELETE)
removeHighlight = true;
}
else
if(event.ctrlKey && event.keyCode == Keyboard.UP)
dropdownClosed=true;
prevIndex = selectedIndex;
}
/**
* @private
*/
override protected function measure():void
{
super.measure();
measuredWidth = mx.core.UIComponent.DEFAULT_MEASURED_WIDTH;
}
/**
* @private
*/
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
//An UP "keydown" event on the top-most item in the drop
//down list otherwise changes the text in the text field to ""
if(selectedIndex == -1)
textInput.text = typedText;
if(dropdown)
{
if(typedTextChanged)
{
//This is needed because a call to super.updateDisplayList() set the text
// in the textInput to "" and thus the value
//typed by the user losts
if(lookAhead && showDropdown && typedText!="" && !removeHighlight)
{
var label:String = itemToLabel(collection[0]);
var index:Number = label.toLowerCase().indexOf(_typedText.toLowerCase ());
if(index==0)
{
textInput.text = _typedText+label.substr(_typedText.length);
textInput.setSelection(textInput.text.length,_type dText.length);
}
else
{
textInput.text = _typedText;
textInput.setSelection(cursorPosition, cursorPosition);
removeHighlight = false;
}
}
else
{
textInput.text = _typedText;
textInput.setSelection(cursorPosition, cursorPosition);
removeHighlight = false;
}
typedTextChanged= false;
}
else if(typedText)
//Sets the selection when user navigates the suggestion list through
//arrows keys.
textInput.setSelection(_typedText.length,textInput .text.length);
}
if(showDropdown && !dropdown.visible)
{
//This is needed to control the open duration of the dropdown
super.open();
showDropdown = false;
showingDropdown = true;
if(dropdownClosed)
dropdownClosed=false;
}
}
/**
* @private
*/
override protected function textInput_changeHandler(event:Event):void
{
super.textInput_changeHandler(event);
//Stores the text typed by the user in a variable
typedText=text;
}
THANKS A LOT!!!!!!!!