To access instances of a custom class that extend box

Hello

Forgive me if I couldn't find an answr my question with various searches in the forum, but I'm not an expert and I can't even find the right words for the search.

Here's the problem:

I created a class (called LAlgExpression) which extends the class box. Instances of the class are added in a box, and I tried to access these instances using mouse events.

Now, I can actually access my custom class instances by using the properties target and currentTarget of the events, but unfortunately they are considered as belonging to the Object class and not to the class LAlgExpression which make it impossible to use all the methods I've defined for LAlgeExpression because the compiler tell me that I am trying to use on an object a method that is not defined for the class Object. What's funny is that when running when I try 'event.target is LAlgExpression' it returns true, but I don't know how to convince the compiler . It's as if the instance that I have on the screen is an object and a LAlgExpression, but the compiler will not let me treat as LAlgExpression, but only as an object and I don't understand why.

is there a way to force the compiler to consider LAlgExpression, something he sees as an object?

Thank you very much in advance for your help

var obj:LAlgExpression = event.target as LAlgExpression;

or

var obj:LAlgExpression = LAlgExpression (event.target);

then call methods on obj and it should go.

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

Greg Lafrance - Flex 2 and 3 certified ACE

www.ChikaraDev.com

Training Flex and Support Services

Tags: Flex

Similar Questions

  • Is a class that extends application need a main method?

    Details
    Windows Vista Enterprise Service Pack 1 32-bit operating system
    Eclipse version identifier: 20090619-0625
    The Java compiler level: 1.3
    BlackBerry OS: Targeting devices running OS 5
    BlackBerry 9700 Simulator
    BlackBerry_App_Descriptor
    Application tab
    Autorun at startup feature: not verified
    The application icons: png files two of the directory res
    Build tab
    Default values...

    Other entry Points
    Title: MyApp_autostartup
    Argument of the application: autostartup
    Autorun at startup feature: checked
    Start level: 7
    Do not... display the home screen: checked

    Question:

    I have a class that extends the net.rim.device.api.system.Application that is launched from a main method (see the following) in a class that extends net.rim.device.api.ui.UiApplication.

    public static void main(String[] args) {
            if (args.length > 0 && args[0].equals("autostartup")) {
                // _app.invokeLater(new Runnable() {
                //
                // public void run() {
                // new ShellFeed();
                // }
                //
                // });
                new ShellFeed();
            } else {
                // Start a new SC instance for GUI operations.
                home = new HomePage();
                home.enterEventDispatcher();
            }
        }
    

    The class that extends the net.rim.device.api.system.Application need a main method too? Such as:

    public final class ShellFeed extends Application {
    
        public static void main(String[] args) {
            ShellFeed app = new ShellFeed();
            app.enterEventDispatcher();
        }
    }
    

    Thank you.

    This should get you:

    public static void main(String[] args)
    {
        if (args.length > 0 && args[0].equals("autostartup"))
        {
            SheelFeed sf = new ShellFeed();
            sf.enterEventDispatcher();
        }
        else
        {
            // Start a new SC instance for GUI operations.
            home = new HomePage();
            home.enterEventDispatcher();
        }
    }
    

    T

  • Development of portlets: when to use the class that extends the PortletBridge...

    When I create a Portlet (based .jspx) JDeveloper generate resources. One of these is a class (with the name I ve configured), which extends from PortletBridge...

    Ok. So, I want to know if I use the standard JSF should I put my actions in this class or should I create an another bean Managed to handle this? What to do with this generated class?


    Thank you.

    A bean managed for a portlet must be recorded in the faces-config. XML
    It has nothing to do with the class that extends the portlet bridge.

    So to create a java class and write it to the faces - config.xml, then you can use in your jspx pages that make up the portlet.

  • How to access the BitmapData instance on the class that extends the charger?

    Hello. I use Flash CS6 to create an AIR application that loads an image from the computer, and then a pixel counts using its bitmap data.

    MyImg is a class that represents the loaded image.

    package com.utils {}

    import flash.display.Loader;

    SerializableAttribute public class extends {charger MyImg

    public void MyImg (): void {}

    }

    }

    }

    In my main class I manage the selection of files and loading.

    private var _myImage:MyImg = new MyImg();

    private var _file:FileReference;

    private var _fileTypes:FileFilter = new FileFilter ("Imagens: (*.jpeg, *.jpg, *.gif, *.png)", "*.jpeg;") *.jpg; *.gif; *.png");

    When the user clicks on a "load image" button on the stage, it calls loadMyImg().

    public void loadMyImg($e:MouseEvent):void {}

    chooseFile();

    }

    The user then selects the file he wants to do.

    private function chooseFile (): void {}

    Inasmuch = new FileReference();

    _File.addEventListener (Event.SELECT, fileSelected);

    _File.browse ([_fileTypes]);

    }

    Once you have selected the file, it is loaded as a byte array.

    private void fileSelected($e:Event):void {}

    _File.removeEventListener (Event.SELECT, fileSelected);

    _File.addEventListener (Event.COMPLETE, fileLoaded);

    _File.load ();

    }

    When it finishes loading it loads the byte array in _myImage.

    private void fileLoaded($e:Event):void {}

    _File.removeEventListener (Event.COMPLETE, fileLoaded);

    _myImage.contentLoaderInfo.addEventListener (Event.COMPLETE, dataReady);

    _myImage.loadBytes (_File.Data);

    }

    Once it's done I try to use the _myImage BitmapData, but cannot...

    private void dataReady($e:Event):void {}

    $e.target.loader.contentLoaderInfo.removeEventListener (Event.COMPLETE, dataReady);

    trace ($e.target + $e.target.content + $e.target.content.name + $e.target.content.bitmapData); Returns [object LoaderInfo] [object Bitmap] instance 155 [BitmapData object]

    trace (_myImage + _myImage.content + _myImage.content.name + _myImage.contentLoaderInfo + _myImage.contentLoaderInfo.content.name); instance of [object LoaderInfo] 155 155 instance [object Bitmap] returns [object MyImg]

    trace (_myImage.content.bitmapData) //compiler error: 1119 of bitmapData property possibly access not defined through a reference with static type flash.flashDisplay:DisplayObject.

    error //same trace (_myImage.contentLoaderInfo.content.bitmapData)

    }

    I don't understand what I'm doing wrong. Instances have the same name so that they are identical. They both trace as bitmaps, yet when I didn't access it from the event I do not get the bitmapData. Can someone tell me what I am doing wrong? I need to use the bitmapData of the classroom MyImg. I guess I could create a BitmapData variable in the class and give it the value of $e.target.content.bitmapData, but I still want to know why it can't be simpler.

    Thank you!

    Cast _myImage.content as bitmap:

    Bitmap (_myImage.Content)

  • Best way to insert data into instances of the custom class

    Hello.

    I have created a custom class (mySuperClass) in an .as file, defined constructor methods, properties, and the get/set. Now in the main .fla I must declare a large number of instances of this class and complete each property. The 'proper' method, I guess, would be to:

    var super1:mySuperClass = new SuperClass();
    super1.setProperty1 ( value1_1);
    super1.setProperty2 ( value1_2);
    ...
    super1.setPropertyN ( value1_N);

    ...
    var superM:mySuperClass = new SuperClass();
    superM.setProperty1 ( valueM_1);
    ...
    superM.setProperty1 ( valueM_N);

    However, with large quantities of variables and information that share the same basic characteristics, I feel always attempted to do through a cycle of dethrone. In that case, I'd probably build tables with the properties to complete.

    So I want to know is how would you guys do it? Are there other ways to do it?

    Thanks in advance.

    Well, the example is based on an object that has a datamodel and which can be any object of course. Now, assuming that the data come Let's say an xml file, I would use a function as the code to generate a collection of objects.
    Edit: so the StoreItem instances are created on the fly and saved in the collection

  • Bean Java properties class that extends data control cannot get data on the user interface

    Hello

    I'm writing a bean something like the following and trying to create a control of data off of it:

    package model.beans;

    import java.util.Properties;

    SerializableAttribute public class PropBean extends properties {}

    String ID;
    The name of the string;
    public PropBean() {}
    Super();
    setName ("TURBO");
    setId("123");
    }

    public String getProperty (String key) {}
    If (key.equalsIgnoreCase ('name')) {}
    return getName();
    } else {}
    return getId();
    }
    }

    public String getProperty (String key, String Valeurdefaut) {}
    If (key.equalsIgnoreCase ('name')) {}
    return getName();
    } ElseIf (key.equals ("id")) {}
    return getId();
    }
    else {}
    return Valeurdefaut;
    }
    }


    public String getName() {}
    System.out.println ("GET =" + myIdName);
    Return myIdName;
    }

    public void setName (String name) {}
    myIdName = name;
    System.out.println ("VALUE =" + myIdName);
    }

    {} public void setId (String id)
    This.ID = id;
    System.out.println ("VALUE =" + this.id);
    }

    public String getId() {}
    System.out.println ("GET =" + this.id);
    return the id;
    }
    }

    When I binds the name and id attaributes text of output values do not appear on the screen.
    But if I do not extend class properties and then on the piece of code just works very well.

    The same thing happened when I extended HashMap.
    I had to override the method getObject (Object obj) to make it work.

    However I am still unable to run when the class extends a class of properties.

    See you soon,.
    REDA

    Hello

    When you extend HashMap then create you a hash table. Properties extend from HashTable, which seems to be similar. Tehre is a reason why your class should extend the properties instead of use the Properies class as a resource reference?

    Frank

  • Access the function of custom class which is stored in a table?

    Hello guys..,.


    I hope I am making stopper, with the title of the thread, because I'm a bit confused, how do you explain in Word...

    anyway I'll describe what I mean and hope you guys can help out me..,.

    Here I am doing some object of action script..,.

    What about this object that is in the constructor function of this object is as I do to send a parameter of sprite that will act as it's parent..,.

    var anObject:myObject = new myObject (parentSprite);

    and in my main project, I used those object and store in a table after it is added to the scene...

    I store it in a table cause I have to be able to return to the it...

    everything was fine until I have to call the function inside this object which I already stored in a table..,.

    so, how should I call the function in this table object that has stored the object?

    hope that I specify me...

    Thanks in advance guys..,.

    Well, the error is tell you that removeChild() destroy() function in the class Newsticker is having a problem because you try to remove a child does not belong to the parent. How your destroy() function looks like?

  • Can I get the lock event of user interface for a class that extends the Application class?


    Here's an article in the knowledge base on the subject:

    http://supportforums.BlackBerry.com/T5/Java-development/alert-a-BlackBerry-Smartphone-user-from-a-BA...

  • Custom button that creates another object in its parent

    I have a function that creates an instance of a custom class that extends of button inside a BorderContainer using MyBorderContainer.addElement ().  It seems to work very well.  What I would like is for the custom button (which it will be several created) in order to create a panel inside the same BorderContainer.  This is the class for the custom button:

    [quote] / public class MySpecialButton extends button

    {

    private var NewPanel:Panel = new Panel();

    public void MySpecialButton()

    {

    this.setStyle ("skinClass", MySpecialButtonSkin);

    }

    override the clickHandler(event:MouseEvent):void function

    {

    this.parent.addChild (NewPanel);

    }

    } [/ quote]

    I get no errors or warnings, it just seems to get hung on the line, addChild.  I worked on this problem for a while now and I'm stuck.  Any ideas?

    I think the parent panel should be responsible for adding the new Panel.  And also, why you override clickHandler?  Try to take responsibility for adding children to the parent of the key and try to add the parent of ITTO.  Here is some pseudo-code of what I speak.

    public function buttonClicked (event: Event): void

    {

    var newPanel:NewPanel = new NewPanel();

    addElement (newPanel);

    }

    .....

    Sincerely,

    Ubu

  • Error 1034: Conversion of video to an instance of a custom object?

    I have several video clips on the stage who each unique instance names.

    I need to instantiate instances of a custom class that I created. It gives me an error, and I know I am missing probably a simple concept somewhere, something wrong, but I don't know what it is.

    Here is my code:

    In the main timeline, I (Simplified):

    var puzzleAL: GeoGroup = new GeoGroup ('AL', 'Alabama', 1, false);

    puzzleAL.addEventListener (TouchEvent.TOUCH_BEGIN, geoTouchBeginHandler);

    function geoTouchBeginHandler (e:TouchEvent): void {}
    e.target.gotoAndStop ("Over");
    nameDisplay.gotoAndStop (e.target.abbrev);
    e.target.addEventListener (TouchEvent.TOUCH_END, geoTouchEndHandler);
    }

    function geoTouchEndHandler (e:TouchEvent): void {}
    If (e.target.lock == false) {}
    e.target.gotoAndStop ("Off");
    }
    Else if (e.target.lock == true) {}
    e.target.gotoAndStop ("Lock");
    }
    nameDisplay.gotoAndStop ("USA");
    e.target.removeEventListener (TouchEvent.TOUCH_END, geoTouchEndHandler);
    }

    It throws an error until the object is never instantiated. It compiles, but when running, I get:

    TypeError: Error #1034: Type coercion failed: cannot convert Puzzleography_fla::Alaska_2@da0a0f9 to GeoGroup.
    at flash.display::MovieClip/gotoAndStop()

    at Puzzleography_fla::MainTimeline/goToFrame()

    My class code looks like this, if it's important:

    package {}
    import flash.display.MovieClip;

    SerializableAttribute public class extends MovieClip {} GeoGroup
    public var abbrev:String;
    public var fullName:String;
    public var assignedOrder:Number;
    public var lock: Boolean;

    public void GeoGroup (abbrev:String, fullName:String, assignedOrder:Number, lock: Boolean) {}
    This.ABBREV = abbrev;
    this.fullName = fullName;
    this.assignedOrder = assignedOrder;
    This.Lock = lock;
    }
    }
    }

    I'm missing something obvious, I know, but I'm new to OOP, switching of procedural issues, so I don't know that I'm a bad concept somewhere.


    Thank you very much!
    Amber

    to have several library objects belong to the same class, assign each a class have different, but each shares the same base (like GeoGroup) class.

    You can assign dynamic properties members of your GeoGroup anytime, not just when they are created.  so, you could change your constructor and add the GeoGroup members in the authoring environment.

    or you can leave your class only GeoGroup and you can add objects to the stage using actionscript.  for example: addChild().

    at this point, I think it would be easier for you to let your single class constructor, remove the scene GeoGroup members and add them using actionscript.  You can simplify your coding by adding your listeners to the class:

    package {}
    import flash.display.MovieClip;
      
    SerializableAttribute public class extends MovieClip {} GeoGroup
    public var abbrev:String;
    public var fullName:String;
    public var assignedOrder:Number;
    public var lock: Boolean;

    public void GeoGroup (abbrev:String, fullName:String, assignedOrder:Number, lock: Boolean) {}
    This.ABBREV = abbrev;
    this.fullName = fullName;
    this.assignedOrder = assignedOrder;
    This.Lock = lock;

    this.addEventListener (TouchEvent.TOUCH_BEGIN, geoTouchBeginHandler);
    }

    function geoTouchBeginHandler (e:TouchEvent): void {}
    e.target.gotoAndStop ("Over");
    nameDisplay.gotoAndStop (e.target.abbrev);
    e.target.addEventListener (TouchEvent.TOUCH_END, geoTouchEndHandler);
    }

    function geoTouchEndHandler (e:TouchEvent): void {}
    If (e.target.lock == false) {}
    e.target.gotoAndStop ("Off");
    }
    Else if (e.target.lock == true) {}
    e.target.gotoAndStop ("Lock");
    }
    nameDisplay.gotoAndStop ("USA");
    e.target.removeEventListener (TouchEvent.TOUCH_END, geoTouchEndHandler);
    }

    }
    }

    ////////////////////////

    then on your timeline:

    var puzzleAL: GeoGroup = new GeoGroup ('AL', 'Alabama', 1, false);

    addChild (puzzleAL);

  • question about custom classes

    I am new to AS3, as well as Flash in general, so forgive me if this seems very basic.  All I'm trying to do is create a custom class that extends the MovieClip class and contains a custom property for 'marker '.  I want to be able to use and change the value of the custom property on the timeline of an instance of this class and have it behave exactly like any other (Ex: this.x == > this.marker).

    Then, my main script, I want to launch certain circumstances according to the value of 'marker '.

    EXAMPLE: if (myCustomClassInstance.marker == 'string')

    {

    doSomething();

    }

    In any case, I checked my classpath and my extenal AS file communicates with my FLA; I know that the problem lies in my custom class, I've pasted below:

    package myClasses
    {
    import flash.display.MovieClip;

    SerializableAttribute public class extends MovieClip PageClass
    {
    public var marker: String;

    public void PageClass()
    {
    }
    }
    }

    I would be extremely grateful for any help.  Sorry for my ignorance.

    I may be forgetting the scenario, but I think that my discussion of event expedition was addressing the wrong event.  If I remember correctly, the buttons of your main timeline would generate menu of wedge activities.  Your sections would be enough to release a 'allowMenu' event when they settle in their display frame.

    I'm going on memory here (too lazy to look back), but I think I mentioned that you can use as a conditional currentLabel property to prohibit the use of a button while you are in the section.  And if you use AS3 and real SimpleButton symbols (aka buttons homemade), AS3 allows you to control the States of the buttons, which means that you can assign btn.upState = btn.downState to have the button appears in its inactive state when it is to the top/intact. Previous versions of actionscript has failed to do this.  You don't end up having to do a bit of juggling to make things that whenever a new item is selected, a single shared function can do this for all, function sense resets all buttons to the upState = condition out of town, before to set the newly selected on his downState.

  • How can I implement my custom class "ToolTip?

    I have has created a custom class that extends the ToolTip to style my ToolTips in six different "styles: background color for most."  I can do very well with the Manager of the ToolTip, but he's left heavy and hoped to simplify with a toolTip class that I can style I like.

    Any help is apprecitaed.

    Thank you.

    You can watch to see how our skin to pick up styles.

  • Properties of the label and the custom class

    I want to do the following persistent: < mx:Label useHandCursor = "true" buttonMode = "true" mouseChildren = "false" / >

    I tried to create a custom class that extends the class Label, but we can't get the syntax right.

    protected override?

    buttonMode = true;

    I don't think I want to replace a function.  It seems to me that I want to override a property or attribute of the Label class.

    Can someone give me advice?

    Hello

    As you Lable with the default property {useHandCursor = "true" buttonMode = "true" mouseChildren = "false"}

    I extend the label, you can do it directly in the constructor by setting

    -Custom label class-

    package
    {
    Import mx.controls.Label;

    SerializableAttribute public class CusLbl extends Label
    {
    public void CusLbl()
    {
    Super();
    super.buttonMode = true;
    super.useHandCursor = true;
    super.mouseChildren = false;
    }
           
    }
    }

    --------------------------------------------------------------------------------

    You can use directly in the application or in any other container with the default property;

    See attached the file if necessary.

    Regarding

    Virat Patel

  • To access the properties of the custom class

    Hello again! Nevermind, I got display list order because it has me even more trouble :)

    I have several items stacked from the other (boxes) and you want to calculate the height of all the underlying boxes for each box. Each box is an instance of a "Kiste"-custom class that has a property "hoehe" (height). "." Usually, I can access this property from anywhere and it works fine. But in the following case, it won't. The alles.getChildAt(j-1) works fine with all other assets, but not with custom properties that I defined in my class?

    OK, get it myself... Type cast!

  • create a listener for a custom class?

    I have a custom class that loads a couple of XMLs. I create an instance of this class in another class and I need to know when it is done so that I can then call a function of loading in this class of parent.

    How can I do this?

    pls know me if I need to explain differently.

    Thank you!

    When you create your instance of the class:

    ///////////////////////

    classinstance.addEventListener ("xmlloadingcomplete", f);

    private void f(e:Event):void {}

    //

    }

    ////////////////////

    and in your xml, class loading, loading is complete:

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

Maybe you are looking for