Replace in external class

HI,
How can I modify an external class? For example to read a value from an outside class and replace it with another one.

You mean modify the state of an object? Your question is very broad and vague, but something like this might be what you're talking about.
// Assume Foo has the constructor, getter, and setter method below and they do what you'd expect
Foo foo = new Foo("Ed");
String oldName = foo.getName(); // gets the name "Ed" from the Foo object
String newName = oldName + "ward"; // "Edward"
foo.setName(newName); // set's the Foo's name field to "Edward"Edited by: jverd on May 17, 2008 10:16 AM

Similar Messages

  • How do I write an external class with global constants?

    Hi you all !
    First I want to explain what exactly I want to do:
    I have an application that should run in different resolutions. The app runs fullscreen, and I don't use Layouts or something, just a single Frame with a Graphics Object.
    Now to handle the different resolutions, I want to write an external class with some constants to use. The usage in my main Class should be something like this:
    public
    class blah
    private Constants myConstants;
    public blah()
    if (highResolution)
    myConstants = new hiResConstants();
    else
    myConstants = new loResConstants();
    System.println(String.valueOf(myConstants.SCREEN_WIDTH);
    }or somthing like that. The important fact is that I can choose the constants at runtime and that I am NOT forced to use methods to get the values, cause something like
    System.println(String.valueOf(myConstants.getScreenWidth());sux if you have methods using 5 or more parameters.
    Anybody out there who understood my problem and can help me??? PLEASE?
    best regards,
    Skippy

    First, what's so much worse about
    System.println(myConstants.getScreenWidth());
    than
    System.println(myConstants.ScreenWidth);
    Is the extra five characters really that bad? (Note
    you don't need the String.valueOf method call.)Well actually it was a wrong example I gave here, but it's not the call that makes me shake but the implementation:
    public int screenWidth = 1024;vs.
    public
    int getScreenWidth()
    return 1024;
    }Here it makes a bigger difference, even when you think of managing about 100 or even more constants.
    Second, why do you have methods that take five or more
    parameters!?Well, maybe this example show up what I mean:
    if (cursorIsInArea(100,100,200,200,areaId))
    doSomeStuff();Ok, I could use Rectangles here, but if you think of the timing here (I draw 30 frames / sec and this check comes about every frame or the animation would be choppy) I refuse to create an Object everytime I make this call.
    Btw: Is it worth thinking about the time of execution like I did in this example? OO is a neat thing, but is it that fast?
    I don't think isCursorInArea(new Rectangle(100,100,200,200),areaId) is such a great idea, but I might be wrong.
    It sounds like you're trying to compound a bad design
    with an even worse design for no good reason!Well, I'm not that experienced Java programmer to judge about that, but I (and my profs at university too) found my codes well structured and designed so far.
    Skippy
    PS: the string.valueOf(123) call came from cut&paste:
    system.out.println(string.valueOf(number1)+string.valueOf(number2));Try this without the function.... ;-)

  • Message Transformation Bean - Usage of external classes

    Hi SDNers,
    I am planning to write an external Java class to be loaded from AF_Modules/MessageTransformBean . The idea is simple, I want my class to handle an extra level of hierarchy in FCC process. I know writing the Java class which is as generic as the one provided by SAP is too complex. But I just want it for some specific requirements, so I dont intend to make it as a generic class.
    Should the external class that I write implement the interface Transform? If so, what is the jar file that contains this interface and where can I find this jar file in my XI installation?
    Also, what is the jar file that contains the standard class com.sap.aii.messaging.adapter.Conversion that gets loaded by default while using the MessageTransformBean?
    If you have already tried with similar requirements, please share your experience on the same.
    Thanks
    Jaishankar

    You can use the same module in J2SE and J2EE adapter without change.
    I recommend to install a J2SE adapter engine on a local PC for testing.
    I have found a sample code from previous tests:
    package sample;
    import com.sap.aii.messaging.adapter.Parameter;
    import com.sap.aii.messaging.adapter.trans.Transform;
    import com.sap.aii.messaging.adapter.trans.*;
    import java.io.*;
    public class MyModule extends Transform {
    Parameter parameter;
    String filename;
         public void init(TransformConfig config) throws TransformException{
                   super.init(config);
                   parameter = (Parameter) config.getParameters("Parameter");
                   filename = (String) parameter.get("filename");
         // obligatory method service
         public void service(TransformRequest request, TransformResponse response) throws TransformException {
              // Get the input stream for request message
              InputStream in = (InputStream) request.getMessage();
              // Get output stream for response message
              OutputStream out = (OutputStream) response.getMessage(Transform.MT_OutputStream);
              try{
                   execute(in,out);
              } catch (Exception e) {
                   throw new TransformException("TransformException: Error converting Message " + e.getMessage(), e);
         public void execute(InputStream in, OutputStream out) throws Exception{
              String filename = (String) transformConfig.getParameters("FileName");
              if (filename == null){
                   filename = "notfound.txt";
              // open file stream
              OutputStream fileOut = new FileOutputStream(new File(filename));
              // copy input stream to output stream and to file
              int c;
              while ((c = in.read()) != -1) {
                        fileOut.write(c);
                        out.write(c);
    //     main Methode, for local testing. A local XML file is expected.
          public static void main (String[] args) {
               try {
                    // Define Input stream and output stream from file
                    InputStream in = new FileInputStream(new File("source.xml"));
                    OutputStream out = new FileOutputStream(new File("target.xml"));
                    // call Mapping
                    MyModule map = new MyModule();
                    map.execute(in,out);
               } catch (Throwable t) {
                    t.printStackTrace();
               System.exit(0);

  • Flash player caches external class files

    Hi I work for a technology company in San Antonio and we use
    flash for developing interactive course ware. We use a flash shell
    which loads the separate pages of our lessons and have noticed a
    very big problem with the way the flash player caches class files.
    Basically it seems that when you use the 'import' call in
    actionscript the flash movie doesn't import the external class if
    it has already been loaded. the problem is that we have a huge
    amount of developed classes, many of which have been updated
    throughout our development. Is there any way for force clear the
    ASO cache in actionscript or force import external actionscript
    classes?

    Yes we know and use the delete aso files feature all the
    time. this however is a runtime problem. meaning that the flash
    player itself is caching class files and there is no way to get it
    to refresh these links without doing a forced refresh of the shell
    itself. this is something that is not an option as it doesn't allow
    for fluid page loading. Is there any way to force reload/import
    class files that have already been loaded, that is clear the
    class/aso cache in the flash player itself using actionscript
    code?

  • Working with AS3 External Classes

    Ok... trying to work with AS3 external classes. I have a movieClip that I want to also function as a button. Instance name is "_onDemand". This movieClip is on the stage of my Home.fla.  "_onDemand" movieClip properties   Class:HomePage  Base clase: flash.display.MovieClip
    I want the user to click this movieClip and take the user to an external URL within a new browser window or tab.
    Can anyone help me? Or at least point me to a really really good tutroial that does exactly this using external classes?
    Thanks so much,
    Mark
    My code:
    package com.cox4college.pages
    import com.gaiaframework.templates.AbstractPage;
    import com.gaiaframework.events.*;
    import com.gaiaframework.debug.*;
    import com.gaiaframework.api.*;
    import flash.display.*;
    import flash.events.*;
    import com.greensock.TweenMax;
    import flash.net.URLRequest;
    import flash.net.navigateToURL;
    public class HomePage extends AbstractPage
    public function HomePage()
    super();
    alpha = 0;
    //new Scaffold(this);
    override public function transitionIn():void
    super.transitionIn();
    TweenMax.to(this, 0.3, {alpha:1, onComplete:transitionInComplete});
    override public function transitionOut():void
    super.transitionOut();
    TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
    public class _onDemand extends Sprite
    // Link Navigation button handlers
    public var _onDemand:Sprite;
    // if you want a hand cursor
    _onDemand.buttonMode = true;
    _onDemand.useHandCursor = true;
    _onDemand.addEventListener(MouseEvent.CLICK, onDemandClickHandler);
    _onDemand.addEventListener(MouseEvent.ROLL_OVER, onDemandRollOverHandler);
    _onDemand.addEventListener(MouseEvent.ROLL_OUT, onDemandRollOutHandler);
    public function onDemandClickHandler(e:MouseEvent):void{
    navigateToURL(new URLRequest("http://ww2.cox.com/residential/santabarbara/tv/ondemand.cox"));
    public function onDemandRollOverHandler(event:MouseEvent):void{
    _onDemand.gotoAndStop("hover");
    public function onDemandRollOutHandler(event:MouseEvent):void{
    _onDemand.gotoAndStop("static");
    Getting the following errors:
    1120: Access of undefined property _onDemand.

    Ok. I admit it... I had some wonderful help to resolve this issue. You ever feel like you are on an island learning AS3 External Classes? I feel that way all the time... so far... I plan on not feeling that way soon. I hope this helps someone get off that island.
    package com.domainname.client {
        import flash.display.*;
        import flash.events.*;
        import flash.net.*;
        import flash.utils.*;   
        import caurina.transitions.Tweener;
        import caurina.transitions.properties.*;
        FilterShortcuts.init();   
        ColorShortcuts.init();      
        public class Main extends MovieClip {
            private var coverDelay:Number = 4;
            //#DF6D27
            public function Main():void {
                initMain();
            private function initMain():void {
                mc_form.visible = false;
                Tweener.addTween(mc_cover,{alpha:1,time:1,delay:coverDelay,onComplete:formIn});
                btn_onDemand.buttonMode = true;
                btn_listings.buttonMode = true;
                btn_ppv.buttonMode = true;
                btn_rhapsody.buttonMode = true;
                btn_onDemand.addEventListener(MouseEvent.MOUSE_OVER,navOver);
                btn_onDemand.addEventListener(MouseEvent.MOUSE_OUT,navOut);
                btn_onDemand.addEventListener(MouseEvent.CLICK,navClick);
                btn_listings.addEventListener(MouseEvent.MOUSE_OVER,navOver);
                btn_listings.addEventListener(MouseEvent.MOUSE_OUT,navOut);
                btn_listings.addEventListener(MouseEvent.CLICK,navClick);
                btn_ppv.addEventListener(MouseEvent.MOUSE_OVER,navOver);
                btn_ppv.addEventListener(MouseEvent.MOUSE_OUT,navOut);
                btn_ppv.addEventListener(MouseEvent.CLICK,navClick);
                btn_rhapsody.addEventListener(MouseEvent.MOUSE_OVER,navOver);
                btn_rhapsody.addEventListener(MouseEvent.MOUSE_OUT,navOut);
                btn_rhapsody.addEventListener(MouseEvent.CLICK,navClick);           
                function navOver(evt:MouseEvent):void {
                    Tweener.addTween(evt.target,{_color:0xffc614,time:.2});
                function navOut(evt:MouseEvent):void {
                    Tweener.addTween(evt.target,{_color:0xffffff,time:.2});
                function navClick(evt:MouseEvent):void {
                    var url;
                    switch (evt.target.name) {
                        case 'btn_onDemand':
                        url = new URLRequest("http://ww2.cox.com/residential/santabarbara/tv/ondemand.cox");
                        break;
                        case 'btn_listings':
                        url = new URLRequest("http://ww2.cox.com/myconnection/santabarbara/watch/entertainment/tv-listings.cox");
                        break;
                        case 'btn_ppv':
                        url = new URLRequest("http://ww2.cox.com/residential/santabarbara/tv/pay-per-view.cox");
                        break;
                        case 'btn_rhapsody':
                        url = new URLRequest("http://ww2.cox.com/myconnection/santabarbara/listen.cox");
                        break;                                                           
                    navigateToURL(url,"_blank");

  • Trouble Using DataProvider in External Class

    Hello,
    I am creating a Flash form which will include a drop-down selection menu from which a user may choose their state. I originally accomplished this by adding a ComboBox to the stage and then populated the ComboBox's DataProvider object with an XML listing of all the state names and the corresponding values. Everything works as expected.
    I have decided, however, that it would make the most sense to create an external class to accomplish the same thing. I have attempted to create such a class using the following code:
    package {
    import fl.data.DataProvider;
    import fl.controls.ComboBox;
    public class StateSelectionList extends ComboBox {
    private var xml:XML;
    private var dp:DataProvider;
    private var cb:ComboBox;
    public function StateSelectionList() {
    xml = <states>
    <state name="AL - ALABAMA" value="AL" />
    <state name="AK - ALASKA" value="AK" />
    <state name="AZ - ARIZONA" value="AZ" />
    </states>;
    dp = new DataProvider(xml);
    cb = new ComboBox();
    cb.dataProvider = dp;
    cb.labelField = "name";
    I then attempted to use this class in my Flash file by adding a ComboBox component to my library and then by creating a new StateSelectionList object and adding it the stage using the following code:
    var states:StateSelectionList = new StateSelectionList();
    addChild(states);
    The data provider for the new object is empty, however, as one can find by tracing the length of the object's dataProvider property;
    trace(states.dataProvider.length);
    I am new to creating external class files so I am not sure why the new object is not populated with any data. Thanks in advance for any suggestions.
    P.S. Please feel free to download the complete XML file I created for the states. The file includes all US states and possessions, US military states, and Canadian provinces and territories. http://windhorsemedia.com/private/states.xml

    There is a something tricky:
    first if you extend the combo box ther is no need to create a new instance in its constructor only to pass the data provider. This will work
        var xml:XML =<states>
                <state name="AL - ALABAMA" value="AL" />
                <state name="AK - ALASKA" value="AK" />
                <state name="AZ - ARIZONA" value='AZ' />
                </states>;
                dataProvider=new DataProvider(xml);
    dataProvider is public from base class ComboBox so you can access it anytime. But the properties that are inspactable may be setted with effect only after second frame is passed so try this
    public class StateSelectionList extends ComboBox {
            public function StateSelectionList():void
              addEventListener( Event>ENTER_FRAME, onsecondFrame, false, 0, true )
    private function onsecondFrame( evnt : Event ): void
    removeEventListener( Event>ENTER_FRAME, onsecondFrame
                var xml:XML =<states>
                <state name="AL - ALABAMA" value="AL" />
                <state name="AK - ALASKA" value="AK" />
                <state name="AZ - ARIZONA" value='AZ' />
                </states>;
                dataProvider=new DataProvider(xml);
                labelField="name";
    Note, In my custom components when I extend the UIComponent a set the parameter in afterComponentParameters or CreateUI( I think this was the name ) methods but more fast is just to pass one frame and set the parameturs

  • How to import GreenSock external classes?

    Hi, I'm having some problems in importing GreenSock external classes into my flash project.
    Line 27: import gs.*;
    Desktop\myFlashAPPS\twitter\src\zainu\twitter\MainClass.as, Line 27
    1172: Definition gs could not be found.
    Here is the directory tree:
    myFlashApp (contains myproject.fla)
         src
              zainu
                   twitter (contains MainClass.as and gs folder)
    MainClass.as:
    package zainu.twitter{

    You could try specifying the path to the gs folder as if you were importing it directly from the myproject.fla file.
    You should set up a classpath for external classes for your system so that Flash has a ready reference for finding them.  YOu can set this up via using Edit -> Preferences... -> Actionscript -> Actionscript 3.0 Settings... -> specify a source path.  Normally what people do is create a folder in a relatively general location and use that as their source path.   Within that they place a "com" folder, and within that com folder they place their subfolders for different classes they acquire from outside sources, such as your gs folder.  So when you want to import the gs classes you can use... import com.gs.*;
    There is a tutorial at gotoandlearn that explains this...   http://www.gotoandlearn.com/play.php?id=30

  • How do I dynamically load a SWF that was compiled from an Fla with a linked external class file

    I am dynamically loading external SWFs in a Main Fla in response to clicks on a menu.
    The loading code is standard and works fine for all of the SWFs except one. When I try to load it I get the following error:
    Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
    I am certain that the URL to the problem SWF is correct. The SWF itself doesn't load any other SWFs or images.
    The problem SWF is linked to an external class file and compiled with it.
    i.e. in the properties panel of the main timeline of the problem SWF's Fla I have entered the path to the external class.
    1. there is no problem compiling this SWF with the class (it works fine by itself)
    2. if I remove the external class from the properties panel and don't use it the resulting SWF imports without a problem into the Main Fla mentioned before
    So the problem seems to be the fact that the external class is linked in the properties panel. Is this a path problem?
    Would appreciate any suggestions,
    Thanks!

    despite what you say, that loaded swf most likely is loading something and that's the cause of the error.
    you could test that by putting the main swf's embedding html file in the same directory with problematic swf.  if the problem is as explained above, you'll have no problem when the main html is in the same directory with the loaded swf.

  • Including AS3 external class file

    How do I include 2 or more external action script files in my FLA document.The first one is easy and taken care by setting the class property of the FLA document to the class file name. But if I have several external class files? I have tried the 'include' directive but the compiler complains - any suggestions?
    Thanks
    Joseph Karov

    To import the other Class, just start typing its name in an expression, and hold down the control key while hitting the space bar. Both the Flash IDE and Flash Builder will bring up a code completion dropdown. When you select the Class, the import statement will be generated.
    For example, if you are in Foo and you type:
    protected var bar:Bar;
    Then when you have typed in the "Ba" part of the word Bar after the colon, if you use the Ctrl-Space keyboard shortcut, it should show you your Bar Class, possibly among other Classes starting with "Ba." Select "Bar" with either your mouse or your cursor, and Flash will finish the word for you and generate the import statement. Note that you can now create and use instances of Bar, but Bar won't be "merged" into Foo, which it sounds like is what you want. To do that, you'll need to do what I suggested, which is to have one Class extend another Class.
    To have one Class extend the other, change the line that says "public class Foo" to "public class Foo extends Bar". Note that the two Classes must have compatible functionality and have the same base Class. I'm assuming they do, or else trying to "include" the code wouldn't work either.
    Another possible solution, depending on exactly what you're trying to acheive, is to apply the second Class to a symbol in the library and use that by placing it on the stage or accessing it through code. However, you haven't given us very much to go on, so it's really difficult to help you.

  • Use "external" classes as plugins

    hi everyone :-)
    i have an application which offers some plugins to the user.
    now the thing is: the plugins shouldn't be included into my JAR-file, the should be in an external folderstructure outside of the JAR.
    when i use the Class.forName(...)-method, i cannot access the external classes... even if i add the package-path of them (i.e. "pluginsp.plugin1.Plugin1")
    has anyone an idea how to solve?
    thx a lot & regards
    manu

    OSGi is pretty bulky and is a spec. Eclipse is built around OSGi. Perhaps the better implementation is OSCAR, an open-source implementation of OSGi that is more a stand-alone plugin engine like my Platonos Pluginengine is.
    Depends on what you want. Small, fast, easy to work with and get up in about 5 mins? Go for mine. If you need something a little more industry standards based but is more complicated to work with and quite a bit bulkier in terms of the library size, go for OSCAR. I am not slamming OSCAR or OSGi. OSCAR is very slick, and OSGi is a great initiative. Just offering another solution that may work out better.

  • Need advice in regards to external class scripting!!

    Hello all,
    For my Flash class, my professor is making us create a four room "adventure game" created entirely in an external class with ActionScript.
    I know how to get things set up, but does anyone have any references or website suggestions that would help me create the mechanics for a multi-room adventure game?
    Much obliged,
    Jerry

    create a document class that instantiates each of the 4 room classes.

  • Replacing an external drive

    I am replacing an external drive that failed. It was previously backed-up with TM and I am restoring from that back-up. If I name the new drive the same as the old one, will TM treat the existing back-up versions as a continuous record??
    I just want to make sure, after I restore 300GB of data, that TM doesn't immediately make another full copy of all that data.

    meljturner wrote:
    Thanks for the (bad) news Here's a follow-up question: How about if I turned TM off until after the restore then, before turning it on again, I deleted all the TM backups for the old drive to free up space. My thinking is that then the new full back-up of the restored drive would have enough space, without deleting back-ups of other important data. I hope this is clear!
    If I follow you correctly, then yes, if you're careful.
    Let me be sure: your internal HD did not fail; only an external that was also being backed-up by TM.
    After you restore from TM to a new external, you propose to delete all the past backups for that external only (not the ones for the internal).
    Enter the TM interface, and select any backup (except "now"), then select your computer name from the sidebar. That should list all the drives/partitions. Select the drive in question, then click the "gear" icon, and you should have the option to +Delete all backups of xxx".
    I've never done this, and would appreciate a post by anyone who has, but it should work.

  • Running external class

    Hi
    i need call some external class from web service method.
    Normally it works, but somehow it doesnt work when i'm calling it from web service.
    Do you know where is problem and how to solve it?
    Thanks in advance.
    code is bellow:
    try {
                String[] cmd = new String[3];
                cmd[0] = "cmd.exe" ;
                cmd[1] = "/C" ;
                cmd[2] = "java -cp lib\\jade.jar;lib\\jadeTools.jar;lib\\iiop.jar;lib\\base64.jar;lib\\http.jar;lib\\log4j-1.2.14.jar;. resender.WatchdogStarter bubak bubu";
                Runtime rt = Runtime.getRuntime();
                Process proc = rt.exec(cmd);
                // any error message?
                StreamGobbler errorGobbler = new
                        StreamGobbler(proc.getErrorStream(), "ERROR");
                // any output?
                StreamGobbler outputGobbler = new
                        StreamGobbler(proc.getInputStream(), "OUTPUT");
                // kick them off
                errorGobbler.start();
                outputGobbler.start();
                // any error???
                int exitVal = proc.waitFor();
                System.out.println("ExitValue: " + exitVal);
            } catch (Throwable t) {
                t.printStackTrace();
            }where StreamGobbler is:
    public class StreamGobbler extends Thread {
        InputStream is;
        String type;
        StreamGobbler(InputStream is, String type) {
            this.is = is;
            this.type = type;
        public void run() {
            try {
                InputStreamReader isr = new InputStreamReader(is);
                BufferedReader br = new BufferedReader(isr);
                String line=null;
                while ( (line = br.readLine()) != null)
                    System.out.println(type + ">" + line);
            } catch (IOException ioe) {
                ioe.printStackTrace();
    }

    solved.
    Problem was that application server couldnt find external class so i
    specified it with absolute path.

  • Referencing Stage From External Class

    I have an external class file that extends the MovieClip
    class and is linked to a movieClip on the main stage. I need it to
    be able to access properties of other movieclips on the main stage.
    How could I do this. Here is what my base movieclip class that I
    want to access the stage with looks like. Remember, it is linked to
    a movieclip on the stage, if that matters...
    Obviously there is more code in the class, but I removed it
    for the sake of simplicity.

    that's what I thought too, but it's not working.
    in my document class Main I tried
    mc_bg:MovieClip = new mc_background();
    then i tried passing the mc_bg MovieClip instance to the Background class.
    That gives Error 1180: Call to a Possibly undefined method mc_background.

  • Referencing external classes in the classes loaded into ORACLE8i

    Hi
    If I have to load a .class file into oracle8i and if it references another class XYZ.class file in the path /export/home/user what should I do to resolve during the loading. What happens if XYZ.class imports from a test.jar.
    Thanx

    Any external class references from classes loaded in ORACLE 8i must also be loaded into the database. The classes loaded into the db must be transitively closed. All external class reference must be either in the CORE Java api's (provided by Oracle) or must be loaded with the class in question.

Maybe you are looking for