Vars within a subfunction in custom class...

Hey hey!
I have beeen a Flash coder for a long time, but just now I
decided to step in custom classes, and I confess that there is some
peculiar details that are driving me crazy. I am trying (with no
success) since yesterday to figure out for what reason I cannot
reach a class var from within a subfunction (it always return me
undefined).
Look below the simple example that shows that:
code:
class MyTest
private var testvar:Number;
private var KeyboardListener:Object;
function startVar ()
this["testvar"] = 1;
function startKeyboard ()
trace (this["testvar"]); // it works...
KeyboardListener = new Object();
KeyboardListener.onKeyDown = function ()
trace (this["testvar"]); // it DOESN'T works!
Key.addListener(KeyboardListener);
As you can see, the first trace (that is within the function
StartKeyboard works as is can see the var); but the second trace
(tha is within the onKeyDown event subfunction DOESN'T works!!
Well, the fact is that I NEED to have access to the vars
within it, and I cant see a way to figure out this.
Anybody out there already experienced this situation and know
hot to resolve that?
PS: Before someone there asks "Why this guy is using
this["testvar"] instead testvar?" The answer is: that's because I
will use vars with dynamic names, then I need to know how to make
it work THIS way...
Thanks a lot.

I'm not sure wether it will be OK in your final design, nor
do I really
know wether it's proper OOP (probably not...) but this will
work:
//-------------- in class file:
class MyTest
private var testvar:Number;
public function MyTest(){
startVar();
startKeyboard();
private function startVar ()
testvar = 1;
private function startKeyboard ()
trace (testvar); // it works...
Key.addListener(this);
public function onKeyDown(){
trace (testvar)
//-------------- in Flash timeline:
import MyTest;
t = new MyTest();
Compared to your script, the main differences are that I
ditched the
KeyboardListener Object. The class itself will become the
listener.
Problem with your code was that when the onKeyDown
eventhandler fired,
it was in the context of the object 'KeyboardListener'. This
object had
no property (or variable) called 'testvar'. In other words:
'this'
pointed towards the variable 'KeyboardListener' instead of
the instance
of class MyTest.
If you would have written this:
KeyboardListener = new Object();
KeyboardListener.testvar = "I'm the property
KeyboardListener";
KeyboardListener.onKeyDown = function ()
the output window would have shown: I'm the property
KeyboardListener.
I added a constructor. This is needed for the instantiation I
used on
the Flash timeline script.
Next I removed the bracket access to the propertie (or
variables) of 'this':
trace(testvar);
instead of:
trace(this["testvar"]);
I assume the first method is faster but that's no more than,
I hope, an
educated guess.
Oh, read the rest of the post.... OK
hope this helps.
BRFlasher wrote:
> Hey hey!
>
> I have beeen a Flash coder for a long time, but just now
I decided to step in
> custom classes, and I confess that there is some
peculiar details that are
> driving me crazy. I am trying (with no success) since
yesterday to figure out
> for what reason I cannot reach a class var from within a
subfunction (it always
> return me undefined).
>
> Look below the simple example that shows that:
>
>
> code:
>
>
>
>
> class MyTest
> {
> private var testvar:Number;
> private var KeyboardListener:Object;
>
> function startVar ()
> {
> this["testvar"] = 1;
> }
>
> function startKeyboard ()
> {
> trace (this["testvar"]); // it works...
> KeyboardListener = new Object();
> KeyboardListener.onKeyDown = function ()
> {
> trace (this["testvar"]); // it DOESN'T works!
> }
> Key.addListener(KeyboardListener);
> }
> }
>
>
>
>
> As you can see, the first trace (that is within the
function StartKeyboard
> works as is can see the var); but the second trace (tha
is within the onKeyDown
> event subfunction DOESN'T works!!
>
> Well, the fact is that I NEED to have access to the vars
within it, and I cant
> see a way to figure out this.
>
> Anybody out there already experienced this situation and
know hot to resolve
> that?
>
> PS: Before someone there asks "Why this guy is using
this["testvar"] instead
> testvar?" The answer is: that's because I will use vars
with dynamic names,
> then I need to know how to make it work THIS way...
>
> Thanks a lot.
>
aloft
Hoge der A 20a
9712AD Groningen
The Netherlands
[email protected]
http://www.aloft.nl
tel: 06-22360652
KVK: 02094451
Bnk: 21.23.89.408

Similar Messages

  • Listening to event within custom class

    I've created a custom class that posts to a web page to authorize a user. How can I listen for an event within the custom class?
    This is my code within my main class.
    var customClass:CustomClass = new CustomClass();
    var testingString = customClass.authorize("[email protected]", "password");
    the fuction "authorize" within the customClass looks like this:
    public function authorize(user:String, password:String):void
      jSession = new URLVariables();
                                  j_Loader = new URLLoader();
                                  jSession.j_username = user;
                                  jSession.j_password = password;
                                  jSend.method = URLRequestMethod.POST;
                                  jSend.data = jSession
                                  j_Loader.load(jSend)
    How can I fire an event within my main class once the j_Loader triggers Event.COMPLETE?

    You can fire an event using the dispatchEvent() function.
    In your main class you assign a listener for the event the CustomClass dispatches after it exists.

  • Arrays within custom Classes - same array for different instances?

    Hello all,
    I have made a very simple custom class for keeping track of groups of offices for a company.  The class has a Number variable to tell it how many different offices there are, and an Array to store the individual offices by name.  It looks like this.
    class officeCluster
        static var _className:String = "officeCluster";
        // variables
        var numOffices:Number;
        var locationArray:Array = new Array();
        // functions
        function officeCluster()
            trace("officeCluster constructor");
    Very simple!
    Now, it is my understand that when I create different instances of the class, they will each have their own version of "numOffices" and their own version of "locationArray".
    When I run traces of "numOffices", this seems to be true.  For example,
    trace(manufacturingOfficeCluster.numOffices);
    trace(servicesOfficeCluster.numOffices);
    yields
    5
    4
    In the output panel, which is correct.  However, there is trouble with the locationArray.  It seems that as I assign different values to it, regardless of what instance I specify, there is only ONE array- NOT one for each instance.
    In other words,
    trace(manufacturingOfficeCluster.locationArray[1].theLocation);   // theLocation is a String.  The locationArray itself holds Objects.
    trace(servicesOfficeCluster.locationArray[1].theLocation);
    yields
    New Haven, CT
    New Haven, CT
    even though I have defined elsewhere that they are different!
    Is anyone aware of any issues partaining to using Arrays within Class instances?  Any help would be appreciated!
    note:  I've been able to work around this by creating multiple arrays within the class and using a different one for each instance, but this seems very sloppy.

    Unfortunately, the code segment you attached results in:
    12
    12
    in the output panel.   So the problem must lie elsewhere!  Let me give some more detail...
    There are several files involved. The "officeCluster" class file looks like this:
    class officeCluster
         static var _className:String = "officeCluster";
         // variables
         var numOffices:Number;
         var locationArray:Array = new Array();
         // functions
         function officeCluster()
            trace("officeCluster constructor");
    I have two actionscript files which contain object data for the individual offices.  They look like this...
    var servicesOfficeCluster = new officeCluster();
    servicesOfficeCluster.numOffices = 4;
    var newHope:Object = new Object();
    newHope.locationName = "New Hope Office";
    newHope.theLocation = "New Hope, NJ";
    //more data
    servicesOfficeCluster.locationArray[0] = newHope; //array index is incremented with each entry
    //more Objects...
    and like this...
    var manufacturingOfficeCluster = new officeCluster();
    manufacturingOfficeCluster.numOffices = 5;
    var hartford:Object = new Object();
    hartford.locationName = "Hartford Office";
    hartford.theLocation = "Hartford, CT";
    //more data
    manufacturingOfficeCluster.locationArray[0] = hartford; //array index is incremented with each entry
    //more Objects...
    As you can see, the only difference is the name of the officeCluster instance, and of course the Object data itself.  Finally, these are all used by the main file, which looks like this- I have commented out all the code except for our little test -
    import officeCluster;
    #include "manufacturingList.as"
    #include "servicesList.as"
    /*lots of commented code*/
    manufacturingOfficeCluster.locationArray[1].theLocation = "l1";
    servicesOfficeCluster.locationArray[1].theLocation = "l2";
    trace(manufacturingOfficeCluster.locationArray[1].theLocation);
    trace(servicesOfficeCluster.locationArray[1].theLocation);
    Which, unfortunately, still yields
    12
    12
    as output :\  Any ideas?  Is there something wrong with the way I have set up the class file?  Something wrong in the two AS files?  I'm really starting to bang my head against the wall with this one.
    Thanks

  • Use of deployment classpath or shared-libraries to pick-up "custom" classes

    Hi,
    I’m trying to determine an approach to dealing with how classes are found in a deployed ADF application via classpath, etc. I’ve tried to explain the situation below as best I can so it’s clear. If you have any comments/suggestions as to how this could be done, it would be much appreciated
    Current Application structure:
    Consists of an application initially deployed to OC4J 10.1.3.4 using an alesco-wss.ear file
    Application contains a single Web Module, initially deployed as wss.war file within the alesco-wss.ear file above.
    The Web Module (wss) was built in JDeveloper 10.1.3.4 using 2 projects, a Model and ViewController project, and uses ADFBC.
    The Model project seems to also generate an alesco-model.jar file in the /WEB-INF/lib/ folder, even though Model classes are in the /WEB-INF/classes/ folder below?
    Exploded structure of application on application server looks something like:
    applications/alesco-wss/META-INF/
    /application.xml <- specifies settings for the Application such as Web Module settings
    /wss/
    /app/ <- directory containing application .jspx pages protected by security
    /images/ <- directory containing application images
    /infrastructure/ <- directory containing .jspx files for login, logout and error reduced security
    /skins/ <- directory containing Skin image, CSS and other files
    /WEB-INF/
    /classes/ <- directory containing application runtime class files as per package sub-directories
    /lib/ <- JAR files used by application (could move some to shared-libaries?) – seems to contain alesco-model.jar
    /regions/ <- directory containing .jspx pages used for Regions within JSPX template page
    /templates/ <- directory containing template .jspx pages used for development (not really required for deployment)
    /adf-faces-config.xml
    /adf-faces-skins.xml
    /faces-config.xml
    /faces-config-backing.xml
    /faces-config-nav.xml
    /region-metadata.xml
    /web.xml
    testpage.jspx <- Publicly accessible page just to test
    The application runs successfully using the above deployment structure.
    We plan to use the exploded deployment structure so that updates to pages, etc. can be applied individually rather than requiring construction and re-deployment of complete .EAR or .JAR files.
    What I’m trying to determine/establish is whether there is a mechanism to cater for a customisation of a class, where such a class would be used instead of the original class, perhaps using a classpath mechanism or shared library?
    For example, say there is a class “talent2.alesco.model.libraries.ModelUtil.class”, this would in the above structure be found under:
    applications/alesco-wss/META-INF/classes/talent2/alesco/model/libraries/ModelUtil.class
    Classes using the above class would import “talent2.alesco.model.libraries.ModelUtil”, so they effectively use that full-reference to the class (talent2.alesco.model.libraries as a path, either expanded or within a JAR).
    From the Oracle Containers for J2EE Developer’s Guide 10.1.3 page 3-17, it lists the following:
    Table 3–1 Configuration Options Affecting Class Visibility
    Classloader Configuration Option
    Configured shared library <code-source> in server.xml
    <import-shared-library> in server.xml
    app-name.root <import-shared-library> in orion-application.xml
    <library> jars/directories in orion-application.xml
    <ejb> JARs in orion-application.xml
    RAR file: all JARs at the root.
    RAR file: <native-library> directory paths.
    Manifest Class-Path of above JARs
    app-name.web.web-mod-name WAR file: Manifest Class-Path
    WAR file: WEB-INF/classes
    WAR file: WEB-INF/lib/ all JARs
    <classpath> jars/directories in orion-web.xml
    Manifest Class-Path of above jars.
    search-local-classes-first attribute in orion-web.xml
    Shared libraries are inherited from the app root.
    We have reasons why we prefer not to use .JAR files for these “non-standard” or “replaced” classes, so prefer an option that doesn’t involve creating a .JAR file.
    Our ideal solution would be to have such classes placed in an alternate directory that is referred to in a classpath such that IF a class exists in that location, it will be used instead of the one in the WEB-INF/classes/ directories, and if not such class is found it would then locate it in the WEB-INF/classes/ directories.
    - Can a classpath be set to look for such classes in a directory?
    - Do the classes have to replicate the original package directory structure within that directory (<dir>/talent2/alesco/model/libraries)?
    - If the class were put in such a directory, without replicating the original package directory structure, I assume the referencing “import” statements would not locate it correctly.
    - Is the classpath mechanism “clever” enough to search the package directory structure to locate the class (i.e. just points to <dir>)?
    - Or would the classpath mechanism require each individual path replicating the package structure to be added (i.e. <dir>/talent2/alesco/model/libraries/ and any other such package path)?
    If we are “forced” to resort to the use of JAR files, does a JAR file used for the purpose of overwrite/extending a sub-set of classes in the original location need to contain ALL related package classes? Or does it effectively “superset” classes it finds in all JAR files, etc. in the whole classpath? That is, it finds talent2.alesco.model.libraries.ModelUtil in the custom.jar file and happily goes on to get the remainder of talent2.alesco.model.libraries classes in the other core JAR/location. Or does it need all of them to be in the first JAR file for that package?
    Any help would be appreciated to understand how these various class visibility mechanisms could be used to achieve what is required would be appreciated.
    Gene

    So, nobody's had any experience with deploying an ADF application, and providing a means for a client to place custom classes in such a way as they're used in preference to the standard application class, effectively to implement a customised class without overwriting the original "standard" class?
    Gene

  • Reproducing Incident Form Elements in a Custom Class

    Hello again everyone,
    I am trying to rollout a completely separate module in SCSM to record MACD (Move/Add/Change/Delete) requests. I decided to use the OOB incident module as my base class as it already contained many fields I require (I inherited the properties
    and relationships) and created a new form assembly in Visual Studio to wire the properties to.
    After created the form and labels, I imported the .dll into the Authoring Tool so I can just drag out each property from the MP explorer onto the form. Everything works except for the last few fields which are a bit more complex than a standard list or textbox.
    I cannot seem to add the controls for the more complicated items like "Affected Services" or "Affected Items", when I try to drag them out to the form I get an error saying cardinality is not set to 1... I am guessing this is because
    its trying to map a relationship between a workitem and a service instead of my custom class and a service...
    So I went back into Visual Studio and added a ListView to the form, thinking I will have to wire the data bindings inside the form itself. However, I am stuck as I am not sure where "Services" are being written to, as I will need this location
    to reference in my empty ListView. I have provided my code and commented where I believe I am missing logic. Thank you in advance for any help!
    Note: "servicerelatestoworkitem" is not actually an object, my logic is conceptual and I still have not found which class/object the list of services is being written to.
    C# Code containing button logic (an add button to add a service to the ListView, and a delete button to remove a service from the ListView.
    private void add_services_button_Click(object sender, RoutedEventArgs e)
       // Open list of Services here, allow user to pick a service, then add selected service to "servicerelatestoworkitem"
       // AffectedServicesListView is populated from servicerelatestoworkitem
    private void del_services_button_Click(object sender, RoutedEventArgs e)
        // Test to see if item is being selected and display selected item to confirm ability to manipulate variable
        try
            var itemSelected = ListView.GetIsSelected(AffectedServicesListView);
            MessageBox.Show(itemSelected.ToString());
        catch (Exception ex)
            MessageBox.Show(ex.Message);
        // Remove selected item from servicerelatestoworkitem and refresh AffectedServicesListView
    XAML Code containing the list view and two buttons: (Note: The binding is most likely incorrect, I was just experimenting with it)
    <ListView x:Name="AffectedServicesListView" HorizontalAlignment="Left" Height="95" Margin="10,414.6,0,0" VerticalAlignment="Top" Width="521" ItemsSource="{Binding Path=AffectedServicesListView, Mode=Default, UpdateSourceTrigger=PropertyChanged}">
                            <ListView.View>
                                <GridView>
                                    <GridViewColumn/>
                                </GridView>
                            </ListView.View>
                        </ListView>
                        <Button x:Name="add_services_button" Content="" HorizontalAlignment="Left" Margin="470.55,382.749,0,0" VerticalAlignment="Top" Width="27.674" Height="26.851" Click="add_services_button_Click" BorderBrush="{x:Null}">
                            <Button.Background>
                                <ImageBrush ImageSource="add.png"/>
                            </Button.Background>
                        </Button>
                        <Button x:Name="del_services_button" Content="" HorizontalAlignment="Left" Margin="503.224,382.749,0,0" VerticalAlignment="Top" Width="27.776" Height="26.851" Click="del_services_button_Click" BorderBrush="{x:Null}">
                            <Button.Background>
                                <ImageBrush ImageSource="delete.png"/>
                            </Button.Background>
                        </Button>

    Cardinality is a property of relationships classes, not a property of specific relationships. each type of relationship has it's own cardinality values, but the engine only really recognizes "one" and "many". it makes sense to say that
    the "affected user" relationship is many to one, because Each work item can have one and only one affected user, but each users may be the affected user of many work items. The Related work items relationship is a many to many, because each workitem
    may be related to many other work items. it doesn't make sense to say this specific relationship between this IR and that user is "many to one", because each instance is only between one specific object and another specific objects. the cardinality
    just controls how many of those specific relationships instances can exist for each type of relationship. 
    There are no out of the box controls for many to many relationships. the Instance Picker control is designed to support one to one and many to one relationships. you'd have to write your own controls for support many to one relationships. Consider Travis
    Wright's SR Example for 2010, since most of this code should execute in 2012 and 2012r2 with only minor modifications. 
    You'd have to either find the control that defines it, like with the history tab, or recreate it using the
    authoring tool or
    Visual Studio. 

  • Parsing XML in a Custom Class Problem

    Hi, I am trying to parse an XML file from a class within my web app. It isn't a servlet, just a custom class to parse the xml.
    However, I keep getting a null document printed when I try to print the document to the log file. This is the class:public class XMLParser
         Document document;
         public XMLParser()
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
              factory.setValidating(true);
              factory.setNamespaceAware(true);
              try
                   DocumentBuilder builder = factory.newDocumentBuilder();
                   document = builder.parse(new File("SiteDescriptor.xml"));
              catch(SAXException sxe)
                   // Error generated during parsing
                   Exception x = sxe;
                   if(sxe.getException() != null)
                        x = sxe.getException();
                   x.printStackTrace();
              catch(ParserConfigurationException pce)
                   pce.printStackTrace();
              catch(IOException ioe)
                   ioe.printStackTrace();
              System.out.println("\n\n\n\n\n\n\n"+document+"\n\n\n\n\n");
    }I know this code works as I use the exactly the same code in another application with the same XML file.
    This is the XML file:
    <root host="http://localhost:8080">
         <branch name="Home Page" shortname="/" type="Home Page" instanceid="44987" typeid="1227">
              <branch name="Films Archive" shortname="/films" type="Branch" instanceid="96354" typeid="1778">
                   <leaf name="Evil Dead" shortname="/films/evil_dead" type="Films" instanceid="58985" typeid="1147"/>
                   <leaf name="1984" shortname="/films/1984" type="Films" instanceid="49741" typeid="1147" />
              </branch>
         </branch
    </root>And this is what I get when i print the document to the log file:
    [#document: null]
    Does anyone know why I cant get the class to read the document? I'm not getting any file not found exceptions or any other errors in the log.
    Cheers,
    Paul

    Hi duffymo, I have tried as you suggested. I created a ServletContextListener implementation and in my web.xml file I have defined the XML file as a <context-param> and I have also defined the listener.
    The ServletContextListener implementation creates the XML file as a resource using getResourceAsStream() and passes the InputStream to my parser. However, the parser still doesn't seem to work and prints out a null document in the log file: [#document: null]. Any ideas??
    The web.xml file:
               <context-param>
              <param-name>siteDescriptor</param-name>     
              <param-value>/WEB-INF/SiteDescriptor.xml</param-value>
         </context-param>
              <listener>
              <listener-class>cms.beans.InitializeXML</listener-class>
         </listener>
    ......and the ServletContextListener is:
    public class InitializeXML implements ServletContextListener
         static InputStream in = null;
         public void contextInitialized(ServletContextEvent sce)
              ServletContext context = sce.getServletContext();
              String siteDescriptor = context.getInitParameter("siteDescriptor");
              try
                   in = context.getResourceAsStream(siteDescriptor);
              catch(Exception e)
                   context.log("Error creating xml resource: " + e);
         public void contextDestroyed(ServletContextEvent sce)
         public static InputStream getXMLResource()
              return in;
    }Thanks,
    Paul

  • How to access MC's textfield created in a custom class?

    I have a custom class which creates a new MC using a library MC. The  library MC contains a dynamic textfield called productName.
    The custom class object gets created fine and is displaying on the  stage. It's also holding custom properties I set as well.
    How do I control the dynamic textfield inside the MC, which is inside  the custom class object?
    My Product.as:
    package {
         import flash.display.MovieClip;
         public class Product extends MovieClip {
             public var prodName:String;
             public var prodCategory:String;
             public var prodQuality:String;
             public function Product():void {
                 var productMC:MovieClip = new cellMC();
                 addChild(productMC);
    My .FLA first frame:
    var myProd1:Product = new Product();
    myProd1.prodCategory = "Heaters";
    myProd1.x = 150;
    myProd1.y = 140;
    addChild(myProd1);
    // THE FOLLOWING DOES NOT WORK
    myProd1.productMC.productName.text = "ABC 123";
    I figure something like this would work, but with lots of variations, still nothing works
    I get errors telling me it can't find productMC.
    UPDATE:
    Using GetByChildName it seems I can access productMC. For example this works:
    myProd1.getChildByName("productMC").visible = false;
    But this does not work:
    myProd1.getChildByName("productMC").getChildByName("productName").text = "dgdhdhdhrgh";
    If I take the textfield out of the library MC, and create it in the class, then this works:
    myProd1.getChildByName("productName").visible = false;
    BUT this does not work:
    myProd1.getChildByName("productName").text = "sdgsgdfsg";

    Hi Otto,
    If I well understood your situation, the solution  might be quite simple.
    Since your Product class is a  MovieClip (and not a Sprite), you could solve your problem many ways  knowing that a MovieClip is a dynamic class.
    But first,  the thing is that you created your productMC object on the fly inside  your Product class.
    So either you correct it like this:
    package {
         import  flash.display.MovieClip;
         public class  Product extends MovieClip {
             public var  prodName:String;
             public var prodCategory:String;
              public var prodQuality:String;
             public var productMC:MovieClip; // *****
             public function  Product():void {
                 productMC = new  cellMC(); // *********
                 addChild(productMC);
    Or use this cheap trick (a MovieClip is a dynamic class):
    package {
         import  flash.display.MovieClip;
         public class  Product extends MovieClip {
             public var  prodName:String;
             public var prodCategory:String;
              public var prodQuality:String;
             public function  Product():void {
                 var productMC:MovieClip = new  cellMC();
                 this.productMC = productMC; // **************
                 addChild(productMC);
    Although it is possible that, for this one, you need to reforce the dynamic property:
    package {
         import  flash.display.MovieClip;
         dynamic public class  Product extends MovieClip {
    I am not sure, but anyway, you will see for yourself.
    Plus, you try to change text to a MovieClip object? Either there is already a TextField in you cellMC object and you are not targeting it, or productMC should be instanciated as a TextField and not a MovieClip. I think you know the answer to that.
    Design Cyboïde
    Designer web Montreal

  • Putting Loader in a custom class: events, returning to main ... asynch challenges

    I'm creating a custom class to retrieve some data using URLoader.
    My code is below, doing this from memory, plz ignore any minor typos.
    The challenge I'm encountering: when my custom class calls the loader, the event handler takes over.  At which point the context of my code leaves the function and it's not clear to me how I then return the data retrieved by the loader.  I sense that I'm breaking the rules of how ActionScript really runs by putting a loader in a separate class; at least, that's my primitive understanding based upon the reading I've done on this.
    So can I do this?  I am trying to create a clean separation of concerns in my program so that my main program doesn't get clogged up with code concerned with retrieving remote data.
    Thanks!
    Main program;
    import bethesda.myLoader;
    var ldr:myLoader = new myLoader;
    var data:String = myLoader.getData("someurl");
    My custom class:
    package bethesda {
         public class myLoader {
              function myLoader(url:String):String {
                   var loader:URLLoader = new URLLoader();
                   var request:URLRequest = new URLRequest(url);
                   loader.addEventListener(Event.COMPLETE, completeHandler);
         function completeHandler(event:Event):void {
              var ld:URLLoader = new URLLoader(event.target);
              data = loader.load(); // here's where I don't know what to do to get the data back to my main program

    I think you are on the right track in abstracting loading from other code.
    Your class may be like that:
    package 
         import flash.events.Event;
         import flash.events.EventDispatcher;
         import flash.net.URLLoader;
         import flash.net.URLRequest;
         public class myLoader extends EventDispatcher
              // declare varaibles in the header
              private var loader:URLLoader;
              private var url:String;
              public function myLoader(url:String)
                  this.url = url;
              public function load():void {
                  var loader:URLLoader = new URLLoader();
                  var request:URLRequest = new URLRequest(url);
                  loader.addEventListener(Event.COMPLETE, completeHandler);
                  loader.load(request);
              private function completeHandler(e:Event):void
                  dispatchEvent(new Event(Event.COMPLETE));
              public function get data():*{
                  return loader.data;
    Although, perhaps the best thing to do would be to make this class extend URLLoader. With the example above you can use the class as following:
    import bethesda.myLoader;
    import flash.events.Event;
    var ldr:myLoader = new myLoader("someurl");
    ldr.addEventListener(Event.COMPLETE, onLoadComplete);
    ldr.load();
    function onLoadComplete(e:Event):void {
         var data:String = ldr.data;

  • How to create a ActiveX Object with custom classes

    Hi
    I am trying to create a Active X object for some of the work I have done in Java to be used with VB, but I cannot get the Active X object to generate and it always come up with the following error:
    Exception occurred during event dispatching:
    java.lang.NoClassDefFoundError: uk/co/agena/minerva/model/Model
    at java.lang.Class.getMethods0(Native Method)
    at java.lang.Class.getDeclaredMethods(Unknown Source)
    at java.beans.Introspector$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.beans.Introspector.getPublicDeclaredMethods(Unknown Source)
    at java.beans.Introspector.getTargetEventInfo(Unknown Source)
    at java.beans.Introspector.getBeanInfo(Unknown Source)
    at java.beans.Introspector.getBeanInfo(Unknown Source)
    at sun.beanbox.JarInfo.<init>(Unknown Source)
    at sun.beanbox.JarLoader.createJarInfo(Unknown Source)
    at sun.beanbox.JarLoader.loadJar(Unknown Source)
    at sun.beans.ole.Packager.loadBean(Unknown Source)
    at sun.beans.ole.Packager.generate(Unknown Source)
    at sun.beans.ole.Packager.actionPerformed(Unknown Source)
    at java.awt.Button.processActionEvent(Unknown Source)
    at java.awt.Button.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForComponent(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForComponent(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    This appears to be beacuse the class uk/co/agena/minerva/model/Model is a custom class which is based on the software I am using. Does anyone know how I can get around this issue. I have tried incluijng those class files for the custom classes within the jar file, but I continue to get the same issue?
    Any help would be gratefully received.
    Thanks
    Angie

    This error is no longer coming up, it is now saying that it has an unsupported class version error. I believe this may be because the class file and library files have been complied under different versions, is there a method to check this?

  • Dynamic Class Reference in Custom Class

    I've created a custom class that I want to be able to
    dynamically insert a movie clip from the library. I'm running into
    trouble because I want to access the clip as a property of the
    custom class object (ie: so it can be swapped out for another
    library clip after instantiation, among other things). I'm using
    getDefinitionByName() but I can't use it outside my addDiagram()
    function (see attached code) because the string variable that
    stores the name of the library clip isn't defined until after the
    custom class constructor function. Any help is appreciated!
    Thanks,
    -Erik

    i'm not quite following - are you saying you want to access
    panelDiagram in functions other than your addDiagram function? just
    take your variable definition out of your function and make it a
    class variable eg put the following line above your constructor:
    private var panelDiagram:*;
    and in the second line of your addDiagram function use:
    panelDiagram = new diagramClass();
    sorry if this isn't your answer, if it isn't i'm struggling
    to understand the problem.

  • Creating custom classes from a more complex DTD

    Are there any examples of creating more complex custom document types? The sample in the dev. guide and the xml syntax are a good start but not enough.
    If anyone has an example from their own work, I'd appreciate it. You can send them to [email protected]
    Thanks!

    I'm having trouble gaining access to the content of those objects within a multilevel tree structure once the XML file has been loaded into the database. Those attributes off root via an editing tool or jsp/bean are rendered; however, the branched object structures are not. Instead the following is in its place: <MYClASSOBJECT2 RefType="ID">7265<!--ClassObject: MYClASSOBJECT2--><!--Name:Null--></MYClASSOBJECT2>
    Here is some background. All custom classes have been successfully loaded into iFS, including the branching objects, which have been entered as extensions of Document as well as the associated ClassDomain entries. I've read Mark's PencilObject entry of June 23, but I continue to get undesired results. Currently, I am using SimpleXMLRender and am inclined to believe that I will need to customize the renderer for it to recognize the deep structures within my XML. Can you shed any light on my situation? In a nutshell, how do I gain access to the content within my multilevel XML?

  • Sqlite, moving sqlstatements to a custom class

    I'm working on a FB AIR app.
    I have a main.mxml file with a source to a main.as file.
    My main.as file is getting very bloated with sqlstatements. I want to move these to a custom class, but I don't know how to proceed.
    I found an example of a package on this page: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/data/SQLConnectio n.html#begin()
    about a 3rd of the way down.
    The example above is exactly what I want to do, but I don't know how to adapt this for use in my main.as file beyond importing the class and instantiating it. How do I assign my values to the class file? How do I use the class to load up the dataProvider, etc...
    Also, in the example above the class extends Sprite. This sounds like it's meant for a Flash application. Would I still extend Sprite in Flex 4? I have done a couple of simple events, passing data back to the main app with the Flash.Events.Event, so the use of Sprite causes some confusion.
    In a previous post, Amy suggested using Robotlegs. I think I need to get a handle on using Flex before I explore other architectures. I'm just not that sophisticated yet.
    Thanks
    Kristin

    ok, a quick example
    make a new package called utilities and then a new actionscript class called DatabaseManager
    package utilities
         import flash.data.SQLConnection;
         import flash.data.SQLResult;
         import flash.data.SQLStatement;
         import flash.filesystem.File;
         import mx.collections.ArrayCollection;
         public class DatabaseManager
              private var sqlConnection:SQLConnection;
              private var stm:SQLStatement;
              public function DatabaseManager()
                   //connect to database
                   sqlConnection = new SQLConnection();
                   sqlConnection.open(File.applicationStorageDirectory.resolvePath("whatever"));
                   //create tables if not exist
                   stm = new SQLStatement();
                   stm.sqlConnection = sqlConnection;
                   stm.text = "create your table here";
                   stm.execute();
                   //create more tables
              public function getThings():ArrayCollection
                   stm = new SQLStatement();
                   stm.sqlConnection = sqlConnection;
                   stm.text = "your query";
              public function addStuff(stuff:Object):int
    then in your main file you need to import
    import utilities.DatabaseManager;
    instantiate the class, this connects and creates tables
    private var myDB:DatabaseManager = new DatabaseManager();
    then to use it
    var listFromDatabase:ArrayCollection = myDB.getThings();
    insertid = myDB.addStuff(thingToAdd);
    hope that gives you an idea 

  • Importing a Custom Class

    Hi everyone...
    I'm working on one final part of a Flash piece that's ended being quite a bear for me. So looking forward to wrapping it up! I'm a big-time newbie. This has been an amazing learning experience but boy it has made my brain hurt!
    The final issue I'm having invloves importing a custom class that calls a custom application. It's a class/application that I downloaded and am trying to apply to my project. It is an application that adds transform handles around targeted objects.
    I'm importing the class as I think I am supposed to but it doesn't work. There aren't any erros but it simply doesn't work.
    Here's how I'm doing it...
    My .FLA, FloorPlan.FLA, is located in my root folder along with the class file, ApplicationMain.as.
    ApplicationMain.as has an import that imports the application called TransformTool.as. TransformTool.as is located in the root as well.
    So in scenen 1 on frame 1 of FloorPlan.FLA I have an import written like so...
    import ApplicationMain;
    In the file ApplicationMain.as I have an import to grab the file TransformTool.as that is written like so...
    package  {
        import flash.display.MovieClip;
        import flash.geom.Rectangle;
        import flash.events.MouseEvent;
        import TransformTool;
        public class ApplicationMain extends MovieClip
            private var _transformTool;
            public function ApplicationMain ()
                _transformTool = new TransformTool();           
                _transformTool.mode = TransformTool.ROTATE;
                _transformTool.iconScale = new HandleHintScale();         
                _transformTool.iconRotate = new HandleHintRotate();
                // _transformTool.boundaries = new Rectangle(50, 50, 475, 260);
                addChild(_transformTool);
            // register targets //   
                _transformTool.targets = [content_MC.e1, content_MC.e2, content_MC.e3, content_MC.e4, content_MC.f1, content_MC.f2, content_MC.f3, content_MC.f4, content_MC.f5, content_MC.f6, content_MC.f7, content_MC.f8];
                _transformTool.activeTarget = content_MC.f8;
            // register radio buttons //   
                  // radio1.addEventListener(MouseEvent.CLICK, changeToolMode);
              //  radio2.addEventListener(MouseEvent.CLICK, changeToolMode);             
            private function changeToolMode(evt:MouseEvent):void
                _transformTool.mode = evt.currentTarget.label.toLowerCase();
    Everything but this class/application is working just fine. It doesn't cause any erros and make other items not function. It simply isn't working. And I had it working at the very beginning of the project so I know its not the class/application files causing the problem; other than possible path issues.
    I'm stumped, yet again! 
    Thanks in advance for your help!

    HandleHintScale and HandleHintRotate are movie clips in the library of the .fla

  • SetRGB from custom class

    I have a custom class that adds clips from the library to
    another clip on the stage. The clips i am adding have a text field
    and a bullet point inside and given the tempory name 'item'. After
    the class adds a clip I can position the bullet point using
    item.bullet._x and _y but when I try to use the following script i
    get no result at all:
    var newCol:Color = new Color(item.bullet);
    newCol.setRGB(0xff0000);
    If i swap item.bullet for a clip on the root level it works
    but not for the bullet.
    The movieclips i am adding are registered as instances of
    another custom class. Could this have something to do with it?
    Any thoughts welcome as the deadline is looming
    Cheers

    a movieclip.
    I can access its positional and scaling properties but nots
    the setRGB method

  • Custom class loader and local class accessing local variable

    I have written my own class loader to solve a specific problem. It
    seemed to work very well, but then I started noticing strange errors in
    the log output. Here is an example. Some of the names are in Norwegian,
    but they are not important to this discussion. JavaNotis.Oppstart is the
    name of my class loader class.
    java.lang.ClassFormatError: JavaNotis/SendMeldingDialog$1 (Illegal
    variable name " val$indeks")
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:431)
    at JavaNotis.Oppstart.findClass(Oppstart.java:193)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
    at JavaNotis.SendMeldingDialog.init(SendMeldingDialog.java:78)
    at JavaNotis.SendMeldingDialog.<init>(SendMeldingDialog.java:54)
    at JavaNotis.Notistavle.sendMelding(Notistavle.java:542)
    at JavaNotis.Notistavle.access$900(Notistavle.java:59)
    at JavaNotis.Notistavle$27.actionPerformed(Notistavle.java:427)
    JavaNotis/SendMeldingDialog$1 is a local class in the method
    JavaNotis.SendMeldingDialog.init, and it's accessing a final local
    variable named indeks. The compiler automatically turns this into a
    variable in the inner class called val$indeks. But look at the error
    message, there is an extra space in front of the variable name.
    This error doesn't occur when I don't use my custom class loader and
    instead load the classes through the default class loader in the JVM.
    Here is my class loading code. Is there something wrong with it?
    Again some Norwegian words, but it should still be understandable I hope.
         protected Class findClass(String name) throws ClassNotFoundException
             byte[] b = loadClassData(name);
             return defineClass(name, b, 0, b.length);
         private byte[] loadClassData(String name) throws ClassNotFoundException
             ByteArrayOutputStream ut = null;
             InputStream inn = null;
             try
                 JarEntry klasse = arkiv.getJarEntry(name.replace('.', '/')
    + ".class");
                 if (klasse == null)
                    throw new ClassNotFoundException("Finner ikke klassen "
    + NOTISKLASSE);
                 inn = arkiv.getInputStream(klasse);
                 ut = new ByteArrayOutputStream(inn.available());
                 byte[] kode = new byte[4096];
                 int antall = inn.read(kode);
                 while (antall > 0)
                     ut.write(kode, 0, antall);
                     antall = inn.read(kode);
                 return ut.toByteArray();
             catch (IOException ioe)
                 throw new RuntimeException(ioe.getMessage());
             finally
                 try
                    if (inn != null)
                       inn.close();
                    if (ut != null)
                       ut.close();
                 catch (IOException ioe)
         }I hope somebody can help. :-)
    Regards,
    Knut St�re

    I'm not quite sure how Java handles local classes defined within a method, but from this example it seems as if the local class isn't loaded until it is actually needed, that is when the method is called, which seems like a good thing to me.
    The parent class is already loaded as you can see. It is the loading of the inner class that fails.
    But maybe there is something I've forgotten in my loading code? I know in the "early days" you had to do a lot more to load a class, but I think all that is taken care of by the superclass of my classloader now. All I have to do is provide the raw data of the class. Isn't it so?

Maybe you are looking for

  • How to close Item while doing GR

    Dear Sir i would like to close PO item when i do Goods Receive Example   PO Qty = 5000 ea and GR = 3000 ea only, then i want to close this item during Goods Receive so, when i do GR for the rest 2000 ea, system will not allow because this item is alr

  • All of Microsoft Office has disappeared.  Can't open files in Dropbox.  Help!

    All of Microsoft Office has disappeared.  Can't open files, even in Dropbox, even after installing LibreOffice.  Can you help me?

  • Suddenly my iPhone shows No Sim?

    Unable to make/receive calls or texts. Connect with 3G , Bell Mobility is my Carrier. If home , will connect to internet through my WiFi Modem. Sim Card is installed, I have shut down. rebooted , no fix. Taken SIM card out and back in . Set the phone

  • Append new records for a spool file

    Hello, I am running a query and sending the output to a spool file. The query never returns the same data because it is run every 2 hours How can I make the spool to append the new records and not overwrite the old records? Thanks Carlos

  • Add an output type in sales order header

    Hi Dear Experts, I try to find a way to add an output type in sales order header after the order was created. I also need the output to be sent immediately to the FAX. Do you know any BAPI or Function that can help me or have any idea how it can be d