Class is not showing up in code hinting

If a class is not showing up in code hinting or the class is not found the package path may be incorrect.

// this class has no path specified
package  {
      public myClass {
      }
}
// the package path is the folder path to the location of the file
// it must reflect the actual location of the "myClass.as" file
// for example, the following class
// would be valid if the file is located at
// ".../com/site/controls/myClass.as"
package com.site.controls {
      public myClass {
      }
}

 

Advertisements

Error: addChild() is not available in this class. Instead, use addElement() or modify the skin, if you have one.

Error: addChild() is not available in this class. Instead, use addElement() or modify the skin, if you have one. spark.components::Group/addChild

Check if the class is a Group (Group Inheritance GroupBase Inheritance UIComponent Inheritance FlexSprite Inheritance Sprite Inheritance DisplayObjectContainer Inheritance InteractiveObject Inheritance DisplayObject Inheritance EventDispatcher)

If you want to allow a Group then you should use the addElement method in place of addChild. But if when you do that you get a compiler error, “1061: Call to a possibly undefined method addElement through a reference with static type flash.display:Sprite.” then you will need to type the class to Group which is the first class to contain addElement().

// original code
function test(container:Sprite):void {
    container.addChild(displayObject);
}

// changed code
function test(container:Group):void {
    container.addElement(displayObject);
}

As long as the class is not a Group you can use the addChild method. If the class is a UIComponent or a subclass (UIComponent Inheritance FlexSprite Inheritance Sprite Inheritance DisplayObjectContainer Inheritance InteractiveObject Inheritance DisplayObject Inheritance EventDispatcher Inheritance Object) then you can use the addChild method.

If you must use addChild method and must use a Group container add a Sprite container first then use addChild with that.

function test(container:Group):void {
    var containerBridge:Sprite = new Sprite(); // SpriteVisualElement?
    containerBridge.addChild(displayObject);
    container.addElement(containerBridge);
}

If you want to support both then you can use the following code:

if (mySprite is Group) {
	Group(mySprite).addElement(displayObject);
}
else {
	mySprite.addChild(displayObject);
}

Unable to locate specified base class 'spark.skins.mobile.ButtonSkin' for component class

Unable to locate specified base class ‘spark.skins.mobile.ButtonSkin’ for component class…

Cause:

The class is not referenced in your project. When you create your Library or Flex project make sure to check the boxes, “Include Adobe AIR Libraries”. This will include the SWC files you need. You may need to create a new Library project or manually add in the missing SWC’s.

ArgumentError: Undefined state 'up'.

Cause:

The skin I was using did not have the required state. The host component was a Button and the Button class requires the “up” state to be defined in the skin. I was using a base skin that did not have the “up” state defined. By using the subclass ButtonSkin I was able to correct the error.

Incorrect:

<s:Button icon="images/rotate1.png"
		  skinClass="spark.skins.SparkButtonSkin"
		  width="48" height="48" />

Correct:

<s:Button icon="images/rotate1.png"
		  skinClass="spark.skins.spark.ButtonSkin"
		  width="48" height="48" />

Initializer for property 'states' is not allowed here

The cause of this error is in this code:

<s:Application xmlns:gta="com.domain.effects.states.*">
	<fx:Declarations>
		<handlers:EventHandler>
			<gta:ToggleStates states="{['something']}">
		</handlers:EventHandler>
	</fx:Declarations>
</s:Application>

When the ToggleStates MXML instance has property “states” the error is generated. When the property is renamed to “myStates” the error goes away.

1067: Implicit coercion of a value of type spark.filters:ColorMatrixFilter to an unrelated type flash.filters:BitmapFilter.

1067: Implicit coercion of a value of type spark.filters:ColorMatrixFilter to an unrelated type flash.filters:BitmapFilter.

var filter:ColorMatrixFilter = new ColorMatrixFilter(grayscale);
var bitmap:BitmapData = bitmapImage.bitmapData.clone();
// line causing the error
bitmap.applyFilter(bitmapImage.bitmapData, bitmapImage.bitmapData.rect, new Point(), filter);

There is a conflict with flash.filters.ColorMatrixFilter and spark.filters.ColorMatrixFilter.

You must explicitly import the flash.filters class for applyFilter method to work.

import flash.filters.ColorMatrixFilter;

Error: The Form must have form items with the same number of constraint columns

Error: The Form must have form items with the same number of constraint columns

Problem:
Form and Form Items use constraint rows and constraint columns to layout the form labels and form elements. When there are conflicting layouts this error is seen. Usually it is when one form item skin class is set to a horizontal layout (or not set) and another form item is set to a vertical or stacked layout.

Solution:
Use the same type of layout skin class in all the form items in your form.

// Does not work
// Notice the skinClass (when not set the form item uses FormItemSkin)

		<s:FormItem width="100%" label="First Name"
					skinClass="FormItemSkin">
			<s:TextInput  />
		</s:FormItem>

		<s:FormItem width="100%" label="Last Name"
					skinClass="StackedFormItemSkin">
			<s:TextInput  />
		</s:FormItem>

// Works

		<s:FormItem width="100%" label="First Name"
					skinClass="myStackedFormItemSkin">
			<s:TextInput  />
		</s:FormItem>

		<s:FormItem width="100%" label="Last Name"
					skinClass="myStackedFormItemSkin">
			<s:TextInput  />
		</s:FormItem>

1144: Interface method addChild in namespace mx.core:IChildList is implemented with an incompatible signature in class.

1144: Interface method addChild in namespace mx.core:IChildList is implemented with an incompatible signature in class.

Description:
Method signatures are not matching. Method signatures must match exactly.

Solution:
Compare the class to the interface. If a method is public you cannot use private. If a value is of type String the value and return type must be type String. Override must be specified.

Secondary cause:
The project you are working in is using a mobile SDK and you have a reference to another library that is using an incompatible SDK. This happens when an mx namespace is used or referenced in a mobile spark project.

Possible Solution:
You must remove the library that is incompatible and create or reference a library with a compatible SDK.

Index: 11, Size: 5 Unknown Flex Problem

The problem is possibly caused by a parsing error in ActionScript in an E4X expression

// does not cause error
var items:XMLList = getItems();
var item:XML = items==null ? null : null // items.(name==name);

// does not cause error
var items:XMLList = getItems();
var item:XML = items==null ? null : null;

// causes error
// sometimes causes error 1131: Classes must not be nested.
var items:XMLList = getItems();
var item:XML = items==null ? null : null; // items.(name==name);

// causes error
var items:XMLList = getItems();
var item:XML = items==null ? null : items.(name==name);

 

The swc '/Applications/Adobe Flash Builder Burrito/sdks/4.5.0/frameworks/libs/framework.swc' has style defaults and is in the library-path, which means dependencies will be linked in without the styles.

The swc ‘/Applications/Adobe Flash Builder Burrito/sdks/4.5.0/frameworks/libs/framework.swc’ has style defaults and is in the library-path, which means dependencies will be linked in without the styles. This can cause applications, which use the output swc, to have missing skins. The swc should be put in the external-library-path.

I don’t know the answer to this. Please add an answer in the comments.

Update
Hershel posted a solution in the comments and I’ve pasted here:

This happens when a added swc has link selection ‘merged into code’. It should be default external.

Since both the libraries have style defaults.css files, the compiler overrides the added swc’s defaults.css

Remedy : Go to build path, and select the conflicting swc, open the node, go to link type, and select edit, and then select ‘external’
save, clean build !