Sunday, July 25, 2010

Detect MouseEvent in FilledElement

I am creating components dynamically using a class that I'm extending from FilledElement. I need to capture mouse events on these components, but Filled Elements cannot detect mouse events. Thankfully, I found a comment in a post on CodeDependent!

http://graphics-geek.blogspot.com/2010/05/video-flex-4-path-to-enlightenment.html

Using that information, in ActionScript, I added a Group and then added my component to the group.

Now I can detect whether my component was clicked and I can even change the stroke! I borrowed the hit test code from Chet's Top Drawer. Thanks to Chet and Guillaume!


//MXML
<s:Panel id="panel" width="563" height="373" x="76">
<s:layout>
<s:TileLayout>
</s:TileLayout>
</s:layout>
<s:Panel>


//ActionScript in MXML
//This is a bit klugey, but it works.
var mySymbol:MyComponent = new MyComponent();
var group:Group = new Group();
var i:IVisualElement = panel.addElement(group as IVisualElement);
group.addElement(mySymbol);
mySymbol.addListeners();

//ActionScript in component
//in the addListeners function:
this.parent.addEventListener(MouseEvent.MOUSE_DOWN, handleMouseDown);

//in handleMouseDown
var selectPoint:Point = localToGlobal(new Point(event.localX, event.localY));
//parent is the Group that was added in the MXML code
if (this.parent.hitTestPoint(selectPoint.x, selectPoint.y))
{
this.stroke = new SolidColorStroke(0x000000,2);
}

Tuesday, May 6, 2008

Flex in Flash

OK, so I thought, "What if I load Flex components in Flash?" Other people have thought of it too. I found the comments in this post interesting. After doing some other investigation, it appears you can create Flash components for Flex, but not vice versa. Ho... Hum... I'd better start building my file components in Flash.

Wednesday, April 30, 2008

Flex Me!

Well, I'm still using Flex, but I've just found out a few things. One, Flex has some nifty components you can use to browse O/S files and folders. Flash does not have them. So, I decided to try and build something myself. While researching that, I have discovered that some controls used in Flash did not make the conversion to CS3. Read the comments here, on gskinner's blog. Grrrr! Building this component ought to be fun. For now, it's probably enough to note that I just need to create it and move on to working out other problems.

Monday, March 31, 2008

Flash, AS3, and Packages

Oy! Thanks to the blogger, Mike Garcia, who pointed out that when using Flash and ActionScript, the .fla file is outside the hierarchy.

If you have your AS3 (.as) files in a directory called c:\src\Prototype, then the .fla file goes in the src directory and the AS3 files go in the Prototype directory. Inside your .as file you must have:

package Prototype
{

//imports

//class definition

}

If your .as files were in the directory c:\src\Prototype\Test, then you would call your package "Prototype.Test". Mr. Moock did explain that in his book, Essential ActionScript 3.0. Link to the companion website.

Tuesday, March 18, 2008

Maybe Flash is the answer....

Flash creates .swf files, so why not create the AIR application using Flash? I've downloaded the updates, so I am now at Flash 9.0.3 and can create an AIR app in Flash. Woo hoo! This should be interesting. I took a class for two weekends at MassArt this past summer to familiarize myself with Flash. Let's see what I remember. I should say that I had a great teacher (Hi, E!) and that I wish it lasted a little longer.

I was able to get started and use the file open dialog with help from the tutes below. When I have something that looks good, I'll publish it. For now, I leave you with Lee and Brian. Thanks, guys!

http://brianchau.wordpress.com/2007/10/11/flash-air-director/

http://www.gotoandlearn.com/

(gotoandlearn.com seems to be having difficulties but should be fine by the time anyone other than myself reads this....)

Oh no... should I change the name of the blog? FlashAIR? AIRFlash? FlAIR? Oooh, I like that one. I like FlexAIR because it sounds like "fresh air." I have plenty of work to do before I figure out which is right. I might have to go back to Flex, after all, so it will remain the same for now. :)

Sunday, March 16, 2008

Generating .swf Files

I'm designing my first Flex/AIR application. I was thinking that it would generate a .swf file. I could then run that .swf file in the player I plan to build or perhaps in a web browser, as a .swf generated using Flash. Surprise! There doesn't appear to be a way to build a .swf file using ActionScript. Some discussion on the topic here:

http://www.nabble.com/Loading-Image-Sequence-into-Movie-%3E%3E-Programmatically-Dynamically-Generate-SWF-td15261040.html

ByteScout has a product called SWFScout. It's an ActiveX/.NET library that allows you to create a .swf file in VB. If ByteScout can do it in VB, I should be able to do it in ActionScript, right? I think that is the next topic I'll pursue.

http://www.bytescout.com/swfscout.html

Someone actually tackled parsing a .swf file. I don't think I'm up for that!

http://flashpanoramas.com/blog/2007/07/02/swf-parser-air-application/

I also found from "Sean the Flex Guy", a PowerPoint slide show that highlights Adobe's RIA technologies:

http://flex.org/tour/slides.pdf

Saturday, March 8, 2008

Flex Builder 3: Invalid Application Descriptor Error

Hello,

If you attempt to debug an AIR app running Flex Builder 3.0 and you get the following message,



chances are all you need to do is open up the correspondig Adobe AIR Application Descriptor File Template and change http://ns.adobe.com/air/application/1.0.M6 to
http://ns.adobe.com/air/application/1.0 (I removed the ".M6" extension).

From looking at other blog posts, it appears that when you move from the beta version of Flex 3 to the "real" version, the ".M6" should be removed. I am following a tutorial from the website -- apparently, they have not updated their tutorials. The one I am working through is here: http://www.adobe.com/devnet/air/flex/articles/air_training_file_system.html

Be sure you change the *-app.xml file and not the .mxml file, as I had done originally! If you change the namespace in the .mxml file, you are likely to get a compile error like: "Could not resolve * to a component implementation." where * is the name of a tag. In my case, the tag was "mx:windowedapplication".

When I run the app instead of executing I get a "socket timeout" message in the console. I don't know what that's about yet.

Wednesday, January 2, 2008

FlexAIR Blog

Hello!

I'm learning Adobe AIR with Flex, so I'm starting this blog to keep track of my progress. My first example starts with a blog post created by someone else:

http://blog.paranoidferret.com/index.php/2007/10/09/adobe-air-and-flex-getting-started/

If you go to this post, you'll see that I added some important information for those using Flex 3:


//changed for Flex Builder 3
//Version: 3.0.190133
import flash.desktop.Clipboard;
var files:Array = event.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;

img.source = files[0].url;


So, I did do some work!

I would like to figure out how to load bitmaps and tiffs, if possible. I'll work on that next.