Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > Adobe Web Programming > BOOK: Beginning ActionScript 2.0
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ActionScript 2.0
This is the forum to discuss the Wrox book Beginning ActionScript 2.0 by Nathan Derksen, Jeff Berg; ISBN: 9780764577680
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ActionScript 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 9th, 2006, 03:42 PM
Registered User
 
Join Date: Dec 2006
Location: Grayson, GA, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to serpicolugnut Send a message via Yahoo to serpicolugnut
Default Javascript call inside of getURL

Hello -
I'm trying to execute a javascript command inside the getURL command inside of Flash.
The javascript command looks like this in the HTML:

Code:
<a href="javascript://" onclick="swapLayers('layer'); return false">Layer</a>
When I try to convert this to the getURL property like this:
Code:
getURL("javascript:onclick=swapLayers('layer'); return false");
...
I get a Syntax error. Does anybody have an idea on how to properly format the this js inside the getURL command?

Thanks

Reply With Quote
  #2 (permalink)  
Old December 15th, 2006, 03:39 PM
Registered User
 
Join Date: Dec 2006
Location: , , USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,

Your attempt is spot on. However, there's a caveat to what you are attempting.

In your original JavaScript, "onclick" is an event handler defined as an attribute of the <a> tag within the document object model of the web page. So the browser does the heavy lifting for you by associating this event with that specific <a> tag.

So what we need to do is take the contents of that onclick event and apply it to a new event. In this case we want the event to be controlled by the getURL event within Flash.

In this case, as long as the Flash is on the same page as where the function swapLayers is available, we can do the following.

Code:
getURL("javascript:swapLayers('layer');");
I am not quite sure why the return false exists at the end of the statement, so I removed it. If you are afraid IE will enact upon some return value via this getURL call then you should use the following syntax to void the return.

Code:
getURL("javascript:void(swapLayers('layer'));");

Reply With Quote
  #3 (permalink)  
Old December 16th, 2006, 11:29 AM
Registered User
 
Join Date: Dec 2006
Location: Grayson, GA, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to serpicolugnut Send a message via Yahoo to serpicolugnut
Default

I scrapped the previous javascript and went with using Macromedia Dreamweavers javascript code to show/hide layers. It works fine in Firefox and Safari, but doesn't do anything in IE6, and partially works in IE7 (in IE7 it shows the layers being swapped, but it doesn't hide the layer that it replaces).

I have an example loaded in my sandbox to see the behavior:
http://www.pixegen.com/sandbox/map.html

Any ideas on why it isn't working in IE, and how I might go about fixing it?

Reply With Quote
  #4 (permalink)  
Old December 16th, 2006, 12:24 PM
Registered User
 
Join Date: Dec 2006
Location: , , USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I noticed in your footer that you have the following:

<a href="javascript:" onclick="MM_showHideLayers('troup','','show')">Tro up</a>

This won't work. Try removing the href attribute, since the onclick is handling your event.

These JavaScript issues may be better answered in the JS forum at http://p2p.wrox.com/javascript-85/



Reply With Quote
  #5 (permalink)  
Old December 18th, 2006, 08:20 PM
Registered User
 
Join Date: Dec 2006
Location: Grayson, GA, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to serpicolugnut Send a message via Yahoo to serpicolugnut
Default

OK, I think I'm making *some* progress. But I've hit another issue with IE6/7 (works fine in Ff, Safari, etc.)

I have a mc that when the user clicks on it toggles a checkbox in a div. When the user clicks another mc (a back button), a getURL is called to load a javascript to swap back to another div, and then another getURL is called to uncheck all the checkboxes. It works as expected in every browser other than IE. It seems IE is only executing one of the getURLs. Is this a known limitation of IE, or have I hit upon another error?

I have all my files viewable (and downloadable) at http://pixegen.com/jstest/ . I am using Flash 8, but exporting my swf in Flash 7 format.

The button that triggers the getURLs that aren't working fully is the back button on each of the alpha, beta and gamma frames. I've tried swapping the order, but that just means one loads and the other doesn't. Any ideas?

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access ASP code inside Javascript deean JSP Basics 1 June 20th, 2008 02:00 PM
How to call normal "write" function inside a class jonen C++ Programming 3 May 25th, 2006 02:19 PM
getURL with javascript window.open properties nancy Flash (all versions) 9 June 4th, 2005 07:52 AM
ASP variable inside my JavaScript crmpicco Javascript How-To 1 June 4th, 2005 12:17 AM
Prb with js function call inside flash using XSL schander10 XSLT 3 September 14th, 2004 07:33 AM



All times are GMT -4. The time now is 05:37 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.