Calling a function in an external actionscript

Hi. First of all I'd like to put my hands up and say that what I know about Flash is antiquated (I used to work with Flash 4 / 5), and have now been thrown into the deep end, as it were.
I have an application that has a button component. In an external actionscript file there's an event listener that calls a function when this button is pressed. I want to replace the button with a graphic that switches according to whether the button is 'on' or 'off'. I've created a movie clip that cycles back and forth between the on and off states when clicked, but the trouble I'm having is getting it to call the function. I have no idea how to do it, other than to just include function_name(); (or call.function_name();) in the onRelease handler (which doesn't work). Is it possible to use event listners for movie clips (rather than components?) Or else how can I call this function? It should be really simple and I'm tearing my hair out trying to get it to work! The function is declared 'public', by the way...
Oh yes, this is ActionScript 1 (I think...)
Eternal thanks and gratitude to anyone who can help me...

Do you mean to copy it here, or copy it into the fla? I've already tried doing the latter, which doesn't work - the script imports other external as files and I think that that's messing things up. The function only seems to work when it's located in this external file. The function I'm trying to call is
public function toggleAudio() {
       //if (btnAudio.label == "Sound Off") {
       if (_root.audio == "mute" or btnAudio2.label == "Sound Off") {
           trace("toggleAudio AUDIO: Off");
           //btnAudio.label = "Sound On";
           _root.audio = "unmute";
                     // stop recieving audio from in stream
           ServiceLocator.getInstance().getService("nsService").returnInStream().receiveAudio(false) ;
           // stop sending audio on out stream
           ServiceLocator.getInstance().getService("nsService").returnOutStream().attachAudio(null);
                 } else {
           trace("toggleAudio AUDIO: On");
           btnAudio2.label = "Sound Off";
           _root.audio = "mute";
                     // start recieving audio from in stream
           ServiceLocator.getInstance().getService("nsService").returnInStream().receiveAudio(true);
           // start sending audio on out stream
           ServiceLocator.getInstance().getService("nsService").returnOutStream().attachAudio(Servic eLocator.getInstance().getService("camService").returnMic());
The bit at the beginning where I've commented some stuff out is where I've been trying out different things to get it to work.
For all intents and purposes though the function could be
public function please_work() {
trace("I work!");
All I need is for a way to call this from the main flash movie

Similar Messages

  • Why do button functions included in external actionscript not persist across frames?

    this one drives me nuts!
    if i include an external actionscript file in frame one of my
    movie, then [as you'd expect] all the functions, global variables
    etc contained in that external AS file are available throughout my
    movie - with one notable exception.
    if i add a button to the stage - in a frame other than frame
    one - whose onRelease handler is defined in the external AS, the
    function is not called when the button is clicked - i have to
    re-include the external AS file again on the frame in which the
    button resides, in order for the buttons function to be called.
    anyone know why this is - and if there's a way round it?
    how come all the other functions in the AS persist across all
    frames and all timelines in the movie, but the button handlers only
    seem to be available on the actual frame in which the AS file is
    included?
    download
    example

    I think you and I are dealing with similar issues and the
    root cause is referred to as "scope." The only difference between
    your and my problems is that your code is in an external as file
    and mine is on the timline. But in both instances, code that should
    work doesn't. Robert Reinhardt has covered this in an article at
    http://www.communitymx.com/content/article.cfm?cid=8E4DF.
    He is the author of the Flash Actionscript Bible series and so
    knows what he is talking about. I have been studying it for an hour
    and darn if I can understand the second page of it. I've asked for
    help myself about this at
    http://www.kirupa.com/forum/showthread.php?t=248316.

  • Calling a function from an external AS file

    I create a AS file that contains my DAO functions. I imported
    the class into my application, but what do I have to do to call one
    of its functions?
    In my ProjectDAO.as I have updateProject(projectID:Number),
    in my mxml I have a button that calls that function but I get a
    'function cannot be found' error.
    What am I missing?

    In your first post you said you wanted to call
    updateProject(projectID:Number).
    In your latest post you have this:
    <mx:Button label="New Project"
    click="PDAO.addNewProject(event)" />
    I think it should be this
    <mx:Button label="New Project"
    click="addNewProject(event)" />
    Where addNewProject is not in class ProjectDAO, but is the
    click handler function in the mxml file.
    Then within that addNewProject click handler you call
    PDAO.updateProject(projectID).
    If in fact addNewProject is another method in class
    ProjectDAO, and is an instance method, then create a click handler
    like myClickHandler(event) and do this:
    <mx:Button label="New Project"
    click="myClickHandler(event)" />
    and here is the handler function:
    private function myClickHandler(e:MouseEvent):void{
    PDAO.addNewProject(projectID);
    If instead addNewProject is a class method, call it like
    this:
    private function myClickHandler(e:MouseEvent):void{
    ProjectDAO.addNewProject(projectID);
    Your actual click handler function may differ, but these are
    some hints. If none of this makes sense, start by reading FB3 help
    topic Flex Programming Elements and all its sub-topics, compiling
    all the sample apps, otherwise you will find it difficult to
    proceed with Flex.

  • Using an external DLL with "Call Library Function"

    Hi!
    I am trying to use an external DLL which is used from Visualbasic & Delphi:
    http://www.keb.de/common/tools/KEBCOMDriver.zip
    the protKEB.dll accesses the serial port to control an KEB frequency
    inverter.
    Unfortunatly there is no prototype header file for the DLL (no help on that
    from KEB).
    I only have a VisualBasic example program which works with the DLL.
    (Unfortunatly I am no Visual basic expert)
    To initialize the com port I have to use the function: setprotproperties &
    getprotproperties
    they are declared as:
    'Setting the protocol properties
    'ctrl is a pointer to a data structure of type tProtProperty
    Declare Sub setprotproperties Lib "protkeb.DLL" (ctrl As Any)
    'Reading the protocol properties
    'ctrl is a pointer to a data structure of type tProtProperty
    'the desired protocol is entered in ctrl.prottype before calling
    Declare Sub getprotproperties Lib "protkeb.DLL" (ctrl As Any)
    and tProtProperty is:
    Public Type tProtProperty
    ProtType As Long 'Type of Protocol (tProt)
    TimeOut As Long 'ALL protocols
    Baudrate As Long 'ANSI, HSP5
    Comport As Long 'ANSI, HSP5
    Flag As Long 'ANSI, HSP5: 01 = Sendslow
    / IP: 01 = UDP
    Port As Long 'IPort number
    Txtlen As Byte 'IP : length of following
    text or 0
    txt As String * 100 'IP : IP-Address or name
    (maximum length)
    End Type
    I already tried to use a cluster with tProtProperty entries as an Input for
    the function
    setprotproperty in a call library function with:
    Parameter Type : Adapt to type
    Data Format: Pointer to Handle
    but I always get an "exception within external code....."
    What am I doing wrong?
    How does a cluster & a "call library function node" look like that works?
    Any help is really appreciated!
    thanks
    tom
    ,-Thomas Kerberger Physikalisch-Technische Bundesanstalt-.
    | Abbestr.2-12 D-10587 Berlin fon: +49-30-3481338 |
    | mailto:[email protected] fax: +49-30-3481386 |
    `--------Labor 7.33 Messung thermischer Energie---------'

    Thomas,
    LabVIEW cannot call a DLL that has structures directly, you will need to create either a wrapper DLL or CIN that will take in all of the data individually construct the structure, and send it to the DLL function.
    For more information on what a cluster looks like in native code, I would suggest creating a simple cluster, creating a Call Library Function Node on the block diagram with a cluster input. Then right-click on the Call Library Function Node and choose "Create .c file". This will generate the data structure for the cluster and give you a better feel for it. I would then suggest going to the Using External Code in LabVIEW manual that can be found in the LabVIEW Bookshelf (Start»Programs»National Instruments»LabVIEW 6»LabVIEW Manuals or »LabV
    IEW 6.1»Search the LaBVIEW Bookshelf).
    There is also the following: Developer Zone: Passing a Variety of Data Types from DLL to LabVIEW.
    Randy Hoskin
    Applications Engineer
    National Instruments
    http://www.ni.com/ask

  • An exception occured within the external code called by a Call Library function Node

    Good Morning,
    I built a VI that contains Matlab nodes in Labview 8.0.  I made an executable and gave it to a colleage to use who is running Windows XP.  I see in the folder C:\Program Files\National Instruments\Shared\LabVIEW Run-Time that she has 7.1 and 8.0 run time engines installed.
    On Friday the executable ran great on her machine.  Today, when she tried running it I received the following error.  "LabVIEW:  An exception occured within the external code called by a Call Library Function Node.  This might have corrupted LabVIEW's memory.  Save any work to a new location and restart LabVIEW.  'my vi' was stopped at node 0x0 of subVI "NI_AALBase.lvlib:Real A x B.vi:1".  This error occured after part of the program ran properly.  More specifically, two of the matlab nodes ran perfectly.  I am unsure about the third because the program stopped too early.  I do have to multiply two matrices using the subvi Real A x B.  Is this causing the error?
    I also saw this error when I installed it on another computer.  However I do not see this error when I run the executable or the main vi on my machine  I know there are other discussions on this topic, however I do not know why it would affect some machines and not others.  Also, I do not know why it would work on Friday and not on Monday.  Should I have checked the box that said "Enable Debugging" under the advanced section when building the executable?
    If anyone could help, I would be very appreciative.
    Thanks,
    -Richard

    molecularvisions wrote:
    Good Morning,
    I built a VI that contains Matlab nodes in Labview 8.0.  I made an executable and gave it to a colleage to use who is running Windows XP.  I see in the folder C:\Program Files\National Instruments\Shared\LabVIEW Run-Time that she has 7.1 and 8.0 run time engines installed.
    On Friday the executable ran great on her machine.  Today, when she tried running it I received the following error.  "LabVIEW:  An exception occured within the external code called by a Call Library Function Node.  This might have corrupted LabVIEW's memory.  Save any work to a new location and restart LabVIEW.  'my vi' was stopped at node 0x0 of subVI "NI_AALBase.lvlib:Real A x B.vi:1".  This error occured after part of the program ran properly.  More specifically, two of the matlab nodes ran perfectly.  I am unsure about the third because the program stopped too early.  I do have to multiply two matrices using the subvi Real A x B.  Is this causing the error?
    This is most likely an error with the use of the Call Library Node, but not in the Real A x B.vi itself. This is a VI that comes with LabVIEW and has been tried and tested many times and unless your LabVIEW installation is messed up simply shouldn't fail in such a way on its own.
    However you do include Matlab code somewhere and that might be more likely to cause this. Are you using the built in MathScript node or some other way to communicate directly to a Matlab DLL or such?
    Are you using anywhere Call Library Nodes that you have created or that did at least not come standard with LabVIEW?
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Calling a function in a swf with TLFTextField from an external program fails

    I have a program A that loads another swf B, and after B is loaded, A will call a function of B.  It used to work when B creates a TextField and uses TextFormat, but when I changed to creating a TLFTextField, I got this error:
    Reference Error: Error #1069:  Property loadCurrentPictureFromMenu not found on ECard__Preloader__ and there is no default value.
    at ECard/swfLoadCompleteEventHandler()....
    And also
    Warning: Ignoring 'secure' attribute in policy file from http://fpdownload.adobe.com/pub/swz/crossdomain.xml.  The secure attribute is only permitted in HTTPS and socket policy files......
    So I wrote these 2 programs to test this:
    ----------------------- Test B -------------------------
    import fl.text.TLFTextField;
    import flashx.textLayout.formats.TextLayoutFormat;
    import flashx.textLayout.elements.TextFlow;
    var myFormat:TextLayoutFormat = new TextLayoutFormat();
    myFormat.fontFamily = "Kids";
    myFormat.fontSize = 24;
    var tlfTextField:TLFTextField = new TLFTextField();
    tlfTextField.x = 50;
    tlfTextField.y = 50;
    addChild(tlfTextField);
    var myTextFlow:TextFlow = tlfTextField.textFlow;
    myTextFlow.hostFormat = myFormat;
    myTextFlow.flowComposer.updateAllControllers();
    tlfTextField.text = "Testing this";
    function changeText(string:String):void
         tlfTextField.text = string;
    ---------------------- Test A -----------------------------------
    import flash.net.URLRequest;
    import flash.display.Loader;
    import flash.display.MovieClip;
    var urlRequest:URLRequest = new URLRequest("testTLFTextField.swf");
    var loader:Loader = new Loader();
    loader.load(urlRequest);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadingCompleteEventHandler);
    function loadingCompleteEventHandler(evt:Event):void
         addChild(loader);
         loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadingCompleteEventHandler);
         var mc:MovieClip = evt.currentTarget.content;
         mc.changeText("We are here");
    I got Error #1069 again, but when I changed TLFTextField back to TextField, it works again.  Test A can now find the function "changeText()" in Test B.
    I am using CS5.5.
    Any help is appreciated!
    Thanks in advance!

    I had this written in the program and commented it out when I was trying to debug an earlier problem.  I uncommented the Embed statement, but it is still not working on Android.  Running on PC is fine.  I will try out a few more things, if it still does not work, I will open a new thread.
    Thanks all for your help!

  • Trying to call a function from a variable in Flex 4.0 ActionScript and need some suggestions

    I am attempting to build a site map in Flex. I have my links (or will have) in a database, along with a "link." On click from a datagrid, I have an event handler where I can get the link. However, everything I have tried to use won't call the function. Ideally, I would like to call a function from from my topLevel application, and I can do that using the mx.core.FlexGlobals.topLevelApplication call. Can anyone point a fairly new Flex coder in the right direction? Thank you.

    Here is the function on the group component (simplified): -- I got this from one of my google searches. The other was using the SWFLoader, but since this is in the same application, I didn't think it was as relevant. Plus, the SWFLoader used some references that I couldn't resolve.
    private function site_click(event:ListEvent):void {
      var sURL:String=list.dataProvider[event.rowIndex].link;
       var sCommand:String="mx.core.FlexGlobals.topLevelApplication." + sURL;
       this.[sCommand]();
    This yields the error message ReferenceError: Error #1059: Property mx.core.FlexGlobals.topLevelApplication.myths_click() not found on sitemap and there is no default value.
    Whereas this works fine:
    mx.core.FlexGlobals.topLevelApplication.myths_click();
    sitemap is my component name.

  • How to import classes from an external actionscript file

    This is driving me crazy, I've been trying to resolve this on my own for ages, and I've reviewed a lot of different materials, but I still can't seem to just import some external actionscript classes correctly.
    I'm using Flash Builder 4 with the Flex 4 SDK on mac osx 10.6
    the class I'm trying to import (I'll call it DesiredClass) is in a folder like this
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    within the class itself, the package declaration looks like this (I left all the guts out for clarity):
    package com.foreignproject
        import flash.display.Sprite;
        public class DesiredClass extends Sprite
            public function DesiredClass()
    I'm working on a totally different actionscript file at
    /Users/username/Documents/Adobe Flash Builder 4/TestProject/src/TestProject.as
    in this file I try to import the DesiredClass:
    package
         import com.foreignproject.DesiredClass;
         import flash.display.Sprite;
         public class TestProject extends Sprite
              public function TestProject()
              var neatClass:DesiredClass = new DesiredClass();
    And then I try to add the class I want to the source path.
    I've tried adding each folder to the source path separately:
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    If I choose the libraries folder or either of the com folders then an error shows up in theTestProject.as file, saying:
    Definition com.foreignproject:DesiredClass could not be found.
    But f I choose either of the foreignproject folders then an error shows up in theDesiredClass.as file saying:
    a file found in a source-path must have the same package structure 'com.foreignproject', as the definition's package, ".
    What am I doing wrong? Please help. I bought a book on actionscript, started doing the flex-in-a-week series, read numerous online discussion boards, and I still can't import these classes.
    Thanks in advance.

    I don't know if this method is supported anymore but you can give it a try.
    If you backed up bookmarks in IE using the following directions, you should be good!
    *In IE, "File -> Import and Export -> Export Cookies".
    *Open newly exported "cookies.txt" in a text editor and put a period before every line that starts with a domain. So a line starting with <b>altavista.com TRUE / FALSE 1388491200 AV_ALL 1</b> will become <b>.altavista.com TRUE / FALSE 1388491200 AV_ALL 1</b>
    *Then, move the "cookies.txt" file to your profile folder.
    You can get to the Profile folder two ways
    *Help > Troubleshooting Information > Profile Directory > Show Folder
    or
    *Go to '''about:support''' and click Show Folder next to Profile Directory.

  • Cannot call AS3 Function from JavaScript

    Hi,
    I am trying to call an ActionScript 3 function with JavaScript. The problem I cannot seem to get any of the browsers to trigger this AS3 function. The debuggers say that the function is undefined when I call it on the flash object. 
    What is supposed to happen is - the javascript function calls the AS3 function, and passes it an integer value.   That integer is then used to pull one of 20 swfs, and load that into the flash movie.
    Please let me know if you guys can think of anything that I can do to make this work!  I've been stuck for hours, and can't seem to make it happen.
    Here is my actionScript:
    import flash.net.URLRequest;
    import flash.display.Loader;
    import flash.external.ExternalInterface;
    var movies:Array = ["idle-ok.swf", "idle-good.swf"];
    // It first loads this "hello swf".
    var helloLoader:Loader = new Loader();
    var helloURL:URLRequest = new URLRequest("idleAvatar.swf");
    helloLoader.load(helloURL);
    addChild(helloLoader);
    var setAvatar:Function = loadAvatar;
    ExternalInterface.addCallback("callSetAvatar", setAvatar);
    // Then, this function should be called by JavaScript to load one of the other swfs.
    function loadAvatar(indx:Number){
        var url:URLRequest = new URLRequest(movies[0]);
        var ldr:Loader = new Loader();
        ldr.load(url);
        addChild(ldr);
    Here is my JavaScript:
    <script type="text/javascript">
    function callExternalInterface(val) {
              document.getElementById("loader").callSetValue(val);
    </script>
    Here is my embed code:
    <div>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="250" height="350" id="loader" name="loader">
    <param name="movie" value="loader.swf" />
    <param name="allowscriptaccess" value="always" />
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="loader.swf" width="250" height="350">
    <param name="allowscriptaccess" value="always" />
    <!--<![endif]-->
    <a href="http://www.adobe.com/go/getflashplayer">
    <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
    </a>
    <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
    </object>
    </div>
    <a href="#" onClick="callExternalInterface(1)">CLICK</a>

    You don't appear to be calling any function in your actionscript.  The names between and within do not agree. 
    document.getElementById("loader").callSetValue(val);
    should be calling a function identified with the string "callSetValue" in your actionscript, but you only have a function identified with "callSetAvatar"  and the function associated with that on your AS3 side is specified to be setAvatar...
    ExternalInterface.addCallback("callSetAvatar", setAvatar);
    but you do not have a function named setAvatar, you have one named loadAvatar
    Here's a link to a tutorial that might help you to see how the functions are specified between javascript and actionscript using the ExternalInterface class.  It gets confusing so I suggest you copy the code to a word processing file so you can clearly highlight where they have the same language between them.
    http://viget.com/inspire/bi-directional-actionscript-javascript-communication

  • 'Basic' external actionscript file/class usage

    Hey All,
    I'm a bit baffled by something that should, in my humble opinion, be a piece of cake...
    The setup is really easy. A simple application with a single textinput, a button and a text component.
    When the button is clicked a function is called that sets the text from the inputfield to the text component.
    code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
        <mx:Script>
            <![CDATA[
                public function click(inputText:String):void {
                    outPutTxt.text = inputText;
            ]]>
        </mx:Script>
        <mx:TextInput x="10" y="10" id="inputTxt"/>
        <mx:Button x="178" y="10" label="Button" id="Btn" click="{click(inputTxt.text)}"/>
        <mx:Text x="251" y="12" text="Text" id="outPutTxt"/>
    </mx:Application>
    As I said, really easy.
    What I want to do is put the function 'click' into an external actionscript file or class. And still be able to, from within the external file, modify the outPutTxt stuff.
    I'm aware that I could create a public bindable variable inside of the external file and then bind the outPutTxt to that variable, but I would really like to be able to 'simply' force the value...
    Is that possible? If yes: how plix
    If it's not possible, I'd like to know as well! And in that case, how would I then re-use the same instance of a class/file in multiple seperate components? Say I got a 'login' thingie where a user logs in (data stored externally in a seperate actionscript file/class) and I want to re-use that information on other pages... Or is this done automatically?
    Any and all comments/answers are higly appreciated!
    Pieter

    Hey Levancho,
    thanks for your answer!! Much appreciated.
    However, the code you proposed threw an error...
    Errormessage:
    ReferenceError: Error #1069: Property outPutTxt not found on controls.Control and there is no default value.
        at controls::Control/btnClick()[C:\...\FlexTest_03\src\controls\Control.as:13]
        at FlexTest_03/__Btn_click()[C:\...\FlexTest_03\src\FlexTest_03.mxml:11]
    So I tried something else where I bind the text in my OutPutTxt to a variable inside of the external class file.
    Code:
    Class:
    package controls
        public class Control
            [Bindable]
            public var outPutText:String = "";
            public function Control()
            public function btnClick(inputText:String):void {
                this.outPutText =  inputText;
    Mxml:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
        <mx:Script>
            <![CDATA[
                import controls.Control;
                [Bindable]
                private var control:Control = new Control();
            ]]>
        </mx:Script>
        <mx:TextInput x="10" y="10" id="inputTxt"/>
        <mx:Button x="178" y="10" label="Button" id="Btn" click="{control.btnClick(inputTxt.text)}"/>
        <mx:Text x="251" y="12" id="outPutTxt" text="{control.outPutText}"/>
    </mx:Application>
    And this basically did what I wanted to do... so I just need to do some major binding between my application and the classes I'll be using for my business logic.
    Now for something else entirely...
    Is there a way for me to pass the instance of my class between flex components?
    Pieter

  • Exit Android App with external *actionscript.as* files

    Hi, i'm trying to make this code work with a application that got 99% of code driving by external actionscript.as files;
    In another app without any external call i mean no actionscript.as files, the code work very fine.
    My goal is to shutdown any activity of the app when the user receive a call or something like that;
    Many thanks in advance and sorry my english
    Scene 1, Layer 'Layer 1', Frame 1, Line 14
    1046: Type was not found or was not a compile-time constant: KeyboardEvent.
    function handleActivate(event:Event):void
        NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
    function handleDeactivate(event:Event):void
        NativeApplication.nativeApplication.exit();
    function handleKeys(event:KeyboardEvent):void        ----- Line 14 -----
        if (event.keyCode == Keyboard.BACK)
            NativeApplication.nativeApplication.exit();
    if (Capabilities.cpuArchitecture == "ARM")
        NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, handleActivate, false, 0, true);
        NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, handleDeactivate, false, 0, true);
        NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleKeys, false, 0, true);

    Look Mr. Colin, added the import flash.events.KeyboardEvent; and thats what i got:
    Scene 1, Layer 'Layer 1', Frame 1,
    Access of undefined property:
    NativeApplication
    SystemIdleMode
    Keyboard
    Capabilities
    I'm addind this code inside Flash CS6, not via external.as

  • Calling a function on an object passed as argument

    Hi everyone,
    i'm trying to call an actionscript function on an object passed as argument to a c function. Here are how I do :
    I have a class named test_class implemented as
    package
         public class test_class
              public var bliblou:int;
    and a C function that have to modify the bliblou var of an test_class object passed as argument. Here is my function :
    static AS3_Val test_obj_param( void* self, AS3_Val args )
         AS3_Val obj;
         AS3_ArrayValue( args, "AS3ValType ", &obj );
         AS3_Set( obj, AS3_String("bliblou"), AS3_Int( 123456 ) );
         return AS3_Null();
    Then I call the function in my actionscript main function like this :
    var loader:CLibInit = new CLibInit;
    var lib:Object = loader.init();
    var test:test_class = new test_class();
    lib.test_obj_param( test );
    But when the test_obj_param is trying to run, I obtain an error saying "unable to access a propriety of a null object".
    What am I doing wrong ? Is it possible to do what I try to (calling a function on an object passed as argument) ?
    Thanks in advance

    After a long trip to Alchemy possibilities and a lot of tests I have finally found a solution to my question.
    Instead of using AS3ArrayValue to get my objet, I use the AS3 function shift on the args array to get my object. Here is how I do
    static AS3_Val test_obj_param( void* self, AS3_Val args )
         AS3_Val emptyParams = AS3_Array("");
         AS3_Val obj = AS3_CallS( "shift", args, emptyParams );
         AS3_SetS( obj, "bliblou", AS3_Int( 123456 ) );
         AS3_Release(emptyParams);
         return AS3_NULL();
    Maybe there is a bug in the AS3ValType getter.

  • MuseJSAssert: Error calling selector function:ReferenceError: Spry is not defined.

    I launched Muse today and it said there was an updated available. I installed it and then made a few small changes to my 5 page website. Then i exported the HTML and uploaded it to my server.
    But now when i try browsing the site in Chrome, I get the following error message:
    MuseJSAssert: Error calling selector function:ReferenceError: Spry is not defined.
    The only changes I made were adding some text to a few pages and adding metadata info to each page and when viewing the exported HTML locally (prior to uploading) it all behaves as it should...no error messages.
    Any ideas why its doing this? or more importantly, any suggestions on how to stop it from doing this? It wasn't doing this yesterday prior to me making these small changes.
    Here's the URL: www.gardensbytheseaursery.com
    Thanks in advance.
    Jake

    This error would occur if not all the files for the site we're uploaded.
    The 2.0 update includes numerous improvements in the generated HTML, CSS and JavaScript, so while you may have directly changed only certain pages, if you're using an external FTP client all the exported files and folders need to be uploaded. (The new built-in FTP support automatically only generates and uploads files that have changed since the previous upload.)

  • PInvoke - Issue while calling DJVU function from C# Code - Attempted to read or write protected memory

    Hi,
    I know there are many questions in this subject but none of them help to resolve the issue I am currently facing.
    Below is the signature of C Function from DJVULibre added in .NET code
    [DllImport("C:\\Program Files\\DJVULIBRE\\LIBDJVULIBRE.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
    private unsafe static extern int ddjvu_page_render(IntPtr page, ddjvu_render_mode_t mode, IntPtr pagerect,
    IntPtr renderrect,
    IntPtr pixelformat,
    ulong rowsize,
    [Out][MarshalAs(UnmanagedType.LPArray)]byte[] imagebuffer);Below is how I am calling this function in the c# codebyte* buffer = (byte *)Memory.Alloc(nSize);
    try
    IntPtr ptr1 = (IntPtr)Memory.Alloc(Marshal.SizeOf(prect));
    Marshal.StructureToPtr(prect, ptr1, false);
    IntPtr ptr2 = (IntPtr)Memory.Alloc(Marshal.SizeOf(rrect));
    Marshal.StructureToPtr(rrect, ptr2, false);
    byte[] array = new byte[nSize];
    fixed (byte* p = array) Memory.Copy(buffer, p, nSize);
    ddjvu_page_render(page, ddjvu_render_mode_t.DDJVU_RENDER_MASKONLY, ptr1, ptr2, fmt, (ulong)stride, array);
    finally
    Memory.Free(buffer);
    }call to ddjvu_page_render in above code is throwing "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
    Prior to this post I must have tried all the option could find in various blogs.
    Appreciate any help, is almost a day I am clueless, your timely help could save my job

    Thanks Viorel, below is the definition of original C function
    DDJVUAPI int
    ddjvu_page_render(ddjvu_page_t *page,
    const ddjvu_render_mode_t mode,
    const ddjvu_rect_t *pagerect,
    const ddjvu_rect_t *renderrect,
    const ddjvu_format_t *pixelformat,
    unsigned long rowsize,
    char *imagebuffer );below is how the code is calling this function in C#, the in pointers are all valid pointer I checked in debugging window byte* buffer = (byte *)Memory.Alloc(nSize);
    try
    IntPtr ptr1 = (IntPtr)Memory.Alloc(Marshal.SizeOf(prect));
    Marshal.StructureToPtr(prect, ptr1, false);
    IntPtr ptr2 = (IntPtr)Memory.Alloc(Marshal.SizeOf(rrect));
    Marshal.StructureToPtr(rrect, ptr2, false);
    byte[] array = new byte[nSize];
    fixed (byte* p = array) Memory.Copy(buffer, p, nSize);
    ddjvu_page_render(page, ddjvu_render_mode_t.DDJVU_RENDER_MASKONLY, ptr1, ptr2, fmt, (ulong)stride, array);
    finally
    Memory.Free(buffer);

  • VC++ WebBrowser call Javascript function in a frame of the main page

    I can successfully call JS function in the main page from VC++, but when I call the JS function in frame, GetIDsOfNames() return DISP_E_UNKNOWNNAME. The question can be describe as below:
    main page is INDEX.HTM, loaded in webbrowser control, src:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Sample</title>    
        <script type="text/javascript">
    function FuncMain()
    alert("Main Page Function Called!");
        </script>
    </head>
    <body>
    <div>
      <div id="div_test1">
        <iframe id="page_test1" width="100%" height="100%" src="test1.htm" frameborder="0" scrolling="no"></iframe>
      </div>
      <div id="div_test2">
        <iframe id="page_test2" width="100%" height="100%" src="test2.htm" frameborder="0" scrolling="no"></iframe>
      </div>
    </div>
    </body>
    </html>
    test1.htm src:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <body>
    <div>Test1 frame page</div>
    </body>
    </html>
    test2.htm src:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <script type="text/javascript">
         function showAlert(x)
    alert(x);
     function callVC()
    window.external.VCFuncTest();
        </script>
    </head>
    <body>
    <div>Test2 frame page</div>
    <div id="test_btn" style="background-color:red;width:100px;height:100px;cursor:pointer;" onclick="callVC();">Test</div>
    </body>
    </html>
    in VC++:
    VC++ code can call JS functions by CWebPage class, I found it here:  http://www.codeproject.com/Articles/2352/JavaScript-call-from-C
    in my VC project, webPage.CallJScript(_T("FuncMain")) succeeded!
    webPage.CallJScript(_T("page_test2.showAlert") failed,  the GetIDsOfNames() return DISP_E_UNKNOWNNAME. BTW, webPage.CallJScript(_T("showAlert")
    also failed! Same error.
    any help?
    Best Regards!

    Thanks for your reply Viorel_.
    i know i can define a function in the main page: 
    function showAlert_Main(x)
            document.frames('page_test2').showAlert(x);
    then, webPage.CallJScript(_T("showAlert_Main"))
    succeeds.
    but this function is just an empty shell doing nothing, and i know there must have a way to call showAlert(x) directly.

Maybe you are looking for

  • Open PO with vendor number

    Hello Expert :    I need to find a  open PO list. I have vendor numbers so from this vendor number how can i get the list of Open PO's link to the available vendors ? what table or logic I can use to get the open PO Note : Please search forum before

  • Calculating liquidation - percentages with subqueries

    Hi, I have a query a sql statement as follows, which I am using to query an oracle database: SELECT EXTRACT(YEAR FROM "CLIENT_TH"."CREATED_DATE") AS LOAD_YEAR, EXTRACT(MONTH FROM "CLIENT_TH"."CREATED_DATE") AS LOAD_MONTH, CONCAT(CONCAT(EXTRACT(MONTH

  • Printing background color - NOT

    I have someone who insists on sending me meeting minutes as email with a background color for the email. I'd like to turn off the background for printing, but can't figure how to do this. If I ask the printer to print B&W I get a grey background. In

  • How to delete syncronised photoes from iphone

    hi can you help me to delete synchronised photoes from my iphone. thanks

  • Will iWork open Microsoft Word & Excel documents ?

    Do I need to install Microsoft Word & Excel or Apple iWork to open documents that are emailed in Word & Excel ? I am going to run Windows XP Pro on this machine.