Access the variable in different class

Hey guys,.

So I make a program that generates circles where you click, and I want to apply some physics. I was thinking about creating a new class that contains all of the physical code and then apply to the circles that are created, which is the way to do it?

I can't use the name of the variable of the circle in the physics class. And some stuff on the web that is said to make the variable public, and static, but I create the variable inside of a function, and it wont let me make public or static it. Even if I put it in the class, I get the same error (access from the circle of property not defined). Here is the code:

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

package {}

import flash.display.Shape;

import flash.events.MouseEvent;

import flash.display.MovieClip;

import flash.media.Sound;

import flash.media.SoundChannel;

Import fl.transitions.Tween;

Fl.transitions.easing import. *;

Import fl.transitions.TweenEvent;

import flash.utils.Timer;

import flash.events.TimerEvent;

SerializableAttribute public class Main extends MovieClip

{

var pop: PopSound;

var soundChannel:SoundChannel;

var circleReady:Boolean = new Boolean;

var coolDown:Timer;

public void Main()

{

stage.addEventListener (MouseEvent.MOUSE_DOWN, mouse click);

pop = new PopSound();

soundChannel = new SoundChannel();

circleReady = true;

cooldown = new Timer (500, 1);

}

function mouseClick(e:MouseEvent):void

{

If (circleReady is true)

{

var theX:Number = mouseX;

var they: number = mouseY;

var circle: Shape = new Shape();

circle.graphics.beginFill ((Math.random () * 0xFFFFFF), 1.0);

circle.graphics.drawCircle (0, 0, ((Math.round (Math.random () * 40)) + 20));

circle.graphics.endFill ();

Circle.x = definition x;

Circle.y = they.

stage.addChild (circle);

var xTween:Tween = new Tween (circle, "scaleX", Bounce.easeOut, 0, 1, 0.5, true);

var yTween:Tween = new Tween (circle, "scaleY", Bounce.easeOut, 0, 1, 0.5, true);

soundChannel = pop.play ();

circleReady = false;

coolDown.addEventListener (TimerEvent.TIMER_COMPLETE, timeDone);

coolDown.start ();

}

function timeDone (e:TimerEvent): void

{

circleReady = true;

}

{

}

}

}

}

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

Any help would be great, thanks

How can ensure me that the compiler finds Collision.as?

According to the file format that you are using:

1. . FLA: Collision.as must live in the same folder as the FLA

2..XFL: Collision.as has to live at a higher level the. XFL file (on the same level as the folder with the same PREFIX as your xfl)

Tags: Adobe Animate

Similar Questions

  • to access the variables in a page in another page qml

    Hey gang,

    I've been watching some of the other problems autour to access the variables from one page on another page qml qml, and I can't get this to work.

    I have a page, main.qml with a NavigationPane.  The NavPane has a Page and some containers.

    I have a property defined in the NavigationPane like this:

    NavigationPane {
        id: mainNav
        backButtonsVisible: true
        property int customInt: 2
    
        onCustomInt: {
            console.log("  -------------> App: customInt");
        }
    

    I have a ComponentDefinition for next page, called SettingsPage.qml.  In the settings, I have two drop-down lists and a slider.

    Page {
        actionBarAutoHideBehavior: ActionBarAutoHideBehavior.HideOnScroll
        id: pgSettings
    
        ScrollView {
            id: pageScroller
            scrollViewProperties.initialScalingMethod: ScalingMethod.AspectFit
            Container {
                topPadding: 25
                bottomPadding: 25
                rightPadding: 25
                leftPadding: 25
                Label {
                    text: "Settings"
                    textStyle.fontSize: FontSize.XLarge
                }
            Container {
                id: dropDown1
                topPadding: 25
                bottomPadding: 25
                rightPadding: 25
                leftPadding: 25
                DropDown {
                       id: ddOption1
                       title: "Option 1"
                       verticalAlignment: VerticalAlignment.Center
                       horizontalAlignment: HorizontalAlignment.Center
                      Option {id: o1o1; text: "One"; }
                      Option {id: o1o2; text: "Two"; }
                      Option {id: o1o3; text: "Three"; selected: true; }
                      Option {id: o1o4; text: "Four"; }
    
                    onSelectedIndexChanged: {
    
                        switch (selectedIndex){
                            case 0:
                                //
                                console.log(" -->App: Option 1 Selector, On");
                                customInt = 0;
                                break;
                            case 1:
                                //
                                console.log(" -->App: Option 1 Selector, Off");
                                customInt = 1;;
                                break;
                            case 2:
                                //
                                console.log(" -->App: Option 1 Selector, Top (default)");
                                customInt = 2;
                                break;
                            case 3:
                                //
                                console.log(" -->App: Option 1 Selector, Bottom");
                                customInt = 3;
                                break;
                        }
                    }
                }
            } }
    

    I look forward to the the statement will change the level property NavPane, called customInt, but it doesn't.

    the output of the console shows that the ' App: Option 1 selector "gets selected in the dropdown list selected index changes, but the onCustomInt() funtion slot never gets called.

    I tried "mainNav.customInt = X" too, but the parameters cannot solve the mainNav.  I get "unknown symbol 'mainNav'" error with alittle bulb.

    what I am doing wrong?

    When you call the second page, SettingsPage.qml, set it as an object.

    Don't do the following:

    attachedObjects: [
    
        ComponentDefinition {
            id: settingsPageDefinition
            source: "SettingsPage.qml"
        }
    ]
    

    Follow these steps:

    attachedObjects: [
        // Definition of the second Page, used to dynamically create the Page above.
        ComponentDefinition {
            id: settingsPageDefinition
            Settingspage{
    
            }
        }
    ]
    

    Then the second page main navigation page in the IDE.  I had the same problem with a multi-page application, I created.

  • How to access the variable in the child video clip

    I have a flash file that uses php to manipulate a database and returns a variable (data_xml) to document data in XML from the database. In this case, as well as others within the parent company. Now, I have a child movieclip that shows analyzed data, but I'm unable to access the variable from the child movieclip. The code associated with this is:

    var myXML:XML = new XML();
    var myXML = XML (event.currentTarget.root.data_xml);

    and I get the following two errors that point to the second line as the problem:

    1151: there is a conflict with definition myXML in the internal namespace.

    WARNING: 3596: duplicate variable definition.

    I unchecked automatically "declare instances of the scene" because I have seen the one proposed for the 1151: error, but I still have not the same two errors.

    Can anyone help? Thank you!

    You've declared the variable twice. Variable can be declared only once in any scope. So, your code should be:

    var myXML:XML = new XML();
    myXML = XML (event.currentTarget.root.data_xml); Note there is no before var

  • to access the variables defined in the Document class

    I can't evaluate the values established in my document class.

    My document class: ZoneViewer.as:

    SerializableAttribute public class ZoneViewer extends Sprite {}
    private var zone_area_alpha_low:Number is. 2;
    }

    This code exists on a frame in a movieclip in my main script:

    This.zone_shape.Alpha = zone_area_alpha_low;


    How to access the valeur.2 which is declared in my class: document ZoneViewer.as? "zone_area_alpha_low" does not work.

    Solution to the problem of access to a variable value (zone_area_alpha_low) from actionscript code framework in a movieclip.

    FYI... my project file structure:

    Project_Folder/MyApplication.fla
    Project_Folder/MyApplication.swf
    Project_Folder/classes/ZoneViewer.as
    --------------------
    Document class: classes. ZoneViewer

    {classes package

    import flash.display.MovieClip;

    SerializableAttribute public class ZoneViewer extends MovieClip {}

    public static var zone_area_alpha_low:Number =. 1;
    }
    }
    --------------------
    This code exists on the first frame of my movieclip in my .fla file.

    import classes. ZoneViewer;< i="" was="" missing="" this="" import="" statement="" within="" my="">
    This.zone_shape.Alpha = ZoneViewer.zone_area_alpha_low;< this="" finally="" is="" referenced="">

    Kudos to ntbdy for the light. Is there better ways to do this?

  • To access the Variables in the class file

    Say that I set a variable in a class file:

    public var container: sprite;

    I add the sprite to the scene and set it's x and y in the class file. How I would go about the change in x and y of the container in my fla file?

    You are welcome.

    using a method to expose parts of your class makes it easier to read and debug your classes.

    p.s. If your issue is resolved and that you are able, please mark this thread as answered.

  • (Question LVOOP) How one access the data of another class in another class?

    Hello-

    Ass title suggests, how do I access another class (or is it class?) data from another (different) class?  I will attach a picture showing where my problem is...

    I was told this:

    http://zone.NI.com/reference/en-XX/help/371361H-01/lvhowto/setting_scope_classes/

    May contain some helful info, but I can still understand how to unbundle Renault of classes inside the component class data (as seen in the attached photo).

    I think there could be something simple I'm missing here when it comes LVOOP or OBJECT-oriented programming in general... If any of you are willing to help me, it would be much appreciated!

    Thank you!

    -pat

    Personal data are always private, you can never set public. Unbundle cluster function can be used only on the thread of class when he is in the class. If you need to access private data, you must create accessors.

    It of simple, just the class right click and select new, VI for access data members. He invites you to a dialog box to fill you with what you want to create, elements of data and if you want them available through property nodes (recommended). Once completed, this will generate the Afterward screw., you can use in any other VI. The nice thing about making them nodes of property is that you can plop down a property node and it thread class, and all the created accessor functions will appear in the list.

  • To access the variables from a movieclip timeline

    Hey everybody!

    Normally, I use MovieClip (this.parent) to access a variable that is outside the movieclip I am writing code in. However, this does not work in both functions.

    For example:

    function editMainText (e:Event) {
         MovieClip(this.parent).headline.text = "Hello"
    }
    

    works.

    but

    function editMainText (e:Event) {
         function editText (e:Event){
              MovieClip(this.parent).headline.text = "Hello"
         }
         editText(null);
    }
    

    does not work

    There is probably some small errors in my code, but I need mainly to learn how to change MovieClip (this.parent) to work within the second function.

    Thank you!

    John

    does not work.

    In most all cases I've seen, nested functions will stand on their own

    function () {} editText
    MovieClip (this.parent).headline.text = 'Hello '.
    }

    function editMainText (e: Event) {}
    editText();
    }

  • How to access the variable script proc SQLplus?

    Lets start with the following SQLplus script:

    variable username varchar2 (100);
    Start select user in: user name of double; end;
    /

    print the user name;

    Select * from WHERE = owner all_tables "& username'"




    Issues related to the:

    Why do I get invited to enter a "/" when running the script in SQLplus? Even if I insert a / after the username 'impression' statement I am invited to enter an end delimiter.

    In addition, I would like to access the user name value in the following SELECT statement. However when I as code above the value of the variable is not taken. Instead, the user is prompted to enter a user name.

    No there is no way to 'transfer' of the value of the SQL user name?

    Peter

    You're confusing SQL * more variable substitution (those with '&') and bind variables.

    Replace the "& username" with: username as shown below:

    SQL> variable username varchar2(100);
    SQL> begin select user into :username from dual; end;
      2  /
    
    PL/SQL procedure successfully completed.
    
    SQL> print username;
    
    USERNAME
    ---------------------------------------------------------------------------
    SCOTT
    
    SQL> select * from all_tables WHERE owner=:username;
    
  • To access the data of a class

    I want to change a class to use the data stored in a public Collection named myData ArrayCollection has been populated in an mxml file. I want to fill the variables newLat and newLng with data stored in myData. For example, if myData contains var1 and var 2, I want to be able to create the next loop, which appears to be illegal:

    "SiHoop" wrote in message
    News:gasigo$L0R$1@forums. Macromedia.com...
    > I want to change a class to use the data stored in a public collection ArrayCollection
    > named myData was populated in an mxml file. I want to fill
    > the
    > variables newLat and newLng with data in myData. For example, if
    > myData
    > contains var1 and var 2, I'd like to be able to create the next loop
    > who
    > seems to be illegal:

    You can either pass data as an argument to the constructor, or a
    property (preferred), or you can watch using a Singleton class.

  • To access the FMS of different (urgent) domain

    Hi all

    I made a request for the cat using the FMS and struts2. I have the internet connection with some settings of proxy and under the domain name.

    I have deplyed my application on local server having Live IP. I want to access application of chat of an organization with some proxy settings using direct IP in the address bar. I am able to view my page web but not able to connect with FMS. but when I'm trying to connect same application using independent inter connection (without any proxy setting) so I am able to access the FMS. Please answer as soon as POSSIBLE.

    Help, please.

    Thanx

    The problem is solved using rtmps with port 443.

  • Different users accessing the data with different rights

    Hello
    I just started with Oracle and I don't know if
    This is the right way for what I was intending.

    I want to allow access to the data (tables, views,...) to different users with different rights.
    For example a user with select only the rights and another with select and insert rights.

    Database Oracle 10 g Express Edition is.

    Here are the steps I did:

    -This user will be allowed to select only
    create user UserSelectOnly...;

    -This user will have select and insert privileges
    create user UserSelectAndInsert...;

    -This user only contains data
    create user BaseDB...;

    -creation of test in BaseDB data
    create the table tdTest (...);

    -definition of role in BaseDB for right to select
    create the role RoleSelectOnly;

    -granting SELECT privilege for RoleSelectOnly
    Grant select on tdTest to RoleSelectOnly;

    -select grant (role) to the user UserSelectOnly
    grant RoleSelectOnly to UserSelectOnly;

    -definition of role in BaseDB to select and insert privileges
    create the role RoleSelectAndInsert;

    -grant select and insert privilege for RoleSelectAndInsert
    Grant select, insert on tdTest to RoleSelectAndInsert;

    -grant select and insert (role) to the user UserSelectAndInsert
    grant RoleSelectAndInsert to UserSelectAndInsert;

    My problem is that the definition of user (BaseDB) works as a database.
    Are there more effective ways in Oracle 10 g Express?

    Thank you
    Wilfried

    Hello Wilfried and welcome to the forum.

    First of all, it's a property that you have given time to review the security of the database.

    My immediate comments:

    You have 3 users:

    -This user only contains data
    create user BaseDB...;

    Very well, good thing. Use an administrative account/data owner.
    You might consider locking when you do not have administrative tasks in the schema.

    -This user will be allowed to select only
    create user UserSelectOnly...;

    -This user will have select and insert privileges
    create user UserSelectAndInsert...;

    OK, but no need to take account of their privileges in the names. You could simply call their

    SomeUser
    AnotherUser

    You have two roles

    -definition of role in BaseDB for right to select
    create the role RoleSelectOnly;

    -definition of role in BaseDB to select and insert privileges
    create the role RoleSelectAndInsert;

    Seems ok, it's a good thing here for the description of privileges in the role itself.

    Maybe I would call them something like
    RoleSelect or RoleRead or BaseDBSelectRole
    RoleInsert or RoleWrite or BaseDBUpdateRole

    Should be updated (and DELETE), as well?

    Another approach would be to separate between the tables.

    For a group of tables, select, insert, update, delete are granted to a role.

    For another group of tables, different privileges are granted to another role.

    That is, there is no general answer, correct, it depends on your application.

    Often the roles are used for ease of maintenance. In other words, if you have several users who need
    the same set of privilege, these are maintained by a role.

    Maybe you don't want to use roles, but I like them.
    But attention not only

    Select on all tables to a single role
    Insert on every table to another role
    Update on all tables to a third party role.

    Unless, of course, it gives meaning to your scenario.

    My problem is that the definition of user (BaseDB) works as a database.
    Are there more effective ways in Oracle 10 g Express?

    Not sure what you mean. Schema in Oracle and user are often used for the same thing.

    In your case, BaseDB is the owner of (all) the tables, no problem.
    As mentioned, you might choose to block the account.

    The main thing is, no application, or ad-hoc user should log in as BaseDB

    And the users of your system should be exactly the privileges they need to do their jobs
    nothing more, nothing less.

    Concerning
    Peter

  • Access the Variable Var in a Collection model

    Hi all

    Guess I used an iterator which traverses a collection template.
    The var attribute, which in this case is 'line' is used.
    <af:iterator id="i1" value="#{bindings.Departments.collectionModel}"
                 var="row">
        //call a managed bean method during iteration and used the var="row"???
    </af:iterator>
    Is it possible in a managed bean method where I could get a handle on this variable?
    My goal is to influence the way in which the GUI is being developed, while the JSF iterator is an iteration?

    Thank you

    Hello

    I'm NOT clear for your use case. Why do you do this?

    But here's the sample, which can be used to achieve the same thing:
    The example assumes that you have ministries and Instances of the employees View object where employees are the child of the departments.

    MultiIteratorPage.Jspx:




    *
    ID = "tt1" >
    *
    ID = "ot2" / >
    **
    **

    MultiIteratorPagePageDef.xml:


    version = "11.1.1.59.23" id = "MultiIteratorPagePageDef".
    Package = "View.pageDefs" > "




    DataControl = "AppModuleDataControl" id = "DepartmentsIterator" / >




















    MultiIteratorPageBean.java:

    import java.util.List;

    Import javax.el.ELContext;
    Import javax.el.ExpressionFactory;
    Import javax.el.ValueExpression;

    Import javax.faces.context.FacesContext;

    Import oracle.jbo.Row;
    Import oracle.jbo.uicli.binding.JUCtrlHierNodeBinding;

    public class MultiIteratorSampleBean {}
    public MultiIteratorSampleBean() {}
    Super();
    }

    private String departmentValue;

    {} public void setDepartmentValue (String departmentValue)
    this.departmentValue = departmentValue;
    }

    * public String getDepartmentValue() {*}
    RootNode = JUCtrlHierNodeBinding
    * (JUCtrlHierNodeBinding) This.evaluateEL("#{node}"); *
    * if (rootNode! = null) {*}
    Line currentRow = rootNode.getRow ();
    * if (currentRow! = null) {*}
    departmentValue =
    * (String) CurrentRow.GetAttribute ("DepartmentName"); *
    *}*
    List children = rootNode.getChildren ();
    * if (children! = null) {*}
    * for (node JUCtrlHierNodeBinding: children) {*}
    * if (node! = null) {*}
    Line childCurrentRow = node.getRow ();
    * if (childCurrentRow! = null) {*}
    System.out.println (childCurrentRow.GetAttribute ("FirstName"));
    *}*
    *}*
    *}*
    *}*
    *}*
    Return departmentValue;
    *}*

    Private Object evaluateEL (el String) {}
    FacesContext facesContext = FacesContext.getCurrentInstance ();
    ELContext elContext = facesContext.getELContext ();
    ExpressionFactory expressionFactory =
    facesContext.getApplication () .getExpressionFactory ();
    ValueExpression exp =
    expressionFactory.createValueExpression (elContext, el,
    Object.Class);
    Return exp.getValue (elContext);
    }
    }

    Thank you
    Nini

  • access the variable got on another timeline

    I have a variable declared in the CODE in the main timeline, I want to access it from the timeline of a movieclip underlying. How can I do this?

    Yes, AS3 is using 'root', and you must type references as you found it.  Then

    MovieClip (root) .yourVariable

    If get you there.

  • to access the variables and functions between external loaded SWF?

    Using AS 3.0: say I have a menu.swf which loads a content.swf below using the following

    var newContent:Loader = new Loader();
    newContent.load (new URLRequest ("fowContent.swf"));
    addChildAt(newContent,0);

    Now I have an image tag in newContent do it is an animation ending to this swf display. When you click another menu key in menu.swf, can I access sequence at the end of this content by:

    newContent.gotoAndPlay (newContent.endingSequence);

    Alternatively, you can use while loops in AS 3.0? I would like to have a Boolean variable "completed" in the newContent don't which evaluates to true after that end animation played.



    While (newContent.ended! = true)
    {
    wait
    }

    then to have it perform the function to load and display the new content.swf

    :

    PS you can not use a loop for and you can't use a while loop to perform any time. They both run from end to end before something is updated on stage and no other code can run outside of these loops (except if it is called from in the loop).

  • Remotely to access the variables of the cRIO

    I have a cRIO-9014 with a cRIO-9114 which is used as a stand-alone system controller (we use several types of modules c I / O and DI/O).  I want to connect a cable ethernet and view select input/output to facilitate tuning PID control.  I am currently using global variables for communication between the host on the PC and the vi rtexe vi.  This works that whent the vi rtexe is launched from the PC.  If I try to launch the host program, while the rtexe is running on the cRIO, when variables deployment stop the rtexe.  If I prevent deployment variables, global variables in the host are not communicating with the cRIO.   Anyone know how to get data in real time of the CRIO without interrupting the program running on the cRIO?

    Thank you!

    If you use variables published shared network and host them on the target (make sure that the library is below the target in the Project Explorer), variables will be deployed when you start the host VI. This way you will not interrupt the program of control over the cRIO.

    See the knowledge base article: How can I deploy a compiled executable shared network Variables? for more information.

    Hope this helps,

Maybe you are looking for