Creation of class objects

Hey,.

I need help with this code he does and the error when I put it in my project, but when sound in an empty space of the project it works fine?

Code:

package

{

import flash.display.MovieClip;

public class newchars extends MovieClip

{

public void newchars()

{

for (var i: int = 0; i < 1; i ++)

{

var newchar1:MovieClip = new mychar();

addChild (newchar1);

newchar1.x = Math.Random () * 500;

newchar1.x = Math.random () *(stage.stageWidth-newchar1.width);

newchar1.y = Math.random () *(stage.stageHeight-newchar1.height);

}

}

}

}

error:

TypeError: Error #1009: cannot access a property or method of a null object reference.

at newchars()

at IceMountain_fla::MainTimeline/frame2()

at flash.display::MovieClip/gotoAndPlay()

at IceMountain_fla::MainTimeline/fl_MouseClickHandler_2()

as soon as I click on my play button in the start menu it interfieres with my class!

but in an empty space of the project it works fine: S

Class can make a few mistakes unusual lol

Thank you.

use:

Section 1:

Stop();

Play_1.addEventListener (MouseEvent.CLICK, fl_MouseClickHandler_2);

function fl_MouseClickHandler_2(event:Event):void

{

gotoAndStop (2);

}

Section 2:

Stop();

var enemy1:newchars = new newchars();

addChilld (enemy1);

addEventListener (Event.ENTER_FRAME, fl_EnterFrameHandler);

function fl_EnterFrameHandler(event:Event):void

{

Bird_1.x = mouseX;  / / assuming Bird_1 is on stage

}

Tags: Adobe Animate

Similar Questions

  • ActiveX in BradySoft (CodeSoft) - what method/class/object I would use to send data to the form variable to BradySoft?

    Can what method/class/object I use to send data to the form variable to BradySoft? I have a basic configuration of BradySoft label and I want to send it data of variable shape (a serial number) from Labview ActiveX. I joined guide Brady ActiveX programmers, but can't understand what to use for that.

    P.S. I would call Brady or TekLynx tech support on this issue, but they have a strict policy while BradySoft supports ActiveX, but does not provide technical support assistance programming with it. I thought I would try the Forums OR.

    Just an update. I could get this to work myself after a few days of playing with it (I suppose that the best way to learn!). I have attached a sample VI for anyone interested. Can we Kudo ourselves?

  • Attention impossible to bind to property 'somevar' on the 'Object' class object is not an IEventDispatcher?'

    Hi all

    How to fix under WARNING:

    Attention impossible to bind to property 'somevar' on the 'Object' class object is not an IEventDispatcher

    Thank you

    Sunil Rana

    Hi Paul,.

    I found the solution on the net & here's news

    Cast the data in your itemrenderer as an objectProxy.

    itemRender.mxml

    http://www.Adobe.com/2006/mxml '.

    verticalScrollPolicy = "off".

    horizontalScrollPolicy = "off".

    creationComplete = "init (); » >

    Import mx.utils.ObjectProxy;

    [Bindable]
    public var dataProxy:ObjectProxy;

    private function init (): void {}
    dataProxy = new ObjectProxy (data);
    }
    ]]>
        

    Thank you

    Sunil Rana

  • A query regarding the creation of shared objects.

    Hello

    I have a query regarding the creation of shared objects.

    I saw an example where the author is creatining Shared Object as shown
    below:


    SharedObj = null;
    sharedObj = SharedObject.getLocal ("myTasks");

    and there is nothing related to the word "myTasks" anywhere in the Application.

    Can someone please let me know what this word "myTasks" mean here?

    Thanks in advance.

    Hello

    With a shared object, it will create one if it does not exist, then "myTasks" becomes the name of the shared object or if it exists it will load all the objects that are in the shared object.

    Here is a simple example that uses the sharedobjects to store the connection information.

    http://gumbo.flashhub.NET/login/

    David

  • XML class object.

    Hello.
    I want to create DataGrid with itemReneder for each column.

    It is generated inline itemRenderer:
    DataGridColumn.itemRenderer = new ClassFactory (MyCustomClass);
    MyCustomClass - it manually generated class that contains some form elements (TextInput, Combox... e.t.c.)

    I want to consturct ItemRenderer dynamics. For this I need to create the class object and send it to itemRenderer:
    var component: DynamicFormClass = new DynamicFormClass();
    var newComponent: Class = component.someMethodWhichWillCreateForm (configData); -This request will display the elements of class that will generate the form that describes in configData
    DatagridColumn.itemRenderer = new ClassFactory (newComponent);

    This code is how I see the solvetion of this problem, but it does not work.
    I don't really know how it create answers how and will be very grateful for any decision.
    Thank you.


    Amy Blankenship Merci for the answer, this is not what I need. I found the answer on this question: is the substitution DataGrid ItemRenderer set, method.

  • Creation of several objects in resource for OOTB connectors

    All,

    I am trying to create a second object of resource AD user for the STANDARD connector. I'd like to think that the connector AD (and all connectors, for that matter) has been designed to manage the creation of several objects in resource for the same Types of resources, but I'm bad? It does not appear the IOM connector can handle this easily.

    Does anyone has created several objects of resource for a connector? It is a relatively simple task, or it will require a big effort? Is it still possible? Pointers?

    Thank you!

    I'll give you a little help with replication. I found the best way to do is to import the original connector. Cross the diff鲥ntes pieces that each have a unique name, which is not part of one of the other names of piece. You must have unique names for the following:

    1 object resource
    2. process definition - commissioning
    3 resource
    4. form - process
    5 scheduled task

    After you import the connector, all of the following for renaming into something unique. I would also update your form of process to have a default value of your IT resources, as well as your scheduled task for point values to new unique names. Export the 5 elements, without addictions. The cards will be the same. Use find and replace the values, and then import the new XML. If it works, duplicate the XML file for each of the new workflows that you want to create.

    -Kevin

  • Failed to instantiate new custom class object - no trace of the stack

    Hello

    I have a little maddening problem. I created a custom class called 'Notification '. When I try to create an instance of the latter, I don't get any stack trace. Here's the class:

    package net.creative.core.util;
    
    import net.rim.device.api.system.Bitmap;
    
    /**
     * These are the notification objects that are created and stored
     * when a push notification is sent.
     * @author Heather
     *
     */
    
    public class Notification {
    
        private String title;
        private String content;
        private Bitmap image = Bitmap.getBitmapResource("appicon.png");
    
        public Notification(){
            title = "Title";
            content = "Content";
        }
    
        public Notification(String _title, String _content){
            title = _title;
            content = _content;
        }
        public Notification(String _title, String _content, Bitmap _image){
            title = _title;
            content = _content;
            image = _image;
        }
        public String getTitle(){
            return title;
        }
        public String getContent(){
            return content;
        }
        public Bitmap getImage(){
            return image;
        }
        public void setTitle(String _title){
            title = _title;
        }
        public void setContent(String _content){
            content = _content;
        }
        public void setImage(Bitmap _image){
            image = _image;
        }
    
    }
    

    I don't think it's a problem, but the screen I have tried to create an instance of in the Notification is in the com.creative.core package. I imported Notification on the screen while... Any ideas?

    Never mind.. just resolved.

  • Help class object.

    Hello, even once, I need help.

    I have two classes,

    1.) Tile.as class - for a game tic tac toe, which creates the tile acutal for the grid

    2.) class Game.as - which implements and creates instances of the tile class puts on a grid, check the round, if there is a solution, and what to do with the solution.

    I attribute questions to each square of the grid as hollywood squares. If they get the question wrong the form of opposing teams will fill in the grid of the user has clicked. My problem is erratic behavior in establishing good shape in the squares of the Board. I put a switch box that goes through all marked forms, not what I want.

    In Tile.as

    Game.isClicked is the e.CurrentTarget in the game class.

    Game.isClicked.isSet is a string value that checks and ensures that the values are all the same inorder to solve.

    public void updateGraphic(e:Event) {}

    {Switch (Game.isClicked.isset)}

    case "X":

    tileO.visible = true;

    tileX.visible = false;

    Game.isClicked.isSet = 'F';

    Game.isClicked.isSet = "undefined";

    break;

    case "O":

    tileO.visible = false;

    tileX.visible = true;

    Game.isClicked.isSet = 'X '.

    trace ("O after update", Game.isClicked.name, Game.isClicked.isSet);

    Game.isClicked.isSet = "undefined";

    break;

    }

    }

    }

    In Game.as

    This code is placed on the 2 boxes called 'straight' or 'bad' called obj is e.currentTarget.name

    public static void checkMark(obj:Object)

    {

    Tile.activateMouse (questBox, Tile.questionEvent);

    switch (obj)

    {

    case "right":

    TweenMax.to(questBox.feedRight,.5,{autoAlpha:1});)

    break;

    case "bad":

    isClicked.dispatchEvent (new Event ("updateGfx"));

    TweenMax.to(questBox.feedWrong,.5,{autoAlpha:1});)

    break;

    }

    }

    When applied in this way, the two questions were answered one being the wrong answer, the two will always go through the case statement Tile.as and reset according to the conditions.

    Example: Form of Question 1 was false and all form O and Question 2 was false and the value of X. Once the condition called the O will have the value X in Question 1 Square and X will be settled on O Question 2 room.

    I hope this explains things a bit, and any help/ideas would be greatly appreciated. Thank you.

    Make sure you that understand the purpose of the 'static' keyword

    staticSpecifies that the variable, a constant, or method belongs to the class rather than to instances of the class

    the erratic behavior might have to do with the fact that you have access to the Tile.class instead of the Tile.instances.

    Just a guess, because the code you show is not enough to isolate the problem.

  • Creation of C++ objects within an exporter plugin (CS6 SDK)

    I downloaded the SDK from Adobe CS6.  In the example of the exporter, within the exSelBeginInstance(), there are calls to the API 'suite of memory '.  He grabs little memory (when running) for an array of struct/C.

    In my case, I need to call the operator new() on a class derived from C++.  The idea is that I will create the object in the exSelBeginInstance(), then remove it during exSelEndInstance.


    If I use the new() operator, then the memory-suite will not know the object at all. Otherwise, I could call the memory-API to grab a piece of memory the size of "sizeof (my_class)" but it works correctly either, because the object itself may need to create instances of other classes.

    So is it possible to use safely created dynamically C++ objects within a plugin exporter? Or should I re-architecture to avoid calling the new() constructor?

    the suite of adobe memory should not be used for this sort of thing.

    Just use the new operator as you normally would.

    the key is to store all pointers to your allocated dynamically in the lRec (IE private data) so that the EndInstance, you can take responsibility for all of the delete (lRec-> xxxxx), you need to do to clean.

  • in the 2.0 class objects - how to swap the depths of a clip

    How do put you an object up? If it's just a clip, I could do a swapdepths, but if it's a clip which is part of an object YOU 2.0, how to exchange the depths of the entire object?

    I create 2 objects (same class) each with a movieclip in their breast. The clip is created on a single level with getNextHighestDepth().

    I have a button that tries to swapDepths of 2 objects, but I can't make it work. Can anyone help?


    Here are the details:

    1. create a symbol in the library called "someShape_mc" and put a form in it - a circle, a square, either - this symbol is exported for action script and received a class AS "ClassObject" 2.0 (I also put a dynamic text in the form field to display the current depth - it is called "depth_txt")

    2. create a button called 'swap_btn' on the stage.

    Frame 1 to the following actionscript code:

    var BottomObject:ClassObject = new ClassObject(this,100,150);
    var topObject:ClassObject = new ClassObject(this,110,160);

    for the button Add this:

    {Swap_btn.onRelease = Function ()}

    Try it with the full path:
    _root. BottomObject.__LocalMovieClip.swapDepths (_root.topObject.__LocalMovieClip);

    Try it with just the objects:
    BottomObject.__LocalMovieClip.swapDepths (topObject.__LocalMovieClip);

    Try it with the object as a movieclip
    BottomObject.swapDepths (topObject);
    trace ("he Swap?");

    Try it with a method in the class...
    BottomObject.swapIt (topObject.__LocalMovieClip);
    BottomObject.swapIt (topObject);
    trace ("nope... no permutation in progress...");
    }

    ================================

    Here is the AS file: 'ClassObject.as. '

    ClassObject class extends MovieClip {}
    var __LocalMovieClip;
    var __Depth;
    function ClassObject (passedIn_mc:MovieClip, x: Number, y: Number) {}
    __Depth = passedIn_mc.getNextHighestDepth ();
    __LocalMovieClip = passedIn_mc.attachMovie ("someShape_mc", "__LocalMovieClip", __Depth);
    trace ("a form to" + __Depth);

    __LocalMovieClip._x = x;
    __LocalMovieClip._y = y;
    __LocalMovieClip.depth_txt. Text = __Depth;

    }

    public void swapIt (targetMc) {}
    __LocalMovieClip.swapDepths (targetMc);
    __LocalMovieClip.depth_txt. Text = __LocalMovieClip.getDepth (); no difference.
    trace ("tried to Exchange class...");
    }
    }


    ========================
    So - the goal is to be 'down' class on the top of the object of 'top '. Button tries various methods of Exchange from the depths of clips – but it is not one that works. What Miss me?

    TIA
    Ferd

    aHA! I got it! Thank you very much - I am not you! good eye!

  • Attribute getters/setters not found in class object view

    Hello

    I use JDeveloper 10.1.3.4 and you have questions about the customization of the display of the advice in the view object.

    In my application that should be used by the students and administrative staff, I generated entity object both display objects for a table of the database. Some of the attributes need customized display format. For example, the numbers of social security in the datatable is 123456789. For student users must be displayed in the form xxx-xx-6789. For staff users, it should be displayed in the format 123-45-6789.

    So I create two objects from view of the same entity object, one for students and one for its employees, each having its own display format. To put customization code in attributes getter methods, however, I found that in view of object class files get accessor methods do not exist. The entity object class file has the getters; However if the customization is done there I won't have two different formats.

    Suits for buyers are available in the object class file so that I can customize?

    Thank you very much for help!


    Newman

    Newman,

    Attribute getters would be placed on the class view LINE object.

    John

  • MovieClip custom class object?

    Hello

    I created a "MyObject" class that extends MovieClip. My flash stage, I have a movieclip and name is "myObj". I do not link. How can I convert a movieclip instance of MyObject.

    I tried the below a, I got error

    var str = MyObject (mc) .name;

    The error is

    TypeError: Error #1034: Type coercion failed: cannot convert flash.display::MovieClip@2b6baf99 to MyObject.

    to Obj_fla::MainTimeline/frame1()

    Is it possible to convert?

    Thank you

    Concerning

    Balasubramaniyan.S

    I'm not sure I understand completely what you are trying to do but you can not convert/cast and independent MovieClip instance in another data type, unless it's one of the great MovieClip classes (Sprite, DisplayObject, etc.).

  • help-based actionscript, tracing of my class object properties

    Hi all, I'm just starting to learn about the ActionScript classes, I am following with Moocks book Actionscript for Flash MX and try to run a trace on the properties of my ballclass, but all I get is undefined. It is what I have in my control panel actions.

    spherical function () {}
    This.RADIUS = 10;
    This.Color = 0xFF0000;
    this.xPosition = 59;
    this.yPosition = 15;
    }
    var boucyBall = new Ball();

    trace (bouncyBall.radius);
    trace (bouncyBall.color);
    trace (bouncyBall.xPosition);
    trace (bouncyBall.yPosition);

    Any help would be great

    You misspelled the name of the variable, 'bouncyBall' on this line:

    var boucyBall = new Ball();
    
  • Prevents the creation of class files "shadow" FB

    Hi, all.

    I mentioned it Flash Builder to a Flash xfl file to create a Pro Flash project.

    my workspace is to

    Leda/CGS

    the xfl is to

    leda/SCG/VJTPlatform3/Core/PlatformTest/PlatformTest.xfl

    For some reason, Flash Builder has created a directory to leda/SCG/PlatformTest which he calls bin-debug. Would not be such an issue, but what happens is that it creates a copy, so each error or warning has two copies.

    If I double-click on an error, I can get a file I can edit (I mean, I can change either, but one of them will have a real effect), or I can get the version of "shadow". In addition, when I run the application in debug mode and want to stop and solve a problem that I see, I can't do it directly from the file I am looking at, since it's always the version of "shadow".

    I can solve this during a few minutes along the path of building and set the output in the same directory folder, I work in, but it comes always to the time where I'm not looking. I do not understand why FB has create these files. When I'm working on a Flex project, she not dumping as files in the bin-debug directory. Is what happens because I'm working on a Flash Pro project, or is there some other difference that I don't see? More important still, how should I do?

    Best regards;

    Amy

    Unfortunately, none of the help I received here was very helpful. However, I finally found the answer to this on mine. Maybe this can help someone else who has had this problem:

    http://flexdiary.blogspot.com/2012/07/when-good-Flash-BuilderFlash-Pro.html

  • With the help of several classes and create an object of a class and calling its method in a different class.

    Creating a new class, I need to move my main method class SaveDate DynamicTest class. Below I've listed the code of both classes. The goal is to be able to run my class DynamicTest program. I need help to understand the process of moving my main method of a different class and creating an object of a class and calling its method.

    public class {SaveData

    private public static final map < String, Object > myCachedTreeMap = new TreeMap < String, Object > ();

    public static final List < String > getLines (final String resourceParam, final Charset charset) throws IOException {}

    System.out.println ("please:" + resourceParam);

    If {(myCachedTreeMap.containsKey (resourceParam))

    Use the file cached, to avoid a further reading.

    System.out.println ("found in memory:" + resourceParam);

    }

    else {}

    Load the file from the disk

    System.out.println ("found in memory:" + resourceParam);

    }

    Returns a null value.

    }

    Public Shared Sub main (String [] args) throws IOException {}

    String target_dir = "C:\\myfiles\\config\\en";

    Line = "C:\\myfiles\\config\\en\\output.txt";

    File dir = new File (target_dir);

    File files [] = dir.listFiles ();

    If (file == null: files.length < 1) {}

    System.out.println ("file list is empty...");

    return;

    }

    Open the Printwriter

    PrintWriter OutputStream = new PrintWriter (output);

    try {}

    for (textFile file: files) {}

    If (textFile.isFile () & & textFile.getName () .endsWith (".txt")) {}

    readFromDisk (textFile);

    }

    }

    }

    {Finally

    outputStream.close ();

    }

    String fileNameFromCache = "en_synonyms.txt";

    Sheet1 = myCachedTreeMap.get (fileNameFromCache) object;

    System.out.println (fileNameFromCache + ": \n" + "Sheet1");

    }

    @SuppressWarnings ("resource")

    private static Sub readFromDisk(File textFile) throws FileNotFoundException, IOException {}

    BufferedReader InputStream;

    inputStream = null;

    String content = "";

    try {}

    inputStream = new BufferedReader (new FileReader (textFile));

    content = readFile (textFile);

    System.out.println ("bytes read =" + content.length ());

    Save the content

    FileContentsObject Sheet1 = new FileContentsObject (System.currentTimeMillis (),

    textFile.lastModified (), content,

    textFile.getName (),

    getLines (null, null));

    Add to the map

    myCachedTreeMap.put (textFile.getName (), Sheet1);

    }

    {Finally

    If (inputStream! = null) {}

    inputStream.close ();

    }

    }

    }

    private static String readFile(File f) throws FileNotFoundException, IOException, UnsupportedEncodingException {}

    Text of StringBuilder = new StringBuilder (1024);

    read int, N = 1024 * 1024;

    char [] buffer = new char [N];

    BufferedReader br = null;

    try {}

    BR = new BufferedReader)

    (new) InputStreamReader

    (new FileInputStream (f), 'UTF8'));

    While (true) {}

    read = br.read (buffer, 0, N);

    If (read > 0)

    Text.Append (new String (buffer, 0, read));

    if(Read < N) {}

    break;

    }

    }

    }

    {Finally

    If (br! = null)

    Br. Close();

    }

    Return text.toString ();

    }

    private static final class FileContentsObject {}

    private long cachedTime; currentTime

    private long lastModifiedTimestamp;

    private string content

    List < String > lines;

    private String fileName;

    public FileContentsObject (long cachedTime, long lastModifiedTimestamp,

    Content string, String fileName, List < String > lines) {}

    this.cachedTime = cachedTime;

    this.lastModifiedTimestamp = lastModifiedTimestamp;

    This.contents = content;

    this.fileName = filename;

    This.Lines = lines;

    SimpleDateFormat sdf = new SimpleDateFormat ("MM/dd/yy hh: mm :"); ")

    System.out.println ("time & Date:" + sdf.format (cachedTime));

    System.out.println ("' last modification timestamp:" ")

    + sdf.format (lastModifiedTimestamp));

    }

    /**

    *

    * @return the lines of the file

    */

    List < String > getLines() {}

    Return this.lines;

    }

    public String toString() {}

    "return"Sheet1 {}"+" fileName =' ' + filename + '------"+", content = "" "

    + content + "\"+ ", lastModifiedTimestamp ="

    + lastModifiedTimestamp + ', CurrentTime & Date ='

    {+ cachedTime + '}';

    }

    }

    }

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

    public class DynamicTest {}

    Public Shared Sub main (String [] args) {}

    Game characters charset = Charset.forName("UTF-8");

    try {}

    List < String > = CacheData.getLines lines ("en_synonyms", character set);

    If (rows! = null) {}

    System.out.println ("number of rows:" + lines.size ());

    for {(String ligne: lines)}

    System.out.println ("DynamicTest:" + line);

    }

    }

    } catch (IOException e) {}

    e.printStackTrace ();

    }

    try {}

    List < String > = CacheData.getLines lines ("en_stopwords", character set);

    If (rows! = null) {}

    System.out.println ("number of rows:" + lines.size ());

    for {(String ligne: lines)}

    System.out.println ("DynamicTest:" + line);

    }

    }

    } catch (IOException e) {}

    e.printStackTrace ();

    }

    }

    }

    I have read and watched videos about the creation of an object of a class and calling its method in a different class. I'm still confused on how to do it properly. By using the code below if someone can explain how to properly call the method of objects from my hand.

    Huh? You have NOT posted any 'hand' or any 'method of objects '.

    If you need help with the code, you need to view the code.

    The Java tutorials has dozens of trails "Classes and objects": what they are, how to create and how to use them.

    https://docs.Oracle.com/javase/tutorial/Java/javaOO/classes.html

    1. create an instance of a class

    2. call to one or more of the public methods of this class

    If the class has public static methods, you don't need to create an instance first.

    I suggest that you work your way through these tutorials. They include the WORKING example code.

Maybe you are looking for