> In my example, I basically described wanting to use Flex 
> controls to define, place, alter a Sprite and then have mouse 
> clicks on the Sprite be recognized by Flex. While I am not 
> asking anyone to code anything for me, isn't it a bit 
> surprising that there are no obvious or well-publicized demos 
> that can do this?

I think you're missing a point somewhere.  Flex and Flash both target
exactly the same runtime.  Anything you could code in Flash, you can
code in Flex.  This is pretty fundamental stuff, most Flash programming
books will have the basics, and the techniques directly apply to Flex as
well.  Now, the low-level API and the language have been tightened up,
so books on the very latest stuff aren't out yet, but I'd be surprised
if anyone who understood how to do Flash programming for Player 8
couldn't take the FlexBuilder docs and build similar things for Player
8.5.

To address your particular example, there aren't "well-publicized demos"
because its pretty silly-simple:

package
{
import flash.display.Sprite;
public class foo extends Sprite
{
    public function foo()
    {
        for (var i:int = 0; i < 10; ++i)
        {
            var b:bar = new bar();
            b.x = 20 * i;
            b.y = 20 * i;
            addChild( b );
        }
    }
}

}

import flash.display.*;
import flash.events.*;
class bar extends Sprite
{
    private var state:Boolean = false;
    public function bar()
    {
        addEventListener( MouseEvent.CLICK, toggle );
        draw();
    }
    public function toggle(evt:Event):void
    {
        state = !state;
        draw();
    }
    public function draw():void
    {
        graphics.clear();
        graphics.lineStyle(5, state? 0xff0000 : 0x00ff00);
        graphics.moveTo( 0, 0 );
        graphics.lineTo( 10, 10 );
        graphics.moveTo( 10, 0 );
        graphics.lineTo( 0, 10 );
    }
}

FYI - the above code is untested, I used Outlook as my IDE, so YMMV.

> The specific task at hand is to build a directed graph - 
> lines connecting nodes with the ability to move a node and 
> have its lines go with it and the ability to drive the event 
> associated with a node selection back into Flex. 

See, the thing here is that you wouldn't be using Flash Authoring to do
this.  This is a coding problem.  There isn't any "back into Flex".  Its
just ActionScript and the Flash Player API.  You might use Flash
Authoring to make a pretty node graphic, but then you simply Embed that
into your Flex app.  In the above example, you might associate it with
"bar".

Note: I've used Flex to do pretty much exactly what you describe; mine
used a force-directed algorithm with simulated annealling to do realtime
layout, and I found that depending on the number of nodes, Sprites are
pretty heavy, and its better to just render everything onto one single
graphics context.

> 
> For a platform/language combination as capable as Flash + 
> Flex/Actionscript, this should be an absolute no-brainer. 
> However, it turns out this type of interaction is either 
> harder, trickier, or less publicized than it should be. 
> (Although JesterXL provided some good tips I've not yet had a 
> chance to try)

Honestly, I think you just need to look deeper.  Its all out there.

My suspicion is that you've gotten an incorrect perception locked in
your head that there's some fundamental difference between "Flash Code"
and "Flex Code".  Once you grok that they both target the same VM and
have access to the same APIs, you'll see that the only real difference
is the paradigm used for authoring.

Good luck,

-rg



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to