Few basic questions on flex/AS - apache-flex

Guys i have struggling with flex since a day or two.I havent found a nice short tutorials.Actually i also have been struggling with FLEX IDE too.Please indicate a nice good tutorials for this
I basically have questions like
Cannot use Alert in AS
Including a AS file in mxml file
org.com.structure and the as file in it.Why do we need to say pacakage org.com inside the as file

You can use flex Alert class. In pure AS, unlike JavaScript, there is no alert().
<mx:Script source="script.as"/>. But script.as will not know about MXML file, it's better to use class defined in as file as a control in MXML.
Because packages are compiler-enforced design decision, and who we are to discuss it.

Flex in a week!
http://www.adobe.com/devnet/flex/videotraining.html
This video series helped me a lot..

Related

Beginner in Flex

Can i learn Flex with out learning ActionScript 3?
Learning Flex means learning both ActionSript 3 and Mxml languages, so in essence, you cannot learn Flex without learning ActionScript.
But if what you're really asking is whether you can learn Flex without prior ActionScript knowledge, then the answer is yes.
Why not try some introductory tutorials to help understand the framework? If you're familiar with other scripting languages then Actionscript shouldn't be too daunting.
Here are some decent tutorials to get started:
http://blog.theflashblog.com/?p=705
http://learn.adobe.com/wiki/display/Flex/Part+I.+Creating+a+Simple+RIA
I'd also recommend downloading "Tour de Flex" as a companion when getting started with the framework.
flex is gud, as i am flex developer, you can start learning flex, but you hav to learn actionscript too, b'coz at the end of day, i found myself working and coding in actionscript,
so flex eases the things, that wre much time taking in Actionscript,
like
Here you don't need to add the child hbox in the vbox, that's been done automatically, and do note that flex code is compiled in to AS code first, then that is converted to bytecode,before given to flash player to execute....so u r most welcome to the flex world , but do note AS is also imoprtant, and it's very intertesting,:-)
tc
Ankur
No, not really. To do anything remotely useful you'll need to be able to write some actionscript. You can easily do some layout, but mxml is really best for just creating views. If you want to just create a 'hello world' program, then you can certainly do that with flex. However, when you want to build something substantive you'll need actionscript. Also note that the mxml tags are all written in actionscript, so if you want to understand them under the hood, you'll also need to know actionscript.

Flex 4 - Using MXML as views - Any references?

I'm looking to create a flashBuilder document which uses seperate MXML files as "views" which are controlled by states - I believe it's a design pattern of sorts but I'm relatively new to FlashBuilder. I was wondering if anyone knew what design pattern it was and if I can be pointed in the direction of some good references!
FYI I'm looking into using FlashBuilder to design Android apps so any better suggestions would be much appreciated.
Cheers
You can do that the way you want. Just consider such file (MXML) as object. It can be easily added to some outer component, ie. UIComponent. You should read something about it but I bet it's quite simple. Just remember - MXML is just a language that describes an object - you could do that using AS 3.0 instead but it's obviously more convenient to use MXML. Considering this fact all the MXML files are compiled before they run so you can easily manipulate them.
Just try to add such object to some outer component like UIComponent - you can read a few words about it here: HTML in Flex. Just take a look at the function createWindow
Good luck!

flex newbie: can MXML be generated on the fly

Flex newbie question: can MXML be generated on the fly, like HTML is generated by a server?
If yes, is it ok to do so or am I missing an important Flex architectural principle.
Sort of... but it still needs to be compiled. MXML is not rendered directly, it is first compiled into ActionScript 3.0, and then into a typical SWF... so, you cannot serve your users with MXML. However, like almost all programmming languages, you can use automatic code generation to ease development tasks.
There is IIS/Apache component given by adobe that can generate your mxml -> html+swf using on the fly compilation, and it also caches the last compiled file.
However its not recommended for bigger projects as it has certain problems that you cant make libraries of your code and organize code accordingly. Namespace usage is very limited.
MXML is just a way of describing user interface layout and scripts. This information is then "compiled" into ActionScript, then converted to SWF format for use in the Flash player.
So, yes, you can generate MXML on the fly, in that you can create a text file that contains valid MXML syntax, then use mxmlc to compile it, but there's no way (that I'm aware of) to create MXML and "add" it to your current movie such that the information appears as it would were it compiled.
It is not officially supported but there is a few similar projects doing stuff similar to this.
as3Query let you create things with xml.
Using createComponentFromDescriptor() maybe can get what you want.
Should be more as I remember, but can't find it out at this moment... Searching for "MXML runtime dynamic compilation" or something like that should be helpful...

Creating and editing CSS in Flex3 Air

I need to create a CSS file via the Flex 3 Air application. I need to create and edit the CSS file and access individual styles by class name. Please give any examples or related links of which you aware.
I don't use Flex that much, but it seems you need to load the CSS file via URLLoader/HTTPService/etc and write a class to parse.
You can probably start from the one that comes with the framework, or have look online and adapt one for your needs. The first this that I found was this. Obviously there could be better alternatives.

How to create/use themes in a Flex project

I just started out with Flex, and while I have worked with Actionscript2 for a few years, I'm still getting my head around Actionscript3. I've been diving into Flex for the past week, and can't figure this one thing out.
I am looking into the best way (or 'a' way) to allow me and other folks working on this project to easily create new themes for kind-of an video player. I show two videos, and need to be able to reposition them, style them, add images and anything else, really. I'm not looking to create a full-on templating engine, but if I could have a separate file/folder for each template, that would totally make my day.
I imagined having a solution in which I would have a folder inside src/templates/, and inside that folder I would have view.mxml that contains everything I need to display the videos. I would then be able to add other files such as images and such to make this template look the way it should.
Which template should be used should be defined by a variable in the main video file. This will either be provided to the swf file on playback, or provided by the video loading an external configuration file (but this is not part of my question :).
So, in short; How do I include mxml files that are inside one or two sub-folders inside src, and how do I do this in a way that the file I wish to include can be chosen via a variable.
Thanks so much in advance!
-Dave
You'd be surprised to what degree a Flex application can change its appearance through styling. Check out the following project:
http://www.fillcolors.com/
If you need more flexibility still, you could have an application with multiple views, one for each theme you want to show. An easy way to do this in Flex is to make use of the ViewStack component which basically layers view displays, showing only one at a given time.
As a very simple example, you could have something along these lines:
<mx:ViewStack selectedIndex="{currentIndex}">
<themes:CustomTheme1/>
<themes:CustomTheme2/>
<themes:CustomTheme3/>
</mx:ViewStack>
Here, currentIndex is a variable bound to the ViewStack, determining which of the three children is currently visible, each of which represent a custom MXML component (in your case, a theme).
Response to comment:
Yes, the above example is designed to do exactly that, but it's really not a feature of Flex, but of AS3. The CustomThemeX components are located using the themes namespace. The namespace is defined within the parent components root tag. In this example, the parent is a Canvas component:
<mx:Canvas xmlns:themes="themes">
This tells the compiler to look for these custom components within the themes sub-folder of your application; in other words, the src/themes folder, which contains the CustomThemeX components.
If the preceding paragraph didn't really sense to you, I'd recommend picking up a book/reading through the documentation about AS3/Flex and learning more about some of the core concepts of AS3 and object oriented programming. I wish I could help out more, but this question is starting to get a little too broad. I hope you understand. :)
I'm not an expert on Flex. But I've seen a tutorial on skins in Flex on gotoAndLearn.com. Maybe that kan give you some hints: Introduction to Flex: Part 3

Resources