Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 01-30-2009, 11:42 AM   #1
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default Cannot use mx:states on custom components?

I have an MXML component which uses for the base class my custom AS class which extends Panel. At the moment it has nothing in it, only calls super in constructor... though, if I change monopoly:UserDetails to mx:Panel it'll work, but, if I use it like in the code below it spits an error saying it cannot resolve mx:states to the component implementation.
SO, please, correct me if I'm wrong, I conclude from this I cannot use states with non standard components even though they extend standard components?

Code:
<?xml version="1.0" encoding="utf-8"?>
<monopoly:UserDetails 
	xmlns:mx="http://www.adobe.com/2006/mxml"
	xmlns:monopoly="http://www.spotlessdesign.com/monopoly"
	xmlns:mate="http://mate.asfusion.com/"
	width="300" height="400"
	title="User Details"
	paddingLeft="10">
	
	<mx:Script>
        <![CDATA[
            import com.spotlessdesign.monopoly.eventmap.events.MessageEvent;
                
            private function submitForm():void
			{
                messageDispatcher.generateEvent();
            }
            
            private function handleResult(text:String):void
            {
                currentState = "response"; 
                display.text = text;
            }
            
            private function handleFault(text:String):void
            {
                currentState = "response"; 
                display.text = text; 
                display.styleName = "error";
            }
            
        ]]>
    </mx:Script>
	
	<mate:Dispatcher 
		id="messageDispatcher" 
		generator="{MessageEvent}" 
		type="{MessageEvent.GET}">
		
        <mate:eventProperties>
            <mate:EventProperties name="{inputName.text}"/>
        </mate:eventProperties>
        
        <mate:ServiceResponseHandler
			result="handleResult(event.result.text)"
			fault="handleFault(event.fault.faultString)"/>
    </mate:Dispatcher>
	
	<mx:Label text="User Profile Picture"/>
	<mx:Image source="images/map.jpg" width="100" height="100"/>
	<mx:Button label="GO" click="submitForm()"/>
	<mx:Text id="inputName"/>
	
	<mx:states>
		<mx:State name="response">
			<mx:AddChild position="lastChild">
				<mx:Text id="display" styleName="message" />
			</mx:AddChild>
		</mx:State>
	</mx:states>
	
</monopoly:UserDetails>
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it
wvxvw is offline   Reply With Quote
Old 01-30-2009, 01:33 PM   #2
fx.barrett
Paintball Freak
 
fx.barrett's Avatar
 
Join Date: Jul 2008
Location: Romania, TM
Posts: 467
Send a message via MSN to fx.barrett Send a message via Skype™ to fx.barrett
Default

Nah, it can be done and it's working just that pay attention to something: don't name the source file the same way as the component... if both files are named the same way ex: CustomPanel.as and CustomPanel.mxml then for a strange reason Flex "dies" and refuses to compile the project correctly... No matter if you try building it manually or automatically it will simply not reflect the changes ( you can try renaming one file and you'll see that you are thrown a warning... the stupid part is that the warning says nothing about the actual problem... it just says that "errors exist in the application"... which in reality means: both of your files have the same name, and I don't like that... ).

So, make sure you have 2 different names and it should work just fine. I threw together a fast example for you ( it's messy but I'm sure you'll manage ) just in case you want to check out a working example.

Good luck man.
Attached Files
File Type: zip ExtendingTest.zip (14.8 KB, 148 views)
__________________
FLASHFORUM.RO - You must speak Romanian in order to join.
BLOG.WISEBISOFT.COM - Share and Experiment.
fx.barrett is offline   Reply With Quote
Old 01-30-2009, 01:43 PM   #3
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

A quick reply while downloading the example
Flex for sure won't compile MXML and AS files with the same names because it generates AS file from MXML, and the name of the AS class compiled from MXML will be the same as the MXML file's name

EDIT: Thanks for the example, just put the states into the namespace of the component and it worked
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it

Last edited by wvxvw; 01-30-2009 at 01:47 PM.
wvxvw is offline   Reply With Quote
Old 01-30-2009, 01:48 PM   #4
fx.barrett
Paintball Freak
 
fx.barrett's Avatar
 
Join Date: Jul 2008
Location: Romania, TM
Posts: 467
Send a message via MSN to fx.barrett Send a message via Skype™ to fx.barrett
Default

Quote:
Originally Posted by wvxvw View Post
Flex for sure won't compile MXML and AS files with the same names because it generates AS file from MXML, and the name of the AS class compiled from MXML will be the same as the MXML file's name
I thought so too but still, it's kinda stupid that they don't throw a correct error to signal what's going on... or any error... users with some experience might figure this out but for a beginner, it will be a living hell

Tell me if the example works for you and if it was of any help.
__________________
FLASHFORUM.RO - You must speak Romanian in order to join.
BLOG.WISEBISOFT.COM - Share and Experiment.
fx.barrett is offline   Reply With Quote
Old 01-30-2009, 02:02 PM   #5
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

Oh, sorry, answered in the previous post. Yes, it put me on the right way Thanks
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it
wvxvw is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
rmtp address for custom made components, can it be done? draper3000 Flash Media Server 0 01-13-2009 11:40 AM
Embed Fonts in Custom Components clinch Components 3 03-05-2008 11:50 AM
Focus on custom components don simon Components 0 06-21-2006 02:08 PM
custom components not updating their as2 code vesoljc ActionScript 2.0 0 06-18-2005 08:44 AM
showing custom components in the component panels ??? [CVX] lucas Components 0 01-05-2005 03:45 PM


All times are GMT. The time now is 04:29 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.