I'm trying to embed a font so that I can rotate a Spark button component, but I'm not able to do it. The button always appears blank, no text.
The code looks like this:
<fx:Style>
#namespace s "library://ns.adobe.com/flex/spark";
#font-face {
fontFamily: verdana;
src: url("VERDANA.TTF");
embedAsCFF: true;
fontWeight: normal;
}
</fx:Style>
<s:Group>
<s:layout>
<s:HorizontalLayout />
</s:layout>
<s:Button id="back"
includeInLayout="{data.thisLevel.getParent() != null}"
label="Back"
fontFamily="verdana"
fontWeight="normal"
height="100%"
rotation="270" />
</s:Group>
My research has indicated you needed to play some games with fontWeight to get mx:Button to work, but that's supposedly fixed with Spark. (And messing around with fontWeight doesn't do anything.) When I turn the Button into a Label, it behaves the way I expect, so I'm apparently embedding the font properly -- the button just can't see it.
What am I doing wrong here?
You have done all right. Your code works by me wonderful. I have added the second button to let you see the effect.
<?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" minWidth="955" minHeight="600">
<fx:Style>
#namespace s "library://ns.adobe.com/flex/spark";
#font-face {
fontFamily: verdana;
src: url("assets/fonts/verdana.ttf");
embedAsCFF: true;
fontWeight: normal;
}
#font-face {
fontFamily: snap;
src: url("assets/fonts/snap.ttf");
embedAsCFF: true;
fontWeight: normal;
}
</fx:Style>
<s:Group x="100" y="100">
<s:layout>
<s:HorizontalLayout />
</s:layout>
<s:Button id="back"
includeInLayout="true"
label="Back"
fontFamily="verdana"
fontWeight="normal"
height="100%"
rotation="270" />
<s:Button id="back2"
includeInLayout="true"
label="Back"
fontFamily="snap"
fontWeight="normal"
height="100%"
rotation="270" />
</s:Group>
</s:Application>
Related
When using the carousel function in Liferay 6.1.1 CE GA2 I see the carousel working properly in both Safari and Chrome.
However, the images are not shown in Firefox.
In order to have the function working I created a Webcontent Structure with following code
<?xml version="1.0"?>
<root>
<dynamic-element name="activeIndex" type="text" index-type="" repeatable="false">
<meta-data>
<entry name="displayAsTooltip"><![CDATA[true]]></entry>
<entry name="required"><![CDATA[false]]></entry>
<entry name="instructions"><![CDATA[Index of the first visible item of the carousel]]></entry>
<entry name="label"><![CDATA[activeIndex]]></entry>
<entry name="predefinedValue"><![CDATA[0]]></entry>
</meta-data>
</dynamic-element>
<dynamic-element name="timeInterval" type="text" index-type="" repeatable="false">
<meta-data>
<entry name="displayAsTooltip"><![CDATA[true]]></entry>
<entry name="required"><![CDATA[false]]></entry>
<entry name="instructions"><![CDATA[Interval time in seconds between an item transition.]]></entry>
<entry name="label"><![CDATA[timeInterval]]></entry>
<entry name="predefinedValue"><![CDATA[0.75]]></entry>
</meta-data>
</dynamic-element>
<dynamic-element name="maxImageHeight" type="text" index-type="" repeatable="false">
<meta-data>
<entry name="displayAsTooltip"><![CDATA[true]]></entry>
<entry name="required"><![CDATA[false]]></entry>
<entry name="instructions"><![CDATA[Provide max height of image element. Min limit advisable is 40]]></entry>
<entry name="label"><![CDATA[maxImageHeight]]></entry>
<entry name="predefinedValue"><![CDATA[254]]></entry>
</meta-data>
</dynamic-element>
<dynamic-element name="maxImageWidth" type="text" index-type="" repeatable="false">
<meta-data>
<entry name="displayAsTooltip"><![CDATA[true]]></entry>
<entry name="required"><![CDATA[false]]></entry>
<entry name="instructions"><![CDATA[Provide max width of image element. Min limit advisable is 130]]></entry>
<entry name="label"><![CDATA[maxImageWidth]]></entry>
<entry name="predefinedValue"><![CDATA[600]]></entry>
</meta-data>
</dynamic-element>
<dynamic-element name="ImageElementSet" type="selection_break" index-type="keyword" repeatable="true">
<dynamic-element name="image" type="image" index-type="keyword" repeatable="false"></dynamic-element>
<dynamic-element name="linkUrl" type="text" index-type="keyword" repeatable="false"/>
</dynamic-element>
</root>
And a web template consisting of
#set($imageWidth = $maxImageWidth.Data)
#set($imageHeight = $maxImageHeight.Data)
#set($imageWidthPx = $imageWidth + "px")
#set($imageHeightPx = $imageHeight + "px")
#set($interval = $timeInterval.Data)
#set($activeIndexValue = $activeIndex.Data)
<style type="text/css">
.aui-carousel {
-moz-user-select: none;
margin: 20px 0;
}
.aui-carousel-item {
border-radius: 10px 10px 10px 10px;
text-indent: -9999em;
}
.aui-carousel li {
margin: 0 !important;
}
}
</style>
#set($totalCount = 0)
<div id="carousel">
#foreach($imageElement in $ImageElementSet.getSiblings())
#if($imageElement.image.getData() != "")
#if($imageElement.linkUrl.getData() != "")
<a href="$imageElement.linkUrl.Data">
<img class="aui-carousel-item" src="$imageElement.image.Data" height="$imageHeightPx" width="$imageWidthPx" />
</a>
#else
<img class="aui-carousel-item" src="$imageElement.image.Data" height="$imageHeightPx" width="$imageWidthPx" />
#end
#set($totalCount = $totalCount + 1)
#end
#end
</div>
#if($totalCount > 0)
<script>
AUI().ready('aui-carousel', function(A)
{
var carousel = new A.Carousel(
{
contentBox: '#carousel',
activeIndex: $activeIndexValue,
intervalTime: $interval,
width: $imageWidth,
height: $imageHeight
}).render();
});
</script>
#end
However, it doesn't give what I need.
I appreciate your insights on how to get this working.
I see your live site and debugged a little and I found that text-indent css property in below css class is causing issue for firefox.
.aui-carousel-item { border-radius: 10px; text-indent: -9999em; }
Removal of text-indent css property shows up the image in firefox so You may have to adjust this css property for firefox.
Please suggest on how to show the hand symbol on mouse hover of the telerik radhtmlchart.AS of now im getting only pointer symbol on mouse hover.
<telerik:radhtmlchart runat="server" id="RadHtmlChartfirst" onclientseriesclicked="OnClientSeriesClickedfirst"
legend-appearance-position="Top" legend-appearance-visible="true" plotarea-xaxis-minorgridlines-visible="false"
plotarea-yaxis-minorgridlines-visible="false" plotarea-xaxis-majorgridlines-visible="false"
plotarea-yaxis-majorgridlines-visible="false" height="444" width="900">
<PlotArea>
<Series>
<telerik:ColumnSeries DataFieldY="myValues1" Name="Name1">
</telerik:ColumnSeries>
<telerik:ColumnSeries DataFieldY="myValues2" Name="Name2">
</telerik:ColumnSeries>
<telerik:ColumnSeries DataFieldY="myValues3" Name="Name3">
</telerik:ColumnSeries>
</Series>
<XAxis DataLabelsField="myLabels">
</XAxis>
</PlotArea>
<Legend>
<Appearance Visible="true" Position="Bottom" />
</Legend>
<Appearance>
<FillStyle BackgroundColor="" />
</Appearance>
<ChartTitle Text="Reviewer Utilization Report">
</ChartTitle>
</telerik:radhtmlchart>
There is no built-in facility for that because this chart renders SVG and the cursor styles generally apply to HTML elements. I tried the following flimsy mouse event handling and it seems to kind of work though:
<telerik:RadHtmlChart runat="server" ID="chart" onmouseout="onmouseoutHandler();">
<ClientEvents OnSeriesHover="OnSeriesHover" />
<PlotArea>
<Series>
<telerik:ColumnSeries Name="first">
<SeriesItems>
<telerik:CategorySeriesItem Y="1" />
<telerik:CategorySeriesItem Y="2" />
<telerik:CategorySeriesItem Y="3" />
</SeriesItems>
</telerik:ColumnSeries>
<telerik:ColumnSeries Name="second">
<SeriesItems>
<telerik:CategorySeriesItem Y="1" />
<telerik:CategorySeriesItem Y="2" />
<telerik:CategorySeriesItem Y="3" />
</SeriesItems>
</telerik:ColumnSeries>
</Series>
</PlotArea>
</telerik:RadHtmlChart>
<script>
function OnSeriesHover(e) {
document.onmouseover = null;
if (e.series.name == "first") { //consider adding some conditions or removing them at all
e.preventDefault();
setTimeout(function () {
document.body.style.cursor = "pointer"
}, 50);
}
return false;
}
//attached to onmouseout of the chart wrapper to restore the cursor
//as soon as the mouse moves on the chart
function onmouseoutHandler(e) {
document.body.onmouseover = restoreCursor;
}
//the handler that restores the cursor for the page
function restoreCursor() {
document.body.style.cursor = "";
}
//resets the cursor
document.body.onmouseover = restoreCursor;
</script>
and I had to add this CSS to ensure my body element is large enough:
html, body, form
{
height: 100%;
margin: 0;
padding: 0;
}
I am actually just learning flex, and i am getting confused with some parts. The problem is that the background image i have set in the skin works fine until i add more elements, it then just becomes a white background rather than laying the elements over the top.
I am starting to think im misunderstanding how this works. I don't understand why i need to have <s:Group id="contentGroup" /> for the image to show in the first place...this just seems like a redundant tag?
Here is the main code and the skin:
<?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" width="800" height="523" maxWidth="800" maxHeight="523" initialize="httpService.send()" showStatusBar="false" backgroundColor="white" backgroundAlpha="1">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
public var returnData:ArrayCollection;
protected function httpService_handler(event:ResultEvent):void{
returnData = event.result.people.person;
}
]]>
</fx:Script>
<fx:Style>
#namespace s "library://ns.adobe.com/flex/spark";
#namespace mx "library://ns.adobe.com/flex/mx";
</fx:Style>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:HTTPService id="httpService" url="" result="httpService_handler(event)" />
</fx:Declarations>
<s:BorderContainer borderVisible="false" mouseDown="nativeWindow.startMove();" skinClass="MainStyle" width="800" height="523" id="container" >
<s:HGroup left="100" top="100" id="newsSlider" width="100" height="100">
<s:Label>
<s:text>Test</s:text>
</s:Label>
</s:HGroup>
</s:BorderContainer>
</s:WindowedApplication>
<?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:mx="library://ns.adobe.com/flex/mx">
<!-- host component -->
<fx:Metadata>
[HostComponent("spark.components.BorderContainer")]
</fx:Metadata>
<!-- states -->
<s:states>
<s:State name="disabled" />
<s:State name="normal" />
</s:states>
<!-- SkinParts
name=contentGroup, type=spark.components.Group, required=false
-->
<s:Group id="contentGroup" width="800" height="523">
<s:BitmapImage id="bg" source="#Embed('/School Catchup/libs/images/App-BG8.png')" scaleMode="stretch" left="0" top="0" right="0" bottom="0" width="800" height="523" />
</s:Group>
</s:Skin>
contentGroup is the only "skinPart" of the SkinnableContainer component, which is the base class for BorderContainer. It's not a required skinpart (the compiler would've thrown you an error otherwise in your previous version where you didn't have the skinpart in your skin).
What is a skinPart?
It's a contract between the host component and its skin. Essentially the host component is instructing the skin (through metadata) that it needs this and this and that element (skin part) in order to function correctly. Some of these elements are absolutely required for the component to function, some are optional.
What is the contentGroup skinpart?
It's the container element to which SkinnableContainer will add its nested elements. As an example:
<s:SkinnableContainer>
<s:Label text="hello"/>
</s:SkinnableContainer>
behind the scenes, the Label instance will be added to the contentGroup skinpart of SkinnableContainer's skin.
So how do I get my example to work?
As you can see from what I explained before, the contentGroup element is just a placeHolder in the skin. If you want to add "chrome" to your custom component, add it outside that Group:
<s:BitmapImage id="bg" source="#Embed('/School Catchup/libs/images/App-BG8.png')" scaleMode="stretch" left="0" top="0" right="0" bottom="0" width="800" height="523" />
<s:Group id="contentGroup" width="800" height="523"/>
This will display the image behind the contentGroup and your Labels will now be added to it without removing the BitmapImage that you declared in there.
This is just a short explanation of the skinning mechanism in the context of your needs. I suggest you do some research on this specific topic to really understand how it works.
I have a case where I'm adding tabNavigator tabs dynamically and I can't figure out how to add HTML styling to some of the words.
I really only need BOLD or UNDERLINE on a few words, but I can't get any HTML formatting to work inside the NavigatorContent tag.
Can anyone help me with this? I have been looking for many hours and found nothing.
Here's what I have so far. (the content is being pulled from an external XML file).
<?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"
width="500" height="600" creationComplete="initApp()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:HTTPService id="chatlist" result="resultHandler(event)"
url="http://localhost/FlexLiveChat/LiveChat2/chat.xml"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
private function initApp():void
{
chatlist.send();
}
private function resultHandler(event:ResultEvent):void
{
var dp:ArrayCollection = event.result.chatsession.chat as ArrayCollection;
for(var i:int = 0; i < dp.length; i++) {
var t:TextField = new TextField( );
t.htmlText = "This field contains <B>HTML!</B>";
var label:Label = new Label();
label.text = dp.getItemAt(i).message;
var context:NavigatorContent = new NavigatorContent();
context.label = dp.getItemAt(i).chatperson;
context.addElement(label);
tn.addChild(context);
}
}
]]>
</fx:Script>
<s:BorderContainer left="10" right="10" top="10" bottom="10" height="100%" borderVisible="false">
<s:VGroup id="mainBG" x="0" y="0" width="100%" height="100%" textAlign="center">
<mx:TabNavigator id="tn" width="100%" height="100%" color="0x323232">
<!-- Define each panel using a VBox container. -->
<s:NavigatorContent label="Home">
<s:Label text="This panel is always available \n\n container panel 1"/>
<mx:Text text="This is a text control."/>
</s:NavigatorContent>
</mx:TabNavigator>
<s:TextArea width="100%" height="62" textAlign="left"/>
<s:Button label="Post Message"/>
</s:VGroup></s:BorderContainer>
</s:WindowedApplication>
You could use a text flow:
<?xml version="1.0" encoding="utf-8"?>
<s:VGroup 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="100%"
height="100%"
gap="0">
<fx:Script>
<![CDATA[
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.elements.TextFlow;
private const text:String =
"<b>bold text</b><br />" +
"<br />" +
"<u>underlined text</u><br />" +
"<br />" +
"<ul>" +
"<li>list item<br /></li>" +
"<li>list item<br /></li>" +
"<li>list item<br /></li>" +
"</ul>" +
"<a href='http://www.google.com'>a link</a><br />" +
"<br />";
]]>
</fx:Script>
<s:RichEditableText editable="false"
selectable="true"
textFlow="{TextConverter.importToFlow(text, TextConverter.TEXT_FIELD_HTML_FORMAT)}"
buttonMode="true"
width="100%"
height="100%" />
</s:VGroup>
Per your comment, you should abstract the navigator content view in to a component.
Based upon your example:
Your main application
<?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"
width="500"
height="600"
creationComplete="initApp()">
<fx:Declarations>
<s:HTTPService id="chatlist"
result="resultHandler(event)"
url="http://localhost/FlexLiveChat/LiveChat2/chat.xml" />
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
private function initApp():void
{
chatlist.send();
}
private function resultHandler(event:ResultEvent):void
{
var dp:ArrayCollection = event.result.chatsession.chat as ArrayCollection;
for (var i:int = 0; i < dp.length; i++)
{
var htmlNavigatorContent:HtmlNavigatorContent = new HtmlNavigatorContent();
// attach result you want in the html text,
// including other properties.
htmlNavigatorContent.htmlText = "This field contains <B>HTML!</B>";
tn.addChild(htmlNavigatorContent);
}
}
]]>
</fx:Script>
<s:BorderContainer left="10"
right="10"
top="10"
bottom="10"
height="100%"
borderVisible="false">
<s:VGroup id="mainBG"
x="0"
y="0"
width="100%"
height="100%"
textAlign="center">
<mx:TabNavigator id="tn"
width="100%"
height="100%"
color="0x323232">
<!-- Define each panel using a VBox container. -->
<s:NavigatorContent label="Home">
<s:Label text="This panel is always available \n\n container panel 1" />
<mx:Text text="This is a text control." />
</s:NavigatorContent>
</mx:TabNavigator>
<s:TextArea width="100%"
height="62"
textAlign="left" />
<s:Button label="Post Message" />
</s:VGroup>
</s:BorderContainer>
</s:WindowedApplication>
Create a MXML Component named: HtmlNavigatorContent
<?xml version="1.0" encoding="utf-8"?>
<s:NavigatorContent 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="100%"
height="100%">
<fx:Script>
<![CDATA[
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.elements.TextFlow;
[Bindable]
public var htmlText:String;
]]>
</fx:Script>
<s:RichEditableText editable="false"
selectable="true"
textFlow="{TextConverter.importToFlow(htmlText, TextConverter.TEXT_FIELD_HTML_FORMAT)}"
buttonMode="true"
width="100%"
height="100%" />
</s:NavigatorContent>
Hello I am having issue with showing everything from my flex application. It only shows around of the whole application.
My application is as such:
<?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="100%" height="100%"
xmlns:local="*">
<mx:ViewStack id="mainstack" width="100%" height="100%" >
<mx:HBox id="Mod1" width="100%" height="100%" label="Mod1" horizontalAlign="center" verticalAlign="middle">
<local:modloader url="Mod1.swf" id="mod1" />
</mx:HBox>
<mx:HBox id="Mod2" width="100%" height="100%" label="Mod2" horizontalAlign="center" verticalAlign="middle">
<local:modloader url="Mod2.swf" id="mod3" />
</mx:HBox>
<mx:HBox id="Mod3" width="100%" height="100%" label="Mod3" horizontalAlign="center" verticalAlign="middle">
<local:modloader url="Mod2.swf" id="mod3" />
</mx:HBox>
</mx:ViewStack>
</s:Application>
I also tried putting the following lines in initialize function of Application container but in vain:
systemManager.stage.scaleMode=StageScaleMode.SHOW_ALL (or TO_FIT);
systemManager.stage.align = StageAlign.TOP;
In fact when using SHOW.ALL..the whole application is as if squeeed to some 50% which makes everything small and this is not nice to view.
I also modified the index.template.html and have put the width and height to 100% instead to explicit values.
BUT my application only shows around 70%..the rest(at the bottom) go beyond the screen. (Just note that my screen resolution is 1366 x 768)*
Any bright idea why this does not work??
Try setting the minHeight property of your application to 100 and see if it helps.