Image disposition in Flex web based apps - image

I came upon a problem, or more of a bug, really. I have a business app programmed in Flex 4.1, and the compiled Flash object displays images within it differently on different browsers.
For example this page : http://www.maastrichtuniversity.nl/web/Main/ProspectiveStudents/HomepageNewPortalProspectiveStudents/ChooseYourProgramme/RequestBrochures.htm
If you select Bachelor's programmes on browsers like Chrome or Safari you will see that flags are aligned with the text (flags are positioned using x,y coordinates. If you do exactly the same on IE 8 or 9, you will see that all flags move a few pizels to the left, and start covering some of the labels.
Has anyone else came across this issue, and how to solve it? Here is the mxml code that is used to position flags.
<mx:Image x="241" y="65" width="15" height="10" source="en.jpg"/>
<mx:Image x="245" y="95" width="15" height="10" source="en.jpg"/>
<mx:Image x="230" y="111" width="15" height="10" source="en.jpg"/>
<mx:Image x="262" y="65" width="15" height="10" source="nl.jpg"/>
<mx:Image x="160" y="246" width="15" height="10" source="en.jpg"/>
<mx:Image x="335" y="260" width="15" height="10" source="en.jpg"/>
<mx:Image x="199" y="305" width="15" height="10" source="en.jpg"/>
<mx:Image x="182" y="246" width="15" height="10" source="nl.jpg"/>
<mx:Image x="169" y="275" width="15" height="10" source="nl.jpg"/>
<mx:Image x="199" y="290" width="15" height="10" source="nl.jpg"/>
<mx:Image x="152" y="124" width="15" height="10" source="en.jpg"/>
<mx:Image x="158" y="140" width="15" height="10" source="en.jpg"/>
<mx:Image x="129" y="154" width="15" height="10" source="en.jpg"/>
<mx:Image x="152" y="230" width="15" height="10" source="en.jpg"/>
<mx:Image x="173" y="124" width="15" height="10" source="nl.jpg"/>
<mx:Image x="162" y="170" width="15" height="10" source="nl.jpg"/>
<mx:Image x="232" y="185" width="15" height="10" source="nl.jpg"/>
<mx:Image x="166" y="200" width="15" height="10" source="nl.jpg"/>
<mx:Image x="285" y="215" width="15" height="10" source="nl.jpg"/>
<mx:Image x="312" y="80" width="15" height="10" source="nl.jpg"/>

This can be achieved in the following way :
<?xml version="1.0"?>
<!-- sparktextcontrols/TLFFloat.mxml -->
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<fx:Script>
<![CDATA[
private function changeSelection(event:Event):void {
image1.float = event.currentTarget.selectedItem;
}
]]>
</fx:Script>
<s:HGroup>
<s:Label text="float for the image (default:none):"/>
<s:ComboBox id="cb1"
change="changeSelection(event)"
creationComplete="cb1.selectedIndex=0">
<s:ArrayCollection>
<fx:String>none</fx:String>
<fx:String>left</fx:String>
<fx:String>right</fx:String>
<fx:String>start</fx:String>
<fx:String>end</fx:String>
</s:ArrayCollection>
</s:ComboBox>
</s:HGroup>
<s:RichEditableText id="myRET1" width="300">
<s:textFlow>
<s:TextFlow columnWidth="290">
<s:p id="p1">Images in a flow are a good thing. For example, here is a float. <s:img id="image1" float="none" source="#Embed(source='../assets/bulldog.jpg')" paddingRight="10" paddingTop="10" paddingBottom="10" paddingLeft="10"></s:img>Don't you agree?
It should show on the left. If it doesn't show up on the left, then it is a bug. You can submit bugs at http://bugs.adobe.com/jira/. You can set how the float is positioned within
the paragraph by using the ComboBox below. You can select left, right, start, end, or none. This example does not use the clearFloats property. That is in a different example.</s:p>
</s:TextFlow>
</s:textFlow>
</s:RichEditableText>
</s:Application>

Related

svg noise not shown in firefox

Made up a cloudy svg background for my project.
It works perfectly in MS Edge,in Google Chrome, it even works when placed as desktop background in XFCE.
But it ain`t working in Firefox. Neither under Win, nor Linux.
Maybe there is some crutch needed?
<svg version="1.2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%">
<defs>
<radialGradient id="Background" cx="50%" cy="50%" r="120%">
<stop offset="0%" stop-opacity="1" stop-color="#369" />
<stop offset="170%" stop-opacity="1" stop-color="#000"/>
</radialGradient>
<filter id="noise" x="0" y="0" width="100%" height="100%">
<feImage xlink:href="#bkgrad" result="image" x="0" y="0"/>
<feTurbulence baseFrequency="0.001" seed="999" type="fractalNoise" numOctaves="8" result="fnoise"/>
<feColorMatrix in="fnoise" result="snoise"
type="saturate"
values="0" />
<feBlend in="SourceGraphics" in2="snoise" mode="multiply"></feBlend>
<feBlend in="snoise" in2="image" mode="multiply"></feBlend>
</filter>
<polyline id="Hexagon" stroke="#000" stroke-opacity="0.15" fill="none" stroke-width = "1.2px"
points="0,0 8,0 12,6.9 8,13.8 0,13.8 8,13.8 12,6.9 20,6.9 24,13.8 20,6.9 24,0 32,0 "/>
<pattern id="Hex_Pattern" patternUnits="userSpaceOnUse" patternTransform="translate(0,0)"
width="24" height="13.8" >
<use xlink:href="#Hexagon"/>
</pattern>
</defs>
<rect x="0" y="0" width="100%" height="100%" fill="url(#Background)" id="bkgrad" ></rect>
<rect x="0" y="0" width="100%" height="100%" style="filter:url('#noise')" fill="url(#Background)"/>
<rect x="0" y="0" width="100%" height="100%" fill="url(#Hex_Pattern)" id="hexes"/>
</svg>
The attribute value for the <feBlend> filter is in="SourceGraphic", not in="SourceGraphics". Firefox did not render the whole filter because of that error, while other browsers and renderers used a fallback and used the last filter result as first source, effectively multiplying the result of feColorMatrix with itself. (This behavior is new in the CSS filter spec, it was not defined in SVG 1.1.)
Since the output of that part of the filter is never used anyway, remove it.
Additionally, as Robert Longson pointed out, feImage does not support references to internal fragments in Firefox. But you don't really need it. The referenced image is identical to the source graphic for the filter, so you can simply remove that primitive and reroute the input to the other primitives:
<svg version="1.2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%">
<defs>
<radialGradient id="Background" cx="50%" cy="50%" r="120%">
<stop offset="0%" stop-opacity="1" stop-color="#369" />
<stop offset="170%" stop-opacity="1" stop-color="#000"/>
</radialGradient>
<filter id="noise" x="0" y="0" width="100%" height="100%">
<feTurbulence baseFrequency="0.001" seed="999" type="fractalNoise" numOctaves="8" result="fnoise"/>
<feColorMatrix in="fnoise" result="snoise"
type="saturate"
values="0" />
<feBlend in="snoise" in2="SourceGraphic" mode="multiply"></feBlend>
</filter>
<polyline id="Hexagon" stroke="#000" stroke-opacity="0.15" fill="none" stroke-width = "1.2px"
points="0,0 8,0 12,6.9 8,13.8 0,13.8 8,13.8 12,6.9 20,6.9 24,13.8 20,6.9 24,0 32,0 "/>
<pattern id="Hex_Pattern" patternUnits="userSpaceOnUse" patternTransform="translate(0,0)"
width="24" height="13.8" >
<use xlink:href="#Hexagon"/>
</pattern>
</defs>
<rect x="0" y="0" width="100%" height="100%" style="filter:url(#noise)" fill="url(#Background)"/>
<rect x="0" y="0" width="100%" height="100%" fill="url(#Hex_Pattern)" id="hexes"/>
</svg>

SVG path : pattern fill not working in firefox and Safari

SVG path element not working in Firefox and Safari but it works in Chrome.
Why doesn't the path filled using pattern in Firefox and Safari?
<svg id="" xmlns="http://www.w3.org/2000/svg" height="500" width="600" style="position: absolute;">
<defs>
<pattern id="imgpattern" x="0" y="0" width="1" height="1" patternUnits="userSpaceOnUse">
<image width="600" xlink:href="https://i.pinimg.com/564x/e1/a5/b7/e1a5b7edacee456a4f3bc3e00c3c01d9.jpg"></image>
</pattern>
</defs>
<path d="M50,100 C50,100 100,100 100,50 L100,50 500,50 C500,50 500,100 550,100 L550,100 550,400 C550,400 500,400 500,450 L500,450 100,450 C100,450 100,400 50,400 L50,400 50,100 L50,100 0,100 0,0 0,425 L0,425 50,425 C50,425 75,425 75,450 L50,450 50,425 0,425 0,500 525,500 525,450 C525,450 525,425 550,425 L550,425 550,450 525,450 525,500 600,500 600,75 550,75 C550,75 525,75 525,50 L525,50 550,50 550,75 600,75 600,0 75,0 75,50 C75,50 75,75 50,75 L50,50 75,50 75,0 0,0 0,100" fill="#ff0000;" stroke="#F000" stroke-width="1px" style="fill:url(#imgpattern)"></path>
</svg>
There is no height attribute on the image. SVG 2 allows width/height to be omitted but only Blink has implemented this part of SVG 2 so far.
You also have a redundant fill on the rect (as you're applying a pattern fill as a style)
<svg id="" xmlns="http://www.w3.org/2000/svg" height="500" width="600" style="position: absolute;">
<defs>
<pattern id="imgpattern" x="0" y="0" width="1" height="1" patternUnits="userspaceOnUse">
<image width="600" height="600" xlink:href="https://i.pinimg.com/564x/e1/a5/b7/e1a5b7edacee456a4f3bc3e00c3c01d9.jpg"></image>
</pattern>
</defs>
<path d="M50,100 C50,100 100,100 100,50 L100,50 500,50 C500,50 500,100 550,100 L550,100 550,400 C550,400 500,400 500,450 L500,450 100,450 C100,450 100,400 50,400 L50,400 50,100 L50,100 0,100 0,0 0,425 L0,425 50,425 C50,425 75,425 75,450 L50,450 50,425 0,425 0,500 525,500 525,450 C525,450 525,425 550,425 L550,425 550,450 525,450 525,500 600,500 600,75 550,75 C550,75 525,75 525,50 L525,50 550,50 550,75 600,75 600,0 75,0 75,50 C75,50 75,75 50,75 L50,50 75,50 75,0 0,0 0,100" stroke="#F000" stroke-width="1px" style="fill:url(#imgpattern)"></path>
</svg>

D3 output not rendering in Safari, Firefox, Edge and IE. Works in Chrome

I have an application that outputs data from D3. The output looks like this:
<div class="horizontalBarGraphContainer"><h4 class="crux-component-title">Greatest Rocker</h4><div class="ct HorizontalBarContainer"><div class="ct HorizontalBarGraph"><div style="width: 100%; height: 410px; position: relative;"><svg width="988" height="410"><g style="transform: translateY(0px);"><rect width="708" y="0" x="240" height="45" fill="#4dbf9d">Tiny Tim</rect><foreignObject fill="#000" width="205" x="0" y="0" class="crux-label-style foreignObject" text-anchor="start">Tiny Tim</foreignObject><text class="ct count crux-numbers crux-numbers--medium" fill="#000" dy=".35em" dx="10" y="22.5" text-anchor="start" x="948">26</text><text class="ct user-answer crux-label-style crux-label-style--small" fill="#000" dx="948" dy="55" text-anchor="end"></text></g><g style="transform: translateY(80px);"><rect width="626.3076923076923" y="0" x="240" height="45" fill="#4dbf9d">Elvis</rect><foreignObject fill="#000" width="205" x="0" y="0" class="crux-label-style foreignObject" text-anchor="start">Elvis</foreignObject><text class="ct count crux-numbers crux-numbers--medium" fill="#000" dy=".35em" dx="10" y="22.5" text-anchor="start" x="866.3076923076923">23</text><text class="ct user-answer crux-label-style crux-label-style--small" fill="#000" dx="866.3076923076923" dy="55" text-anchor="end"></text></g><g style="transform: translateY(160px);"><rect width="544.6153846153846" y="0" x="240" height="45" fill="#4dbf9d">Ted Nugent</rect><foreignObject fill="#000" width="205" x="0" y="0" class="crux-label-style foreignObject" text-anchor="start">Ted Nugent</foreignObject><text class="ct count crux-numbers crux-numbers--medium" fill="#000" dy=".35em" dx="10" y="22.5" text-anchor="start" x="784.6153846153846">20</text><text class="ct user-answer crux-label-style crux-label-style--small" fill="#000" dx="784.6153846153846" dy="55" text-anchor="end"></text></g><g style="transform: translateY(240px);"><rect width="544.6153846153846" y="0" x="240" height="45" fill="#4dbf9d">Iggy Pop</rect><foreignObject fill="#000" width="205" x="0" y="0" class="crux-label-style foreignObject" text-anchor="start">Iggy Pop</foreignObject><text class="ct count crux-numbers crux-numbers--medium" fill="#000" dy=".35em" dx="10" y="22.5" text-anchor="start" x="784.6153846153846">20</text><text class="ct user-answer crux-label-style crux-label-style--small" fill="#000" dx="784.6153846153846" dy="55" text-anchor="end"></text></g><g style="transform: translateY(320px);"><rect width="381.2307692307692" y="0" x="240" height="45" fill="#4dbf9d">Jon Bon Jovi</rect><foreignObject fill="#000" width="205" x="0" y="0" class="crux-label-style foreignObject" text-anchor="start">Jon Bon Jovi</foreignObject><text class="ct count crux-numbers crux-numbers--medium" fill="#000" dy=".35em" dx="10" y="22.5" text-anchor="start" x="621.2307692307693">14</text><text class="ct user-answer crux-label-style crux-label-style--small" fill="#000" dx="621.2307692307693" dy="55" text-anchor="end"></text></g></svg></div></div></div></div>
In Chrome, I see both the title (in the rect element). But in Safari, Firefox, Edge and IE I don't. Is there some reason why this only works in Chrome?
Demonstrated and viewable in this Codepen: https://codepen.io/serpicolugnut/pen/xWZwbb
Browsers implement SVG 1.1 with some smattering of SVG 2. Different browsers have implemented different parts of the SVG 2 specification.
One of the myriad changes in SVG 2 is that width and height parameters on foreignObject elements are now optional and can be set in CSS. Chrome is the first browser to implement this part of SVG 2.
Your content is missing a height attribute on the foreignObject elements so it only renders in Chrome at the moment.

Can you transition using Fade specifying all elements, without listing individually?

I've got the beginning of an air app, and I'm trying to transition between the states using Fade (a Sequence that should, in theory, fade out, then fade the next state in.) Is there a way to target it to fade out ALL the elements, or will I need to use targets="..." and list every element?
I've tried nesting all the elements in a Group, but that isn't seeming to work.
Shortened version of my current code:
<s:states>
<s:State name="HomeScreen"/>
<s:State name="EnemyBuilder"/>
<s:State name="EncyclopediaBuilder"/>
</s:states>
<fx:Declarations>
<s:Transition toState="*" fromState="*" >
<s:Sequence >
<s:Fade alphaFrom="1" alphaTo="0" duration="250" target="{wrapper}" />
<s:Fade alphaFrom="0" alphaTo="1" duration="250" target="{wrapper}" />
</s:Sequence>
</s:Transition>
</fx:Declarations>
<s:Group id="wrapper" includeIn="HomeScreen, EnemyBuilder, EncyclopediaBuilder" >
<s:BorderContainer id="encounter" includeIn="HomeScreen"
x="49" y="99" width="200" height="44"
styleName="falseButton"
rollOut="alphaOver(event)" rollOver="alphaOver(event)" click="currentState='EncyclopediaBuilder'" >
<s:Label x="48" y="8" color="#000000" fontFamily="Arial" text="Create a new encounter" />
<s:Label x="48" y="24" color="#000000" fontStyle="italic" text="Single encounter" />
<s:Image x="10" y="10" source="assets/001_01.png" />
<s:BorderContainer id="back" includeIn="EncyclopediaBuilder"
right="20" bottom="20" width="200" height="44"
styleName="falseButton"
rollOut="alphaOver(event)" rollOver="alphaOver(event)"
click="currentState='HomeScreen'" >
<s:Label x="48" y="16" color="#000000" fontFamily="Arial" text="Save and Return"/>
<s:Image x="10" y="10" source="assets/001_01.png"/>
</s:BorderContainer>
</s:BorderContainer></s:Group>
Try to use something like the following:
<s:states>
<s:State name="HomeScreen"/>
<s:State name="EnemyBuilder"/>
<s:State name="EncyclopediaBuilder"/>
</s:states>
<s:transitions>
<s:Transition toState="*" fromState="*" >
<s:Sequence target="{wrapper}">
<s:Fade alphaFrom="1" alphaTo="0" duration="250" />
<s:Fade alphaFrom="0" alphaTo="1" duration="250" />
</s:Sequence>
</s:Transition>
</s:transitions>
<s:Group id="wrapper">
<s:BorderContainer id="encounter" includeIn="HomeScreen"
x="49" y="99" width="200" height="44"
styleName="falseButton"
rollOut="alphaOver(event)" rollOver="alphaOver(event)" click="currentState='EncyclopediaBuilder'" >
<s:Label x="48" y="8" color="#000000" fontFamily="Arial" text="Create a new encounter" />
<s:Label x="48" y="24" color="#000000" fontStyle="italic" text="Single encounter" />
<s:Image x="10" y="10" source="assets/001_01.png" />
<s:BorderContainer id="back" includeIn="EncyclopediaBuilder"
right="20" bottom="20" width="200" height="44"
styleName="falseButton"
rollOut="alphaOver(event)" rollOver="alphaOver(event)"
click="currentState='HomeScreen'" >
<s:Label x="48" y="16" color="#000000" fontFamily="Arial" text="Save and Return"/>
<s:Image x="10" y="10" source="assets/001_01.png"/>
</s:BorderContainer>
</s:BorderContainer></s:Group>

Help with creating a custom ItemRenderer for Flex 4

I'm trying to create a custom ItemRenderer for a TileList in Flex 4.
Here's my renderer:
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
autoDrawBackground="true">
<mx:Image x="0" y="0" source="../images/blank-offer.png" width="160" height="144" smoothBitmapContent="true"/>
<s:Label x="5" y="20" text="{data.title}" fontFamily="Verdana" fontSize="16" color="#696565" width="155"/>
<s:Label x="5" y="42" text="{data.description}" fontFamily="Verdana" fontSize="8" color="#696565" width="154"/>
<mx:Text x="3" y="59" text="{data.details}" fontFamily="Verdana" fontSize="8" color="#696565" width="157" height="65"/>
<mx:Text x="3" y="122" text="{data.disclaimer}" fontFamily="Verdana" fontSize="5" color="#696565" width="157" height="21"/>
</s:ItemRenderer>
Here's my tile list:
<mx:TileList x="0" y="0" width="100%" height="100%" id="tileList" creationComplete="tileList_creationCompleteHandler(event)" dataProvider="{getDataResult.lastResult}" labelField="title" itemRenderer="renderers.OfferLibraryListRenderer"></mx:TileList>
When I run the app, I get this error:
Error #1034: Type Coercion failed: cannot convert renderers::OfferLibraryListRenderer#32fce0a1 to mx.controls.listClasses.IListItemRenderer.
I think in Flex4 you should use the <s:List> component instead of the <mx:TileList>. I've tried this way and it works.

Resources