How to use classes of packages in flex mx:Script/ or mxml/

Hi.I am just learning Flex using Flex Builder 3 facing one problem,
Suppose I declare one package with name alert.as
package
import mx.controls.Alert;
public class alert
public function alertBtn()
Alert("Hello btn 1");
Now in want to use the function in mxml that I declared in a package.
<mx:Button label="btn1" click="alertBtn();"  />
I have few questions
1)How to Import the class alert.as in <mx:Script> and where should i store the file alert.as in the directory folder of flex?
2)How to call the function alertBtn() when btn1 is clicked.
Thanks so much!
Regards
Ankur

Hi Greg.I think I was not able to clear my problem properly.Let me try this time again.
What I wanted to do was that in the below written code I have the full access of the id=panel1 in the  script tag .This works properly.
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
import flash.display.Sprite;
import mx.core.UIComponent;
private function addChildToPanel():void {
var circle:Sprite = new Sprite();
circle.graphics.beginFill(0xFFCC00);
circle.graphics.drawCircle(0, 0, 20);
var c:UIComponent = new UIComponent();
c.addChild(circle);
panel1.addChild(c);
]]></mx:Script>
<mx:Panel id="panel1" height="100" width="100"/>
<mx:Button id="myButton" label="Click Me" click="addChildToPanel();"/>
</mx:Application>
This above functionality when I tried to do using class Outside the code ,its not working !
Here is with the package:-
But suppose I make One package 
package
import flash.display.Sprite;
import mx.core.UIComponent;
class getPanel extends Sprite
public function addChildToPanel():void {
var circle:Sprite = new Sprite();
circle.graphics.beginFill(0xFFCC00);
circle.graphics.drawCircle(0, 0, 20);
var c:UIComponent = new UIComponent();
c.addChild(circle);
panel1.addChild(c);
          }//class
                    }//package
Now in MXML
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
import getPanel;
]]></mx:Script>
<mx:Panel id="panel1" height="100" width="100"/>
<mx:Button id="myButton" label="Click Me" click="getPanel.addChildToPanel();"/>
</mx:Application>
So My problem is that this code doesnt do anything.
Neither the addChild function is working in it ,Nor the Panel1 is accessible here.
Can u pls help me here.
Thanks
Ankur

Similar Messages

  • How to use user-defined packages in JAX-RPC web service

    I am trying to use Object of my class located in my package in jax-rpc webservice,the code is
    package supercomputer;
    import Hello.*;
    public class SuperImpl implements SuperIF
    public String sendParam(String data)
    Temp ob=new Temp();
    int i=ob.get1(10000);
    return data+"returned by supercomputer";
    Temp is located in Hello package,I have jar the Hello package as Hello.jar and has set its classpath in targets.xml of Ant tool.
    The code compiles well and service is deployed successfully,but when i try to call the service from the client its gives me following error.
    [echo] Running the supercomputer.SuperClient program....
    [java] java.rmi.ServerException: Missing port information
    [java] at com.sun.xml.rpc.client.StreamingSender._raiseFault(StreamingSender.java:357)
    [java] at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:228)
    [java] at supercomputer.SuperIF_Stub.sendParam(SuperIF_Stub.java:60)
    [java] at supercomputer.SuperClient.main(Unknown Source)
    I dont know if it deploys why it gives error on client side.
    Please tell how to use user-defined packages and class in jax-rpc service code ,i am not talking about passing user-defined parameters i am just talking about making objects of user defined classes in jax-rpc service.I think there is some problem in classpath.
    Please guide me in doing that.
    Thanks,
    Farrukh

    Farrukh,
    I don't know if your error is about a missing class from your custom package, ... what track did you followed to say that?
    To use your package in the implementation of you web service, you should only follow the rules of making a web application: put your package jar in your \lib directory inside WEB-INF/ or your package classes unjared in classes (also in WEB-INF/).
    As I already said, I have doubts that your error should be originated from a missing class from your package, but:
    -try to see the logs (errors?) when you deploy your web service that could give a hint about the problem.
    -try to see if you can access your endpoint through your browser to see if there is a online status
    -display your config/WSDL file, and the steps you did to build your web service.
    regards,
    Pedro Salazar.

  • How to use my as3 file in flex

    hi, I am new in flex and want to divert into flex. How to  use my as3 file into flex. Is there any sample tutor . so, that I could learn fast.

    Please clarify. Is this .as file a class you previously used as a complonentcomponent you now wish to use as the main application?
    If the .as file just has variables and functions you wish to access from your Flex app, use:
    include "subfolder1/subfolder2/etc/MyASFile.as";
    If you want to use classes from the file, do this:
    import subfolder1.subfolder2.etc.MyClassName;
    If this post answers your question or helps, please mark it as such.
    Greg Lafrance - Flex 2 and 3 ACE certified
    www.ChikaraDev.com
    Flex / AIR Development, Training, and Support Services

  • Need samples how to use classes in WebDynpro

    Hi,
    I Need To simple Samples how to use classes in WebDynpro.
    Regards

    Continued....
    and in the model
    right click->create model
    select the radio button import java bean .
    next ADD jars option will be seen
    Browse the jar on the dekstop.
    now add this model to the used models by right clicking on it.
    Now if you go to Data Modeler.
    You will find the used model.
    From there map to the component controller->view Controller.
    And continue with ur coding.
    Hope this helps you.
    Thanks & Regards,
    Lokesh.

  • How to use  third party package in java application

    hi, i am a student , new to java world can any of u tell me how to import third party package in our java application.
    i want to know how CLI is done in java.
    i am going thru this link http://www.codezoo.com/pub/component/5574
    not able to get anything.
    please please help me

    There are two steps -
    1. Import the classes you need from the package(s) using the Java import statement in your classes that need access to them.
    2. include the 3rd part code (one or more .jar files and/or root directories holding the code's package tree and .class files) to your javac and java class path and optionaly to the class path found in your .jar's manifest file.

  • How to use JPublisher generated package in JSP

    I am finding difficulty in using JDeveloper genereted (Using JPublisher) package ( from PL?SQL packages of Oracle) using in JSP . can any body help
    Prashant

    Can you be more specific on what you are doing and what problem you are facing.
    You can refer JPublisher documentation here.
    http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96658/toc.htm
    JPub help with Jdeveloper
    http://otn.oracle.com/jdeveloper/help/
    Go to using SQL in Java Programs ->Accessing Oracle Objects and PL/SQL Packages using Java
    Also you can see how JPub generated classes can be used in SQLJandJPublisherSample at following url. You can apply similar concept for JSPs.
    http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/9i_sqlj/9i_sqlj.html
    Chandar

  • How to use Class "CL_GUI_CHART_ENGINE" in a abap program ?

    Hi Guys,
    I want to display data in my internal table in the form of a Graph using class "cl_gui_chart_engine".
    I had a look at sample program given by SAP - GRAPHICS_GUI_CE_DEMO but need some help to understand how can we use our own data to be displayed in the graph ? Basically what I am looking for is that where we need to do the changes in creation of XML file so that we can pass our own data ?
    ( perform create_data_demo using l_ixml_data_doc)
    Could you please help me with some sample code or pseudocode ?
    Thanks
    Ashwa

    Thanks Kai,
    I had already done the same thing and got the required output.
    Populate X-Axis ( Categories )
      LOOP AT ITAB.
    Populate Categories
        l_element = p_ixml_doc->create_simple_element(
                  name = 'C' parent = l_categories ).
        l_element->if_ixml_node~set_value( itab-value).
      ENDLOOP.
    Populate Y-Axis ( Values )
      LOOP AT VALUE_TAB.
       l_element = p_ixml_doc->create_simple_element(
                 name = 'S' parent = l_series ).
        l_element->if_ixml_node~set_value( value_tab-value).
      ENDLOOP.
    I am now trying to find the ways to change the default layout of the graph. I guess it should be done in "perform create_custom_demo using l_ixml_custom_doc." . I want that my graph should be displayed as lines instead of bar's.
    Once I achieve this I will share my findings along with sample code with the community.
    I wish I could get some documentation on class "cl_gui_chart_engine" and interfaces like "if_ixml_document".
    Thanks
    Ashwani

  • How to use class.getResource() to create an ImageIcon

    Hi,
    I am well acquainted with creating and using ImageIcon icons using the ImageIcon constructor
    and putting the image file in a folder called Images which is at the same level as the
    bin and src folders.
    I discovered a demo program, LayeredPaneDemo, that uses class.getResource() to create
    an icon and found that in my eclipse version, the icon's image file was not found when
    I used the original getResource() call but the icon was created when I used the ImageIcon
    constructor.
    I posted on JavaRanch and eventually realized that the image file needed to be with the
    .class files, so I moved the Images folder under bin and getResource() works fine and I'm
    happy.
    However, I have three questions for you.
    One poster on JavaRanch told me that it's better to use getResource() rather than the
    ImageIcon constructor for distributing an app (I'm not distributing anything but want
    to do it all correctly).
    Do you agree with that or can I safe keep using the ImageIcon constructor?
    Another poster told me he doesn't think it's safe to leave the image file in bin because
    it might be lost during the build in eclipse and that there is a way to have eclipse copy
    the files to bin during the build which should mean that I can leave the images folder at
    the level of bin and src.
    Do you agree with that?
    If yes, how do I get eclipse to copy the file during the build?
    P.S.
    Before I posted on JavaRanch, I put the Images folder at every level of the project's
    directory as shown in eclipse (which is why I missed the bin folder until JavaRanch
    whacked me upside the head) and getResource() still didn't work.

    The contents of the Java Source folder are compiled if they're source files, copied otherwise (assuming no filter's been put in place to prevent copying), so your images belong under a source folder.

  • How to use class.forName

    I am trying to use Class.forName() from a string which is passed to me as argument.
    Class batchClass = Class.forName(args[1]);
    A jar file contains the class file for the string received above and I have this jar file in the manifest of my executable jar.
    I get a class not found exception when I run my executable jar
    Can some body give pointers..what could possibly be the issue.
    The jar file is in my classpath
    run script
    #!/bin/csh
    java -jar -DDBPROVIDER=NO -DDBUS_ROOT=$DBUS_ROOT -DVTNAME=$VTNAME ./jar/IntraDayDepotPositionBatch.jar MagellanStart IntraDayDepotPositionBatch INPUTFILE LOGFILE
    Exception
    Magellan program starting - program class IntraDayDepotPositionBatch
    Cannot find program class - IntraDayDepotPositionBatch
    IntraDayDepotPositionBatch
    java.lang.ClassNotFoundException: IntraDayDepotPositionBatch
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at com.db.mmrepo.app.IntraDayDepotPositionBatch.MagellanStart.main(Unknown Source)
    Thanks for your time and feedback on this

    actually i tried both...with package name and without package name..
    nothing worked...
    my manifest file also contains the path to the package..so does the classpath

  • How to use the Client_image package

    I need to use the client_image package (read_image_file, write_image_file) to do the file upload from my client pc.
    we use a digtal camera to take picture and need to use the oracle 9i form webutil to insert into the form and save in 9ias.
    Any samples about how I can use the webutil to upload images will be truly appreciated!
    Thanks for replying!

    Thanks for your reply on Oracle Forums about using webutil to perform image upload in 9i forms.
    I just download the new Webutil Demo but I got the error messages:
    WUC-015: Your Form must contain the following Bean for this function to be available:
    Oracle.forms.webutil.clientinfo.GetClientInfo
    WUC-015: Your Form must contain the following Bean for this function to be available:
    Oracle.forms.webutil.fileTransfer.FileTransfer
    WUC-015: Your Form must contain the following Bean for this function to be available:
    Oracle.forms.webutil.browser.BrowserFunctions
    I have done all the environment config. and things in FAQ
    (Make sure the your environment is set up correctly; including issues such as CLASSPATH and ensure it is no longer that 512 characters.
    Ensure that the WebUtil object group has been dragged onto the form.
    By putting the form into visual view, ensure that you have a window called WEBUTIL_HIDDEN_WINDOW and that it contains a set of WebUtil Java Beans.
    If your forms does already contain the WebUtil object group then the cause is likely to be that the triggers used internally by the bean areas are uncompiled (usually because the OLB was subclassed before the library was attached). To resolve the problem try performing a Compile All on your module (ctrl-shift-k))
    The errors are still coming out and would you please let me know what I should do to solve the problem and thanks a lot!

  • How to use classes CL_DOCX_*

    We have a need to use word 2007 OOXML classes  all of which start with CL_DOCX*.
    Basically what we are trying to do is take a DOCX files (File 1 & File 2) saved by MS WORD 2007 application and replace the header of File 1 with the header from File 2.
    The basic functionality described above is working fine. However the same is not working when the header from File 2 has an IMAGE embedded in it.
    We found several  word 2007 OOXML classes  in the system (all of which start with CL_DOCX*), but couldn't find usage for these classes anywhere in the system or SDN or OSS Notes etc.,
    Just wondering whether anyone used these classes in their development environment and whether they can share this information here?
    Any help in this regard is highly appreciated.
    thanks,
    -Sreenath

    Which NetWeaver release are you using? The whole OOXML seems to be evolving within EhPs.
    You'll find examples how to use the framework in the Unit Tests of class CL_DOCX_FORM - so have a look at those classes. For me those test code runs fine.
    Best Regards,
    Tobias

  • How to use classes from an existing outside library ?

    Dear People,
    I added a library to use classes already built.
    In JBuilder7 I went to Tools | ConfigureLibraries
    and added the objectdraw library. At the left when I look in the
    directory structure under User Home is "objectdraw" so I did
    add the library correctly but when I put in the coding a try
    to run it, the error messages say:
    "MakeBox.java": Error #: 200 : <identifier> expected at line 8,
    which is the line : public void MakeBox()
    The entire code is :
    package stan_e_makebox;
    import objectdraw.*;
    import java.awt.*;
    public class MakeBox extends WindowController
    void public MakeBox()
    public void onMousePress(Location point)
    new FilledRect(40,80,30,20,canvas);
    public static void main(String[] args)
    new MakeBox();
    Thank you in advance
    Stan

    oo sorry,
    this is the constructor i assume, so should be
    public MakeBox()

  • How to use classes in Actions tab

    Hello guys!
    I'm just a beginner so i'm sorry for my stupid question.I'm developing a game in which movie clips in our case people have their own schedule.I have multiple screens and so i want to be able to set their locations and make them invisible on other screens(rooms)they're not currently at.The trouble is i can't use variables from Actions in my class,neither can i use classes in my Actions.Can anyone tell me how to export classes into Actions code?
    Here is my code:
    var currentlocation;
    var currentscreen;
    if (person.currentlocation!==currentscreen){
    person.visible=false;
    btn.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
    function fl_MouseClickHandler(event:MouseEvent):void
              currentscreen = "classroom";
              classroom.visible = true;
              playroom.visible = false;
    btn_2.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);
    function fl_MouseClickHandler_2(event:MouseEvent):void
              currentroom = "playroom";
              classroom.visible = false;
              playroom.visible = true;

    Your problem/question is not clear to me.  If you are getting errors you should include the error messages in your posting.
    Could the problem arise from using a variable that is not defined?
    currentroom = "playroom";
    I do not see currentroom defined as a variable anywhere.  There is a currentscene variable though.

  • How to use .class files from jsp

    hi i want to use .class files in my jsp program can any one help me

    so if you are using pacakges here is normal example...
    say you .java code is something like...
    package com.util;
    public Class BeanUtility{
    }place the .class file at WEB-INF/classes/com/util folder if those folders are missing create it and place the .class file there. or pacakage it as a jar file & put it into WEB-INF/lib folder
    Now in jsp you can either use jsp:Usebean tag or use normal scriplets to create an instance of the nessary class...
    here is an example for you
    <%@ page language="java" import="com.util.BeanUtility" %>
    <%
    BeanUtility bn = new BeanUtility();
    %>however,i'd suggest you to make use of JSTL / Inbuilt tag libraries /MVC 2.0 approach for better maintainance & readablity.
    Hope this might help
    REGARDS,
    RaHuL

  • How to use two different packages which in  different directories?

    In my progrom, I'm using two differnet packages that in two different directories, but if I use classpath , the program can only be in one environment, so what can I do?

    or you set your classpath to the first common dir they have, and specify the packages from that dir on...
    or you just simply copy (you don't have to move it) the one package together with the other package...
    by the way you can add multiple paths to your classpath...
    between the paths you specify a ";"
    if i'm not mistaken...
    SeJo

Maybe you are looking for

  • Unable to install java on Mac OSX Lion.

    When getting promted with a "you must download java runtime"-dialogue box, it says I'm not connected to an internet connection when I most certainly are. I've tried every known method for installing java on this OS, all of them prompts me with the sa

  • Variable switch with no other variables or temps

    I am a first level Java student in college. We have been instructed to write a Java program that promts the user to input three integers to int variables a, b,c and switch them so that a=c b=a and c=b with out using any other variables or temp variab

  • This is my iphone 4  ECID: ********, now restore or update showing error code 1 what can i do now?

    this is my iphone 4  ECID: ******, now restore or update showing error code 1 what can i do now?

  • URGENT - New business group

    I created a new BG, and LE,SOB ETC...., but my operating unit is still under old BG. CAN anyone help me out , how to c new BG

  • Segment Namespace Error

    Hi, Am using the SEGMENT_DELETE function which in turn uses SEGMENT_NAMING_CHECK. My requirement is to suppress an standard segment E1EDL44 if the E1EDL44-VELIN EQ 3. Unfortunately, it is giving me an error in segment_delete stating as "Name E1EDL44