I am accessing some params from HTML to flex, those are special characters(html codes).
Below is the Sample Code:
HTML Param:
flashvars.sampleText = "スー谷スー谷スー谷スー谷"
Flex Code:
<?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:Script>
<![CDATA[
import mx.core.FlexGlobals;
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Panel>
<s:Label text="{FlexGlobals.topLevelApplication.parameters.sampleText}" />
</s:Panel>
</s:Application>
When i am checking the above sample code in IE Browser its working fine, But its not working in Mozilla and Chrome browsers.
What could be the Problem ? How can i able to display this in other browsers? Can anyone help on this?
Thanks in Advance
Rajesh
Have you tried url encoding your String in Javascript then decodinf in AS?
For e.g.:
Javascript:
flashvars.sampleText = escape("String with special characters");
AS/MXML:
<s:Label text="{unescape(FlexGlobals.topLevelApplication.parameters.sampleText)}" />
Hope it helps,
Rob
Related
I am new to flex and I am trying to open modules in a new window modal.
I have managed to load and add a module in a container ( vbox ) but what I really need is to open them in separate windows.
All posts that I could find are samples on how to load modules but nothing on how to show them.
I found a post here
Modules and Panels issue
and it looks by the screenshot exactly what I am looking for.
Thanks for your help.
I found a way of doing this.
Thanks for all the pointers
here is how I did it for all of you to see and maybe use. If you have suggestions to make it better, do not hesitate to comment.
I am using a component : collapsabletitlewindow
mainapp.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:components="de.aggro.components.*">
<fx:Script>
<![CDATA[
import de.aggro.components.*;
private function createWindow():void{
var w:window = new window;
w.title = "Window " + container.numChildren;
container.addChild(w);
}
]]>
</fx:Script>
<components:CollapsableTitleWindowContainer id="container" width="100%" height="100%" >
</components:CollapsableTitleWindowContainer>
<s:Button buttonDown="createWindow()" label="Create Window" />
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:WindowedApplication>
window.mxml
<?xml version="1.0" encoding="utf-8"?>
<components:CollapsableTitleWindow 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:components="de.aggro.components.*" layout="absolute" width="400" height="300"
creationComplete="initApp()" >
<fx:Script>
<![CDATA[
import mx.events.ModuleEvent;
import mx.modules.ModuleManager;
import mx.modules.IModuleInfo;
import mx.core.IVisualElement;
public var info:IModuleInfo;
private function initApp():void {
info = ModuleManager.getModule("mod.swf");
info.addEventListener(ModuleEvent.READY, modEventHandler);
/* Load the module into memory. Calling load() makes the
IFlexModuleFactory available. You can then get an
instance of the class using the factory's create()
method. */
info.load(null, null, null, moduleFactory);
}
/* Add an instance of the module's class to the display list. */
private function modEventHandler(e:ModuleEvent):void {
this.addElement(info.factory.create() as IVisualElement);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</components:CollapsableTitleWindow>
mod.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Module 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="400" height="300">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:LinkButton x="131" y="124" label="Module link"/>
</s:Module>
I'm making simple editor. And I want that, let write replacing colorless text to color text from RichEditableText when I will write any text.
For example:
PHP --> <s:span color="#FF0000">PHP<s:span>
This codes not work:
editorum.text = editorum.text.replace('PHP','<s:span color="#FF0000">php<s:span>');
Editorum is: <s:RichEditableText id="editorum" ></s:RichEditableText>
Click here and try
Source code:
<?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="319" height="198" minWidth="955" minHeight="600">
<fx:Style source="ops.css"/>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import flashx.textLayout.formats.TextLayoutFormat;
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
import spark.events.TextOperationEvent;
import spark.utils.TextFlowUtil;
protected function editorum_changeHandler(event:TextOperationEvent):void
{
editorum.text = editorum.text.replace('melon','<s:span color="#FF0000">melon<s:span>');
}
]]>
</fx:Script>
<s:RichEditableText id="editorum" x="10" y="28" width="299" height="159"
change="editorum_changeHandler(event)">
</s:RichEditableText>
<s:Label x="10" y="10" width="119" text="Write 'melon' :"/>
</s:Application>
A other problem; How do I send the pointer at the end? When I press any key, pointer going to deal. Try: http://samed.us/samples/ops3.swf
Thanks for your help...
Instead of this line:
editorum.text = editorum.text.replace('melon','<s:span color="#FF0000">melon<s:span>');
Try something like this:
var text : String = editorum.text.replace('melon','<s:span color="#FF0000">melon<s:span>')
editorum.textFlow = TextConverter.importToFlow(text, TextConverter.TEXT_FIELD_HTML_FORMAT);
Basically, you need to convert the HTML into something that the TLF Framework will understand. Read some docs on textFlow and the TextConverter
I'm trying to scale text from 1 to 5, a sort of zoom in type of look. I'm using the code below:
<s:Scale target="myLabel" autoCenterTransform="true"
duration="2000"
scaleYFrom="1" scaleYTo="5" scaleXFrom="1" scaleXTo="5"
>
The text scales terribly. So my goal is to take a snapshot of the text label at a large font, add it to the display list, set the scale to a 5th and then animate the scale up to 1. After that I have to set the text again and do it all over again.
This is a Flex app and that's where my question comes in. I don't know how to take a snapshot, then what to add it to (group?) and then how to erase it and start over again? Any advice in any of this would be appreciated.
Here's a very simple approach which animates the fontSize style, instead of animating the scale properties:
Depending on what you're doing this may not perform well b/c it is setting a new style so frequently. Also, if you play this animation slowly, it looks like the individual characters "wobble" (they move or shake a teeny bit).
I'll post something on taking a snapshot and scaling that next...
<?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:Declarations>
<s:Animate id="scaler" target="{scaledText}" >
<s:MotionPath property="fontSize">
<s:Keyframe time="0" value="12"/>
<s:Keyframe time="1500" value="48"/>
</s:MotionPath>
</s:Animate>
</fx:Declarations>
<fx:Script>
<![CDATA[
protected function onLabelClick():void
{
scaler.play();
}
]]>
</fx:Script>
<s:Label id="scaledText" text="this is some text" click="onLabelClick()" />
</s:Application>
And here is the approach that takes a snapshot of the text. This has the same problem as your original solution, the scaled text is very jagged. But this does show how to take a snapshot of something and use the snapshot in another Flex object:
<?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:Declarations>
<s:Scale id="scaler" target="{drawingTarget}" scaleXFrom="1" scaleXTo="5" scaleYFrom="1" scaleYTo="5"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import spark.core.SpriteVisualElement;
protected function onLabelClick():void
{
var data:BitmapData = new BitmapData(200,200,true, 0xFFFFFF);
data.draw(scaledText);
var g:Graphics = drawingTarget.graphics;
g.beginBitmapFill(data);
g.drawRect(0,0, 200,200);
g.endFill();
}
protected function onBitmapClick(event:MouseEvent):void
{
scaler.play();
}
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout/>
</s:layout>
<s:Label id="scaledText" text="this is some text" click="onLabelClick()" />
<s:SpriteVisualElement id="drawingTarget" width="200" height="200" click="onBitmapClick(event)"/>
</s:Application>
I'm trying to come up with the optimal solution for validating IP addresses in Adobe Flex. My current solution is to use a regexp validator and look for dotted quad numbers, see code below. For some reason this will also allow an address like "1.2.3.4.5". Does anyone have a better solution out there?
<?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:Script>
<![CDATA[
import mx.controls.Alert;
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<mx:RegExpValidator source="{ipAddr}" property="text"
expression="\d+\.\d+\.\d+\.\d+"
invalid="Alert.show('The IP address is invalid');"/>
</fx:Declarations>
<s:TextInput id="ipAddr" x="10" y="10"/>
<s:Button label="OK" x="10" y="40"/>
</s:Application>
Regexp to validate an IP is the following:
var regexp:RegExp = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/;
trace(regexp.test("10.0.0.5")); // true
trace(regexp.test("243.1.254.15")); // true
trace(regexp.test("256.0.0.0")); // false
Hope that helps
You could split("\\.") the string, check that the resulting array has a length of either 4 or 6, and that each element is an integer between 0 and 255
I have problem. I'd like to make dragable am Air TitleWindow application only by titlebar/header. I have this code, but its dragable everywhere. Could you help in this?
<?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">
<fx:Script>
<![CDATA[
import mx.events.CloseEvent;
private function mainWindow_closeHandler(event:CloseEvent):void
{
stage.nativeWindow.close();
}
protected function OnDrag(event:MouseEvent):void
{
stage.nativeWindow.startMove();
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:TitleWindow id="mainWindow" width="100%" height="100%"
title="Title Window Header"
mouseDown="OnDrag(event)"
close="mainWindow_closeHandler(event)">
</s:TitleWindow>
</s:WindowedApplication>
In the appliacation xml the settings are:
<systemChrome>none</systemChrome>
<transparent>false</transparent>
This is a kind of solution:
<?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">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:TitleBar height="24" width="100%" x="0" y="0" title="Title"/>
</s:WindowedApplication>