|
Naw, actually you can do that. I forget what
they recommend, but you need to cast DisplayObjects to IUIComponent to ensure
what you add them to Flex DisplayContainers, it doesn't bitch.
var a:Sprite = new Sprite() as
IUIComponent;
my_canvas.addChild(a);
Or something like that, I forget but I know one of
the casting combos works just fine. Or you could add everything to a
UIComponent:
var b:UIComponent = new UIComponent();
b.addChild(new Sprite());
Again there are other ways; I'm more interested in
what works, not what is the best way so take that with a grain of
salt.
As far as playing together, I've managed to get
various incarnations of Flash 8 SWF elements embedded into a Flash Player 8.5
SWF; embedding specific MovieClip's and embedding specific SWF's as a
whole. Loading them at runtime has worked well too as long as no code is
involved.
For anything more advanced, you're best bet is to
create more designer centric content in Flash 8.5 (Blaze) and then utlize with
Flex 2 since they both will output Flash Player 8.5 SWF's, and use AS3 allowing
true interop. An alpha of Blaze should be out whenever Flex 2 is
officially released.
----- Original Message -----
From: Mark Wales
Sent: Saturday, February 18, 2006 8:32 AM
Subject: RE: [flexcoders] Actionscript-based Applications with Flex
2 Jesse, First, let me apologize
for a somewhat misleading subject line. My goal is to define a project that uses
both Flex and Flash components in the same project. It simply appears that an
Actionscript-only project is the most likely to
work. In Flex speak, what I
think this means is that I would like to create an Actionscript project that
embeds both an Application container and a non-Application container. For
example, if a high-level description of my project is something like
this: Everything
from 0,0 to 200,300 is my (Flex) application container where Ill do Flex stuff
and everything else on the screen is where, perhaps, Ill draw Sprites and have
them bounce around. And, as either container generates events, either container
can add listeners to process them. Then it appears the
standing advice is to create and separately compile a SWF component for the
Flash stuff and embed it in my Flex app. Is this really the only route?
In my ideal world, I
could embed a canvas-like component in my Flex application, and then draw,
play with Sprites, or run animation-type stuff within it. Ill certainly settle
for less, but from a big picture sales/marketing perspective, this is what Java
(and WebStart) can do (albeit with much more work but at least a bit more
consistency of approach). The combination of Flex
and Flash are both superstars within their respective domains - but on first
glance, it is not quite clear they can play together very
well. -Mark -----Original
Message----- If you are looking for a HelloWorld,
see the bottom of this email. Here's the quick(?) skizzy on the various
technologies. Don't have time? Read to the
######### to skip the background. Flash Player 8.5 is engineered to
work with the improved ActionScript 3 language, and have pimp new
features. ActionScript 3 is a clean-up of
ActionScript 2, a stricter adherence to ECMA (depending on who you talk to), and
organized around the new package organization structure with additional
constructs added in. Can you create applications alone
with those 2 technologies? Yes. Would I personally want to?
Hell no. If you paid me too? Nope, because I'd inform you that you
are over-paying. Flex Framework 2 is the creation of
a set of compoents and framework classes to do all the things needed to create
applications. Your buttons, and dropdowns and datagrids, your data classes
that expose server operations in a clean and easy to use API. Your
modality, focus management, binding, etc. The same reason you use the Flex
Framework 2 to create applications instead of pure ActionScript 3 is the same
reason you use Rails for Ruby, ActionStep for C, Cake for PHP... common
problems, tasks, and needs are solved by well written and proven application
component frameworks. Re-inventing the wheel, while cool from a
developer's standpoint, is not cost-effective
business. On the flip-side, there are many who
will never use the Flex 2 framework. For example, I currently cannot use
it's pre-decessor, the v2 component framework for Flash 7 on my cell phone; I
have to resort to pure ActionScript 2 and modified-Flash Player 7
technology. I have no choice, the CPU and RAM requirements of the phone
force me to do so. Naturally, 2 things happen; the scope of my work is
greatly limited, and I still make at least a lean set, enough to get me to an
acceptable level (buttons, labels, image loaders,
etc.). Now, Flex is unique in that mxmlc,
the commandline compiler, actually knows about things like MXML as well as
ActionScript files, and compile both into a SWF. This is further expanded
upon because the mxmlc and the Flex Framework were built in tandem, allowing
certain compilation features and framework features to be mutually exclusive in
benefit. Therefore, while there is no reason someone couldn't port the
ActionStep framework to ActionScript (they are actually...), Flex Framework has
an advantage out of the starting gate because it takes advantage of some of the
new features mxmlc has in regards to creating
SWF's. Bottom line, while you can do
this: var a:Sprite = new
Sprite(); addChild(a); a.addEventListener(Event.CLICK,
onPress); var g:Graphics =
graphics; a.beginFill(0x000000); a.lineTo(100,
0); a.lineTo(100,
22); a.lineTo(0,
22); a.lineTo(0,
0); a.endFill(); ...using the framework, you can do
this instead: <mx:Button click="onPress"
/> Beyond the portability of the code,
let-alone readability, it's approachability from those with an HTML background,
it has many other benefits not so easily
visible. - built-in focus
management - already looks like a
button - has an optional
label - has rounded corners looking more
like a button than a box - is in the MX namespace, allowing
other buttons to be differentiated - has rollover
states ... I could go on all
night. Yes, there is more overhead, but it
is negligible, ecspecially with the speed improvements made in Flash Player
8.5. At this point in the software industry, there is little point to do
these things in code when months of development consisting of dozens of
developers, qa, managers, etc. has already been done for you.. and it's free I
might add. ...unless of course you are
developing for a phone, set-top box, XBox, or some other low-resource environ,
where I'd concur it is a wise decision to abandon the framework. Of
course, we aren't there yet. ######### Bottom line, if you create a Flex
project, you have to use Flex components (at least at the forefront) as shown
here: ----- Original Message -----
From: Mark Wales
Sent:
Subject:
[flexcoders] Actionscript-based Applications with Flex
2 I am
interested in writing an all Actionscript application (i.e. using the
Actionscript project option within the Eclipse-based Flex Builder) that combines
both Flex-based and traditional Flash-based components.
For
example, I want to define a Canvas on one side of the screen and populate it
with the traditional Flex-based components then create things like
DisplayObjects, Sprites, whatever on the other side while having events from
both sides intermingled (for lack of a better word) using events and
listeners. I am fine going with a strictly Flash 8.5 diet (that is the future
after all, right?). Everything
I read seems to imply that these must be in different SWFs and that there is a
fair bit of gymnastics involved in achieving even nominal interoperation between
the two paradigms. Am I
missing something? Are there any simple examples out there to illustrate how
this might work? (Preferably ones that dont require CF like the FileUpload
example on the Macromedia site, dont try to get fancy with MovieClips and
animation, etc.) The ideal
scenario would be an application where, on the Flex side I could pick square
from a pull-down list of a few standard shapes, press a button, and something
vaguely resembling that description would appear using flash components. Then,
when that component was clicked/moved, perhaps it could make the name of the
event that fired show up in a Flex label. Effectively the Hello World of the
new and improved Actionscript. Does anyone have anything like that?
-Mark -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
YAHOO! GROUPS LINKS
|
- [flexcoders] Actionscript-based Applications with Flex 2 Mark Wales
- Re: [flexcoders] Actionscript-based Applications wit... JesterXL
- RE: [flexcoders] Actionscript-based Applications... Mark Wales
- Re: [flexcoders] Actionscript-based Applicat... JesterXL
- RE: [flexcoders] Actionscript-based Applicat... Roger Gonzalez
- RE: [flexcoders] Actionscript-based Appl... Mark Wales
- Re: [flexcoders] Actionscript-based... JesterXL
- RE: [flexcoders] Actionscript-based... Roger Gonzalez
- Re: [flexcoders] Actionscript-based... Joe Berkovitz
- Re: [flexcoders] Actionscript-based Applications wit... Darron J. Schall

