Skins that effect the host component behaviour.

There was an interesting question that was raised in the pre-release forums about what is the appropriate way to handle animations between the skin and its host. Basically the issue was if there is an animation in the host and another in the skin what would be the best way to code it so that both animations ran in parallel, My thoughts are why not do it all in the skin. this example animates a container by resizing it and centering it in the application.
I figured it would be an interesting topic for those that are trying adding extra component functionality into the skin.
@PD - Maybe you could apply a little of your magic to something like this and add it your blog.
David
The App
=============================================================
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
  xmlns:s="library://ns.adobe.com/flex/spark"
  xmlns:mx="library://ns.adobe.com/flex/halo"
  creationComplete="application1_creationCompleteHandler(event)" width="100%" height="100%">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
protected function application1_creationCompleteHandler(event:FlexEvent):void
menu1.verticalCenter=height/2*-1 + 35; 
menu1.horizontalCenter=width/2*-1 + 110;
]]>
</fx:Script>
<s:SkinnableContainer id="menu1" left="10" top="10" width="200" height="50"
skinClass="SkinnableContainerSkin2" backgroundColor="#A16969">
</s:SkinnableContainer>
</s:Application>
=============================================================
The Skin
=============================================================
<?xml version="1.0" encoding="utf-8"?>
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:fb="http://ns.adobe.com/flashbuilder/2009" alpha.disabled="0.5" creationComplete="skin1_creationCompleteHandler(event)">
<fx:Declarations>
<s:Parallel id="sizer">
<s:Animate target="{hostComponent}" duration="2000" repeatCount="1">
<s:SimpleMotionPath id="setheight" property="height" valueTo="500"/>
</s:Animate>
<s:Animate target="{hostComponent}" duration="2000" repeatCount="1">
<s:SimpleMotionPath id="setvertical" property="verticalCenter" valueTo="0"/>
</s:Animate>
<s:Animate target="{hostComponent}" duration="2000" repeatCount="1">
<s:SimpleMotionPath id="sethorizontal" property="horizontalCenter" valueTo="0"/>
</s:Animate>
</s:Parallel>
</fx:Declarations>
<fx:Metadata>
    <![CDATA[
        [HostComponent("spark.components.SkinnableContainer")]
    ]]>
    </fx:Metadata>
    <fx:Script fb:purpose="styling">
        <![CDATA[       
import mx.events.FlexEvent;
import mx.core.FlexGlobals;
private var Vert:int;
private var Horz:int;
            override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number) : void
                bgFill.color = getStyle("backgroundColor");
                bgFill.alpha = getStyle("backgroundAlpha");
                super.updateDisplayList(unscaledWidth, unscaledHeight);
protected function resizeMe(e:MouseEvent): void
Vert = int(FlexGlobals.topLevelApplication.contentGroup.height/2*-1)+35;
Horz = int(FlexGlobals.topLevelApplication.contentGroup.width/2*-1)+110;
if (hostComponent.height < 51)
setheight.valueTo=500;
setvertical.valueTo=0;
sethorizontal.valueTo=0;
else
setheight.valueTo=50;
setvertical.valueTo=Vert;
sethorizontal.valueTo=Horz;
sizer.play();
protected function skin1_creationCompleteHandler(event:FlexEvent):void
Vert = int(FlexGlobals.topLevelApplication.contentGroup.height/2*-1);
Horz = int(FlexGlobals.topLevelApplication.contentGroup.width/2*-1);
        ]]>       
    </fx:Script>
    <s:states>
        <s:State name="normal" />
        <s:State name="disabled" />
    </s:states>
    <s:Rect left="0" right="0" top="0" bottom="0">
        <s:fill>
            <s:SolidColor id="bgFill" color="0x00DDDD"/>
        </s:fill>
    </s:Rect>
    <s:Group id="contentGroup" left="0" right="0" top="0" bottom="0" minWidth="0" minHeight="0" click="resizeMe(event)">
        <s:layout>
            <s:BasicLayout/>
        </s:layout>
    </s:Group>
</s:Skin>

This is a good question.
There's no hard and fast rule to apply which says "this belongs in the skin" vs. "this belongs in the component".  Similarly, there are also no hard and fast rules around when to use a the new skinning architecture vs. just creating a custom component.  Just do whatever you feel comfortable with and makes your job easier.  At the end of the day, it's about productivity and not living up to ideals.  That said, there are probably some easier and more logical ways to do some things.
On the skinning architecture vs. custom component debate, with a SkinnableComponent we have a clear separation of the component properties and behavior on one side and the look and feel of the component on the Skin side.  Also, there's a clear contract we use to talk back and forth to one another.  The reason for the separation between the Skin and the SkinnableComponent is so that we can have one Button SkinnableComponent and multiple Skins for that Button which all tweak the visual appearance of it.
It doesn't make sense for every component to be skinnable.  If you know what your component is going to be and look like and don't need the extra flexibility skinning provides, then you can get rid of the extra overhead that skinning requires (like having 2 classes).  An example custom component is:
<s:Group>
<s:Rect>
</s:Rect>
<mx:Image src="..." />
<s:Panel skinClass="myCustomSkinClass">
</s:Panel>
</s:Group>
If you want more flexibility and want the ability to easily change the look and feel of the component (i.e. skin it), then you'd extend SkinnableComponent, fill out the skinning lifecycle methods, and create a default Skin for its appearance.
Now, when you're building a SkinnableComponent, there's always a question of what to put in the component vs. what to put in the skin.  In general, we try to put the core properties and behaviors in the component and anything visual in the skin.  However, another guideline to consider is whether all skins would want this behavior.  If so, then it makes sense (and makes your life easier) to put it in the SkinnableComponent rather than the Skin.  We do this in the framework for components like VSlider, where the logic for positioning the y-axis of the thumb is in the component and not the skin, even though it's a "visual" thing.  We also have discussed how we would build up a ColorPicker component, and I think the way we would go about it is by putting a lot of the "visual" logic in the component because otherwise we'd have to duplicate it across all skins.
Now, the other question you guys are asking here are "when do I bake effects (or any behavior) in to the component (either in the skin or in the SkinnableComponent AS class) vs. when do I declare effects alongside the component".  Again, I think the answer to that is whether you want all your components to have this behavior.  If that was the case, then I'd lose no sleep baking it in to the component.  However, if it's not the case, then I'd make the end-developer delcare it when they use your component, like:
<s:MyCustomComponent id="myComponent" />
<s:Resize id="resizer" widthTo="100" heightTo="50" target="{myComponent}"/>
I would think most of the time, you probably wouldn't want to bake an effect like that in to the component, especially because it has some sizing information on it.  However, we have some effects baked in to some of the framework components, like when the thumb of a Slider moves around due to someone clicking on the track.  I think it's fine that it's baked in to the component, but I do think it should probably be stylable so that a user can customize it (that's on our list of lower-priority things to do btw).
The framework has definitely evolved.  I think we started out with a more purist attitude and wanted a clear separation between the skin and the component.  However, as we built out components, we realized it's not always practical to do that.  Similarly, we wanted our skins to be pure MXML; however, for usability reasons, we decided that our skins should be styleable, and that requires a little bit of ActionScript code.  Border is a great example where it doesn't really follow a lot of these guidelines, but it's just a styleable component; however, this component makes other people's jobs easier.  At the end of the day, it's about productivity and usability, and hopefully the Spark architecture is a step in the right direction.
Anyways, I hope that helps some.  These are just some guidelines.  As people play around with the architecture more, I'm sure some other people will have some good advice to share as well.
-Ryan

Similar Messages

  • Is there a way to expose properties or styles from a skin part to the host component?

    For example, I have this skin that contains a border around an image. I would like to be able to let the user set the cornerRadius.
    Skin:
    <fx:Metadata>
    <![CDATA[
    [HostComponent("spark.components.Image")]
    [Style(name="cornerRadius", inherit="inherit", type="int")]
    ]]>
    </fx:Metadata>
    </code>
    I would like to see that style show up in code complete in a UIComponent that uses this skin,
    <s:Image x=”10″ y=”30″ width=”50″ cornerRadius=”12″ skinClass=”ScaleImageSkin” height=”50″ source=”avatar.png”/>
    However the style “cornerRadius” throws an error at compile time.

    The only way I've found to pass properties or styles to a skin is through CSS or extending the host component and adding the styles or properties onto it. However this seems like a hack. Shouldn't the skin expose it's configuration to the host component? I think that is what Flex themes are doing.

  • If your iPad has a dent that effect the functioning of something does apple keep the iPad to work on it?

    I recently noticed that a dent was on the side of my iPad that effects the proper functioning of the volume controls. I have AppleCare on my iPad. But will apple keep my iPad to work on it?
    Thank you in advance!

    Apple's Limited Warranty http://www.apple.com/legal/warranty/ for iPad excludes coverage for damage resulting from accident, disassembly, unauthorized service and unauthorized modifications.
    Out-of-Warranty Service
         If you own an iPad that is ineligible for warranty service but is eligible for Out-of-Warranty (OOW) Service, Apple will replace your iPad with an iPad that is new or equivalent to new in both performance and reliability for the Out-of-Warranty Service fee listed below.    
    iPad model
    Out-of-Warranty Service Fee
    iPad mini
    $219
    iPad 3rd, 4th generation
    $299
    iPad 2, iPad
    $249
    A $6.95 shipping fee will be added if service is arranged through Apple and requires shipping. All fees are in US dollars and are subject to local tax.
    Certain damage is ineligible for out-of-warranty service, including catastrophic damage, such as the device separating into multiple pieces, and inoperability caused by unauthorized modifications. However, an iPad that has failed due to contact with liquid may be eligible for out-of-warranty service. See http://support.apple.com/kb/index?page=servicefaq&geo=United_States&product=ipad
    Make a Genius Bar Reservation
    http://www.apple.com/retail/geniusbar/
    You may can get the iPad repaired at 3rd party repair sources for less $, however, any remaining Apple warranty will be voided.
    iPad Repair & Screen Replacement Services
    http://www.ifixyouri.com/16-ipad-repairs
    RepairZoom iPad Repair
    http://www.repairzoom.com/ipad-repair.html
    Mission Repair
    http://www.missionrepair.com/Apple_iPad_Repair_Services_s/431.htm
    iGadgetResQ
    http://www.igadgetresq.com/ipad-repair/
     Cheers, Tom

  • Accessing the host component in a PDF navigator

    Hi all,
    I'm trying to access the host (i.e reader or acrobat) in a PDF navigator (Portfolio) created in flash builder.
    I have seen numerous examples that override the host set method by doing the following:
    public function set host(host:INavigatorHost):void
                                                 if(host != null) {
                                                           _host = host;
                                                           startEverything();
                                                 } else {
                                                           _host = null;
                                                           //Alert.show("Navigator Ending");
    Then the _host:INavigatorHost is used to access the host application.
    When I try to do this using Flex 4.1 it tells me that this method is not marked for override.
    If i just try to access 'host' it tells me that it is 'write-only'.
    Any help at all, or another method would be greatly appreciated.
    Thanks,
    Chris

    Hi,
    there are several possibilities to achieve that.
    For example
    - JDO
    - SQLJ
    - direct access to the database via JDBC from your WD Controller (not recommended).
    For more information about JDO see at
    /program files/SAP/JDT/eclipse/examples
    There you will find the tutorial J2EE_GettingStartedJDO
    For general information about Java persistence have a look at
    http://help.sap.com/saphelp_erp2004/helpdata/de/61/fdbc3d16f39e33e10000000a11405a/content.htm
    Regards
    Helmut

  • I have an image that I removed from its back ground and I would like to scale the bottom portion of the image because its to wide but not have that effect the top portion of the image which is the correct with. but also keep the aspect ratio correct? how

    I have an image that I removed from its back ground and I would like to scale the bottom portion of the image because its to wide but not have that effect the top portion of the image which is the correct width. but also keep the aspect ratio correct, keep it looking as natural as possible (its a piece of jewlery) ? how can I begin to do this.

    The area circled in red is to wide (the width) the necklace's width is as wide as the models entire chest. And also the length of the necklace it's to long it should come down to the clevage area on the model/woman.

  • If the I phone 5 stay more than 8 hours  on charger , is that effect the batteries?

    If the I phone 5 stay more than 8 hours  on charger , is that effect the batteries?

    No I charge mine overnight and always have ... Once the battery reaches full charge the charge only trickle charges or turns off

  • HT4060 If the ipad got overheated due to being put in the seat pocket in a car would that effect the battery?

    If the ipad got overheater due to being put in the seat pocket of a car, would that effect the battery? It is not charging very fast at all, it also froze once .

    So replace the battery?

  • Having the top( ) Volume stuck in the press down position would that effect the phone ringer not to work.

    My ringer was working fine from one day to another it stopped working, looking at the phone I looked at all the setting , the little switch on top was not showing the line, but I did notice the top volume button was stuck in the down position. Would this effect the ringer not to work. I can listen to videos, music and streaming videos on the internet without any issues. What you think

    *UPDATE*
    I have been able to use the Zoom function to zoom in and the keys on the top row no longer are in the non-responsive strip of area.

  • Difference in using the same component made in mxml or action-script

    Hi,
    I made a sample project to show a kind of bug in the SuperTabNavigator component of FlexLib
    In this sample you can see that using the same component (made in both mxml or action-script) can make a difference
    I'm just wondering why ?
    Thanks
    Here is what i've posted :
    What steps will reproduce the problem?
    1. Create a button to dynamically add new tab with icon on a SuperTabNavigator
    2. Click on this button to add new tabs
    What is the expected output?
    - The expected output is tabs added without abnormal behavior
    What do you see instead?
    - Every time a new tab is created the one who had the focus has its content
    (icon + label) moving from the top-left of the tab to its original position
    Please provide any additional information below.
    Configuration:
    - Flex Builder 3 in Eclipse
    - FlexLib 2.3
    Sample:
    (see attached file)
    There is two type of tab, one in action-script and one in mxml
    They both are equal
    - Adding a new action-script tab to SuperTabNavigator works fine
    - Adding the same tab but an mxml one doesn't
    - Adding a new action-script or mxml tab to TabNavigator works fine
    -> meanings that the issue comes with SuperTabNavigator
    - Adding a new mxml tab to both SuperTabNavigator and TabNavigator at the
    same time makes TabNavigator to get the same bad behavior
    Remarks:
    - Tried everything but i'm really stuck
    - Weirdly, removing the PopUpButton correct the issue
    - In the same way if you keep adding action-script tab it automatically scroll to the
    last tab. And if you do the same with mxml tab then it add the tab at the end and
    scroll to the first one.
    => what could be the difference between using action-script or mxml object ?

    Here is one possible solution:
    You can use the ExternalInterface (
    http://livedocs.macromedia.com/flex/2/langref/flash/external/ExternalInterface.html)
    class to communicate with JavaScript. JavaScript can then popup the
    media player very easily like this:
    http://www.webreference.com/programming/javascript/jf/column5/index.html
    The documentation on the ExternalInterface class has a nice
    example (in the bottom of the page) on how to communicate with
    JavaScript in a browser. Hope this helps,
    -george

  • How to use the predefined component such as 'POWL_UI_COMP'

    hi,expert.
    i am new to webdynpro for  abap.  i want to use some sap predefined component such as 'SALV_WD_TABLE' and 'POWL_UI_COMP'.
    can someone give me a simple demo about the application of there component?
    thank you.

    HI,
    Well there are lots and lots of examples and tutorials for the type of material you are searching, may be you can search in the WebDynpro for ABAP forum. I am sure you will get lots of threads there which will help you.
    Well to begin with, to use the standard components you need to include them in your WebDynpro component . You can do that in the Used component tab of you component. After doing this you will be able to use the methods, views of that standard compnent.
    Regards,
    Runal

  • Protective shield (skin) and replacing the battery

    Hi,
    I have a new iPod Classic 80GB and will have it covered with a shield (skin) that covers the entire iPod. When or rather IF I have to replace the battery will I ever have a problem with Apple because of my skinned iPod?
    Will they require that I remove the skin before having it serviced?

    No.
    Apple will simply send a replacement iPod (without the shield).

  • Backup Host Component via wbadmin

    Hi everyone,
    I am using 2012 R2 and I am trying to backup the Host Component via wbadmin:
    wbadmin START BACKUP -backupTarget:E: -hyperv:"Host Component"
    but I have not being successful so far. The error I get is:
    ERROR - Command syntax incorrect. Error: Component. See the command syntax below.
    Any ideas anyone please?

    Hi,
    Sorry to be unclear in my description.
    -hyperv is of course a supported parameter.
    In your command line you mentioned: 
    wbadmin START BACKUP -backupTarget:E: -hyperv:"Host Component"
    and the error said "Error: Component". So I'm thinking if the error is caused by the words you typed after -hyperv - "host component" is obviously a not supported name in -hyperv. 
    If you have any feedback on our support, please send to [email protected]

  • The search service is not able to connect to the machine that hosts the administration component. Verify that the administration component 'GUID′ in search application 'Search Service Application' is in a good state and try again.

    Another post with a well-known title. Believe me, I know. Here's my setup;
    - 1 Server 2012 WFE, SharePoint Server 2013, totally up-to-date, including the september 2014 hotfix
    - 1 Server 2012 DB, SQL Server 2012
    Installed SP 2013 using PowerShell, with the AutoSPinstaller. Worked like a charm. Got everything up and running, with some tweaking here and there to customize it to fit my situation. Now, I can't get the Search Service Application to work. Must have created,
    deleted and recreated it at least 30 times. Used both PowerShell scripts, PowerShell line-by-line, Central Admin, heck, I even went so far as to use the configuration wizzard... No luck. I keep on getting the message that search cannot connect to the machine
    that hosts the 'administration component'.
    In order to avoid answers that suggest all the things I've already tried, here's a summary of the various scenarios I followed:
    Tried both a dedicated application pool as well as the SharePoint Web Services Default
    Timer job job-application-server-admin-service is running and not showing errors
    IIS 8.0 is installed, so is .NET 4.5 (not the known perp of IIS 7.5 and .NET 4.0)
    the get-SPEnterpriseSearchServiceInstance -local returns a healthy, online state
    the SPEnterpriseSearchQueryAndSiteSettingsServiceInstance is also running
    FireWall is disabled; registry has the BackConnectionHostNames modified with the necessary FQDNs
    Accounts used to install and / or run the serviceapp all have sufficient rights - tried a dedicated managed account, SP_2013_SearchSvc, the SP admin account, and even the original Farm account; all to no avail, I keep on getting the error message.
    Even tried stsadm to start the server search running - NOTHING WORKS!!!
    As you might understand, this is driving me nuts. About to miss my second deadline, and no amount of IISresetting is making this go away. Been stuck on this issue for far too long, now (my searching is measured in days and weeks instead of hours, by now).
    Whoever helps me solve this - you will have my eternal gratitude, and a nice bottle of Prosecco. Or whatever's your poison. You need to come get it, though. I´m situated in the Netherlands. Hey, you always meant to visit Amsterdam and see for yourself, right?
    Thanks, community, for coming to my rescue!

    Thanks again - Alas, I've been there. Deleted Search a dozen times, at least, and tried installing it, initially using a PowerShell script (tried several scripts actually, from full-blown total Search Applications with extensive topologies to the most basic
    of basics 'please just start without showing me errors'), PowerShell line-by-line to see where things went South, next tried installing through Central Admin (hoping that it was my own stupidity in overlooking things and hoping The System would get it right
    for me), and eventually even tried using the config wizzard as a total and utter last resort - Nothing worked.
    At first, I found out that removing a Service App needs a *little* bit more work than simply removing it through Central Admin, but by now I can truthfully state that if there's one thing I've become supergood at, it's removing Search Service Applications.Totally.
    I will check out the article, though - I realized early on in my SharePoint experience that regardless of what you think you know, there's so much more to find out. I know, that's almost philosophical. That is, my friends, indeed the point I've reached...

  • The search service is not able to connect to the machine that hosts the administration component

    Hi
    After uninstalling the binaries, and reinstalling / joining back to the farm, everything seems happy expect search.
    When we try and start the Search Service back, it takes us to the Search Application section, and shows this message;
    The search service is not able to connect to the machine that hosts the administration component
    How can I get search to work again, or get around this error?
    I am pretty inexperienced with Search

    Hi  Tibsy80,
    For your issue, it can be caused by the search admin timer job was disabled.
    Run below PS command to know the status:
    Get-SPTimerJob job-application-server-admin-service | fl
    If it returns “IsDisabled: True”, ran below PS command to enable the service:
    Enable-SPTimerJob job-application-server-admin-service
    Then run below PS command to stop and start the timer and IIS reset:
    Net Stop timer
    Net start timer
    iisreset
    Then wait 1-2 min and try browsing to the SSA again.
    Reference:
    http://neelb.wordpress.com/2012/01/19/the-search-service-is-not-able-to-connect-to-the-machine/
    Also you can refer to the blogs:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/b04498ec-78d1-4bb9-8077-0481977cef10/the-search-service-is-not-able-to-connect-to-the-machine-that-hosts-the-administration-component?forum=sharepointadminprevious
    http://davidbajak.com/blog/post/2011/09/29/Fix-SharePoint-2010-Enterprise-Search-After-Using-AutoSPInstaller-Script-Installer.aspx
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • How to email text from a text component in my applet on a the host server ?

    How to email text from a text component in my applet on a the host server, back to my email address ?
    Assuming I have Email Form on the host server.
    Help will be appreciated.

    You can do like below
    =REPLACE(Fields!Column.Value," " & Parameters!ParameterName.value & " ","<b>" & Parameters!ParameterName.value & "</b>")
    The select the expression and  right click and choose placeholder properties
    Inside that set Markup type as HTML 
    then it will highlight the passed parameter value in bold within the full xml string
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Maybe you are looking for

  • Open dialog box: Dropdown "path" menu gone?

    When I choose Open in Apple/iCloud enabled apps like Preview, I get a new kind of dialog box. It is missing the dropdown menu at the top that gives the path to the current folder. This was my main navigation tool for moving to the place where my file

  • Problem with distortion in CS5

    Hello, I am a total beginner with a very frustrating problem using flash. When I try to rotate an image (using either the free transform tool or the transform panel) the image completely distorts and becomes very pixelated. I have tried everything I

  • Facebook "Make Shared Album" breaks Aperture connection

    As far as I can gather, Facebook albums of type "Shared Album" will disappear from your Aperture Facebook listing. You can no longer share photos directly from Aperture for Facebook albums of this type. I've not found much discussion on the web about

  • Canon Optura 50 capture won't connect

    I have new Canon Optura 50; great camcorder, BUT my Mac will not connect/see it via 1394 in any application (FC HD/iMovie/istopmotion). I know it's not a cable etc. issue, since it sees my junker ZR10 just fine. DV setting is set to "Basic". Please h

  • Attachment in Pricing condition records ?

    Hi experts, Do we have ability to attach documents to pricing condition records in SAP 4.7 ? Or any easy way to achieve this ? Thanks ! Pricing, Condition, VV11, VV12