Fire Floatbox in Flash. Please post a working .fla in AS2?

Page: 1

Author Post
Member
Registered: Apr 2009
Posts: 56
I have worked on this for a almost a 1-1/2 days trying to fire your script from Flash .swf files. Normal HTML is fine and pretty darn easy.
I have searched your forum right and left, read your API page, FAQ and read all the threads relating to using getURL to fire your script. To no avail here.

Can you post an actual Flash file, with an .fla saved in Action Script 2 showing the actual code for a demo? For the sake of future readers, you might back-save to Flash 8. (We use CS3 and yes, we are saving as AS2) Flash is pretty dang popular as a navigational tool and your demo page does not have an .fla file showing exactly how to call your script. It would be useful to have an .fla example like the normal HTML "href" code that you show on your Demo page.

Here are various examples we have tested to call your script:
http://www.japaneseautotech.com/carousel_test/index10.html
The normal HTML "href" calls are working fine.

Try clicking on the "mybtn" Flash image (scroll to bottom).
It loads the following in the URL bar in Firefox: javascript:fb.loadAnchor('images/big/07.jpg')

The actual browser window responds with "true".

Here is our AS2 code for the mybtn image:

mybtn.onRelease = function()
{
getURL("javascript:fb.loadAnchor('images/big/07.jpg')");
}

The Instance name is correct and assigned "mybtn". We have checked it ten times. Maybe more.

Ignore the rotating Carousel at the top for now. We were trying for almost 1/2 a day trying to get the Carousel flash file working through XML calls. After striking out with that, we decided to fall back to a very simple button (mybtn) called from Action Script rather than XML. If you decide to click on the carousel buttons, maybe try the image of the cat. There are several. Each button has a different XML syntax trying to call your script. We threw the kitchen sink at it. You'll maybe note that some of the cat thumbnails result in the same "javascript" statement in the URL bar and return "true" or "false" in the browser window.

Are we missing an options settings in the floatbox.js file? We are using the Default settings that came with the download. We have not fiddled with that file at all.

Any input you can offer would be appreciated. Thanks!
« Last edit by jatss on Mon Apr 20, 2009 7:42 am. »
Administrator
Registered: Aug 2008
Posts: 3382
I feel your pain.
No, I can't post the .fla you are requesting. I'm not a flash developer and don't have any flash authoring tools. The javascript:loadanchor has been confirmed to work. And, of particular interest to you is, it's working on your page in Chrome, Safari and Opera, but not FF or IE.

So you've got the code right, and it is firing onRelease. The question is, why in your particular case are FF and IE not co-operating? The only thing I can see that might be giving them grief is that your test page is missing the opening <body> tag. Let's get that in place and see if the browsers start to behave. If that turns out to be the problem and solution, I'm sure you'll be banging your head on the wall for a bit. :) And if it's not the solution, I'm sure I'll hear back from you.

Update: I've copied your swf file to my server and have confirmed that the missing body tag is NOT the problem. I've also confirmed that the floatbox code is being fired correctly but is not completing. At this early stage it looks like a probable floatbox code bug that manifests in FF and IE only. I'll keep digging and get it sorted out.
« Last edit by admin on Mon Apr 20, 2009 2:38 pm. »
Administrator
Registered: Aug 2008
Posts: 3382
Found the trouble, and I have a fix for you.

When FF and IE see a return value from the code in a javascript url, they open a new page with that return value displayed as the content. (A very odd behaviour choice in my opinion.) Hence the single word "true" on the page.

Edit floatbox/modules/core.js. Should be line 83 that says "return true;". Delete that line. (It's the last line of substance before the "getCurrentSet" function definition.)

Or... Wait until this evening when I'll post a fixed floatbox zip file with that change and a couple of related follow-on changes.

My apologies for your frustrating day and a half.
Member
Registered: Apr 2009
Posts: 56
Thank you for your fast response.
Rem/delete two words and now it's fixed! And this smoked-up the weekend here! ;) ***head bang*** There's a reason the file name for the URL you visited ended with "index10.html". It's because there were nine other html pages and attempts. :o

Don't take that last comment as criticism. We've been there, and done that, writing our own code only to find a few bugs in Browsers, or the need to change a :, ; or some curly brackets. It comes with the turf. It's amazing the time you can smoke up.

I will say this. There is a reason we spent the time we did. It's because:

1. You appear to have one of the superior Javascript Window Systems on the market.

2. The ease of installation and simplicity of coding. (exclude our case)

3. The superb support and immediacy you appear to have with responding to comments or questions in your forum. (we surfed a lot of your forum and examples)

4. The concise, detailed, and thorough responses you write. No one line explanations and you often explain multiple ways to skin the cat.

In general, your system seemed very easy to implement and had all the features.

Now that we have your script working, we will play around with some options and settings.

Perhaps we can provide some original .fla files and .swf files that will maybe be useful on your Demo page? Not the ones we linked to above. Perhaps a more polished example. Let me know.

Thanks again for your punctual help on this matter. We will download the new Zip file when you post it.

Cheers.
Member
Registered: Apr 2009
Posts: 56
The XML data is now cleaned up and the Javascript links feeding the carousel dynamically are firing correctly. :)
Administrator
Registered: Aug 2008
Posts: 3382
I admire your perserverance. :)

The patched update is available for download now.

Your point is well taken about there being no flash integration samples on the demo page. If there were, this problem would not have occurred (or, more correctly, would have been caught prior to rollout). So sometime in the next week I hope to fill that gap with some AS2 and AS3 samples showing a couple of different ways to get flash and floatbox talking. (I understand AS3 does away getURL.) It may be a little late to be of help to you, but at least your aggravation helped make floatbox's corner of the world a little bit better of a place.
Member
Registered: Apr 2009
Posts: 56
Yes sir.

AS2 & AS3 are different.
You probably want to have both versions firing your Script.

Check your email box.

Thanks again.

P.S. It wasn't a solid 1-1/2 days. Took a break/breather toiling in the garden with this year's crop between sessions on the keyboard. A man's gotta feed the mouth. :)
« Last edit by jatss on Tue Apr 21, 2009 6:43 am. »
gwolson
Guest
jatss and Admin,

Thanks for this thread. Unfortunately I'm a total newb and am stumbling in the dark. I've been talking to one of the Admins here via email, but if either of you could walk me through this process a little bit I'd really appreciate it.

My entire site is basically built with Flash, the homepage is basically an empty HTML page with the Flash content stuck right in the middle of it. I'd like to use buttons on my Flash content to launch a Floatbox overlay that would have other .swf files in it. This sounds like what is being discussed here (kind of) and if either of you could help me sort through this I would be super grateful. I'm sure it's possible, I just don't know what components I'm missing to make it a reality.

Thanks in advance!

G
Administrator
Registered: Aug 2008
Posts: 3382
There might be some nuggets of help in this thread too.
Jatss is the man on flash stuff. I am a mere grasshopper.
gwolson
Guest
admin,

Thanks for the link. Unfortunately I'm not even knowledgeable enough to sort it from there. I get a vague idea of what's going on but I need more direct explanation. Is there a way to email jatss directly?
Administrator
Registered: Aug 2008
Posts: 3382
Ok, I'm a complete newby at flash. I created my very first flash widget tonight, and getURL runs just fine from it. If I can do it, anyone can. I did find something different in the ActionScript from the common wisdom that people share about the onRelease action. Here's what I did.

I walked through this article to create a small widget with a single button on it. Once the button was created in the library and added to the document, I then made sure the button was selected and went over to the actions window. Here I added the following code:
on (release) {
getURL("javascript:alert('eat a peach')");
}


Now this is where I differed from previous recommendations. Most folks on this board, and on the internet in general, say to use:
onRelease = function() {
getURL("javascript:alert('eat a peach')");
};

I made 3 widgets. This last syntax worked in one of them, and not in the other two. Very odd. The "on (release)" syntax worked 3 out of 3 times so I recommend you go with that.

A save, a publish, and an inclusion in a web page found me with a widget that said 'eat a peach' when clicked. A true achievement for this novice. I then changed out the function and made it:
on (release) {
getURL("javascript:fb.start({ href:'myImagePath.jpg' })");
}

Up popped my image in floatbox.

I think this is the way to go. Use on (release), get the damn thing working with a simple alert first so that you know your actionscript is firing, and then change the alert over to a fb call, either "start" or "loadAnchor" as you prefer (see the API reference).

Here's the fla and swf files I built if they're of any help to you.
http://randomous.com/misc/getURL.fla
http://randomous.com/misc/getURL.swf
Member
Registered: Apr 2009
Posts: 56
I've been meaning to reply to this thread, but I'm swamped here right now with deadlines. Everybody is tugging at me for stuff.

I thought I would post this link.
http://www.gotoandlearn.com

It's very helpful if you are just learning flash. There's a lot of content covered with great tutorials from the early days of Flash to CS4. Code examples, AS2, AS3, FLA's, SWF's, Video, XML feeds, the whole enchilada. Smothered with cheese, guac, sour cream and all the trimmings. You'll just need a bottle(s) of Tequila and several evenings to wash it down. Or, if you are a FISH eater, you can grill Salmon with a side of Jelly Fish and heaping portions of Bushmills.

The videos are quite in depth and explain the code very well. It will be a steep learning curve for newbies, but the presenter of the tutorials is very good and hardly misses a beat.

What we need is to put together some simple, tasteful button examples in real world scenarios. I'm swamped right now but maybe I can help Admin out when the fires die down.

Be aware that if you buy off the shelf Flash scripts and components pre-built by third parties, you are at the mercy of the authors coding skills. These are great tools and wonderful time savers, but sometimes it can be Russian Roulette getting your SWF to fire Floatbox. Particularly if you are using pre-built components that are fed by XML content. If the author of the component doesn't share the source code with your purchase, you are only guessing/hoping they coded the loops and getURL calls correctly. To me, it is worth the risk because of the huge amount of time these components save. Fortunately, most components are pretty darn cheap.

The first and foremost thing to confirm prior to purchasing a component is to make certain your version of Flash supports the Actionscript used in the author's component. Otherwise, you could certainly be hosed and waste your money and more importantly your TIME! So, in summary, before you start pointing the finger at Floatbox because your component isn't firing the window, insure you know what you have both inside your version of Flash and your third-party components.

Also, if you are a cut-and-paste hacker with code, you might want to stick with AS2 for now until you learn how it works. There are a lot more FLA examples and classes floating around the web because it has been around longer. AS3 may be superior and the new wave forward, but doesn't have the strong history of FLA examples online yet.

Hope that helps some folks for now. So, enjoy your patience with the Tequila bottle. Some of you will need a lot and will have to be weaned :shock:
gwolson
Guest
jatss,

Thanks for the response, and the excellent information.

Through one of the admins here, your information, and persistence of my own I've got everything working firing correctly from regular HTML and from inside a Flash file. It was definitely my own issues with coding, but I got it started.

I can put up some of the examples that I worked through here to get it sorted out if anyone is interested.

Now I've got a final question jatss, have you been able to specify a Floatbox window height and width within flash successfully? I'm clicking a Flash button that launches a Floatbox with .swf content in it, however it's skewing the content proportional to the screen. I've gone into the floatbox.js and framebox.js and turned off what I think are the appropriate options but it is still skewing weirdly.

My site is at:

www.gordonwolson.com

It's still under construction/renovation. The resume page works fine but it's generated completely with HTML, the index.html page however is all Flash and that's where I'm running into this scaling/skewing issue.
Administrator
Registered: Aug 2008
Posts: 3382
Gordon,
When we were working on your flash calls I saw that you had copied the option sizeRatio:1.618 from my demo page sample into your getURL call. My bet is, it's still there and is defining your floatbox dimensions. (Check way down near the bottom of the options reference to see what it does.)

Check the options you're using in the parameters to either fb.start or fb.loadAnchor inside your actionscript. Get those the way you want, and you'll get the box behaviour that you want.
Administrator
Registered: Aug 2008
Posts: 3382
Examples of invoking floatbox from flash ActionScript 2 and 3 have been added to the code tab of the demo page.
gwolson
Guest
Admin,

Thanks for the response.
admin wrote
I saw that you had copied the option sizeRatio:1.618 from my demo page sample into your getURL call. My bet is, it's still there and is defining your floatbox dimensions.


Unfortunately I haven't been able to spot the sizeRatio tag anywhere in my current pages. Would it be possible to send my pages along to you to see if you might spot them?

I also can't currently find a working way to specify a Floatbox window size from within a Flash getURL call. Is it possible?

As always, thanks for all help.
Administrator
Registered: Aug 2008
Posts: 3382
Specifying dimensions or any other option for the floatboxed items has nothing to do with running from flash. You control floatbox by its options. For anchors, you can place these options in the rev tag. For launching from javascript, you can pass these options in a string to the fb.start or fb.loadAnchor functions.

See the API reference for details on using those two functions. See the options reference for details on each of floatbox options and what they do. And see the instructions for how to set things up and use those options.

In your particular case, I would go back and take a look at the fb.loadAnchor or fb.start function call that you're using in your getURL call. The second string parameter is the options you are passing to floatbox. If you are getting weird sizing, it will because you are asking for that sizing through the options you are using. I don't know if you're loading images or other content into floatbox, but note that images don't need any sizing info set - image dimensions are auto-detected.

Remember, I said I had spotted sizeRatio being set in your getURL call in your flash object. From your post, it sounds like you went looking for that everywhere but in your flash object. Ask yourself where your code is that is firing floatbox. Go there, and find the options that are being used in that code.

Hope this helps...
gwolson
Guest
Admin,

I'm sure I sound terribly dumb by now right? My apologies.

The call that I'm using reads:
Quote
on (release) {
getURL("javascript:fb.start({href:'Productions/Operas/Butterfly.swf'})");
}


This is the format that all of my fb.start calls are using. I've got no other fb information listed within any of those calls on any of the other Flash triggers in my file, so that's what has me confused.

Sorry I'm being so difficult about this. I really appreciate your patience with me!
Administrator
Registered: Aug 2008
Posts: 3382
Hi Gordon,
I don't think you've read the floatbox docs - the instructions, options reference, and api reference. Floatbox is really easy to use and there's just a few things you have to do to get it right. One of those things is to set the size you want for non-image content. Or, as you could read in the docs: There are three rev options that should be assigned to each non-image anchor: "width", "height" and "scrolling".

The reason why you are not getting the sizing you want on your swf file in floatbox is because you have not assigned any sizing to it. Only images report their native dimensions. An .swf file does not have native dimensions to use in setting up its display. Those same docs will tell you how to assign options, including width and height, whether through normal anchor configuration or in the javascript function calls. If you want the floatbox display of your swf content to be a particular size, tell it what that size is.
gwolson
Guest
Admin,

I'm sorry, I definitely understand the rev options. I've used them to successful effect on my resume page which is solely built out of HTML. I've had no issues specifying the content size of the .swf files. And yes, I didn't understand the default settings to begin with in Floatbox, but I think I understand now that in terms of Flash content it defaults to full screen and what not (as opposed to image size where it auto detects size of image and uses that as the basis for the Floatbox window.)

My concern however is this. On my Flash driven index page I'm using the following code on one of the buttons:
on (release) {
getURL("javascript:fb.start({href:'Productions/Operas/Butterfly.swf' rev='width:1030 height:520 scrolling:no'})");
}

And this doesn't seem to work at all. The button indicates that it is click-able, but doesn't actually do anything when clicked.

Other buttons on the page with the code:
on (release) {
getURL("javascript:fb.start({href:'Productions/Operas/Butterfly.swf'})");
}

Do indeed work just fine, but the content isn't sized properly due to my not having specified the rev information.

So I'm not getting the coding right on the button where I have specified the rev options, and I don't know how to alter them within Flash to make them work properly on the page when loaded online. I will continue reading through the Floatbox documentation, thank you for your assistance.
Administrator
Registered: Aug 2008
Posts: 3382
Sorry Gordon, I got lost as to what the problem is you're looking for help with. I understood that your flash was firing, but that you didn't like the size it was being displayed at. The absence of sizing options on the floatbox call you quoted would explain that.

On this one, that is not showing, your floatbox call syntax is incorrect. Yours is:
fb.start({href:'Productions/Operas/Butterfly.swf' rev='width:1030 height:520 scrolling:no'})


The correct syntax is
fb.start({href:'Productions/Operas/Butterfly.swf', rev:'width:1030 height:520 scrolling:no'})


Look for the difference around the word "rev".
The parameter to the start function is a single javascript object of name:value pairs. The names and the values of each pair are separated by a colon. Each set of name:value pairs is separated from the others with a comma.

Cheers...

Page: 1