Menu:

Sponsor

Discover Master of Alchemy, our first iPad/iPhone and iPod touch game!

Follow Me

 

Forum's topics

Latest Files

Archives

Top Rated

Categories

Photo Gallery


Alessandro Crugnola on September 15, 2006 in flex

Flex2 and namespaces extending components

setStyle_mx_internal.pngI took 2 hours to find a solution for that and I decided to blog it..
I was creating my new Flex2 component extending the UIComponent class and I need to define new custom styles for my own component...
Ok, i opened the "create and extend components" PDF guide and found that I need to put this code to accomplish it:
private static function classConstruct():Boolean 
{
	if (!StyleManager.getStyleDeclaration("ResizeManager"))
	{
		var newStyleDeclaration:CSSStyleDeclaration = new CSSStyleDeclaration();
		newStyleDeclaration.setStyle("boxSize", 4);
		StyleManager.setStyleDeclaration("ResizeManager", newStyleDeclaration, true);
	}
	return true;
}

That's all, but at this time the compiler die with that error message "1000: Riferimento ambiguo a setStyle", which in english should be: "1000: Ambiguous reference to setStyle".
I google for some time but without finding a solution, then I discovered the problem. I was using in my component the mx_internal namespace, that was the problem. Once changed namespace everything was ok.

 

 

Bookmark and Share

 

Tags: mx_internal , namespaces 

 

3 comments
I found that I could still use mx_internal (because I needed to) and still use setStyle by specifying the namespace in the call: newStyleDeclaration.public::setStyle("boxSize", 4);
I also had the same problem, if you need to use 'mx_internal' name space then call 'setStyle' explicitly using that name space: private static function classConstruct():Boolean { if (!StyleManager.getStyleDeclaration("ResizeManager")) { var newStyleDeclaration:CSSStyleDeclaration = new CSSStyleDeclaration(); newStyleDeclaration.mx_internal::setStyle("boxSize", 4); StyleManager.setStyleDeclaration("ResizeManager", newStyleDeclaration, true); } return true; }
Thank you for this! You just saved me probably hours of frustration. I'm doing pretty much the same thing you are, extending UIComponent. I needed the mx_internal namespace because I'm calling CursorManager.registerToUseBusyCursor(), etc. So I just ditched the use namespace declaration and instead used the explicit mx_internal::CursorManager.registerToUseBusyCursor().


Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Type the characters you see in the picture above.





 

TrackBacks

TrackBack URL for this entry: http://www.sephiroth.it/cgi-bin/mt/mt-tb.cgi/129