Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-23-2010, 04:25 PM   #1
scorpion9
Senior Member
 
Join Date: Feb 2008
Location: Estonia
Posts: 453
Default AS3 in Flex

Hi


im quite familiar with as3 in flash CS. Recently i got a task to edit/write a source for flex app.

i read from Adobes site an interesting line that said, flex uses mxml and/or as3.
does that OR mean i could write flex in pure AS3?

also, are the flash API elements available in flex as well. I mean MovieClips, URLRequests etc etc, or does flex have its own API.




thanks for ur time

Last edited by scorpion9; 11-23-2010 at 04:38 PM.
scorpion9 is offline   Reply With Quote
Old 11-23-2010, 04:35 PM   #2
TomMalufe
Salmon Eater
 
TomMalufe's Avatar
 
Join Date: Jun 2007
Location: Doylestown, PA, USA.
Posts: 740
Default

Flex includes all the same AS3 libraries you know from Flash IDE, but it contains very different components.

You can write a Flex app almost entirely in AS3, but you are going to need your main MXML file that includes that AS file.

I would watch the intro to Flex videos on gotoandlearn.com if I were you. They don't take too long and it will give you a pretty good idea of what Flex is.

In simple terms... Flex is Flash within a heavy framework. It's the same thing plus a bunch more.
__________________
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." -- Chinese Proverb.

Last edited by TomMalufe; 11-23-2010 at 04:37 PM.
TomMalufe is offline   Reply With Quote
Old 11-23-2010, 04:59 PM   #3
drkstr
Flexpert
 
drkstr's Avatar
 
Join Date: Sep 2006
Location: Seattle, WA: USA
Posts: 1,587
Default

MXML is Actionscript in a way. It's basically just short cut notation for defining display layouts, bindings, and other such things that are easier to define in a markup language. All of that MXML get's converted into Actionscript before it's compiled, so yes it is possible to write your entire project in AS. But why would you want to? MXML is actually quite nice once you get used to what it's good at, and what it's not.
drkstr is offline   Reply With Quote
Old 11-23-2010, 07:23 PM   #4
scorpion9
Senior Member
 
Join Date: Feb 2008
Location: Estonia
Posts: 453
Default

atm, i havent programmed anything in flex (first encountered it 5 hours ago). Ive used to the code flow of as3, all the nice oop etc + timeline.


so here are few general questions about flex

what is the main stage/timeline in flex.
is there a display list as it is in flash....e.g are the objects created/layered in the order of code appearance. eg. stuff defined between tags at the beginning of the file are placed at the bottom of the display list, and as the code moves along rest of the stuff is added on top.

does objects/tags nesting determine their placement in display list+parent child relationship.

do the width and height in a markup like this
<mx:Object width="400" height="400" >

refer to DisplayObject.width/height in flash.

and lastly, how do events propagate in flex. ive seen in tutorials that flex uses listeners like javascript eg onclick=function().
is there a way to listen events by addEventListener()


anyway this whole flex structure and oop seems very odd atm. cant see much benefit of using it. the only thing atm i could think if is the use of % in defining objects width and placement on the screen.

Last edited by scorpion9; 11-23-2010 at 08:02 PM.
scorpion9 is offline   Reply With Quote
Old 11-23-2010, 09:58 PM   #5
drkstr
Flexpert
 
drkstr's Avatar
 
Join Date: Sep 2006
Location: Seattle, WA: USA
Posts: 1,587
Default

Quote:
what is the main stage/timeline in flex.
is there a display list as it is in flash....e.g are the objects created/layered in the order of code appearance. eg. stuff defined between tags at the beginning of the file are placed at the bottom of the display list, and as the code moves along rest of the stuff is added on top.
Yes.

Quote:
does objects/tags nesting determine their placement in display list+parent child relationship.
Yes.

Quote:
do the width and height in a markup like this
<mx:Object width="400" height="400" >

refer to DisplayObject.width/height in flash.
Well yes and no. All you are doing in your example is instantiating an Object and giving it a width and height.

The following do the exact same thing in MXML / AS:

Code:
<mx:Object id="myObject" width="400" height="400" />
Code:
public class MyClass()
{
  function MyClass()
  {
    this.myObject = {width:400, height:400};
  }

  public var myObject:Object;
}
When you add a tag to MXML you are telling it to instantiate whatever Actionscript class that tag represents. You can then use the attributes to set initial class properties, add event handlers, etc. If the class happens to be a DisplayObject, it will add it to the display list of it's parent tag. So yes, if your tag is a DisplayObject, than you are assigning the width/height of the DisplayObject.

Quote:
and lastly, how do events propagate in flex. ive seen in tutorials that flex uses listeners like javascript eg onclick=function().
is there a way to listen events by addEventListener()
Again, same things:
Code:
<fx:Script>
<![CDATA[
  private function changeHandler(event:Event):void { }
    
]]>
</fx:Script>
<s:TextInput id="textInput" change="changeHandler(event)" />
Code:
this.textInput.addEventListener(Event.Chage, changeHandler);
...it's a matter of personal preference.

Quote:
anyway this whole flex structure and oop seems very odd atm. cant see much benefit of using it. the only thing atm i could think if is the use of % in defining objects width and placement on the screen.
It helps if you think of every MXML file as an Actionscript class. Any code you add in the script tag is just like you were to add it to a Class. Any MXML tags within that file is just a shortcut notation to instantiate other classes, assign initial properties, add event handlers, assign styles, etc.

All of the same OOP rules apply. Just like in AS, it's up to the programmer to follow OOP conventions or not.
drkstr is offline   Reply With Quote
Old 11-24-2010, 02:08 PM   #6
scorpion9
Senior Member
 
Join Date: Feb 2008
Location: Estonia
Posts: 453
Default

thanks for the replies.
that cleared out some stuff.


now all i need is a programming environment.

whats the best free program for that?

i have eclipse installed for java and other stuff. ive read that adobe has a plugin for that. but it isnt free as far as i know.

is there something thats free.
scorpion9 is offline   Reply With Quote
Old 11-24-2010, 11:50 PM   #7
drkstr
Flexpert
 
drkstr's Avatar
 
Join Date: Sep 2006
Location: Seattle, WA: USA
Posts: 1,587
Default

The eclipse plugin is free, I thought. There is FlashDevelop too.
drkstr is offline   Reply With Quote
Old 11-25-2010, 03:38 PM   #8
scorpion9
Senior Member
 
Join Date: Feb 2008
Location: Estonia
Posts: 453
Default

thanks for the replies.

i decided to go with the 60 day trial- plugin.
scorpion9 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:13 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.