Using AS2 to Call JavaScript w/ External Interface: What Am I Doing Wrong?

I am trying to trigger a JavaScript fuction from inside a
Flash 8/AS2 movie created by my coworker. The JS function is called
disappear(), which is meant to close the DIV that contains the
flash movie itself.
I know the JS works in all my target browsers - it's been
tested already. Now I need working ActionScript. The ActionScript
I've been studying is 3.0 so the fact that this task must be
accomplished in AS2 makes it that much harder for me; I know very
little about the way Flash Virtual Machine 1 works so I don't know
where to begin with the code.
I would like to implement this one of two ways:
Preferred Method: I'd like to create an AS file that I can
send to my coworker for inclusion in his FLA along with any code
necessary for linking the button instance to the class in the AS
file (don't think code is necessary; linkage done during
right-click on library panel, right?)
Alternative Method: I'd like to send my coworker text that he
can simply drop into the first frame in the movie to make it go.
I started out trying to call the javascript with on(press) {
getURL("avascript:myFunction"); }, which worked in Firefox but not
in IE6 or 7. Then I read over the tutorial here:
http://www.adobe.com/devnet/flash/articles/external_interface_print.html
and switched to using ExternalInterface.call() instead. That's
where I am now. My brain is hurting trying to dig up answers for
AS2 without reference materials... You are my best hope.
Please help me make sense of this ActionScript 2.0 code with
one of the prefered methods above. I am away from my copy of Flash
8 - I'm using FlashDevelop here at work - so I'd appeciate if you
could test any suggestions you make before you make them - unless
you are a Flash genius who I should not be questioning :) I've
provided the HTML/JS code; all you have to do is make a 500x300 SWF
and put a button instance in it.
----------------------------------------The attempt at
ActionScript 2.0 (don't
laugh)----------------------------------------
import.flash.external.ExternalInterface;
class JsCallerButton {
private var _caller_btn:Button;
//Constructor
public function jsCallerButton():Void {
this._caller_btn:Button = new Button();
this._caller_btn.addEventListener("click", clickHandler);
//Event handler for event set in class constructor
function clickHandler(eventObj:Object):Void {
ExternalInterface.call("disappear");
----------------------------------------The
HTML/JavaScript----------------------------------------
<html>
<head>
<script>
var timeout;
function appear(){
var the_style = getStyle("floatingflash");
if (the_style) {
var current_top = parseInt(the_style.top);
var new_top = current_top + 5;
if (document.layers) {
the_style.top = new_top;
} else {
the_style.top = new_top + "px";
if (new_top < 150) {
the_timeout = setTimeout('appear();',10);
} // appear
function disappear() {
var the_style = getStyle("floatingflash");
the_style.display = 'none';
} // disappear
function getStyle(ref) {
if(document.getElementById &&
document.getElementById(ref)) {
return document.getElementById(ref).style;
} else if (document.all && document.all(ref)) {
return document.all(ref).style;
} else if (document.layers && document.layers[ref]) {
return document.layers[ref];
} else {
return false;
} // getStyle
</script>
<style>
#floatingflash {
position:absolute;
border:1px solid red;
background:white;
</style>
</head>
<body onload="appear();">
<div id="floatingflash"
style="top:-400px;left:-150px;margin-left:50%;">
<!--This 'X' link is for manual calls to the function that
should be triggered from inside Flash-->
<a href="javascript:disappear();">X</a>
<p>  </p>
<p>
<object
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="
http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"
width="500" height="300" title="Hover Ad">
<param name="movie" value="
http://------------------------------/500x300.swf"
/>
<param name="quality" value="high" />
<embed src="500x300.swf" quality="high" pluginspage="
http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="500"
height="300"></embed>
</object>
</p>
<p><a
href="launch.html">Back</a></p>
</div>
</body>
</html>

Thank you for your response. The drives are in fact different letters -- I changed the drive name to correspond the original drive letter...but that doesn't seem to have fixed the problem.
Where I seem to stand is:
Old computer (with iTunes library) + external hard drive (with iTunes music) work just fine.
New computer -- iTunes library copied from old computer, iTunes music folder identified in iTunes, but iTunes can't find the music.
At this point, am I better off starting from scratch with the new computer (in terms of installing iTunes and moving my library over from my old computer)?
And if so, what would be the best way to approach this?
Thanks much.

Similar Messages

  • I'm trying to activate my new 4S and I can't make any calls -it says "No Service" What am I doing wrong?

    I followed all the prompts and plugged my new 4S into my desktop, everything has sync'd but I still can't make any calls. It's obviously not connecting to the network. What am i doing wrong?

    Do you have a SIM in the iPhone?

  • New computer -- can't find music on external drive - what am i doing wrong?

    I have searched previous posts and cannot seem to find an answer.
    Up until recently, I ran iTunes from my desktop, and housed the music on an external hard drive. Recently, I purchased a new laptop and transferred applications and files over from the desktop using Windows Easy Transfer.
    I thought that simply pointing my laptop to the iTunes Music Folder location on the external hard drive was all I needed to do (F:\iTunes\MyMusic) but I seem to be mistaken, as I am getting the “iTunes cannot find the original files” messages when I click to play songs.
    Have I missed something incredibly obvious here? I’ve been futzing around with this for a while now and tend to think I am missing the easy fix.
    Thanks in advance for any assistance you may be able to provide.

    Thank you for your response. The drives are in fact different letters -- I changed the drive name to correspond the original drive letter...but that doesn't seem to have fixed the problem.
    Where I seem to stand is:
    Old computer (with iTunes library) + external hard drive (with iTunes music) work just fine.
    New computer -- iTunes library copied from old computer, iTunes music folder identified in iTunes, but iTunes can't find the music.
    At this point, am I better off starting from scratch with the new computer (in terms of installing iTunes and moving my library over from my old computer)?
    And if so, what would be the best way to approach this?
    Thanks much.

  • I have a lot of friends with an iPhone or iPad,which I can send them messages,but there is one person I can't,I'm in the uk and she is in the us the number she apparently uses to log in is not being recognised,what am I doing wrong

    My iMessages work with most of my friends apart from the one that lives in the US,I'm in the UK,the number she uses is to log in,but when I type her name in it says not registered with iMessage,and I don't understand why,is it because with the added international code because I've tried with and without it with no success,please help

    Something doesn't seem right here. If she has to use her email address as her contact address in order to message with you, that suggest to me that she either doesn't meet the requirements to use her iPhone number as the contact address (iOS 6 or later with an iPhone number linked to her Apple ID) or there is an issue with the way the phone number is being entered.

  • Many of my songs have a "!" next to them and it says the song could not be used bc original file could not be found, what am I doing wrong?

    Help

    Your iTunes may have lost track of your music file location, you may find many of the songs in Itunes music library to precede with an ! symbol. 
    Do you know where is the location of the original music file?
    If so, double click a song with ! mark on side, you will be given an option to locate the file where the song is held. Select "locate" and direct it to your folder / file where the song is and open it.
    iTunes then will give you the option to use this process to update all of your library. OK that as this will do it automatically instead of fixing them one by one.

  • My iMac can not see my mini Mac via Airport extreme using host name, only via IP address. What am I doing wrong ?

    I have an iMac and a mini Mac attached to the same Airport extreme. It would appear that Bonjour works because I can see the hostname of the mini Mac server in Finder on the iMac.
    But if I type in the host name (myminimac.private) in the Safari browser at the iMac it can not find the mini mac. However if I type in the IP address of the mini mac server it can see the see it.
    It used to work but I must have done something to mess it up.
    Anybody any suggestions ?

    You have the wrong card. You need the original AirPort card for your G4.
    ...how the **** do i get the Superdrive to open up so i can put in a CD/DVD?
    If the keyboard has a media eject key, press that. If not, hold down F12.

  • Can't use my wireless keyboard after updating to iOS8, what am I doing wrong?

    I'M ready to throw it all out.  I've tried to charge it all night, I have used every different way to recharge it but it still will not work.  I've pushed the reset button as was suggested,but that didn't work

    What problem are you having?  You did not mention one.
    Does she have an iphone 4?
    iOS: Using FaceTime

  • In Aperture using the external photo editor Adobe photoshop elements 10 editor.  My photo will not come back to aperture unless the photo is saved on the desktop and then imported back to Aperture. What am I doing wrong?

    Using Adobe Photoshop Elements 10 Editor as external editor in Aperture.  The issue is once i make the changes in Photoshop it request that I save (use tiff) and the photo is not update in Aperture.  What am I doing wrong?

    Marianne,
    how do you save? Photoshop Elements can save either versions or overwrite the original file, afaik.
    You need to set the save preferences, so that it will write to the original file and not write a version. Also the filename extension should be "tiff" and not the default "tif" (I think you did that already).
    Regards
    Léonie

  • Have airport extreme, square model, have a external harddrive to use as back up(formated for mac)hooked it up to the usb port in back. can't find it on my computer. what am i doing wrong

    have the airport extreme, square model. have a external harddrive formated for mac hooked up to the usb port in back.
    i can't find the harddrive on the computer for back up in timemachine. what am i doing wrong?

    First, if you are not aware, you need to know that Apple does not officially support Time Machine backups to a drive at the USB port of the AirPort Extreme.
    That may be part of the problem here, so if you want to continue to try this, you need to understand that there are no guarantees of success.
    Some users do seem to be able to make this work, but most have some problems and some....like me....have nothing but problems when they try this.
    If you want to continue to try this, the first thing to verify is that the drive is formatted specifically in Mac OS Extended (Journaled). Have you verified that the drive is formatted correctly by connecting it directly to your Mac and using Disk Utility to check?
    Some drives that are advertised as being "compatible for Mac" are not formatted correctly in Mac OS Extended (Journaled). Time Machine has no chance of success unless the drive is first formatted correctly.
    I would also ask that you consider leaving the drive connected to your Mac for Time Machine backups. That will be supported, and is a far more reliable way to keep backups if your data is important to you.
    Next, we need to know what operating system you are running on your Mac. If you do not know, click the Apple icon in the upper left corner of the screen and then click About This Mac.  Post back with the OS X Version number that you see there.

  • I am trying to use siri. It was working earlier. Now when I ask it to call name and number it say, Siri keeps saying( SORRY SOMETHINGS GONE WRONG CAN YOU TRY AGAIN) I HAVE TRIED SEVERAL NAMES AND NUMBERS IN MY CONTACTS.   What am I doing wrong or how can

    I am trying to use siri, Siri keeps saying( SORRY SOMETHINGS GONE WRONG CAN YOU TRY AGAIN)
    I HAVE TRIED SEVERAL NAMES AND NUMBERS IN MY CONTACTS.
    What am I doing wrong or how can I correct it.

    Siri Fix
    Turn OFF Siri
    Reset Network Settings
    Turn ON Siri
    Done
    Steps:
    Tap Settings App>General>Siri>Turn OFF
    General>Reset, near bottom>Reset Network Settings
    Tap Settings App>General>Siri>Turn ON
    Done

  • AppleScript to call a Photoshop Script: what am I doing wrong?

    Hi All.
    I'm using AppleScript to try and call a photoshop Java script stored in my *** project.
    The basic set up is:
    Tell Application Photoshop CS3
    set myscript to POSIX path of ((path to me as Unicode text) & "Contents:Resources:Equipment_ProductSilosthumb.js")
    do javascript myscript
    end tell
    when i try and run the script i get the following error
    - Error 25: Expected: ;.
    Line: 1
    -> /Users/amannone/Production Tools CS3/build/Debug/Production Tools.app/Contents/Resources/Equipment_ProductSilosthumb.js (8800)
    If i embed the script in the apple script it will work ok.
    ie do javascript "insert js code here"
    What am I doing wrong?
    Software: Adobe CS3 Extended, Mac OS X 10.5, Xcode 3
    Thank for the help.
    -andrew

    Your description of the issue is not clear:
    What format, bit depth and color was your original file "from the net"?  It sounds like it was a Color Indexed GIF, which would cause what you are describing.
    In the Macintosh Finder, select said "net image" and do a Get Info on it (Command+i). When the Info box appears in the Finder, take a screen shot and upload it here by using the little camera icon in the Reply Editor in the forum's web interface.
    If the image is a 256-color GIF, remember the rule:  GIGO = garbage in, garbage out.

  • I make annotations to my photos in iphoto using preview. But once I have made the annotation I do not get the photo back in iphoto into the event from which I took the photo. What am I doing wrong?

    I make annotations to my photos in iphoto using preview. But once I have made the annotation I do not get the photo back into the event in iphoto from which I took the photo. What am I doing wrong? I am not using aperture

    For the annotations to display on the photo in iPhoto you must setup Preview as the external editor in iPhoto via iPhoto's Advanced preference pane.
    After adding the annotations just do a Save.  iPhoto will then recognize the change via a new modified version.  You can revert to the original at any time if you want to get rid of the text.
    OT

  • I am having trouble exporting .raw files to an external storage device.  Even though I export "original" they end up as jpeg files.  Any idea what I am doing wrong?

    I am having trouble exporting .raw files from my Mac Book Air to an external storage device.  Even though I am exporting as "original" they are being exported as jpegs.  Anyone have an idea what I am doing wrong?

    Using the "original" setting is the correct way to do it.  Select on of the photos and use the File ➙ Reveal in Finder ➙ Original menu option.  That will take you to the file inside the library via the Finder.  Confirm that what you see if the raw file.
    If it is then try the following:  make a temporary, backup copy (if you don't already have a backup copy) of the library and try the following:
    1 - delete the iPhoto preference file, com.apple.iPhoto.plist, that resides in your
         User/Home()/Library/ Preferences folder.
    2 - delete iPhoto's cache file, Cache.db, that is located in your
         User/Home()/Library/Caches/com.apple.iPhoto folder. 
    Click to view full size
    3 - launch iPhoto and try again.
    NOTE: If you're moved your library from its default location in your Home/Pictures folder you will have to point iPhoto to its new location when you next open iPhoto by holding down the Option key when launching iPhoto.  You'll also have to reset the iPhoto's various preferences.
    OT

  • Can not use my backup photos, what am I doing wrong?

    I am having problems using the photos from my external hard drive. I switch library, and get all the thumbs up in iphoto. When I try to edit them or export in any way, I am not allowed to. This is very frustrating, can anyone tell me what I am doing wrong?

    n555:
    Welcome to the Apple Discussions. The "!" in the edit window indicates that iPhoto has lost the link to the original file in the Originals folder. Check in the Originals folder to make sure you have the full sized image files in there.
    Did you rename or move any files/folders in the iPhoto Library folder from the Finder? That's one way to get the situation you're experiencing but it would be only for those you tampered with. Since it's the entire library then you've probably fallen victim to the damaged database file problem that hit a lot of users.
    If the full sized image files are there you can try to rebuild the library as follows: launch iPhoto with the Command+Option keys depressed and follow the instructions to rebuild the library. Select all of the options. I'm not optimistic that the rebuild will recover your library but it's worth a try.
    If the rebuild does not work you'll have to start a new library and import the image files from the damaged one as follows:
    1 - rename the iPhoto Library folder that's on the external HD.
    2 - launch iPhoto with the Option key depressed and, when asked, select Create a new library, navigate to the external HD and do so.
    3 - with the new library open, drag the Originals folder from the old library into the open iPhoto window.
    This will give you a new library with the same rolls as the old one. However you'll lose your albums, slideshows, keywords, etc.
    To help protect from this type of problem in the future check out the tip at the end of my signature.
    Do you Twango?
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.

  • I can't facetime with anyone, it starts the call and ends it immediately on its own. Any suggestions on what I am doing wrong?

    I can't facetime with anyone, it starts the call but ends it immediately on its own. Any suggestions on what I am doing wrong?

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It won’t solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of this test is to determine whether the problem is localized to your user account. Enable guest logins* and log in as Guest. Don't use the Safari-only “Guest User” login created by “Find My Mac.”
    While logged in as Guest, you won’t have access to any of your documents or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this behavior; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault in OS X 10.7 or later, then you can’t enable the Guest account. The "Guest User" login created by "Find My Mac" is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.

Maybe you are looking for