Help the passage of a variable JavaScript to ActionScript.

My goal is to pass a JavaScript variable in ActionScript in my swf file. I am using Flash CS3 and AS3.

Currently, all I want is my test to work where I hover over a text link and a function is called with a past

variable in my swf file.

Here is my code:

test.html - Cropped excess code

< html >

< head >

< script type = "text/javascript" >


function myMovie (movieName) {}
If (navigator.appName.indexOf ("Microsoft")! = - 1) {}
return window [movieName];
}
else {}
return document [movieName];
}

}

function sendToActionScript (str) {}

myMovie("accelachart").sendToActionScript (str);

}

< /script >

< / head >

< body >

< a href = "#" onmouseover = "sendToActionScript ('closed')" > click < /a >


< object width = "320" height = "190" id = "accelachart" >
< param name = "movie" value = "accelachart.swf" >
< embed src = "accelachart.swf" width = "320" height = "190" name = "accelachart" > "
< / embed >

< / object >

< / body >

< / html >

accelachart.swf - Cropped excess code

ExternalInterface.addCallback("IsStatic",IsStatic) ("sendToActionScript", fromJS);

function fromJS (isClosed)
{
currentSpeed = 0;
}

PS - as a supplementary question, I need to run ExternalInterface.addCallback("IsStatic",IsStatic) ("sendToActionScript", fromJS); only once, or inside my onEnterFrame(event:Event) function loop? I tried both, but since I can't make it work I don't know which is the appropriate injector.

Looks like your syntax is correct.

I think by the time you write ExternalInterface your html wrapper is not yet ready and Flash cannot save the JS function. Perhaps one of the ways is to ensure there is external interface. For example, you can create a timer and check periodically if ExternalInterface is available. Once it is - register function JS:

var timer:Timer = new Timer(200);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start();

function onTimer(e:TimerEvent):void {
     if (ExternalInterface.available) {

ExternalInterface.addCallback("sendToActionScript",fromJS);
     }
     timer.stop();
     timer.removeEventListener(TimerEvent.TIMER, onTimer);
     timer = null;}

Tags: Adobe Animate

Similar Questions

  • Need help with passage of a variable in a function

    Hello. I'm working on a Flash application that needs to play videos. I have the code using netstream that works very well for a movie. The problem is I have 3 movies that I want to play and I need to find a way to replace the string variable with the information of correct path depending on what button is pressed. I think this must be a table that I coded, but it does not work. Here's the code:

    var buttonArray:Array = [chamber.btnV01, chamber.btnV02];

    var strSource:Array = ["HiFlow_Conventional_4.mp4","Tool_Less_5.mp4" "];

    trace (buttonArray)

    for (var i: int = 0; i < buttonArray.length; i ++) {}

    buttonArray, [i] .addEventListener (MouseEvent.CLICK, playClicked);

    }

    function playClicked(e:MouseEvent):void {}

    check, if the FLV has already begun

    to download. If so, resume playback, else

    load the file

    {if(!bolLoaded)}

    var clickedIndex:int = buttonArray.indexOf (event.currentTarget);

    nsStream.play ([clickedIndex] strSource);

    bolLoaded = true;

    trace (strSource)

    }

    else {}

    nsStream.resume ();

    }

    Is given just to two buttons for the tests. I get the "'1120: access of undefined property event." the straight line to the 'nsStream.play (strSource [clickedIndex])";." The variable strSource is what I'm trying to pass paths different film in, but I'm having no luck. Will put it straight up or y at - it another way to do this? Any help would be appreciated. Thank you.

    -Shawn

    use:

    var buttonArray:Array = [chamber.btnV01, chamber.btnV02];

    var strSource:Array = ["HiFlow_Conventional_4.mp4","Tool_Less_5.mp4" "];

    trace (buttonArray)

    for (var i: int = 0; i< buttonarray.length;="" i++)="">

    buttonArray, [i] .addEventListener (MouseEvent.CLICK, playClicked);

    }

    function playClicked(e:MouseEvent):void {}

    check, if the FLV has already begun

    to download. If so, resume playback, else

    load the file

    {if(!bolLoaded)}

    var clickedIndex:int = buttonArray.indexOf (e.currentTarget);

    nsStream.play ([clickedIndex] strSource);

    bolLoaded = true;

    trace (strSource)

    }

    else {}

    nsStream.resume ();

    }

  • Help the passage of the document class for the class of database!

    Hello comrades!

    I thought that I ve solved that problem, but I was wrong

    I created a movieclip with a star. Then I create a document class and I named it like Main.as.

    In this document class that I wrote:

    package 
    {
         import flash.display.*;
    
         public class Main extends MovieClip
         {
              var st:star=new star();
    
              public function Main()
              {
                   stage.addChild(st);
                   st.x=20;
                   st.y=30;
              }
         }
    }
    

    If I run this code, I will get a star on the stage in the x direction and y positions.

    Now, I want to drag the star with the mouse and drop it anywhere on the stage. After the fall, the star must return to its original position.

    To achieve this, I create a new AS3.0 class. I named it DragDrop.as, and I linked to the movieclip as the baseclass.

    Inside this category I wrote:

    package 
    {
         import flash.display.*;
         import flash.events.MouseEvent;
    
         public class DragDrop extends MovieClip
         {
              var x_origin:Number;
                    var y_origin:Number;
                    public function DragDrop()
              {
                            x_origin=this.x;
                            y_origin=this.y;
                            trace(x_origin);
                            trace(y_origin);
                   this.addEventListener(MouseEvent.MOUSE_DOWN,drag);
              }
              function drag(evt:MouseEvent):void
                    {
                   this.startDrag();
              }
         }
    }
    

    I m not posting the code here, but you can easily see that the use of variable I m x_origin and y_origin to keep the original position of the clip.

    I'll use them to bring star back in its original position.

    The problem is that instead of being respectively 20 and 30, retracing their I see that they are both ZERO.

    So, when I drop the star, instead of going to x = 20, y = 30 back to x = 0 and y = 0.

    I ve for the position of Star compared to the scene, but I can´t find anyway!

    Could you help me?

    Thanks in advance!

    Best rgds

    Eduardo

    I think I see... you have:

     stage.addChild(st);               st.x=20;               st.y=30;
    

    for the init works in the star before set the position... so still 0,0. You can set the x, y front sets addChild... or you can change your star class to accept the position in the constructor. And then you'd like: var st:star = new star (20,30);

  • Simple question on the passage of ID variables in a url after you add a new record

    Hello;
    I know it's a simple question, I have a brain block. I'm going from a form and insert a new record in the db, but after I insert the new record, I want to pass the ID variable that gets are entrusted to him. How can I do this?

    It's my code to insert:

    < cfset EventDate = "#DateFormat(form.eventDate,"mm/dd/yyyy") #" >
    < datasource = "" #APPLICATION.dataSource # cfquery "dbtype ="ODBC">"
    INSERT INTO events
    (title, eventDate, eventTime, location, contact, telephone, fax, email, URL, sponsor, body)
    VALUES (< cfqueryparam cfsqltype = "cf_sql_varchar" value = "#form.title #" >,)
    < cfqueryparam cfsqltype = 'cf_sql_date' value = "" #EventDate # ">,"
    < cfqueryparam cfsqltype = "cf_sql_time" value = "#form.eventTime #" >.
    < cfqueryparam cfsqltype = "cf_sql_varchar" value = "#form.location #" >.
    < cfqueryparam cfsqltype = "cf_sql_varchar" value = "#form.contact #" >.
    < cfqueryparam cfsqltype = "cf_sql_varchar" value = "#form.phone #" >.
    < cfqueryparam cfsqltype = "cf_sql_varchar" value = "#form.fax #" >.
    < cfqueryparam cfsqltype = "cf_sql_varchar" value = "#form.email #" >.
    < cfqueryparam cfsqltype = "cf_sql_varchar" value = "#form. "URL #" >.
    < cfqueryparam cfsqltype = "cf_sql_varchar" value = "#form.sponsor #" >.
    < cfqueryparam cfsqltype = "cf_sql_longvarchar" value = "#form.body #">) "
    < / cfquery >
    < cflocation url = "events_RecordView.cfm" >

    In the cflocation I want to pass the variable ID, how about a new record?

    Thank you.

    CFmonger

    Try this. This will select in the query exactly what was inserted just enter the id and pass id just to get in the variable. If two people fill out the form at the same exact time, that assure that they are redirected to the appropriate page.

  • Helps the guest of session variable and dashboard

    Hi, I ran into soemthing that I can't understand.

    In the administration tool, I defined a CURR_MONTH session variable and set the query to find month max in the date dimension. It's all works fine - if I test the variable in OBIEE administration tool, it currently returns "January 2010".»

    In addition, in the responses, I can create a query that moves back calendar information and then put a filter on it so the specific columns is equal to the session variable. It works perfectly - I get the 3 lines of return data that correspond to the 3 days of data we loaded for January 2010.


    However, now that I'm trying to do is set a dashboard with the dimension command prompt date in it. I want the default to months / year equal to the value of CURR_MONTH. However, when I do this, instead of getting the correct value, for some reason some, it becomes the default value I put in place for this variable.

    Any ideas on what I am doing wrong or if it is a bug?

    Thanks in advance,
    Scott

    p.s. using OBIEE 10.1.3.4, with no applied patches. I'll upload pictures when I get home... is not a way to their work stations.

    Hi Scott,.

    I just tested and it works fine for me.

    (1) in your DB guest pass by default to
    (2) select the Server Variable
    (3) NQ_SESSION. CURR_MONTH
    (4) save and test

    Well, that should work for you. Here is a link to a jpg file that you should probably keep for future reference. She'll show you the proper syntax to use in different situations.

    http://shivabizint.files.WordPress.com/2008/10/OBIEE-variables-overview.jpg

    -Joe

  • with respect to an application to turn with the help of a global static variable

    Hello. I've read a few articles on JavaFX competition, and as a beginner, so I have to practice on this subject. Now, I'm trying to implement a turn-based application which can be played between 3 to 6 players. Furthermore, I use a scene from a .fxml file and I need to update it properly depends on certain calculations of each thread (in other word players). My main problem is, I don't want to use a while loop that checks the status of similar game;

    While (GameState! = State.GAME_OVER) {}

    currentPlayer = GameBoard.getNextPlayer ();

    perform certain actions, calculations, etc.

    }

    So, I want to use threads to work instead while loop. I guess only with the help of the Service used to iterate class and assign the next player will be adapted to instead of using the while loop and the tasks for the calculation of each player, or waiting for a few responses of human players on the UI account, however, I am faced with two problems.

    1. It has a global static variable (like the GameState which is an Enumarator) determines the State of the game, so it should be updated and must be verified by each round. Is it possible to do this?
    2. How can I get rid off this while loop?

    I would like for each answer. Thanks anyway.

    It shouldn't make too much difference. The basic idea is that you have a model class that represents your state of the game (the class of game in example jsmith). When a player makes a move, you update the game state. Because this will result in changes to the user interface, this update must be performed on the Thread of the FX Application.

    If the player makes the passage is a human player, the move would be done by a user action (mouse click or press button, etc.); This will be handled on the FX Application thread in any case.

    When the State of the game changes so it is in an "artificial" player's turn to move, have the object representing the artificial player calculate his next move and then update the game state. Since it is a response to the evolution of the game state (it is the artificial player's turn), it will also be on the Thread of the FX Application.

    The only (slight) complexity comes if the calculation of displacement for the artificial player takes a long time. You don't want to perform this calculation of long duration on the Thread of the FX Application. To handle this, the cleaner is to start a task that computes the desired pass and then updates the status of the game when travel is ready. So, something like this:

    GameState game = ... ;
    // UI is bound to the game state.
    ExecutorService executorService = ... ;
    // ...
    
    final Player currentPlayer = game.getCurrentPlayer() ;
    final Task calculateMoveTask = new Task() {
         @Override
         public Move call() {
              Move move = // compute next move...
              return move ;
         }
    };
    
    calculateMoveTask.setOnSucceeded(new EventHandler() {
         @Override
         public void handle(WorkerStateEvent event) {
              gameState.makeMove(currentPlayer, calculateMoveTask.getValue());
         }
    });
    
    executorService.submit(calculateMoveTask);
    

    If you make a thread more than that, you're probably do badly... Also, there should be no need anything it either, will be held in a "global" static variable (the idea above is the only structural change you the example posted by jsmith).

  • the values of simple variables share .swf files

    I need to send three simple film of mother variable values to subsequent files .swf test-tube. I use loadMovieNum() to load external .swf two files replace the film of the mother and also to sit top and can't get the values of the variables to pass from one to the other. I have to load them from an external file, or do something fancy. I just need the film to retrieve the values of the film of the mother who gave birth there.

    Thanks in advance.

    I had a similar problem, since I started to learn As.

    use _global.variableName = "no matter."

    Let's say that you need to pass the variable "tom" of the film at the cinema

    Try this...

    _Global.myName = 'tom '.

    in another film use

    theText_txt.text = MyName;

    It would create dynamic text with instance name equal to your global variable "theText_txt" in this case, "tom."

    I would start here.
    try to look for the passage of the variables or global variables and see what happens in the posts previous forums.

    I hope this helps.

    Sky

  • Black screen with blinking cursor after the passage in MSC mode

    I followed the recommendation to disable startup secure in the Bios then move the UEFI Bios to the CSM. But when I go to set up what I see is a black screen with a stable cursor in it. And it doesn t go in the Bios.

    The black screen remains.
    I turn off the laptop and once again now, but I still have a black screen with a cursor that is stable and that s it.

    It's like that and it doesn t go to windows even go into the Bios, I can t.
    What should I do?

    Help, please...

    Hello

    After the passage of the CSM and disabling secure boot UEFI mode, you will not be able to boot from the HARD disk as the installation of Windows 8 requires secure boot and the mode of the UEFI.

    Now you can boot from the disc or other media bootable (USB flash key) to install the Windows 7 system.

    I guess you've made these changes installed Windows 7. Right?

    By the way: what model of laptop you have exactly?

  • How to set the value of a variable in automator?

    I'm totally new to automator I found a post that I try to reuse

    to Re: copy multiple files from TextEdit in one Word file

    I want to open a series of html files in a folder and convert in a TextEdit rtf file.

    However, I am unable to automator find out how set the value of a variable such that it appears in this post

    I looked at every command in library without a lot of fortune

    Any help?

    Thank you

    Dan

    Its in Utilities.

    In Automator, use the search box:

  • JavaScript does not work although Java has been installed correctly and enabled javascript in the menu options. Surprisignly javascript works fine in Internet Explorer.

    I installed FireFox 3.6.9 and after while JavaScript began to malfunction, even if I have the latest Java installed (Java 6 Update 21) and JavaScript enabled in my Options menu. I tried already several times to reinstall Java and Firefox as well, but nothing helps, the Firefox browser still don't know the java installed. I am running Windows Vista. I had the same problem once a long time ago, but don't remember, how I solve it. Otherwise, I was really happy with Firefox and wishes to continue to use it, however, without Javascript runs it's useless.

    To avoid confusion: http://kb.mozillazine.org/JavaScript_is_not_Java

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of your modules is causing your problem (switch to the DEFAULT theme: Tools > Modules > themes).

    See the extensions, themes and problems of hardware acceleration to resolve common troubleshooting Firefox problems and troubleshooting questions with plugins like Flash or Java to solve common Firefox problems

  • Mac Pro is not displayed after the passage of the screens

    OK, so this is a strange problem but it's very annoying (at least for me). I just bought a LG Ultrawide 29 "display and connected via a HDMI cable to my Mac Pro (Home machine) and a second HDMI cable to my Macbook Pro (desktop computer). The Mac pro / Macbook pro good work with the big screen, HOWEVER, when I use my Mac pro and select the tilt of the screen to switch to the HDMI 2 connection, it works and rocking on my Macbook pro. But when I try to switch it back to HDMI 1 (Mac Pro), it comes back with a black screen and says no signal. Even if I plug the HDMI cable it does not work. I set the timer to 3 hours sleep, doesn't always help. I know he's not missing sleep because itunes can be played when I spend and still playing music throughout and continued when I try to switch back. The only way I could get is long, press the button on my Mac Pro and restart.

    The only reasonable difference that I know is that the Macbook pro is running Yosemites, while my Mac Pro running Beta El Capitan. I have a feeling, this is probably the cause, but I just wanted to know if someone has solved this problem somehow.

    Thank you

    Hello Hemlock70,

    Thank you for using communities of Apple Support.

    I understand that your external screen remains completely black, with a message no signal, during the passage of the views.  For assistance with this problem, please go through the steps in the link provided below.

    Get help with graphical problems on external displays connected to your Mac.

    Take care.

  • Causing problems of custom data type to deploy the shared target RT variable

    I seem to have some difficulty in using a shared variable published network created from a customized data type when it is deployed as an executable on a target of cRIO RT.  I'll start by describing why I think that this is the rub.  I created my RT VI in the LabVIEW (LV 2012) development environment and everything works fine.  This VI is quite simple, because these were quickly devolved into an exercise in debugging.  The RT VI begins by simply flashing the LED to a couple of times and then starts a loop simple acquisition to read some values out of the material using the analytical engine (while still flashing the LED of the user).  After reading the material, the values are grouped in a cluster and written in a shared variable published to the network defined by a custom control type def.  The custom control contains five floats double precision.  If it's important, the RT cRIO system hosts the shared variable in this case.

    So I have that deploy in the development environment, and everything works fine.  The LED flashes merrily along, telling me that the program runs correctly.  Running a VI host who reads the shared network has published variable gives the desired result.  Everything is good.

    Now, I want the cRIO system to run this simple program by itself at startup.  I build, set it as start VI, deploy it, and then restart the cRIO target.  The LED never flashing... the VI doesn't seem to work.  I'll spare you the major part of the work of debugging and access to the end.  I basically "diagram Disabled" various sections of the code up to the VI began to run correctly in an executable file.  I kept reducing the size of the disabled code until something has been disabled: the writing in the shared variable for the custom data type.

    So, I guess my question is this: are custom data types defined by type def would be personalized orders authorized executables to RT?  I read through the cRIO Developers Guide, my book of development in real time course of NOR and the white paper using shared Variables and I see nothing that forbids it.  I know that there are things not allowed in the executable files that are allowed in the development environment (property nodes façade, dialogue live, operating system specific calls, etc.), but no mention of the shared variable type custom data.  Any ideas as to why my VI is running in the development environment, but does not update unless I have delete the entry on the published network variable shared?

    Thank you in advance for your help!

    You must disconnect the data types of variables and then recompile. You can find it useful to keep on disk, a copy of the original lvlib.

    Don't know if this is a bug or not. It was suggested by someone in the forum that putting the ctl files in the right position (the disk? in the draft?) would allow the rtexe start; I did a quick check and it didn't work then I dropped the tests more far.

  • Executable does not connect to the hosted PXI shared Variables

    Hello

    I'm developing an application to run with RTE 8.2.1 on Windows XPe machine. Data are passed through network shared Variables in a target RT PXI. I developed on a laptop with the top Suite Developer Pro and everything works wonderfully here. When I create a program installation (and an EXE version) and on the port to the XPe machine, variables don't connect with each other (as seen to drag the control to the public Service, view the small arrow to the right to the status of the connection). I think it's due to not having the right drivers on the target XPe. Do you have any suggestions as drivers that I should include in the installation properties? I currently have:

    OR LabVIEW 8.2.1 RTE

    Engine OR Variable

    And NI-DAQmx is already installed on the machine (I think... a previous installation, the wizard sees a newer version about this than what I'm trying to install). I have also included the library with the shared variables in the properties of the EXE in the part of the Support files.

    I know this is a very old version of LV, but if you have ideas, or things to check, I would be very happy to help.

    Thank you!

    I understand the problem!

    In the structure of the Project Explorer files, I had included the buttons under the heading of the library (HMIvariables.lvlib), with the rest of the variables. I guess when you try to deploy by programming, he's trying to deploy the control files and get the dreaded error 1. I moved out of the library control files in Project Explorer and it fixed the issue and deployed the library, as verified by the Manager of shared Variable.

    I got 1 Core 3, and on the RT 1 and 2. Nobody never mentioned against it and could not find any documentation talking about do not do. I hope it helps someone else!

    Thanks for your help.

  • How to measure the difference in time between the passage by zero of a sine wave and the rise time of a pulse on a same graphic?

    I have a sine wave of 50 Hz and a pulse of the signal on the same chart. The difference in phase between the two is between 0-90 degrees.

    Now I need to calculate the time difference between (when the sinusoidal wave passes through zero volts) and (when the pulse increases). The frequency will remain about even for the two signals.

    The request is for a three-phase generator. In simple terms, when the difference in time between the passage to zero of the sine wave and pulse increases increases, it means that the load on the generator has increased.

    I am a novice user of LabView (version 9, 2009), maybe it's a very simple problem but I was pulling on my hair for the past few days and couldn't understand anything. Any help would be greatly appreciated. I use DAQ USB-6008 to measure these tensions and the impulse of the generator and a sensor

    I have attached a jpg file (a graphic that I just did with excel to explain). The time 't' is what I'm trying to measure

    See you soon

    Zdzislaw

    Awais.h,

    For problems of this kind I recommend start writing the granular steps you would take to manually fix this problem.  You can't say LabVIEW (or any programming language) If you can't succinctly describe the solution to your problem.

    The I want to address this problem is to:

    1. find all the zero crossing points and edges on the rise
    2. for every rising edge find the difference between the timestamp and previous passage by zero

    Here is an implementation of this algorithm LabVIEW:

  • How can I see where the letters are on the keyboard after the passage for the french, Spanish or German

    I use a standard keyboard, but write in Spanish, German and French and English. How can I see a Visual of the key Governing Council after the passage of languages so I know where the special keys are for each language?

    Tuesday, July 17, 2012 17:42:37 + 0000, DavidSouthard wrote:

    I use a standard keyboard, but write in Spanish, German and French and English. How can I see a Visual of the key Governing Council after the passage of languages so I know where the special keys are for each language?

    If I were you, I would not go to all languages. You can get all the
    These special letters on the English keyboard with the help of a third party
    program. I use a program background small freeware called AllChars.
    This allows me (in all applications, type many common special characters
    (many of them are used in other languages) by pressing the key ctrl
    followed by a combination of two-character mnemonics.

    For example, for n the two characters are ~ and n. "C is for c, and, for u, you and.

    To get it, go to http://allchars.zwolnet.com/

    Ken Blake, Microsoft MVP

Maybe you are looking for

  • Video and audio question on NB510

    While watching the video (via the Internet or the hard drive), it begins to freeze, and I can hear vibrate sound from speakers. The same thing happen with a helmet too. I send it to customer Service. They changed them both, but the problem has not di

  • How can I move files downloaded (e.g. mp3) in a folder

    I downloaded music files using the version of Android, but FireFox does not use the same download folder.When I access those files in FireFox, no option to move them to the folder where I want them - or do anything else with them except remove them.

  • Add a point to a 3d object

    Hello I use the object creation of cube to create vi and vi the of the control library of 3d images to create a cube.  Is there a way I could add a point on a face on the cube?  I just want to select some point on the cube and have a point that I see

  • Why can I not connect to ms money 2007 with xp OS? identification of phase of rejection

    I can not connect to my microsoft money 2007 using my windows Live ID.  Microsoft say that they cannot help me.  Ms money dialog box and says my sign in information cannot be verified.   I called microsoft and updated all my information and reset my

  • always using plugged my laptop will damage my battery?

    If I always use my laptop connected and drain my battery once in 5-7 days, there will be no problem to my laptop battery?