Calling a function in a component

Hi, I know it's simple, but I can't it works I have looked for example but come uo with nothing

I want to call a function in a component

I created a label-based acompoinent

<? XML version = "1.0" encoding = "utf-8"? >

< mx:Label

' xmlns:mx = ' http://www.Adobe.com/2006/MXML " >

< mx:Script >

<! [CDATA]

public var mp3:String;

private var soundChannel:SoundChannel;

This function will load and play the sound

public function playSound():void{}

       var urlRequest:URLRequest = new URLRequest (mp3) ;

      var sound: sound = new Sound();

sound. load (urlRequest);

stop no. device sound turns

     if (soundChannel! = null ) {}

soundChannel.stop ();

}

soundChannel = sound.play().

}

This function stops the sound of the game, this need tos work on the sound channel

private function stopSound():Sub

{

soundChannel.stop ();

}

[]] >

< / mx:Script >

< / mx:Label >

call looks like

<? XML version = "1.0" encoding = "utf-8"? >

< mx:Application

' xmlns:mx = ' http://www.Adobe.com/2006/MXML "layout =" " absolute "xmlns:uofs =" " UofS.* " >

< uofs:ulable " text = ' Hellow " id=" B21 " x=" 200 "y =" 300 "mp3 =" jazz.mp3 "click ="playSound ()" / >

< / mx:Application >

also how wolud you pass a string in the click

"Click =" playSound (jazz.mp3) "or click =" playSound ("jazz.mp3").

do not work

You call the function in the main folder of the application; not the component.

Change the code like this:

B21.playSound ('whatever')

Tags: Flex

Similar Questions

  • How to call a function in a component when selected some viewStack

    K I'm sure my way around this is to use a custom event, but maybe someone out there knows different.

    This is my layout views

    MainApp > allVideos > video - videoPlayer component

    OK I'll allVideos select my video viewsStack video display past init() is called on sends complete to create a property to my videoPlayer component and everything works well.

    Now I navigate back to allVideos and select a new video, we go back to the view of videos and I need a way to call init() again so I can send my new property to my component to play the new video. Complete creation is not called again.

    I was reading about the currentStateChange or currentStateChanging event. I don't really understand how those who work. So I assumed that custom events are the way to go? Thanks guys and influence is grateful.

    The 'show' event should work, be aware that the docs say that

    Distributed in the case of State of an object changes from invisible to visible.

    If you try to call something in the first display (such as a request to load data)

    You may need to use creationComplete also...

    https://bugs.Adobe.com/jira/browse/SDK-14158 has more information

  • Is it possible to call the function in the module through function of interface component

    Hello

    I see this in the livedocs.

    "In general, if you want to set properties on controls in the module using external values, you must create the variables that may be related. Then, you set the values of these variables in the methods implemented in the interface. If you try to set properties of the controls of the module directly using the external values, controls may not be instantiated by the time the module is loaded and the attempt to set the properties may fail. »

    I have a component in a module. I have to call this component of the interface function funcion. That is to say my main application call the function of interface, and that interface funcion must call funcion of the component. Is this possible. I get error that the element is null, if I try this. Is it possible to do so.

    Thanks in advance.

    Hi, yes I got your problem now when I have your code.

    See it here:

    MOD = modInfo.factory.create (like TestInterface);
    var el: IVisualElement = modInfo.factory.create () as IVisualElement;
    this.addElement (el);

    It won't - you create 2 separate instances of the module, which you create - 'el' and the other a not - "mod".

    It should look like this:

    var el: IVisualElement = modInfo.factory.create () as IVisualElement;
    Note: I usually use var el: Module = modInfo.factory.create () like Module; Does not need at least for the moment to cast as IVisualElement but I know that it is not bad, I read in some articles before getting if I remember correct it does not give access to some methods, but not sure.

    MOD = el like TestInterface;

    addElement (el);

    First, you create the instance of the module with the factory.create (), and then cast you to the interface.

    F

  • Is it possible to call a function in a parent of a child component component in Flex 3?

    It is probably a very basic question, but ask for this for awhile.

    I need to call a function in a parent component and the appeal of its child element in Flex 3. Is there a way to access an element functions of the child element parent? I know that I can send an event for children and add a listener in the parent to call the function, but just wanted to know if could also directly call a function of parent of a child (similar to how you can call a function in the main mxml file using Application.application). Thank you

    There are no performance issues, but it's ok if you use the child component in a single category. Suppose that you want to use the same component as a child to a lot of parents then if all the following

    public interface IParentImplementation{
    
         function callParentMethod();
    }
    

    and the parent of the class has to implement this 'IParentImplementation '.

    usually to the next line

     public class parentClass extends Canvas implements IParentImplementation{
              public function callParentMethod():void{
         //code
              }
         }
    

    in children, you should do something like that.

    (this.parent as IParentImplementation).callParentMethod();
    

    Here the use of Interfaces, we're to decouple the parent and child

    If this post answers your question or assistance, please mark it as such.

  • Way to know which component is called a function

    Hi all.

    I think I saw a way to know which component is called a function. For example, lets say that I have two datagrids, each with a similar list from items in a database, but with of different ComponentID. A datagrid control ID is dg1, and the other is dg2. I remember having seen a way to NOT have to hard code each dg ID in the service, but to recognize which component calling the function. In my view, that it was something like 'thisComponent' or "theComponent" or something like that.

    So, if I click on an item in a list, I call the getComponentDetails() function.

    private function getComponentDetails (): void {}
    var setComponentID = thisComponent.selectedItem.ComponentID;

    ... use now to get the data from the database and send it to the Manager of...
    }

    Anyone know what it was / is or someother way to do this.

    Thank you. Gary

    Well, it seems that the answer is event.currentTarget.selectedItem.ComponentID. Hope this helps you to someone else.

    Gary

  • Call a function within the same CFC component

    Hello
    / * Niewbie Question * /.
    I have a strange problem. When I try to call one function on the other in the same CFC component, I get an error named: "Entity has incorrect type to be called as a function."
    I looked on many forums and searched in Google groups. I have yet found a work around for this problem.
    I thought I did caution o not use twice the same name...
    Can someone tell me what I did wrong?

    My sample code to reproduce this error is included

    The full error message is:
    Entity is of the wrong type to be called as a function.
    The symbol you provided superfunction is not the name of a function.

    The error occurred in C:\ColdFusion8\wwwroot\admin\_components\test.cfc: line 6

    4: < cfinvoke
    5: method = "superfunction".
    6: returnVariable = "myReturn" >
    7: < / cfinvoke >
    8: < cfset some_text = myReturn >

    OK, solved with all your advice!

    A big thank you to everyone

    Here is the final code for others...

  • How can I call a public function in a component to another component?

    I have two components: form and Confirmation.  Form is a Web and Confirmation is a TitleWindow.

    Form contains several controls and a "submit" button.  Confirmation contains an OK button.  When the user clicks on the button send, Confirmation is displayed above the form (the form is blurred).  When the user clicks OK on the Confirmation button, I want to perform a function on the form to set default values in controls.

    How can I address the function of the component in the form of Confirmation component so I can start the function?

    Thank you!

    Here is the source

    CustomForm.mxml

    http://www.Adobe.com/2006/mxml"width ="400"height ="300">

    public function callBack(): void {}

    lblStatus.text = "success";

    }

    ]]>

    label = "Submit" / >

    CustomTitle.mxml

    http://www.Adobe.com/2006/mxml '.

    layout = "absolute" width = "200" height = "80".

    showCloseButton = "true" closed = "closeMe (event)" "

    backgroundAlpha = "1".

    Color = "#173553" backgroundColor = "#EEEEEE."

    headerColors = «#FFFFFF, #CBCCCC»

    borderColor = "#666666" borderStyle = "solid" >

    Import mx.managers.PopUpManager;

    public var callBack: Function = new Function();

    private void closeMe(event: Event): void {}

    PopUpManager.removePopUp (this);

    callBack();

    }

    ]]>

    TitleWindowSample.mxml
    "" xmlns = "*".
    layout = "absolute".
    Width = "100%" height = "100%".
    creationComplete = "init ()" > "
    Import mx.managers.PopUpManager;
    private void init (): void {}
    customForm.submit.addEventListener (MouseEvent.CLICK, onMouseClick);
    }
    private void onMouseClick(event: MouseEvent): void {}
    customForm.lblStatus.text = "";
    var customTitle: CustomTitle = new CustomTitle();
    customTitle.callBack = customForm.callBack;
    PopUpManager.addPopUp (customTitle, this);
    PopUpManager.centerPopUp (customTitle);
    }
    ]]>
    Width = "100%" height = "100%".
    verticalAlign = "middle" horizontalAlign = "center" >
  • Call a function of another class

    Hi!, I have a Flex project with this code inside the package 'package ':

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   backgroundColor="black"
                   creationComplete="init();callLater(showInitTime);" currentState="Inicial"
                   frameRate="24" preloader="paquete.CustomPreloader" >
    ...
    <fx:Script source="Principal.as" />
    ...
    

    File "Principal.as" has this function:

    public function loquesea():void{
         ...
    }
    

    And for the preloader, I have this class:

    package paquete
    {   
        imports ...
        
        public final class CustomPreloader extends DownloadProgressBar
        {
           
            public function CustomPreloader() 
            {
                
               //HOW I CALL FROM HERE loquesea() FUNCTION in Principal.as ????
                super(); 
            }
    
    

    Well, my question is in the code above

    Thank you!

    Hi Raulkirm,

    If you include this script in your main mxml file (remember not in another mxml component) you can call this function using the class of toplevel as shown

    FlexGlobals.topLevelApplication.loquesea ();

    Also don't forgtet to import the namespace corresponding to the...

    Thank you

    Jean Claude

  • Calling a function in the application

    What is the best way to call a function that is located in the main file of the application to a custom component that is nested several layers down

    Thank you

    Try to use FlexGlobals.topLevelApplication

  • Call a function every time viewstack element takes over.

    I have a viewstack with multiple MXML components. I want to call a function doSomething() when a MXML component is loaded. I'm the creationComplete property of the component function. The problem is that the creationComplete method is called only for the first time. and not when I return to the same point of view even once...

    Help, please...

    -Thank you, Guruji...

    Hello

    Try to call the function in the event of the viewstack changes. In particular check the mxml component index change event and call the function.

    private

     

    function ViewStackChange():void

    {

    switch

    (vsAdmin.selectedIndex)

    {

    case 0:

    {

    Write the function component mxml

    Break;

    }

    case1:

    {

    write the function to call for the "second" component

    Break;

    }

    }

    Hope this helps you

  • Calling a function only when the State is active

    I turn to find the event just to call a function only when the status is active. In fact, I created a State to display the 'product details' click and once the system changes to this State - I have to perform a function.

    Here's the context:

    Let's say that you are on the home page where you will need to click on a product to see details. By clicking on the product, the State to view the details of the product will be activated and a variable inside the new state you will receive all the data (from the class of product). But I discovered Flex run all States at the beginning and we need to watch how declare our function to make sure that we do not have a null to a variable/object reference. Given that value is moving to the State only when the click event to occur, the process of globalization, execution of all States at the beginning will not have any value yet (for the specific product to deal with in the State of the productDetails). So I can't use creationComplete to perform a simple function like setSpecs(), where all the values (for example, width, height, circumference, diameter, price, etc.) will be instiate specific labels.

    What event to use to call a function internal once we are in the State? Just using the creationComplet and stated if he check the currentState = that I have to work on is not enough. I tried 'activate', 'show', 'enterStage' and many others, but without success. I tried to search the Internet, but it seems that this problem is not popular enough to generate sufficient results.

    But I know that it is possible in the case otherwise it will be is not logical and since Flex work very well with the event, I found the right event. It's something basic I know, but when you do not know, it seems difficult to find! ;-))

    Thanks Greg!

    I agree, this is a better method. So I'll change my SENSITIVITY to use viewStack instead of the State. But the problem persists what that, if we use the viewStack State to launch an event only when the State/viewStack is displayed on the screen.

    I found something that works very well for me: updateComplete.

    First of all, I found this before reading your information about viewStack so it worked very well for the method of the State. That I decided to do a test to viewStack and made the necessary changes to the code to reflect a viewStack navigation and make sure the updateComplete was not within my component (stateProduct.mxml). The system was not able to view the specification as the setSpecs() function was not instantiate when displayed. I added the updateComplete = "{setSpecs ()} ' and everything worked great!" So I conclude that no matter if you are using a viewStack State, the updateComplete event can be used to run or functions only when the component is displayed on the screen.

    Now, I have to make my transition between the State working with viewStack effect! ;-))

    Thanks to Greg for this useful tip!

  • ItemRenderer how call a function (this.function).

    I use an itemRenderer to populate datagrid miy with 3 custom buttons, but I need to call a function published in...
    the beginning of my form, not in my RenderComponent,

    HOW DO I...?


    < mx:Component id = "ResultadoRender" >
    < mx:VBox
    Width = '80' height = '26 '.
    horizontalAlign = "center" verticalAlign = "middle" >
    < mx:HBox width = "100%" horizontalAlign = "center" >
    < mx:Button label = "" visible = "true" icon="@Embed('.. /.. / icons/utilisateurs 2.png") "click =" ChecarBoton (); "width ="24"/ >
    < mx:Button label = "" visible = "true" icon="@Embed('.. /.. utilisateur green.png/icons /')" click = "ChecarBoton (); "width ="24"/ >
    < mx:Button label = "" visible = "true" icon="@Embed('.. /.. / icons/display.png')" click = "ChecarBoton (); "width ="24"/ >
    < / mx:HBox >
    < / mx:VBox >
    < / mx:Component >

    < mx:DataGrid x = "10" y = "40" width = "700" height = "382" id = "dtgUsuarios" >
    < mx:columns >
    < mx:DataGridColumn headerText = "Number (s)" dataField = "NAME" / >
    < mx:DataGridColumn headerText = "User number" dataField = "NAME" / >
    < mx:DataGridColumn headerText = "Number Grupo" dataField = "NAME" / >
    < mx:DataGridColumn headerText = "Options" dataField = "NAME" itemRenderer = "{ResultadoRender}" / >
    < / mx:columns >
    < / mx:DataGrid >

    Sorry, I found the answer...

    Check this box

  • call a function on PopupWindow closed

    Hi all

    I have a popup that opens when users click a button.

    This popup is written as an element that is outside the main mxml file.

    Now is my scenerio, I call a function that goes through a collection ArrayCollection object after the closure of the pop-up window.

    The function resides in the main MXML file, and the code of Popup TitleWindow is a separate mxml as a component file

    At the close of the popup, the function should be called who runs the block of logic in it...



    How to achieve this?

    Kind regards
    Madan N

    Hi exiz,

    I used the close event but could not find a way to send the event.

    In addition to surfing in the group saw this thread that resemble the same as question. It solved my problem.

    http://www.Adobe.com/cfusion/webforums/Forum/MessageView.cfm?CATID=585&ThreadId=1303691

    Thank you
    Madan N

  • How to implement a callback to the help function call library function node in LabView?

    I try to call a fuction from a SDK.dll library by using the node call library feature. The SDK has been provided to

    me and I don't have the source code, just the .dll and .h files.

    The SdkSetPropertyEventHandler function has a function of recall as one of its parameters. How to apply the

    callback using the NSI node? I'm a good programmer LabView but this is my first time using the library to call

    Function node. I read all the info I can find on the web site of NOR and the discussion Forum, but can not understand

    This one out. I'm using LabView 8.6.

    The deacribes SDK.h function as:

    Function: SdkSetPropertyEventHandler

    (SdkSetPropertyEventHandler) SdkError SDKAPI
    SdkCameraRef inCameraRef,
    SdkPropertyEvent inEvnet,
    SdkPropertyEventHandler inPropertyEventHandler,
    SdkVoid * context);

    //
    Description:
    Registers a callback function to receive the status
    change the notification events for the States of property on a camera.
    //
    Parameters:
    In: inCameraRef - designate the object camera.
    inEvent - designated one or all the events will be completed.
    inPropertyEventHandler - designate the pointer to the callback
    function to receive the camera property-related events.
    inContext - designated application information must be passed
    way to the callback function. All the data necessary to
    your application can be passed.
    Output: no
    //
    Returns: A sdk errors.
    -----------------------------------------------------------------------------*/

    A separate header called SDKTypes.h file contains the following data:

    typedef SdkUInt32 SdkPropertyEvent;
    typedef SdkUInt32 SdkPropertyID;
    typedef void SdkVoid;

    typedef struct __SdkObject * SdkBaseRef;
    typedef SdkBaseRef SdkCameraRef;

    /*-----------------------------------------------------------------------------
    SdkPropertyEventHandler
    -----------------------------------------------------------------------------*/
    typedef SdkError (SDKCALLBACK * SdkPropertyEventHandler))
    SdkPropertyEvent inEvent,
    SdkPropertyID inPropertyID,
    SdkUInt32 inParam,
    SdkVoid * context);

    Thanks for your help.
    Alejandro

    Andrew_E wrote:

    Hi Rolfk,

    You are absolutely right. This article describes what you were talking about? I'm just trying to get as much information as possible on this thread if the solution is easier to find for the future. Thank you.

    Yes, but I find the idea of using .net to call a LabVIEW VI as callback function C a bit as using a roll of Steam ironing your pants. Why do it? Well the steamroller has extra security guards that make it less likely that you'll break your pants in the process, but it's not elegant IMHO.

    Write a C DLL that translates between a C callback and a user event LabVIEW using the PostLVUserEvent() of the interface of the kernel to run LabVIEW function seems so eleganter for me. Yes, it's a bit of programming in C, but good!

    Rolf Kalbermatter

  • Call library function node

    When using a call library function node, and the program came out, I get an error "has encountered a problem and needs to close" having to do with ntdll.  It does not stop the program from running properly, but it's annoying.  Any ideas?

    You should NOT specify the full path to a DLL system in the configuration dial the node of the library. This mess something in the newer versions of Windows. Instead just enter the name of the DLL only. It is sort of a bug in LabVIEW not automatically detect the system paths and shorten the path accordingly in itself, but this is how things have been for a long time and you just need to be a little careful.

    Also the return value must be really set up to be an integer of size of pointer, since a HANDFUL is really a pointer under Windows and that the first parameter is also better configured as such. The way you did works very well for LabVIEW 32 Bit but will misbehave in LabVIEW 64 Bit.

Maybe you are looking for

  • eheheh

    xxxxxxxxxxxxxxxxxx

  • Satellite L300D: changing in Vista keyboard language settings

    Hello! I bought a cell phone in Spain (Satellite L300D series) and I added to the 'language bar' option 'Portuguese' (my language).Usually I write texts in both languages - this is why I have not removed the "Spanish" option in the "language bar".How

  • FaceTime works not properly. Can I reinstall?

    FaceTime only works on my iPhone and the iPad, no problem.  On Mac, red button does not disconnect, and video calls are made for my iPhone and not the Mac. If I can reinstall Facetime (OSX 10.11.3 El Capitan) if I remove it?  Maybe I am doing somethi

  • Error 403 on the HP ePrintCenter website

    Hello I have just bought a HP Photosmart printer and like to register on the HP ePrintCenter website. However, I get all sorts of "403 Forbidden" errors on this site: When I select a different country and language (using the button at the bottom of t

  • iMessage and FaceTime says "Waiting for activation...". »

    My 5s iPhone keeps saying "Waiting for activation...". » How to solve this problem?