Posts Tagged ‘flex’

Pain in my snow leopard…

Tuesday, September 8th, 2009

Today, I finally got my hands on my copy of Snow Leopard. I installed it immediately and low and behold, it sucks.

It pains me to say that about an Apple product, but I can no longer run Xtorrent (no biggie), but Flex Builder won’t run either. It can’t seem to find the Java SDK. I tried a fresh install of Flex Builder 3 and due to some install errors, I can’t even get the damn thing to try to start up to give me the error anymore.

I’ve been searching tirelessly for a solution through Google, and sadly, it looks like I am going to have to go ahead and make a copy of the data on my HD, and do a fresh “install and erase” on my Macbook. This isn’t the solution I wanted to have to do, but I need Flex so that I can work, and I need to be able to work ASAP.

I have to throw out a big “fail” for Apple here… and I am not happy about this at all…

Flash Library Symbols in Flex

Monday, June 29th, 2009

Currently I am working on some games for my full time job with theRedSpace. The team I am a part of decided that what would be best is that we go with Flex (now Flash Builder) rather than Flash. Now I am by no means “afraid” of Flex, but as a very visual person I prefer to program in Flash, games especially. The main reason for this of course is because in Flash I have my beloved library where I can build my Movieclips to my heart’s content.

So the problem for me was “how can I use my Flash symbol inside my Flex project easily?”. At first I was thinking about simply loading external assets, but I then would have about 50 or more asset SWFs that I would have been trying to manage, and for me, that just wasn’t an option. I thought next about using the “Embed” meta tag to embed the SWFs and then use the symbol attribute to grab the clip I wanted by simply marking my Movieclip symbol for export into ActionScript in my Flash library. I learned quickly though that this would not be an option as when I bring a clip in through use of the embed tag that my code in the timeline is stripped (I don’t like putting code in the timeline, but for my simple stop() and gotoAndPlay() commands I really don’t mind it).

So I was back to where I started. Luckily I came across a great tutorial online (can’t find the link, but when I do I will post it here) that mentionned using the getDefinition() function to grab symbols from library symbols in Flash. The code is actually very simple. You just load the clip using a normal loader, you then use the getDefinition() function to grab the library object as it’s own class and then create an instance of the class.

Here’s a very quick and dirry example to give the feel:

var loader:Loader = new Loader();
loader.addEventListener(Event.COMPLETE, _loaded);
loader.load("theswf.swf");

function _loaded(e:Event):void
{
var skinClass:Class = e.target.applicationDomain.getDefinition("ElememtClassExportName") as Class;
var clip:MovieClip = new skinClass() as MovieClip;
this.addChild(clip);
}

Of course, here this example assumes that the element you’re trying to load in the is being exported to ActionScript as “ElementClassExportName” which would never happen (or should never, rather).

This little bit of code though is great because it will allow you to have all of your visual assets in a single SWF file that you can load at the start of your Flex application and not have to worry about managing boat loads of SWF asset files. Hope it can help you as it helped me!