Passing arguments to a custom class of MC constructor

I have problems with the Builder for a custom class linked to a MovieClip library.

I have a MovieClip in my library called circle, which is related to the com.shapes.Circle class. I want the contstructor of class circle to take 2 arguments, xScale and yScale:

public function Circle (xScale:Number, yScale:Number) End Sub

However, if I try to call it from code, for example ball circle = new Circle (3.14,2.0); , I always get a 'number of Incorrect arguments. Waiting 0 " error.

Is it possible to have a custom class linked to a MovieClip that can take arguments, or Flash not allow this? I had asked about this before and thought I figured out, but look at it now, I apparently had not thought of it and has resorted to a workaround sloppy; I'm hoping to fix now.

Library items cannot have constructor arguments, because the user can drag on the stage and in this way has no way of passing arguments. If you wat to initialize instances, define public void init() where you can add as many arguments as you want.

Tags: Adobe Animate

Similar Questions

  • Passing Arguments to a custom CellRender

    I am creating a simple two marked list by creating two areas of label labels using a class called TwoLabelCell that extends AlternatingCellRenderer and looks like this:

    package views
    {
      import flash.text.TextFormat;
    
      import qnx.fuse.ui.listClasses.AlternatingCellRenderer;
      import qnx.fuse.ui.text.Label;
    
      public class TwoLabelCell extends AlternatingCellRenderer {
        private var description:Label;
        private var labelFormat:TextFormat;
        private var text:String;
    
        public function TwoLabelCell(labelText:String) {
          this.text = labelText;
        }
    
        override protected function init():void {
          super.init();
    
          labelFormat = new TextFormat();
          labelFormat.color = 0x777777;
          labelFormat.size = 17;
    
          description = new Label();
          description.x = 17;
          description.y = 33;
          description.format = labelFormat;
          description.text = text;
    
          this.addChild(description);
        }
      }
    }
    

    Remember that this is just a test at the time, so I'm working with a single label (once I tell myself on this issue, I'll add the other and use the same logic). The main idea here is that when I call, he will define the text variable that will be used to change the text of the label on the list, when it is created. Now, this is the main file for the application:

    package {
      import flash.display.Sprite;
    
      import qnx.fuse.ui.events.ListEvent;
      import qnx.fuse.ui.listClasses.List;
      import qnx.fuse.ui.listClasses.ListSelectionMode;
      import qnx.fuse.ui.listClasses.ScrollDirection;
      import qnx.ui.data.DataProvider;
    
      import views.TwoLabelCell;
    
      [SWF(height="600", width="1024", frameRate="30", backgroundColor="#FFFFFF")]
      public class PackTrack extends Sprite {
        private var packList:List;
    
        public function PackTrack() {
          super();
    
          initializeUI();
        }
    
        private function initializeUI():void {
          packList = new List();
          packList.setPosition(0, 0);
          packList.width = 310;
          packList.height = 400;
          packList.rowHeight = 50;
          packList.selectionMode = ListSelectionMode.SINGLE;
          packList.scrollDirection = ScrollDirection.VERTICAL;
    
          var arrMonth:Array=[];
          arrMonth.push({label: "January"});
          arrMonth.push({label: "February"});
          arrMonth.push({label: "March"});
          arrMonth.push({label: "April"});
          arrMonth.push({label: "May"});
          arrMonth.push({label: "June"});
          arrMonth.push({label: "July"});
          arrMonth.push({label: "August"});
          arrMonth.push({label: "September"});
          arrMonth.push({label: "October"});
          arrMonth.push({label: "November"});
          arrMonth.push({label: "December"});
    
          packList.dataProvider = new DataProvider(arrMonth);
          packList.cellRenderer = new TwoLabelCell("Testing Label");
    
          packList.addEventListener(ListEvent.ITEM_CLICKED, onListClick);
    
          this.addChild(packList);
        }
    
        private function onListClick(event:ListEvent):void {
          trace("Item clicked: " + event.data.label);
          trace("Index clicked: " + event.index);
        }
      }
    }
    

    When I try to run I get this error:

    Error: skin must be Class or String
        at qnx.fuse.ui.listClasses::List/set cellRenderer()[E:\hudson\workspace\GR2_0_0_AIR_SDK_API\src\qnxui\src\qnx\fuse\ui\listClasses\List.as:1069]
        at PackTrack/initializeUI()[/Users/Nathan/Documents/Adobe Flash Builder 4.6/AIRTest/src/PackTrack.as:46]
        at PackTrack()[/Users/Nathan/Documents/Adobe Flash Builder 4.6/AIRTest/src/PackTrack.as:19]
    

    Any idea on how to fix this (preferably without using MXML)?

    PS: I'm learning Flex (from Java)

    The API is looking for a class, not an object, when you set the cellrenderer property.

    The cell rendering engine has a data property you can inspect for the label data.

    This property is populated by the data provider of the list.

    To add your 2nd custom label you can create it as a property of your data provider object

    elements of the array.  Something like:

    arrMonth.push({label: "January", customlabel: "Custom label text"});
    arrMonth.push({label: "February", customlabel: "Custom label text"});
    

    The data provider is an array of objects of value Object literals (which can be object literals) with

    You can set the properties.  The class expects a property called label, but you can add your own

    Properties of the object here.

    Then in the display of your cell, you can reference

    this.data.customlabel
    

    to get the data of the custom label.

  • Object generic casting/conversion of custom class

    I know that the right way to do what I want is to use the ORM and type all my objects in the database that I have, but it's a little late for this approach.

    So, I have an arrayCollection collection that is returned from ColdFusion. I have a custom class, call the MyClass. What is the best way, assuming that the properties match 1-1, to copy all the properties of the generic object in the collection arrayCollection in an instance of myClass with the same properties. I tried "MyClass" and not of chance (that would be nice. I happen to hit on a syntax to use 'foreach' so if you have an example or other suggestions, I would be happy.

    At this point, I add any parameters to the MyClass constructor if there is an object passed, it copies the properties of an instance, but who feels 'dirty' in the sense of duty hardcode this mapping:

    public var GUID:String;
    public var frameName:String;
    public var frameType:String;
    public var helpTitle:String;
    public var helpText:String;
    public var baseMovieGUID:String;
    public var notes: String;
    public var hotspots: ArrayCollection collection;
    public var JSONHotspots:String;
    public var baseMovieURL:String;

    public void MyClass(obj:Object_=_null):void {}
    If (obj! = null) {}
    GUID = obj. GUID;
    frameName = obj.frameName
    frameType = obj.frameType
    helpTitle = obj.helpTitle
    helpText = obj.helpText
    baseMovieGUID = obj.baseMovieGUID
    Notes = obj.notes
    points = hot obj.hotspots
    JSONHotspots = obj. JSONHotspots
    baseMovieURL = obj.baseMovieURL
    }
    }
    }

    Does that help? http://forums.Adobe.com/message/2928367

  • Interpolation in custom class

    I am a newbie in flash/actionscript related. I created a towers of hanoi video clips solution using the motion tweens. It worked great all when the action script containing the creation of Tween existed on what I think is the clip of root (in my FLA file action script window).
    I tried to move the solution of hanoi in a custom class (which extends from EventDispatcher) and now the interpolation "does not. I reinforced with my code with the debugger and added a lot of tracing instructions and I'm sure that all the arguments for the Tween constructor are correct.

    _currentTween = new Tween (_movingDiskMc, "FLF", Regular.easeOut, _movingDiskMc._y, _yMin, _duration);

    Is there something fundamental, that I'm missing? Is the frequency of images, a problem with the custom class? _Duration above value is 5.

    THX

    -Kurt

    Ahhhh... after a further examination found that my "onMotionFinished" event handlers have been called, but in the debugger, the scope is the interpolation my class of Hanoi. Went wrong

    found the discussion in the help topic regarding the scope of event handlers and using things 'suggested strategy' work very well now

  • You need to pass arguments to the Sub - VI which runs in parallel to the main vi.

    Please help me.

    I can pass arguments to a subvi using "call-by-reference-node" but the sub - vi will not work in parallel.  I can also run my sub - vi in parallel using "invoke the node", but then cannot pass arguments.  I can't understand how to merge these two concepts.

    When I open the reference VI, I specify the strict type, using call-by-reference-node.  When I use call node, I don't specify the type.  It seems that specifying the type strict guard screw run in parallel, but also seems necessary to pass arguments.

    I apologize for my absence of a deeper understanding of this and appreciate any help you can give me.

    Chris

    You must invoke 'Ctrl Val.Set' node.

  • Passing arguments to the script

    Hello

    I have created a dialog box load the files in the folder and when I click the button I run another script of command StartScript (...)

    How can I pass arguments to the script (the paths of files)?

    Thank you

    Hey OzShimon,

    As long as you use a tiara predefined global variables (T1, T2,...)  you'd be fine. You can also define user variables (.) SAV files) or even to declare your own global variables with: call GlobalDim ("Myname").

    These variables are not re-initialized until you restart the script engine. So just change 'obj' for T1 your test should work

    ' Dim obj

    Void Button1_EventClick (ByRef This)

    T1 = "Hello World".

    Call ScriptStart("C:\Users\Oz\Desktop\test.vbs")

    End Sub

    * the script code (test.vbs):

    Call MsgBox (T1)

    Kind regards

    Javier

  • How to passing arguments to an exe

    Hai Everbody

    I know that LabVIEW has the ability to call an exe file created in different platform, can I know how to pass arguments to the special exe (which is located in another platform) via LabVIEW... I wish someone could help me out of this

    Thanks for your answers, I found the solution... As the exe is in .net, I used the syntax for the command line arguments in .net...

  • Unable to make a call to the custom class

    Hi all

    I train to call the custom since the screen as below class, but its not picking up the custom class features and gives the result, I don't know if something is not in the below class or the way I call this method.

    package com.ge.bbcalendar;

    Import net.rim.device.api.ui.Color;
    Import net.rim.device.api.ui.Graphics;
    Import net.rim.device.api.ui.component.LabelField;

    public class TestClass extends {LabelField
    Private boolean brought;
    private string text;
    style long private;

    public {TestClass (String text, long style)

    Super();
    This.Text = text;
    This.style = style;
    }

    protected void onFocus (int direction) {}
    focused = true;
    Invalidate();
    super.onFocus (branch);

    }

    protected void onUnfocus() {}
    concentrate = false;
    Invalidate();
    super.onUnfocus ();
    }

    protected void paint (Graphics graphics) {}
    graphics.setColor (Color.WHITE);
    graphics.setBackgroundColor (0x544E4F);
    If {(targeted)
    graphics.setColor (Color.BLUE);
    }
    Graphics.Clear;
    Super.Paint (Graphics);
    }
    }

    Called as of the screen

    SerializableAttribute public class NativeScreen extends form {}

    final cas15 TestClass = new TestClass("",LabelField.FOCUSABLE);
    }

    What is the problem above?

    I suspect that your problem is the LabelField don't think it has any text to display.

    You really need this, I think

    public TestLabel (String text, long style) {}
    Super (Text, FOCUSABLE);

    ...

  • 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.

  • ClassCastException in the custom class loader

    I created a custom class Leon.

    CCL ClassLoaderDemo = new ClassLoaderDemo(); assume that it works very well
    CLAS class = ccl.loadClass ('com '' ' MyObject');

    com MyObjectSuperClass o1 = (com. MyObjectSuperClass) clas.newInstance ();

    Now I want to get the object responsible for MyObjectSuperClass which is super class if MyObject. But I'm getting the following exception

    Exception in thread "main" java.lang.ClassCastException: com. Com cannot be cast to MyObject. MyObjectSuperClass

    Help, please.

    821458 wrote:
    My requirement is the class MyObject needs to be loaded by my client class loader. If you say that let the superclass (MyObjectSuperClass) be in the class path and let the class system charge charger, then usually it be a problem

    No, it's exactly what you want.

    MyObject loaded by the custom class loader, its super class loaded by the system class loader, I will be able to cast then.

    Yes, you will be able to cast to the upper class, then.

    It is not similar to the statement "MyObject loaded by the class loader and custom class system are different and we cannot throw.

    No, it isn't. your confusion is due to the fact that you don't seem to understand that you can have a class hierarchy that spans the Chargers of classes. This should be obvious because each object hierarchy extends eventually object, which is always in the system class loader. Therefore, you can always convert any instance of any class loader "Object". in the same way, you can have MyObjectClass in your chargers personalized classes and MyObjectSuperClass in the system class loader. You can instantiate an instance of MyObjectClass to aid reflection on your custom class loaders and assign it to a reference of the type MyObjectSuperClass. This is how pretty much any plugin system is implemented (the API is in the 'main' class loader and the implementation is in a nested class or custom ClassLoader).

  • Listen to the event within the custom class

    I created a custom class that publishes on a webpage to authorize a user. How can I listen to an event within the custom class?

    It is my code in my main class.

    var customClass:CustomClass = new CustomClass();

    var testingString = customClass.authorize ("[email protected]", "password");

    the fuction "authorizes" within the customClass looks like this:

    public void 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 trigger an event in my main class once the j_Loader triggers Event.COMPLETE?

    You can raise an event using the dispatchEvent() function.

    In your main class, you assign a listener to the event the CustomClass distributes when there are.

  • How to pass arguments to the SQL Script in command prompt

    I don't know about the ' & nom_de_variable "to request a value in the command line.

    But, how can I pass arguments from the command line for the following script to the command - prompt

    Example:

    ex_proc. SQL

    CREATE OR REPLACE PROCEDURE ex_proc (employee_id NUMBE IN)
    IS
    v_emp_id Number (38);
    BEGIN

    v_emp_id: = employe_id;

    UPDATE emp_employee SET sal = 2000 WHERE emp_id = v_emp_id;

    END;
    /


    call_ex_proc. SQL

    Appellant for procedure above:

    BEGIN

    ex_proc (100); -The employee id is 100.

    END;
    /

    Here are the General controls that we use to run the scripts above-

    SQL > @ex_proc.sql

    SQL > @call_ex_proc.sql



    But my requirement is to pass the employee id as an argument in the command line as.
    SQL > @call_ex_proc.sql 100

    Is it possible to pass command line arguments?

    Usually this question start with reading documentation, wouldn't it?

    Solomon Yakobson showed you the method gross and unreadable.

    You will use best

    set = '& 1' '.

    -use & in the rest of the code

    ----------
    Sybrand Bakker
    Senior Oracle DBA

  • How to pass values from a Java class to a class of JavaFX?

    Hi Forum,
    I get nuts on this problem:
    I designed a program with Java and JavaFX classes. JavaFX classes handle the GUI and Java classes mix program logic. I think that's the way it is supposed to be. My program calculates something, so in my JavaFX GUI, I have a button to run this calculation. It's not a problem to call the start function calculation (which is in my Java class) on click of a button. But now I want to display the result of this calculation in my GUI. I can't just simply pass the result to my class of JavaFX GUI. I tried to import the JavaFX class in my Java class to call a set function, but I can't import them with the import statement. So my question is, how do I make the results to my GUI? What is the right way to do it?
    I hope someone can help, thanks in advance :)

    Two ways, either:

    -your JavaFX class asks the Java class for the result once the task completed in exactly the same way he instantiated to start the task. Of course, you should regularly check the completion of the task (a mere PauseTransition).

    - or your JavaFX class implements a Java INTERFACE and your Java class accepts (whether through the method or constructor) a variable of type of this interface. For example, you can set a reference to the subject of JavaFX itself in the Java object using the interface.
    When the task is completed, your Java class calls a method defined in the INTERFACE to set the result in the object of JavaFX.

    In addition, JavaFX 1.3.x provides an API to start asynchronous and be notified when a task is completed in the javafx.async package that allows you to run the task of basic Java (you mind that the class is named...) JavaTaskBase, see also the RunnableFutre interface) in a separate thread.

  • 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"));

  • SQLite, from SQLinstructions to a custom class

    I'm working on an AIR of FB app.

    I have a file with a source main.mxml in main.as file.

    My main.as file becomes very swollen with SQLinstructions. I want to switch to a custom class, but I do not 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)

    on a 3rd down.

    The example above, that's exactly what I want to do, but I do not know how to adapt it for use in my file main.as beyond to import the class and instantiate. How can I assign my values in the class file? How to use the class to load up the dataProvider, etc...

    In addition, in the example above, the class extends Sprite. This sounds like it is for a Flash application. I always extend Sprite in Flex 4? I made a couple of simple events, data transmission to the main application with the Flash.Events.Event, so using Sprite causes some confusion.

    In a previous post, Amy suggested using Robotlegs. I think I need to get a handle on the use of Flex before I explore other architectures. I'm just not that sophisticated.

    Thank you

    Kristin

    OK, a small example

    a new package called utilities, then a new called class class actionscript 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, it 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

Maybe you are looking for

  • Cannot open the view youtube. The plug-in module did open in simplified display only some images. Why?

    FIRST PART. All of a sudden we can open more or videos to youtube. All that appears is a black box. Then when we open modules, the view is basic, no pictures, incapable of doing some outages. What we've done over the last four hours trying to correct

  • A100-529: OTG database does not work on USB ports

    Hello.I bought my laptop a few days ago and I have already problem.I've got OTG Databank with HARD drive (it is Apacer ShareSteno CD211 with 20 GB IBM travel... Disc). And here's my problem:Computer cannot start this database. When I plug it in, noti

  • When will be released Windows 7 SP1 via WSUS?

    I see that Windows 7 SP1 is available for download and also appear through Windows Update.  The update does not appear when I sync my WSUS server.  Anyone know when it will be available via WSUS? Thank you!

  • error code 57

    I tried to update/fix windows Vista net Framework

  • Computer suddenly starts running slow

    Hi all More computer problems - yay. I can boot my computer without problem. For about 2 minutes, it works perfectly - things open fast, close quickly, etc. Then all of a sudden, the whole system just slows down. All that I'm starting to take forever