I am working on an air-application but written in as3.
How can I still display an fileSystemList-Component(flex) written in actionscript?
Thanks
fileSystemList i also Available for AIR Since AIR1.1 see API
also see About file system controls
EDITED Please find AIR APP sample using action script to Create FileSystemDataGrid
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="{onCreationComplet()}">
<mx:Script>
<![CDATA[
import mx.controls.FileSystemDataGrid;
private var fileSystemDataGrid:FileSystemDataGrid;
private function onCreationComplet():void
{
fileSystemDataGrid = new FileSystemDataGrid();
fileSystemDataGrid.directory = File.desktopDirectory.resolvePath('');
fileSystemDataGrid.percentHeight = 100;
fileSystemDataGrid.percentWidth = 100;
this.addChild(fileSystemDataGrid);
}
]]>
</mx:Script>
</mx:WindowedApplication>
Hopes that helps
Related
I need to create a component using ActionScript. Can't use mxml in this case.
In my component I need to create PopUpAnchor using new operator and addElement to the stage. Unfortunatelly when I'm doing it, the PopUpAnchor's displayPopUp property does not respond to any values.
Here is my the example:
<?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"
initialize="init(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import spark.components.Label;
import spark.components.PopUpAnchor;
protected function init(event:FlexEvent):void
{
var anchor:PopUpAnchor = new PopUpAnchor();
var label:Label = new Label();
label.text = 'ABC';
anchor.addChild(label);
addElement(anchor);
anchor.displayPopUp = true;
}
]]>
</fx:Script>
</s:WindowedApplication>
I'm using Flex SDK 4.5 with AIR SDK 2.6.
What am I doing wrong?
I figured it out. The problem is that i connot use addChild on anchor. I should use popUp property instead.
So, this line is WRONG:
anchor.addChild(label);
and should be corrected to this form:
anchor.popUp = label;
hello i'm new to flex builder and trying to populate an array from an external file consisting of a list of strings.
how do i go about that? should i use some sort of a data object?
Here's an example to get you started:
Sample File (file_with_strings.txt):
one, two, three
Sample App
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
initialize="initializeHandler()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
protected function initializeHandler():void
{
service.send();
}
protected function updateList(result:Object):void
{
var array:Array = result.split(/,\s+/);
var collection:ArrayCollection = new ArrayCollection(array);
list.dataProvider = collection;
}
]]>
</mx:Script>
<mx:HTTPService id="service"
url="file_with_strings.txt"
resultFormat="text" result="updateList(event.result)"/>
<mx:List id="list"/>
</mx:Application>
I would just use the HTTPService class to load your external file. You can change the resultFormat to XML, Object, and a few other things if you'd like. Then just customize that updateList() method however.
Hope that helps,
Lance
I have a Flex RIA App, and in the application tag there is a button when it's pressed calls upon a TitleWindow from another .mxml file, and sets
application.enable = false
That way the user can't use any of the components in the application, and still can use the components in the TitleWindow.
The problem is when the TitleWindow is closed I want it to restore the application back to
application.enable = true
Which enables the application once again. But I can't call that code from inside the TitleWindow .mxml
How can I do it?
Here is the Source:
Loja.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="585" height="450" xmlns:ns1="com.*">
<mx:Style source="theme/simplicitygray.css" />
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
private var clientid = 0;
public function openWindow() : void
{
if (clientid == 0)
{
PopUpManager.createPopUp(this,Login,false);
application.enabled = false;
} else {
PopUpManager.createPopUp(this,Conta,false);
application.enabled = false;
}
}
]]>
</mx:Script>
<mx:Panel x="10" y="40" width="565" height="400" layout="absolute">
</mx:Panel>
<mx:MenuBar x="10" y="10" width="565" height="22"></mx:MenuBar>
<mx:Button x="508" y="10" label="Aceder" click="openWindow();"/>
</mx:Application>
And one of the title windows. Once they are the same.
Login.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="350" height="200" creationComplete="centerWindow()" showCloseButton="true" close="closeWindow()" title="Login">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
public function centerWindow():void
{
PopUpManager.centerPopUp(this);
}
public function closeWindow():void
{
PopUpManager.removePopUp(this);
}
]]>
</mx:Script>
</mx:TitleWindow>
application is a static property of the Application class and can be called from the TitleWindow
public function closeWindow():void
{
PopUpManager.removePopUp(this);
Application.application.enabled = true;
}
BTW, There is another easier way to achieve the following:
That way the user cant use any of the components in the application, and still can use the components in the TitleWindow.
That is to use a modal popup. Set the third parameter of the createPopUp to true and that's it - you don't have to enable/disable the application manually: flex will take care of it.
PopUpManager.createPopUp(this,Login, true);
application will automatically become functional once you call removePopUp.
You can use custom events to enable this functionality, as described here.
Essentially, you set up a custom event in the class you are calling, then create a function that runs when the event is consumed. That way your 'Loja' will know when the 'Login' is done.
I went through a document at Adobe Livedocs that describes working with pdf: http://livedocs.adobe.com/flex/3/html/help.html?content=PDF_1.html
But I'm stuck with it and can't get it to work.
Can anyone help me?
thanks
Vladimir
Adobe Air relies on the Adobe Reader browser plugin to render the PDF files. So a user of the AIR application will have to have Adobe Reader installed. This also means that any customization that might have been done by the user to the Adobe Reader interface will be reflected in their AIR app.
This being said, do you have Adobe Reader installed? It has to be at least version 8.1.
You could put a breakpoint in the code below where it checks the pdfCapability and it will tell you whether it supports pdf.
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="onCreationComplete()">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
public function onCreationComplete():void
{
if(HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK)
{
var htmlLoader:HTMLLoader = new HTMLLoader();
var pdfUrl:URLRequest = new URLRequest("http://www.adobe.com/devnet/flex/pdfs/getting_started_with_Flex3.pdf");
htmlLoader.load(pdfUrl);
htmlLoader.width = 1024;
htmlLoader.height= 768;
pdfComponent.addChild(htmlLoader);
}
}
]]>
</mx:Script>
<mx:VBox>
<mx:Label text="pdf below:" />
<mx:UIComponent id="pdfComponent" />
</mx:VBox>
</mx:WindowedApplication>
I am getting a value in a MXML... now i need to pass it to another MXML to invoke an event... how can i do it.
It can be done like this
Test.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
public var a:String;
]]>
</mx:Script>
</mx:Application>
Test2.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
public var a1:String;
public var te1:Test=new Test();
public function init():void{
a1=te1.a;
}
]]>
</mx:Script>
</mx:Application>
this is not right i think but it may serve your purpose
Assuming one MXML component is the child of the other, you should be using binding to pass data around.
You could dispatch an event containing the string value from the source component to be received by the destination component.
You need to explain more about how your two mxml components relate to each other... parent/child? two siblings within a parent? That will determine the best approach. Of course, your components should not really be "wired into each other" if possible, which is where frameworks such as Mate come in, but that is probably way beyond where you're at just now.