Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rate Thread Display Modes
Old 01-28-2009, 09:34 AM   #1
pulse00
Senior Member
 
Join Date: May 2008
Posts: 112
Default Define custom states for skins to use with degrafa

hi,

i'm currently trying to skin a couple of my components using degrafa. most of the sample code uses buttons and their pre-defined flex states like overSkin, downSkin, selectedUpSkin etc.

In my case i'd need much more different states which are available for the button, that's why i would need to implement my own custom states.

The adobe docs say you can define your custom states like this:

Code:
[Style(name="mySkin", type="Class", inherit="no", states="foo, bar")
The test component i've written looks like that now:

Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:UIComponent xmlns:mx="http://www.adobe.com/2006/mxml">
  
  <mx:Metadata>
    [Style(name="mySkin", type="Class", inherit="no", states="foo, bar")] 
  </mx:Metadata>
  
  <mx:states>  
    <mx:State name="foo"/>
    <mx:State name="bar"/>
  </mx:states>
  
</mx:UIComponent>

Here's the part of the degrafa skin:

Code:
    <geometry>
        <GeometryComposition state="bar">
            <RegularRectangle fill="{solidFill}" height="{aheight}" width="{awidth}"/>              
            <RegularRectangle fill="{diagFill}" height="{aheight}" width="{awidth}"/>              
        </GeometryComposition>

        <GeometryComposition state="foo">
            <RegularRectangle fill="{solidFill}" height="{aheight}" width="{awidth}"/>
            <RegularRectangle fill="{diagFill}" height="{aheight}" width="{awidth}"/>              
        </GeometryComposition>
    </geometry>
Unfortunately, when applying the skin to the component using mySkin="myDegrafaSkinClass", no skin is applied to it.

It works without any problem if i use the pre-defined states, ie if i use the button and use the overSkin etc states.


Anyone knows how this is done ?


thanks!
pulse00 is offline   Reply With Quote
Old 01-28-2009, 10:05 AM   #2
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

I'm afraid you'll need to define states inside myDegrafaSkinClass, because, as it seems now the states aren't bound to anything... though, I'm not a pro with Degrafa, so, I can't tell for sure... Another suggestion, I'd make the component in AS, override the setStyle() and look what I'm getting in there...
__________________
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-28-2009, 10:17 AM   #3
pulse00
Senior Member
 
Join Date: May 2008
Posts: 112
Default

thanks for the hint, myDegrafaSkinClass eventually subclasses ProgrammaticSkin which doesn't seem to let me define states. i'm getting

Code:
Could not resolve <mx:states> to a component implementation.
inside the class.

I guess i'll post in the degrafa group and see what they say.
pulse00 is offline   Reply With Quote
Old 01-28-2009, 12:01 PM   #4
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

Another guess... What happens if you do:
Code:
<mx:Style>
     MyComponent {
        foo: ClassReference("myDegrafaSkinClass");
        bar: ClassReference("myOtherDegrafaSkinClass");
     }
  </mx:Style>
EDIT:
http://livedocs.adobe.com/flex/3/htm..._7.html#224961
OK, kind of figured that out..
So, what you needed to do is to define what happens once the component enters some specific state. I.e. Your <state/> tags ware empty, but, you needed to do something like this (in the skinning class)
Code:
<mx:State name="over">
            <degrafa:GraphicSurface/>
            ..... define what to do when this state is entered .... 
</mx:State>
__________________
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-28-2009 at 01:21 PM.
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
creating separate classes for custom event frank grimes ActionScript 3.0 6 06-27-2009 10:55 PM
how to trigger a custom event from a grid? j.steele Components 0 10-29-2008 08:51 PM
ColorTransform within custom class wmbenedetto ActionScript 2.0 2 05-12-2006 07:59 AM
Database simulated with arrays on a cd-rom lecasn5 Components 61 09-07-2004 11:40 AM


All times are GMT. The time now is 01:58 AM.

///
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.