Change the Selected TEXT Color on Spark DataGrid cell - actionscript-3

Does anyone know a way to apply style on selected text in a Spark DataGrid?
I think that the best way is to have an itemrenderer with textarea but after, I don't know how to do.
My goal isn't to change color label if cell is selected.
Indeed, in my dream, item is editable, and you can selected only some words inside cell and apply a specific style to the selected part of text (by click on a button, one for bold, one for italic...). Than, text may be store in database like html text.
I'd like use cell itemrenderer like a RichTextEditor but without ControlBar. In my case, I'd like to have only one control bar outside the datadgrid.
I'll happy, if you can help me.
Thanks

Best approach with Spark is generally a skin.
There's rudimentary control via properties, such as changing the selected color:
<?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">
<s:DataGrid selectionColor="0xff0000">
<s:dataProvider>
<s:ArrayList>
<fx:String>a</fx:String>
<fx:String>b</fx:String>
<fx:String>c</fx:String>
</s:ArrayList>
</s:dataProvider>
</s:DataGrid>
</s:Application>
To implement an item renderer for a GridColumn, use States to define how the selected state will appear
GridColumnItemRenderer
<?xml version="1.0" encoding="utf-8"?>
<s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
clipAndEnableScrolling="true">
<s:states>
<s:State name="normal" />
<s:State name="selected" />
</s:states>
<fx:Script>
<![CDATA[
override public function prepare(hasBeenRecycled:Boolean):void
{
lblData.text = data[column.dataField]
}
]]>
</fx:Script>
<s:Label id="lblData"
color.selected="0x00ff00"
top="9"
left="7" />
</s:GridItemRenderer>
DataGrid
Item renderer above is specified from a Spark GridColumn, as in:
<s:DataGrid>
<s:columns>
<s:ArrayList>
<s:GridColumn itemRenderer="GridColumnItemRenderer" />
</s:ArrayList>
</s:columns>
</s:DataGrid>

Related

Scroller in the first accordion item in Flex does not appear

I have created an accordion to store images on categories. Everything is ok when I add a new element to an item, the scroller appears. The image address is saved in an txt file. However, when I open the application again the scroller does not appear. This is strange as it happens only in the first item of the accordion. If I add more elements to the other items (from the second further) everything works alright.
Does anybody have any idea why??
Hard to say without seeing your code.
Sample of using accordion with images inside which you can try
(scrollbars are visible for both tabs):
<?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/mx">
<mx:Accordion height="500"
width="100%">
<s:NavigatorContent label="Tab 1"
height="100%"
width="100%">
<s:Scroller height="100%"
width="100%">
<s:Group>
<s:Image source="http://d1c739w2xm33i4.cloudfront.net/2.2/top_image.jpg"/>
</s:Group>
</s:Scroller>
</s:NavigatorContent>
<s:NavigatorContent label="Tab 2"
height="100%"
width="100%">
<s:Scroller height="100%"
width="100%">
<s:Group>
<s:Image source="http://eofdreams.com/data_images/dreams/image/image-07.jpg"/>
</s:Group>
</s:Scroller>
</s:NavigatorContent>
</mx:Accordion>
</s:Application>
In accordion just write resizetocontent = true; It will work
Hope it will help

Flex id contentGroup query

iam learning Flex and practising skins. So, i just had one doubt:
I have written one custom skin named : ApplicationContainerSkin.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<s:states>
<s:State name="normal" />
<s:State name="disabled" />
</s:states>
<fx:Metadata>
[HostComponent("spark.components.Application")]
</fx:Metadata>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Group horizontalCenter="0" verticalCenter="0">
<s:Rect left="0" right="0" top="0" bottom="0"
radiusX="10" radiusY="10">
<s:fill>
<s:SolidColor color="#CCCCCC" />
</s:fill>
</s:Rect>
<s:Group id="contentGroup"
left="30" right="30" top="30" bottom="30">
</s:Group>
</s:Group>
</s:SparkSkin>
My Doubt:
When I removed s:Group id="contentGroup" , iam unable to see any content inside my application, so why is this 'contentGroup' id necessary?
where this id predefinedly specified.? sorry if its a noob query, but iam eager to knew it.I even tried to check the source code, but I didnt found it, Could anyone tell me where it specified and how does my content render only after using this contentGroup id...? ( I mean, how it internally works? )
Awaiting your responses!
Skinnable Spark components specify "skin parts," identified by the id.
The Application component, which you are skinning, defines 2 skin parts - contentGroup and controlBarGroup, as you can see in the documentation here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/Application.html#SkinPartSummary
The Application class uses the contentGroup skin part (if it has been added in the skin) to lay out the content. Skin parts can either be required or not. The contentGroup part is not required, and therefore when you left it out, the content just did not display.

Rotating animation wobbles

I'm trying to create a simple "AJAX loader" type animation, just a circle that rotates around it's center. My problem is that the rotation isn't smooth, it wobbles slightly back and forth.
Demo SWF: http://swfup.com/view/1mn0
Code for the swf:
<?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/mx"
width="160" height="160"
backgroundColor="0xCCCCCC"
initialize="loadingAnim.play()">
<fx:Declarations>
<s:Rotate angleFrom="0" angleTo="360" autoCenterTransform="true" id="loadingAnim" target="{loader}"
repeatCount="0" duration="2000" easer="{null}" />
</fx:Declarations>
<s:Image id="loader" source="#Embed('loader.png')" smooth="true" smoothingQuality="high"
horizontalCenter="0" verticalCenter="0" />
</s:Application>
I've made sure that the image is an exact circle, if you want to check for yourself then here is the image file:
The center of the image (73, 73) doesn't match up to the visual center of the graphic.
Here's your graphic with the center marked:
So, it's spinning off-center (visually) which causes it wobble.

Switch window size in flex

So me and a friend have made a tool using flex which we have released, we made the window 680x480 and people are saying its too small for them.
So what i want to do is include possibly a switch or something that switches the size from 640x480 to 800x600, so you have both options available to use.
I just wondered if this was possible? I have searched google all morning and cant find exactly what i need.
I am also pretty novice at this... my friend is the coder but he has no idea and no time to sort this out, so would be a great help if i could get some insight here please.
I failed to mention, it's not a scale, i have all the assets in the package for 800x600 aswell as the standard files so, i guess would be a state change, but i'm not sure if its possible to change state to a larger page.
Thanks.
Well, basically, you can occupy 100% width and 100% height by your SWF within the containing HTML page.
Then if you need a fixed size, you can organize your application within a Group container and size it accordingly.
Try this:
<?xml version="1.0" encoding="utf-8"?>
<s:Application
width="100%"
height="100%"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<s:Group horizontalCenter="0" verticalCenter="0" width="{resolutionDropDownList.selectedItem.w}" height="{resolutionDropDownList.selectedItem.h}">
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="#FF0000"/>
</s:fill>
</s:Rect>
</s:Group>
<s:HGroup top="10" horizontalCenter="0" gap="5" verticalAlign="baseline">
<s:Label text="Size:"/>
<s:DropDownList id="resolutionDropDownList" labelField="label" selectedIndex="0">
<s:dataProvider>
<s:ArrayList>
<fx:Object w="640" h="480" label="640x480"/>
<fx:Object w="800" h="600" label="800x600"/>
</s:ArrayList>
</s:dataProvider>
</s:DropDownList>
</s:HGroup>
</s:Application>
Veeeeeery rough convertion from 640x480 to 800x600 resolution:
stage.scaleX = 800 / 640;
stage.scaleY = 600 / 480;

create custom chrome adobe air desktop application using flex4 sparks controls

I have googled around but the only resource for teaching me how to create an Adobe Air Desktop Application uses mx controls instead.
inside app-xml i have set transparent to true and systemChrome to none.
the following is my main mxml
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:dragdrop="org.robotlegs.demos.draganddrop.*"
xmlns:view="org.robotlegs.demos.draganddrop.view.*"
mouseOver="layoutCanvas.visible = true;"
mouseOut="layoutCanvas.visible = false;"
>
<fx:Style>
#namespace s "library://ns.adobe.com/flex/spark";
#namespace mx "library://ns.adobe.com/flex/mx";
s|Application {
background-alpha:"0.7";
padding: 0px;
}
</fx:Style>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<dragdrop:DragAndDropContext contextView="{this}"/>
</fx:Declarations>
<s:Image id="background" width="100%" height="100%"
source="#Embed('theme/assets/MaxBackground.png')"/>
<s:BorderContainer id="layoutCanvas" width="100%" height="100%" visible="false">
<s:Image id="applicationClose" right="5" top="2"
click="stage.nativeWindow.close()"
source="#Embed('theme/assets/buttons/CLOSE WINDOW icon.png')"/>
<s:Image id="applicationMaximize" right="25" top="2"
click="stage.nativeWindow.maximize()"
source="#Embed('theme/assets/buttons/EXPAND WINDOW icon.png')"/>
<s:Image id="applicationMinimize" right="45" top="2"
click="stage.nativeWindow.minimize()"
source="#Embed('theme/assets/buttons/COLLAPSED WINDOW icon.png')"/>
</s:BorderContainer>
</s:WindowedApplication>
I have two issues.
1) the initial application window size. How can i set this to 100% full screen?
2) there is a strange grey horizontal footer at the bottom. How do i get rid of it? See here
I do not wish to use mx controls. I want to use sparks controls as much as possible.
Thank you.
1) the initial application window size. How can i set this to 100% full screen?
To do this you can add a CREATION_COMPLETE handler to your application and within that handler add a line similar to:
this.maximize() where this is you WindowedApplication.
2) there is a strange grey horizontal footer at the bottom
From the sounds of it, this is the status bar. Try setting the showStatusBar property on you WindowedApplication root tag to false :
showStatusBar="false"
Hope this helps.