flex core api hidden - apache-flex

is there any way to change file mode to hidden by flex?
for example
var myFile:File = new File(File.applicationDirectory.nativePath + File.seperator + "a.txt");
myFile.setHidden

I'll suppose you mean Adobe Air, since the File class is not available in Flex.
Still, no, you can't change file attributes. You can access them (isHidden, for example) but unfortunatelly they're read-only. Here's the reference for the File class.

Related

How to run one application from another application in flex?

I have two flex applications Main.mxml(where I have a button called loadDataViewer) and ViewData.mxml. What I want is when the user press the loadDataViewer button, the application ViewData.mxml will open in a new window. Is there any way to do it in Flex?
SWFLoader class looks interesting but I think it will load the other appliation inside the Main application which I don't want. I also saw that there is ExternalInterfaceAPI which can be used to open a url browser but not sure if I can reference the swf file of VewData application. As suggested here( http://learn.adobe.com/wiki/display/Flex/Local+Connections ) that LocalCOnnection can be used to reference one flex application in another but that's only when both applications are open I guess.
Any suggestion to guide me to the right direction wouild be greatly appreciated.
You could embed your viewData swf to an HTML file, and either do any of the following:
Call External Interface...
var url:String = 'myViewData.html';
ExternalInterface.call('window.open("' + url + '")');
or
Call the navigateToURL method...
var url:String = 'myViewData.html';
var urlReq = new URLRequest(url);
navigateToURL(urlReq,'_blank');
Use Modules. Adobe help.

How to add flex controls to my AS3 project?

I'm absolute newbie in Flash development but anyway I need to do something.
I have a pure AS3 project that plays video from youtube (chromeless player). I need to add some controls to manage this player. I don't know how to do that? If I just add mxml file into the project nothing happens. How to bind this file to as3?
Thanks
Flex components need to have UIComponent parent to function properly. If your player is based on Sprite, controls will not be initialized.
There is a trick to use Flex controls in the Sprite, but only after initialization in Flex Application. If you don't have Application, no luck.
You could use an AS3-only alternative. One library I've used is minimalcomps which offers some simple but effective controls for use in any AS3 project.
You can't use MXML, but nobody stops you to create your own controls if they are simple.
A short and simple example of how to add a button with an image:
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
loader.load(new URLRequest('http://i1.nyt.com/images/misc/nytlogo379x64.gif'));
function onComplete(event:Event):void
{
var button:Sprite = new Sprite();
button.addChild(event.currentTarget.content);
addChild(button);
button.buttonMode = true;
button.addEventListener(MouseEvent.CLICK, onButtonClick);
}
function onButtonClick(event:MouseEvent):void
{
trace ('click');
}
This would be the most basic version of a button with a loaded bitmap image.
Normally you would like to check for errors as well... what to do if the image is not found, or when you're not allowed to access it.
If you're going to need more then one button you could make a class which accepts an url, so you could just pass the url to the class and the button would be created.
A completely other way to approach this is with an SWC file, you could create the buttons in the Flash IDE and export them as an swc, which you can embed and use in your pure AS3 project.

Export SWC from Flash and Access Child from Flex

I'm creating an actionscript project in Flex Builder. I succeed to export from Flash a SWC file, and to use it succesfully in Flex. I have a good programming background and Flex looks very simple for me, but I have difficult times in flash.
I'm trying to achieve something that might be very simple(not for me of course):
I create a simple shape in Flash, convert it to symbol. Then I create a TextField. The I select both the elements and convert them to another symbol, and Export it as a movieclip in swc.
In flex I want to change the value from the textfield. How should I do? I'm trying to do:
var t:ExportedMC = new ExportedMC();
t....(what should I write here)
As I mentioned when I open flash I feel like an elephant in a porcelain store. I have 2 questions here:
- how to assign a name to the textfield in flash? I'm using CS4.
- how to access it as a child in flex?
When you create the symbol in Flash and export it to actionscript (in symbol properties dialog), you created a class that is accessible in Flex (after including the resultant swc in flex project library path). Any controls/shapes/symbols within that class will be contained within and created along with the containing class.
If you have any objects/smybols in that class that you would like to access/modify/whatever, you need to give them an instance name (you can do it without this step, but it's more complicated). In Flash, you edit (doubleclick) the class object in the library, then select a particular sub-object/symbol/control in the class object and give it a name by entering something under in object properties tab. That name will be included in the exported class as an property that you can access as any other class property (width,height,x,y,...).
For example, if you have a ExportedMC symbol that includes a TextField control which you gave instance name ('txtFieldName', for example), you would access it in Flex like so:
var t:ExportedMC = new ExportedMC();
t.txtFieldName.text="something";
Flex will actually be able to autocomplete the property name on the class, so you'll easily be able to know if things worked out or not.
Hope this helps.

Displaying content from bulkLoader which is typed as MovieClip in Flex app

I know this is somehow trivial, but I couldn't find appropriate solution so please help me :)
I am using bulkLoader to load dozens of SWFs into my Flex app, and all of SWFs are static (1 frame only). 'Everything' works fine, however, I'm not sure how to handle data from bulkLoader... I am getting MovieClip types for all of my SWFs, and I am not sure how to tell to Image or SWFLoader classes to use some of those MovieClips as source...
Thanks for any help really :)
m.
The source property of the Image or SWFLoader class only stores the location of the file (URL or local path) as a string. If you set this property the class tries to load that file (with bindable blabla)
So, you can't overwrite the source property with a movie clip.
Maybe you could cast the MovieClip to an Image component using
var image:Image = bulkLoaderMovieClip as Image;
bye,
tux

Flex: Passing MXML file as XML Parameter

Is it Possible to pass MXML it self as parameter(XML param) from external application and load in Flash Player dynamically to create page. For e.g
passing xml = <mx:canvas><mx:label text="hello" /></mx:canvas> to Flex and flex should create canvas with label control in it. Is there any example related to it.
Thanx
MXML code needs to be compiled down to ActionScript before Flash Player can do anything with it. MXML is not interpreted by Flash Player at runtime.
What you are wanting to do is not possible. Like brd6644 said, mxml is compiled down to bytecode in the swf which is interpreted by the flash player. The mxml (and even actionscript) is not understood by the flash player.
That being said, there is a JSP library that you can use for dynamic MXML. See here:
http://www.adobe.com/devnet/flex/articles/server_perf_05.html
That link is old, and right now I can't seem to find an updated link, but I know the project still exists. I believe it actually ships as part of ColdFusion still. It allows you to create dynamic mxml which gets JIT compiled at the request. It of course has a substantial performance hit because of it, but if you need dynamic MXML it is an option.
I will update this comment with a better link when I find it.
Just store the properties of the
component to a XML and put a className
attribute so that if you load the XML
you can have a function to set the
attributes of the XML to the
properties of your created component
which will be determined in your
className attribute
My initial guess is no, it would still be of type "XML", and there is no "eval" in Actionscript 3. I did a quick search and am going to have to say no, this is not possible.
I have however, done something similar in an app I created.
What I did was store in a database the object type, and some properties (x,y,width,height, etc). This data is returned from a remote object call and these objects are then created at runtime, which can get a similar effect you are trying to achieve.
For example:
var resultAC:ArrayCollection = event.result as ArrayCollection;
var tmpCanvas:Canvas;
for(var i:int = 0; i < resultAC.length; i++)
{
if(resultAC.getItemAt(i).type == "Canvas")
{
tmpCanvas = new Canvas();
tmpCanvas.x = resultAC.getItemAt(i).x;
tmpCanvas.y = resultAC.getItemAt(i).y;
...
parent.addChild(tmpCanvas);
}
}

Resources