ExteralInterface Tutorial: Calling Fancybox from Flash

7 Apr

ExteralInterface Tutorial: Calling Fancybox from Flash

So, over the past few days, I’ve been working on a project that requires a fancybox call from flash. WOE. I know, say what? It’s actually a lot easier than you think! So, Check this out… here is how to call fancybox from your AS3 swf.

After the directions… you’ll notice I trying to call a list of images (a gallery). If anyone has achieved that, please feel free to let us all know.

External Interface Tutoral : Zunski Graphics

1. create a button in AS3 (or movieclip)

2. give it an instance name of myButton.

3. In order for fancybox to hear your click, you’ll have to use ExternalInterface to call your js functions from flash.

Sounds like a mouth full, but it’s simple. Just add this to the first frame of your
time line:

 
// IMPORT CLASSES
import flash.external.*;
 
// ADD MOUSE EVENT LISTENER
myButton.addEventListener(MouseEvent.CLICK, myClick);
 
// CREATE FUNCTION
function myClick(e:MouseEvent):void
{
     // CALL YOUR JS FUNCTION HERE IN STRING FORM
     ExternalInterface.call("callFancy");
 
}

4. Now we need to add some code to our HTML document. First, we need
to add a hidden < div > container. So, just above your flash div,
(assuming your using SWFObject — which you should be) add this:

<div id="hidden_clicker" style="display:none;">
        <a class="featured"></a>
</div>


****NOTE : You must call your swfobject.js first… then put in the swf calls, followed by the jquery.min.js, followed by all your fancybox.js scripts. See example for more info ****

5. Now we need to add our JavaScript code. You’ll see the name of
this function is the same as the string we called in flash. Add the
following to your < head > section:

<script type="text/javascript" >
     function callFancy(my_href) {
        var j1 = document.getElementsByClassName("featured");
        j1.href = my_href;
        $('.featured').trigger('click');
     }
</script>

6. OK, now that we are done with that, we still need to define our
fancybox JavaScript — to make it look the way I want… now, this is where I
have questions, but I’ll get to that in a minute. Add this to your
fancybox call. In my case ‘.featured’.

**NOTE – I am calling several different fancybox calls, so I have a
separate .js file with all these calls in it. make sense?

        $(".featured").fancybox({
                'overlayOpacity'        : 0.7,
                'overlayColor'          : '#000',
                'centerOnScroll'                : true,
                'hideOnContentClick'    : true,
                'hideOnOverlayClick'    : true,
                'autoDimensions'        : true,
                'padding'                       : 0,
                'href'                          : 'PUTYOURIMAGEHERE.jpg',
                'title'                                 : 'PUTYOURTITLEHERE',
                'transitionIn'                  : 'fade',
                'transitionOut'                 : 'fade'
        })

7. That’s it.. your done!

Get the SOURCE files here

I hope you find this helpful.

L

Popularity: 100%

Posting from my iphone

5 Apr

Just got a new iPhone. I also got the wordpress app so I can post directly from my phone. Really cool!

I’m wondering if I can link text?

Let’s see. Click here.

Popularity: 17%

Friday Video of The Day

26 Mar

In light of the Winter Music Conference in Miami in full swing as I write this post. I thought I’d share just a couple of videos to get you all hyped up. This is absolutely the biggest party of the year for electronic music fans. All week DJ’s, record labels, artists, and anyone who LOVES Miamiheads down to South Beach for a week of celebration and collaboration! This is also the spot most artist drop their next big hit for the upcoming year, and if your lucky, you won’t end up coming home with multiple promo mixes and more!

To top it off, tonight (roughly 4 hours from now) starts the main event… Ultra Music Festival in Bicentennial Park in Miami. This year they are expecting over 100,000 people!

I didn’t get to make it this year, but mark my words, I won’t miss it EVER again.

Popularity: 14%

Video Tutorial :: GAIA Framework Part 1

18 Mar

I’ve had the awesome please of being reminded of an awesome flash framework called the Gaia Flash Framework. Erin over at The Loud Few and I were discussing Flash stuff, and she mentioned I should check it out. Well, I did and it’s good thing! While I’m still learning it from A to Z, I’ve already noticed it cutting my developing time for creating flash websites or even partial flash websites a substantial amount! In a nutshell, GAIA basically takes care of all the low level stuff that is required for every flash website you do. Preloaders, SWFObject, Page Transistions, SWFAdress, etc…

So, in my search for GAIA knowledge, I happen to come across a set of excellent video tutorials from Josh Chernoff at AS3Apex. As a side note, it looks like As3Apex is a local St. Louis blog. Really Cool! I think you’ll find these tutorials very helpful and very detailed! Thanks Josh!

Intro to Gaia Flash Framework. from Josh Chernoff on Vimeo.

Popularity: 42%

Friday Video of The Day

13 Mar

New season starts April 30th! By far this is the best TV show around.

Popularity: 2%