How to write a custom component

I have 3 quick questions on How to write a component. Here is the code in my main file I want to write as a component:

buttonCanvas = new Toile;

buttonCanvas.addEventListener (MouseEvent.MOUSE_DOWN, buttonMouseDownHandler)

buttonCanvas.addEventListener (FlexEvent.CREATION_COMPLETE, setcanvasPosition)

buttonCanvas.width = 300;

buttonCanvas.height = 30;

if (i%2==0){

buttonCanvas.setStyle ("styleName" "style1");

}else{

buttonCanvas.setStyle ("styleName" "style2");

}


This is the component:


<? XML version = "1.0" encoding = "utf-8"? >
" < = xmlns:mx mx:Canvas ' http://www.Adobe.com/2006/MXML "creationComplete ="init ()">
< mx:Script >
<! [CDATA]
public var i: int
public void init (): void {}
trace ("i =" + i)
This.Width = 300;
This.Height = 30;
If (i %2 == 0) {}
this.setStyle ('styleName', 'style1');
} else {}
this.setStyle ('styleName', 'style2');
}
this.addEventListener (MouseEvent.MOUSE_DOWN
}
[]] >
< / mx:Script >
< / mx:Canvas >

Question 1: What is the best way to pass the value of the variable 'i' to the compoonent? What I have to write:

buttonCanvas.i = i;
or can I pass the argument to the component as follows, and if so, how I capture the value of the component? :

buttonCanvas = new ButtonCanvas (i);


Question 2: Where is the best place to put the listeners? Should I put them in the main file:

buttonCanvas.addEventListener (MouseEvent.MOUSE_DOWN, buttonMouseDownHandler)
buttonCanvas.addEventListener (FlexEvent.CREATION_COMPLETE, setcanvasPosition)
or should I put them in the component like this:

this.addEventListener (MouseEvent.MOUSE_DOWN, buttonMouseDownHandler)

Question 3:If I put them in the component, how to point to the function named "buttonMouseDownHandler" in the main file?

Thanks for your time!

Hi SiHoop,

Well come to your question, here is the solution:

Question 1: What is the best way to pass the value of the variable 'i' to the compoonent? What I have to write:

buttonCanvas.i = i;
or can I pass the argument to the component as follows, and if so, how I capture the value of the component? :

buttonCanvas = new ButtonCanvas (i);

(A) you can use the method buttonCanvas.i = i; but not buttonCanvas = ButtonCanvas (i) again because this corresponds to an instantiation of the constructor, and you cannot specify a constructor explicitly for your component as the Flex compiler automatically provides at the time of the compilation;

Using the second approach, you can pass that I appreciate, but you can use this syntax to get the value I have...

buttonCanvas = new ButtonCanvas();

buttonCanvas ["i"] = i;

Question 2: Where is the best place to put the listeners? Should I put them in the main file:

buttonCanvas.addEventListener (MouseEvent.MOUSE_DOWN, buttonMouseDownHandler)
buttonCanvas.addEventListener (FlexEvent.CREATION_COMPLETE, setcanvasPo)
or should I put them in the component like this:

this.addEventListener (MouseEvent.MOUSE_DOWN, buttonMouseDownHandler)

(A) it depends purely on your condition if you want to listen to these events with in your component and make somechanges in your component itself and not to other elements, then you can set headphones for events in the same component.

But if you want to know or communicate with other components in your component event has occurred then define you the eventListeners in other components as below and update of data or make changes in the other component accordingly...

buttonCanvas = new ButtonCanvas();

buttonCanvas.addEventListener (MouseEvent.MOUSE_DOWN, buttonMouseDownHandler);
buttonCanvas.addEventListener (FlexEvent.CREATION_COMPLETE, setcanvasPosition);

Question 3: if I put them in the component, how to point to the function named "buttonMouseDownHandler" in the main file?

(A) If you put the eventListeners with the component and if you want to point to the function named "buttonMouseDownHandler" in the main file, then you must do the following:

In your component

this.addEventListener (MouseEvent.MOUSE_DOWN, buttonMouseDownHandler);

private void buttonMouseDownHandler(event:MouseEvent)

{

Here, you need to send a custim event to warn other components this thi event has been dispatched

this.dispatchEvent (new Event ("buttonMouseDownEvent"));

}

Now in your main mxml, you have to listen to this event, as shown below:

buttonCanvas = new ButtonCanvas();

buttonCanvas.addEventListener ("buttonMouseDownEvent", buttonMouseDownHandler);
buttonCanvas.addEventListener (FlexEvent.CREATION_COMPLETE, setcanvasPosition);

 

private void buttonMouseDownHandler(event:MouseEvent)

{

It is the function in your main mxml file

}

Hope you understand most... If you have any doubts do let me know...

Thank you

Jean Claude

Tags: Flex

Similar Questions

  • How to import the custom component exported from flash cs3

    Hello

    I exported a custom component that I designed in flash cs3 as a SWC file. How to import it in my project flex and how to use it?

    Sorry if this is a stupid question. I'm new to flex. Thank you.

    You must add the swc file in your path of the project. Please check the following URL for more information about how to import Flash components in Flex project.
    http://www.Adobe.com/devnet/flash/articles/flex_component_workflow.html

    I hope this helps.

  • How to make the custom component space - fill?

    I am writing a custom for a space - component fill exercise. There could be several sentences in the exercise with several gaps – something that looks like this:

    London is the largest urban area in the __________. An important institution for two millennia, London history goes back to its founding by the _____.

    The component must be "generic" data will be fed to a database. I was wandering if someone could give me some advice to an existing solution or clues how to approach the issue.

    Although I got a fair amount of experience on the server side (java), this is my first attempt to write something that is 'displayed on the screen"and any help will be greatly appreciated.

    It is an interesting requirement. Flex, unlike html, is not oriented around a style of flow interface.

    Maybe a Tile container would work, but I anticipate formatting issues since the tile waits for fixed elements of width and height

    There is a component that someone created called a FlowBox, which would be likely to be a good starting point for the user interface. Then according to Amy, I would use Repeater to generate controls. This part would be pretty simple.

    Tracy

  • How to write a custom in profileFormHandler error messages

    Hello
    I use profileFormHandler to register user and I need to validate the password in it field. whether or not it has the 10 characters. Here I call a JAVA class named REG.java which is the ProfileFormHandler extension and I want to validate the password field and return the error user code again in this JSP page.

    You should write your validation logic in preCreateUser and add your error messege using method prominently in the preCreateUser() above. We shouldn't have custom logic in handlemethod, but such validation logic should go to pre... methods.

    -RMishra

    Edited by: RMishra October 12, 2012 17:49

  • How to write a custom init or prerender method?

    some ide provide methods init() and prerender() override, I can use this method in netbeans, but
    If I use jdeveloper; I can't find methods prerender and init, so I try to write, but I couldn't.
    I did;
    (1) write phaselistener
    (2) and extends from my beans with phaselistener
    phases of the public class implements {PhaseListener
    public phases() {}
    }

    public void init() {}
    System.out.println("/***phase***init***"); "
    }

    {} public void afterPhase (PhaseEvent phaseEvent)
    }

    {} public void beforePhase (PhaseEvent event)
    If (event.getPhaseId () == PhaseId.RESTORE_VIEW) {/ / / this is the page's init}
    init();
    }
    }
    protected boolean isPostBack() {}
    If (getFacesContext () .getRenderResponse ())
    Returns false;
    on the other
    Returns true;

    }
    }


    and my bean;
    public class login extends phases {}

    @Override
    public void init() {}
    System.out.println("/***init***"); "
    }

    }

    but nothing (did not enter the init method);

    pls how can I do this? or another method if exists

    In my grain of support I lay phase Listener page

    SerializableAttribute public class OrderPage extends CustomPagePhaseListener {}

    You can manually create the pageDef (goto Structure window, on the view menu, click Structure; right click anywhere in the tree and click on go to definition of the Page, if there is no he will inspire you; click Yes) and it will look like below. Add the controllerClass in the pageDefinition tag. If you are still not clear, let me know your username email and I will send my code.

    
    
      
      
      
    
    

    After adding the controllerClass:

    
    
      
      
      
    
    
  • How to write a personalized check-ins

    Hello
    Version: UCM 11.1.1.5

    I need to write UCM custom component to extend the behavior of checkIn. When the document comes from Capture of Document, it must be registered in the specific folder. This folder id (collectionId) comes with document in the field of metadata (added by codes DC bar). What is the best way to replace default checkIn behavior? I want to say something like that, but im not sure is correct in this way:
    public class CheckinFilter implements FilterImplementor{
    
         public int doFilter(Workspace ws, DataBinder binder, ExecutionContext cxt) throws DataException, ServiceException{
    
              String barcodeStr = binder.getLocal("xBarcode");
    
              String collectionId  = processBarcodeString(barcodeStr);
    
                    binder.putLocal("xCollectionID", collectionId);
    
              return CONTINUE;
         }
    }
    Kuba

    Kuba,

    There are at least two other ways how to implement this requirement without a custom component. However, your approach will work as well - so I'll leave the decision to you which way to go. Note that CheckinFilter is not overwhelming, but rather strengthen the check-in.

    The other two ways are:
    -you could implement the code logic to bars, collectionId to ODC. ODC allows you to create various scripts where you could place the code necessary
    -you could also implement the logic in a global rule (in a code of idocscript)

    Also note that the rule of the world and checkinFilter will have to differentiate when the logic must be applied and which not. If I understood your direction, you want to drive through an another metadata field value xBarcode, but have you thought about what should happen if a user between the xBarcode and the xCollectionId?

  • How to write a procedure to call and run the custom package backend

    Hi all

    Oracle 10g
    Oracle Apps R12

    I work with here oracle order management, we have a package called (Pick Release) to customize. Due to a problem, we have this concurrent program execution manually giving Route_id as parameter. The route_id comes from the road to the Table. By using this query

    Select distinct route@DB_LINK_APPS_TO_ROADSHOW route_id
    When trunc (route_date) = trunc (sysdate + 2).

    on a daily basis, we have almost 42 routes and we run this simultaneous program manually close times.

    so now how to write a procedure for this

    Step 1 make the route to the routing table. (By cursor we can get the route_id accordingly)

    Step 2 How to trigger custom backend package and run accordingly to this output of the cursor (route_id)

    If 40 routes of cursor get is - that the simultaneous program runs 40 times according to this route_id.


    can some could provide the steps to do this


    Thanks and greetings

    Srikkanth.M

    To submit a competing request from the back - end:

    FND_REQUEST. SUBMIT_REQUEST (Client or server)

    Summary

    function FND_REQUEST. SUBMIT_REQUEST

    (application IN varchar2 default NULL,

    program IN varchar2 NULL by default,

    Description IN varchar2 default NULL,

    start_time IN varchar2 default NULL,

    sub_request IN default boolean FALSE

    Argument1,

    argument2,..., argument99.

    Return to argument100 number);

    Description

    Submits a competing treatment by a simultaneous Manager. If the query is successful, this function returns the ID of the concurrent request; Otherwise, it returns 0.

    ATTENTION: FND_REQUEST needs to know information about the user and accountability whose application is submitted. Therefore, this feature works of concurrent programs or forms within the Oracle Applications.

    The FND_REQUEST. SUBMIT_REQUEST function returns the ID of the concurrent application after successfully. It is up to the caller to issue a commit to complete the application.

    Your code should retrieve and handle the error message generated if there is a problem of presentation (the ID of the concurrent request returned is 0). Use FND_MESSAGE. RETRIEVE and FND_MESSAGE. ERROR to retrieve and display the error (if the application is made on the client side).

    Related essays: overview of the Message dictionary (see page)

    You must call FND_REQUEST. SET_MODE before calling FND_REQUEST. SUBMIT_REQUEST of a database trigger.

    If FND_REQUEST. SUBMIT_REQUEST fails to go anywhere but a database trigger, database changes are cancelled until the time of the function call.

    After a call to the FND_REQUEST. SUBMIT_REQUEST function, installation of all parameters are reset to their default values.

    Arguments (input)

    short name of the application associated with the concurrent request for enforcement.
    short simultaneous program (not the executable) name of the program for which the application must be made.
    Description Description of the application that appears in the form of concurrent requests (optional).
    start_time time during which demand is expected to start running in the (optional) HH24 or HH24:MI:SS format.
    sub_request set to TRUE if the request is made by another application and should be treated as a subquery.
    From version 11, this parameter can be used if you submit requests for in a concurrent program of PL/SQL stored procedure.
    argument1... 100 arguments for the concurrent request; up to 100 arguments are allowed. If the Oracle Forms submitted, you must specify all arguments of 100.

  • How to pass skinclass for custom component?

    Hi guys, I'm moving my main application of my custom component skinClass. Here is my code, but it gave me an error saying "initializer for 'skinType': values of type spark.componets.supportClasses.Skin' cannot be represented in the text. "  I don't know if it is possible to do. Any thoughts? Thank you very much.

    hand. MXML

    < components: loginPanel id = "loginPanel" horizontalCenter = "33" "-15" = Red

    skinType = 'skins. CustomPanel.

    loginButtonClick = "loginpanel_loginButtonClickHandler (event)" / >

    component loginPanel

    script

    [Bindable]

    public var skinType:Skin;

    MXML

    < s:Panel cornerRadius = "5".

    ID = "loginPanelComp".

    "32" = x y = '8 '.

    width = "373" height = "200".

    title = "sign in".

    skinClass = "{skinType}.

    >

    ...............

    < / sign >

    You try to pass a string to match the value of a class. SkinnableComponent skinClass property is a style.

    You must use styles css, or if you want to set this runtime do something like

    private var _skinRef: Class;

    public function set skinClassRef(value:Class):void

    {

    _skinClassRef = value;

    If (loginPanelComp)

    {

    loginPanelComp.setStyle (skinClass, skinRef);

    }

    }

    C

  • How to manage the focus in the custom component

    Hallo. As you know some flex components have indigenous focus, like buttons, textinput, etc... I created a custom component which is a borderContainer... As you know, by default, if the user press TAB my BorderContainer will never receive the focus... I tryied to set a property as setFocus() and tabFobusEnabled to true, but I still have some problems with my borderContainer development... It's as if my app knows that my custom component is not a native component... Is there a way for my component to receive focus without problems?... Which is the best way to do this?

    Thx a lot

    Max

    Components must implement IFocusManagerComponent in order to receive the focus.

  • How can I access an image embeded in a custom component?

    Hello

    I'm using Flex 3 and I want to access an image embedded in a custom component.

    Let's say that I included an image in the root of the application with the following code:

    [Embed ("myImage.jpg")]
    public var myImg: Class;

    ... and I made a custom in ActionScript using VBox as the base component

    ... and add an image control to the custom component.

    Is it possible that I can use the image embeded as a source for the image in the custom control?

    Hi the CCJA.

    Yes you can do...

    Just use as shown below.

    Import mx.core.Application;

    Don't forget to import the namespace above...

    Application.application gives a reference you to upper-class main level. of demand... and the variable of integration must be public, as you had already kep...

    Thank you

    Jean Claude

  • How to change the State of a custom component

    HI (sorry for my English)

    I am new to flex and actionscript...

    I hava a < Application > with 3 States.

    I also create and a custom component that I use in the 'Phase A '.

    Inside the element, I have a < LinkButton > click = "" currentState = "" but do not work. "

    I know that the easy solution is to get out the < LinkButton > component and put it on 'Stage-A' in the Application <>

    Please any other solution?

    Thank you

    You must add an import or you can use it like this

    mx.core.Application.application.currentState = "

    Sincerely,

    Michael

    Sent from my iPhone

    El 20/06/2009, a las 16:27, Ant - will [email protected]> escribio:

    >

    It gives me an error

    «1120: access of undefined property Application.»

    >

    I think I need to change the Application.application. But what?

    >

    Thank you

    >

  • Getting the list of Custom Component ListView

    Hello

    I'm trying to figure out how to get the 'checked' property of a custom component of QML.

    Basically, it's the same as the first example on https://developer.blackberry.com/cascades/documentation/ui/custom_components/index.html

    This is a list, with a listItemComponents, whose type: "item" contains a check box and the label.

    I have an ActionItem whose job is to take all elements that are enabled and do something.

    The ActionItem triggers a C++ code that should get this list.

    Problem is, I can't figure out how to get the selected items. I tried the selected() function but it returns empty.

    I have to turn this into a multiple selection?

    I got so far is the back of GroupModel, after selection, but this does not include anything other than what I fed in the first place. Which makes sense.

    There are a lot of similarities between this issue and the other. Should help to my code and comments in this post, I think: http://supportforums.blackberry.com/t5/Cascades-Development/LstItemComponent-doesn-t-track-the-model...

  • How to create the custom filter "addFiles" in Oracle UCM?

    Hello

    I need help on creating a filter custom in Oracle UCM in which I want to integrate a code custom until the file is checked in fact means of the Complutense University of MADRID, this custom piece of code should be called when the user clicks on the Check-In on a profile button to check-in a document and before the document is moved to the vault directory.

    UCM Check-In forms-> Check-In button-> [custom]-> Document moved to the vault dorectory as a native file-> after release document copied Weblayout directory.

    I came across a filter named 'addFiles' that can be used to achieve this goal, as stated in the link below:

    https://jonathanhult.com/blog/2012/09/favorite-WebCenter-content-filters/

    I'm kind of new at the Complutense University of MADRID and don't know how to implement it as a custom component or a custom filter...

    Could someone please help on how to start or steps that must be followed?

    Thank you and best regards,

    Sanket.

    The file must first be uploaded to the server. Your Java code will not work unless the file exists on the server. You can then edit this file before the rest of the consignment does not happen.

    This component, you should get pointed in the right direction: https://bitbucket.org/jhult/pdfpagenumbers/src

    Jonathan

    https://jonathanhult.com

  • Is it possible to "build" a custom component using a command line script?

    Hi all

    From time to time to replicate our environment in instances of development/sandbox sandbox, we need the current generation of custom components production.

    What we do in general is - Component Wizard allows you to "build" each component one & then download the ZIPs. \

    I wonder if there is some sort of command line to "build" a custom component?

    That would allow me to write a script to quickly create all my custom components in a go, whenever necessary.

    Kind regards
    Prateek

    To answer the original question, Yes, there is a command line tool to build, activate, deactivate and install the components (even with the preferences), her right here:

    / Data/Oracle/user_projects/Domains/my_domain/UCM/CS/bin/ComponentTool

    Usage: ComponentTool [v |-vv] [t trace_section]--enable |-disable name

    ComponentTool [v |-vv] [t trace_section]... - sync

    ComponentTool [v |-vv] [t trace_section]... [- Install] path.hda: path.zip [-path.hda Preferences]

    ComponentTool [v |-vv] [t trace_section]--check-depends name

    ComponentTool [v |-vv] [t trace_section]... - name of the package

    ComponentTool [v |-vv] [trace_section]...--list-enabled|--list-disabled|--list|--interact|--help t

    The only thing is to compile the Java classes for you. For this you will need to an ANT script or something.

  • Alternative to RIDC getResponseStream() in Custom Component

    I am trying to create a custom component that does some work with the primary file and checks in another file. When the replacement file is started, I want to check in the primary file.

    I have found a way to recover the primary file using RIDC, but I'd like to find a way to include this functionality in a custom filter class. Here's a snippet of what I want to reproduce inside the filter:

    ServiceResponse response = idcClient.sendRequest (userContext, binder);

    InputStream fis = response.getResponseStream ();

    OutputStream fos = new FileOutputStream (filename); @

    read of fis, write to fos

    the comparison/work

    My question is mainly to find where the content server provides the input stream for a file that is stored in the database.

    http://www.redstonecontentsolutions.com/technical-blog/Java-filter-retrieving-aFile

    http://www.ecmconsultant.NET/2011/09/UCM-11g-retreiving-rendition-path.html

    Jonathan

    http://jonathanhult.com

Maybe you are looking for