The_asMan
The_asMan

Reputation: 6403

Flex 3 IDE autogenerated code does not seem correct

I have a class ExtendedComboBox.as

In package com.ui.comboBox

So I import it. import com.ui.comboBox.ExtendedComboBox;

When I do <comboBox:ExtendedComboBox /> It can not locate the class.

When I use the auto generated code <comboBox1:ExtendedComboBox /> it works fine

My question is why is the auto generated code adding the 1?
Where is the 1 coming from?

Upvotes: 1

Views: 73

Answers (1)

merv
merv

Reputation: 77098

It's not the import in the script block, but the namespace defined in the parent component (eg, Application) which defines the namespace on the tag and enables the class to be located.

The namespace you actually use (eg, "comboBox" or "comboBox1") is fairly arbitrary:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comboBox2012="com.ui.comboBox.*">
  ...
  <comboBox2012:ExtendedComboBox />

So, there really is no "incorrect" namespace.

As to why the "1" was appended by the IDE, I can only guess. Perhaps Flex Builder 3 starts counting from 1 to keep custom namespaces unique, or somehow you already had "comboBox" as a namespace. I can't quite verify, since I only have FB4, which from my tests auto-generates "comboBox2" if "comboBox" is already reserved.

There is another question on how to direct the auto-generated namespace to adhere to your definition, which might be worth checking out: How can I make FlashBuilder use a custom namespace prefix


Update: Behavior Recreated in Flash Builder 4

I have run into an instance where Flash Builder 4 will increment the namespace in exactly the way it is indicated in the question. Namely, I have the following package structure in one of my projects:

--com
    |
    |--mydomain
    |    |
    |    |--behaviors
    |    |--components
    |    |--skins
    |    |--utils
    |
    |--anotherdomain
         |
         |--components

Whenever I use components from com.mydomain.components, the IDE uses the auto-generated namespace "components". Subsequently, if I then use a component from the com.anotherdomain.components package, the IDE auto-generates the (incremented) namespace "components1".

So perhaps you may have had a similar setup when you experienced this identical behavior. In the end it seems like a well-designed fallback behavior to prevent namespace collisions.

Upvotes: 1

Related Questions