AS3 - scope question

Hi guys,.


THE INSTALLER - WHAT WORKS

I created and randomly distributed a list of tables, simple enough.

I created a "box_mc" which includes 2 images 'Before' and 'Back '.

The "box_mc" appears on the scene in "the front".

When I clicked the "box_mc" goes back to the frame "" AND a text box on the frame appears 'Back' with the first random array element.

I NEED HELP ON

When I click on "box_mc" again back to the framework 'Before' the framework change UNLESS I click on the text inside the "box_mc" box

I use:

e.target.gotoAndPlay ("Front"); selects the "box_mc" during a frame "Front".

How can I do something like:

e.target.parent.gotoAndPlay ("Front");  can select "box_mc" or 'box_mc.myText_txt' frame 'Back' depending on where you click

What can I use?

Thanks for the help,

Sky

First of all, do not use 'target', but use instead "currentTarget".  Make sure your textfield is not selectable and also set box_mc.mouseChildren = false;

Tags: Adobe Animate

Similar Questions

  • AS3 syntax question

    Hello

    Having a problem or issue of syntax. When I'm writing this in AS3, I get the right result: 4

    var wordArray1:Array = ['test', 'Apple', 'orange', 'olive'];

    var theLevel:Number = 1;

    trace (root ["wordArray" + likethis] .length);

    but when I write it in this way, inside a function, I get an error:

    function test (): void

    {

    var wordArray1:Array = ['test', 'Apple', 'orange', 'olive'];

    var theLevel:Number = 1;

    trace (root ["wordArray" + likethis] .length);

    }

    test();

    I don't understand what I am doing wrong? Any ideas?

    in the second case, wordArrays scope is limited to the function.

    so when you try to address wordArray with root.wordArray, the main timeline is unclear on this issue.

    simple solution: declare it outside the function.

    var wordArray1:Array;

    function test (): void

    {

    wordArray1 = ['test', 'Apple', 'orange', 'olive'];

    var theLevel:Number = 1;

    trace (root ["wordArray" + likethis] .length);

    }

    test();

  • O'Reilly book: AS3 essential Question page 29

    Hello

    I was hoping that someone has read or maybe this book by Moock has called «Essential AS3» I'm stuck on page 29, I want to understand what is happening here.

    package zoo {}

    Friend class VirtualPet {}

    petName internal var = "unnamed pet";

    public void VirtualPet (name) {}

    this.petName = name;

    }

    }

    }

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

    Maybe it's simple and I'm making it bigger than it is. Please forgive me if I do not mention the correct sentences to the code that I learn.

    The "Unnamed pet" value is the value of the variable to petname and I understand that the code creates an instance via the var function. The restructuring next code [shown in the book don't here] they remove actually "="Unnamed pet";" as I assume that this is redundant since they added the code after him thus showing the reader that it is a placeholder for an idea of the past.

    The constructor function 'this.petName = name.' is shake me. If the variable is defined in the constructor? And "(name)" in the line of code above is the return value? Or it creates a link between the code and the ' = name: "below?

    The line of code "petName internal var ="Unnamed pet";" which is then reduced to "var internal petName;" is it because he is no longer a decisive value and is just a simple local variable needed to help start the constructor function under?

    Thanks for any input... I do my best to pass any info in this book do not confuse myself later.

    Yes, you have. There are several different flavors of variable. The importance of this is the scope or extent of the structure of code, when this variable is accessed. Variables are only containers of storage.

    Variables are defined outside a function so that they can be used in more than just only one function. If you set the variable inside a function, then it will recognize only inside the function. If you give the variable an initial value when you set it, then it has value first. There are times where you want an initial value and when it is not important. For example, if you set a Boolean variable, it is generally important to give an initial value. When you define a variable that will be used as a parameter in a function, it may be less important.

    There are only constructor function in a given class. Think of a class as a set of code that performs a single operation. In this example, VirtualPet made a single instance of a pet. VirtualZoo made on an instance of a zoo, which can contain one or more instances of VirtualPet.

  • Table MC AS3 n00b question

    OK I loaded xml in video clips created dynamically, and when the user clicks on these other dynamically created clips video clip appears with more info loaded in XML. My question is how can I go back the information individually for each clip instead of all at once. My code:

    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.display.MovieClip;
    import flash.text.TextField;
    import flash.events.MouseEvent;

    var theXml:XML;
    var loader: URLLoader = new URLLoader();
    var mcArray:Array = new Array();
    var boxArray:Array = new Array();
    Loader.Load (new URLRequest ("template.xml"));
    loader.addEventListener (Event.COMPLETE, loadXML);
    function loadXML(e:Event):void
    {
    Check = new XML (e.target.data);
    for (var i: Number = 0; i < theXml.name.length (); i ++)
    {
    var theMC:MovieClip = new MovieClip();
    var theText:TextField = new TextField();
    theText.text = theXml.name [i]. @ Title;
    theText.x = 20;
    theText.y = 40;
    theText.selectable = false;
    theMC.addChild (theText);
    theMC.graphics.beginFill (0xff0000);
    theMC.graphics.drawCircle (50,50,50);
    theMC.graphics.endFill ();
    theMC.x = theMC.width * i;
    theMC.name = "mc" + i;
    mcArray.push (theMC);
    mcArray [i] .addEventListener (MouseEvent.CLICK, moClick);

    var descBox:MovieClip = new MovieClip();
    var descText:TextField = new TextField();
    descText.height = 100;
    descBox.graphics.beginFill (0xff0000);
    descBox.graphics.drawRoundRect (0,0,100,200,10,10);
    descBox.graphics.endFill ();
    descBox.name = 'box' + i;
    descBox.addChild (descText);
    boxArray.push (descBox);
    mcArray [i] .addChild (boxArray [i]);
    descText.text = theXml.name [i]. @ Title + ":"+ theXml.name [i]; ".
    boxArray [i] = mcArray [i] there .height-70;
    boxArray [i] .visible = false;
    addChild (mcArray [i]);

    }

    function moClick(e:MouseEvent)
    {

    / * If I try to put a loop here obviously it would display all and when I try to target by e.currentTarget.boxArray [n] .visible = true;

    its not able to find the properties in the table and get the error:

    TypeError: Error #1010: a term is undefined and has no properties.

    to MethodInfo - 1)

    */


    }
    }

    Any help would be greatly appreciated, thank you!

    Load the data separately only must not serious.  I don't see a reason why you want to put a loop in the event handler.  If you add a descBox as a child of each object in mcArray, then you should be able to target the descBox using his name, but I would just change the name to be 'box' for each of them so that you can use the following syntax...

    MovieClip (event.currentTarget) .getChildByName ('box');

    That should be the object descBox, you have added as a child object theMC as long as you assign it the 'name' box (instead of 'box ' + i).

  • AS3 button Question

    Hey all,.


    My problem is this: I have a flash file in which I add MovieClips dynamically as buttons using a loop for. At each iteration, I add a new button, give it a name and add an event listener. My question is, with this method, how do I not know what button was clicked? In other words, say my for loop runs 5 times, adding 5 different buttons in 5 different places on the stage. Anyway is to leave in the code to determine which button has been activated? I feel like there should be a simple way to figure it out and I just lack.


    The code looks like this:


    for {(var aCount:String in pNameArray)


    This ["btn" + m1Count] = new buttonMC();


    This ["btn" + m1Count] .addEventListener (MouseEvent.MOUSE_OVER, select);

    This ["btn" + m1Count] .addEventListener (MouseEvent.MOUSE_OUT, leave);

    This ["btn" + m1Count] .addEventListener (MouseEvent.CLICK, goTo);

    This ["btn" + m1Count] .buttonMode = true;

    This ["btn" m1Count] .name plus 'btn' + m1Count;


    addChild (this ["btn" + m1Count]);

    function goTo(e:MouseEvent):void {}

    Code.

    }

    }


    Any advice or ideas would be greatly appreciated. Thank you.

    Don't include this feature inside the loop.

    The argument passed to the function can be used to identify the button that was clicked.  Given that you have assigned a name to the button property, you can make use of that.

    function goTo(e:MouseEvent):void {}

    trace (e.currentTarget.Name);

    }

  • New in AS3: stupid question about event listeners...

    Hi all

    I am a newbie in Flash and have a question about event listeners. I have a site I'm developing with a movie clip navigation which is composed of several buttons. What is the right way to write the event listener?

    Here's a sample of what I have:

    I have a clip called 'buttons_mc' that contains the symbols of individual button with various names such as "btn_history". So far, I don't have an instance name for the clip of the film itself.

    My event listener:

    btn_history.addEventListener (MouseEvent.CLICK, history);

    I have to put something before the "btn_history" which refers to the video? I get this error message:

    1120: access of undefined property btn_history.

    Thank you!!!

    Julia

    Yes, it is preferable to have at least one layer dedicated to actionscript.  I often use a couple... one for code shared (functions and variables) and a level of the frame code (stop(), etc.).

    The code must be in a scenario where the button is directly accessible.  If your button is accessible in frame 1, which means that it does not animate in place such that it is not really intended to be used until you get somewhere near the bottom of the timeline, then you can target the button of the timeline that holds the buttons_mc movieclip.  So as I described earlier, if you give this movieclip an instance name of "buttons", and then to assign a code to the button on the inside you should use...

    Buttons.btn_history.addEventListener (MouseEvent.CLICK, history);

    But if the button exists somewhere down the timeline inside the buttons_mc due to the animation of the button, which means that there is more than one key image for the button, then you must place the code that you have initially shown in the last keyframe to the bottom of the timeline where he set the button in place.

    .

  • Rule scope Question

    Hey guys,.

    I make a file system rule that excludes our sharepoint servers.

    Windows_System_FileSys_Table where (name! as "sps")

    The result include the servers for some reason any. No idea where I am going wrong?

    FMS 5.5.82

    Daniel,

    When we work with objects as it the name property cannot reference the host name.

    I think that with the object of Windows_System_FileSys_Table if you want to exclude by host name, you must do something like

    Windows_System_FileSys_Table where (monitoredHost.name! like '% sps %')

    You can validate the scope and this should return only guests who does not not to like your clause.

    Let me know how it goes.

    Sorry that I don't have a Windows box in my lab... Linux only

  • AS3 Math question

    If I have this code:

    var test: Boolean;

    test = false;

    If (2 == 2 == 1)

    {

    test = true;

    }

    trace (test);

    Result: true.

    var test: Boolean;

    test = false;

    If (2 == 2 == 2)

    {

    test = true;

    }

    trace (test);

    Result: false

    var test: Boolean;

    test = false;

    If (2 == 2 == 3)

    {

    test = true;

    }

    trace (test);

    Result: false.

    Why is this?

    This is not a math problem, it's a matter of how condfitonal is a test.   Conditions are analyzed as pairs (with left to right hierarchy except if otherwise arranged by using brackets), meaning for 2 == 2 == whether, first, the test is performed to see if there are 2 == 2?, which is true, which means that the result is evaluated as a 'true '.  Then the following comparison is performed using the result of the first... that would be... is true whatever?. that depends on "whatever" is.  1 is evaluated as true as the logic goes, but another figure not, so true is 1 = true, true is 0,2,3,4,5... = false

    You will find that nothing passes the test if you reverse the order of the numbers.

    If you want to compound conditional tests are the best to do in pairs or use parentheses to set the order in which evaluations are managed.

  • Flash/AS3 base Question - Please help!

    I am fairly new to ActionScript 3 and Flash. I don't want my video to play unless the cursor of the mouse of the person is on the clip for more than one second. If the person is just their cursor on the film clips quickly, then it should do nothing. It takes more than one second. How do I don't code that?

    ActionScript Code that I have to be changed:
    stop(); var myTimer:Timer = new Timer(1000, 1); myTimer.addEventListener(TimerEvent.TIMER, timerListener); function timerListener (e:TimerEvent):void{ gotoAndPlay("over1"); } image1.addEventListener(MouseEvent.MOUSE_OVER, image1overFunc); function image1overFunc(e:MouseEvent):void { myTimer.start(); }

    assuming they all have the same parent, I showed how to do this.

    Once again:

    whatever.addEventListener (MouseEvent.ROLL_OVER, f);

    function f (e:MouseEvent) {}

    e.currentTarget.parent.addChild (e.currentTarget);

    }

  • The storage objects and listeners (base)

    A wannabe-AS3 newbie question. My problem (I think) removes unwanted objects and listeners that I switch from one mode to another in my project... Although my difficulty behind which is probably insufficient understanding of the basics of the display list.

    In a "mode" of my project, I generated the following structure:
    1... sprite ("reviewPage");
    2a......... Some graphics on reviewPage
    2b......... TextField ("commentBox");
    2c......... A number of Sprites ("displayCard_1", "displayCard_2"... "displayCard_n");
    3a............. Some graphics on each displayCard;
    3b............. Multiple EventListeners on each displayCard (e.g. displayCard.addEventListener (MouseEvent.CLICK, gotoReviseCardMode, false, 0, true))
    3c............. TextField (questionBox_1 ""...) "questionBox_n");
    3d............. TextField (equationBox_1 ""...) "equationBox_n");
    3e............. TextField (answerBox_1 ""...) "answerBox_n").

    One of the eventListeners attached to each Sprite displayCard calls a tidy supposed to function, unwanted objects and eventListeners and then move the activity to another mode, defined by another function.

    There is only one child on the stage. I guess this will be my reviewPage with all the objects it holds. However when I draw it, and it's name, I get 'root1 [object MainTimeline] ". With the help of stage.removeChildAt (0) removes all visible objects in the display list and left me without children on the scene.

    I tried to 'Explorer' my structure by writing a small function to identify each object/container and the hierarchy of the objects attached to them... but have been spectacularly failed in this effort and still overwhelmed by the error messages.

    I have a couple of issues / questions:
    1. can I remove all eventListeners when I stage.removeChildAt (0)?
    2. do I still need to remove these objects from memory? If so, how? How can I explore what listeners and objects use memory after I tried a cleaning like that?
    3. How can I remove one of the TextField objects, say answerBox_212, or one of the eventListeners attached to one of the "displayCard" Sprites, the list display and memory?

    Any guidance would be greatly appreciated.

    See you soon
    Dougal

    A wannabe-AS3 newbie question. My problem (I think) removes unwanted objects and listeners that I switch from one mode to another in my project... Although my difficulty behind which is probably insufficient understanding of the basics of the display list.

    In a "mode" of my project, I generated the following structure:
    1... sprite ("reviewPage");
    2a......... Some graphics on reviewPage
    2b......... TextField ("commentBox");
    2c......... A number of Sprites ("displayCard_1", "displayCard_2"... "displayCard_n");
    3a............. Some graphics on each displayCard;
    3b............. Multiple EventListeners on each displayCard (e.g. displayCard.addEventListener (MouseEvent.CLICK, gotoReviseCardMode, false, 0, true))
    3c............. TextField (questionBox_1 ""...) "questionBox_n");
    3d............. TextField (equationBox_1 ""...) "equationBox_n");
    3e............. TextField (answerBox_1 ""...) "answerBox_n").

    One of the eventListeners attached to each Sprite displayCard calls a tidy supposed to function, unwanted objects and eventListeners and then move the activity to another mode, defined by another function.

    There is only one child on the stage. I guess this will be my reviewPage with all the objects it holds. However when I draw it, and it's name, I get 'root1 [object MainTimeline] ". With the help of stage.removeChildAt (0) removes all visible objects in the display list and left me without children on the scene.

    I tried to 'Explorer' my structure by writing a small function to identify each object/container and the hierarchy of the objects attached to them... but have been spectacularly failed in this effort and still overwhelmed by the error messages.

    I have a couple of issues / questions:
    1. can I remove all eventListeners when I stage.removeChildAt (0)?
    2. do I still need to remove these objects from memory? If so, how? How can I explore what listeners and objects use memory after I tried a cleaning like that?
    3. How can I remove one of the TextField objects, say answerBox_212, or one of the eventListeners attached to one of the "displayCard" Sprites, the list display and memory?

    Any guidance would be greatly appreciated.

    See you soon
    Dougal

  • Question of closure of AS3

    I just started to use the closure in AS3 recently and I have a lot to learn. Here's the question. This is a loop that puts 5 balls one above the other on the stage. So far so good. However, I would like to create a situation when clicking on a button, the bottom ball is removed, and then each ball take the place of the ball below one by one, this continues for each click, until all balls have disappeared. .  I created this situation with add/remove child and I thought it might be more effective with a loop. I don't know how to access the balls because I don't have the instance name or class name can I refer too.

    var ball: gBall4M;

    var i: number;

    for (i = 0; i < 5; i ++) {}

    Prom = new gBall4M();

    ball.x = 331.30.

    ball.y = 25 + i * 17

    addChild (ball);

    }

    function release2Ball2(event: MouseEvent): void {}

    }

    using a table is a common way to keep a reference to the object ball.

    var ball: gBall4M;

    var i: number;

    var ballA: Array = [];

    for (i = 0; i< 5;="" i++)="">

    Prom = new gBall4M();

    ball.x = 331.30.

    ball.y = 25 + i * 17

    addChild (ball);

    ballA.push (ball);

    }

    function release2Ball2(event: MouseEvent): void {}

    {if(ballA.Length>0)}

     Ball = ballA .pop ();

    removeChild (ball);

    Prom = null

    for (i = 0; i<>

    ballA [i] = 17 there;

    }

    }

    }

  • Questions of scope ADF mobile

    Do the separate thread for the second question in this thread. https://forums.Oracle.com/message/11097822#.

    The question is:

    How to ensure that an instance of the bean is not created when I go to a new page of the AMX. I tried to use all scopes (PageFlow and Application) of the bean, but each of them create a new instance of the bean when the command is in the next page. Then the variables no matter what I put in the first page is not taken to the next page. Here's how I wrote my app.

    Click on a button on FirstPage to call the method of a bean using actionListener-> function call DB SampleBean method and set of values to the variables in this bean members-> go to the second Page based on the action of the taskflow.

    I added the code here as TestNestedIterator2.zip,

    Add the code below in build report.java. Because the variable is declared in pageFlowScope, its value is cached by default so you need firePropertyChange UI to update the value one. You have added the call to propertyChangeSupport.firePropertyChange, but you missed the party sub. If you automatically generate code to inform listeners jdev should do it for you.

    {} public void addPropertyChangeListener (PropertyChangeListener l)

    propertyChangeSupport.addPropertyChangeListener (l);

    }

    {} public void removePropertyChangeListener (PropertyChangeListener l)

    propertyChangeSupport.removePropertyChangeListener (l);

    }

    As Frank, said using the same java class bean as well as DC may not be a good design practice, but it should work without any problems. Please separate your code from generateReport in a bean and dc as you see fit.

    Thank you

    Arun

  • Question &amp; VI credentials of the scope again

    Just trying to keep quickly my powershell...

    So I created a .ps1 include file that I load in my PS profile by making a point scoring. .\VIinclude.ps1 ... Some of the functions I want to put here are common things as VC connect and disconnect-VC, also define some global variables. For example, these functions to connect to VC using a file of credentials of cookie in read-only format for the statement of the functions of type. The issue I noticed is, when I call these functions of PS by simply entering the function, authentication works and holds for this session. But when I run other scripts in the session that call these functions in the include file, the credential is not retained.  (for example a script dump-vms-in - cluster.ps1 calling definied connect-VC in the include file, does not work, but if I run VC plug then dump-vms... all works)

    What are the rules for the determination of the scope for this kind of thing?

    Question - is there a way to prevent the automatic connection using the currently logged-on user is connect-viserver ?  IN many cases, I want to force PS scripts to always ask authentication, because my rule of thumb is to run scripts with as little as possible privilege on VC/Resource Pools etc to do the job.

    Happy to be told if go and RTps.1FM but I am a prime, second VCP PS guru-wannabe.

    Thanks Peeps, happy vSphereing

    /Kimono/

    I suspect that the Connect-ViServer is called from a function in the include file?

    Then the framing rules begin to play, see also to connect-viserver to remain persistent through different functions..

    This thread also contains a pointer to course of PowerShell of Tobias (strongly advised to have a look).

    You can force a prompt for a username/password by practice

    Connect-ViServer -Server  -Credential (Get-Credential)
    
  • Question on the scope, theoretical

    Hello

    I have a question on the scope. It's something that I'm probably not on Java and OBJECT oriented programming.

    I am writing a program, that can handle several documents (images) of simple image processing. Now I have a DialogNewGUI with an actionPerformed method. In this method, I test for the appropriate action command and if NEW is the action command that I should create a new document (for example, a Document class). What worries me is that if I create an instance of a Document class in the scope of the actionPerformed method, we only see in this method, right? So, how do I access these Document instances newly created throughout the entire application? I think, I need a kind of global variable holding a reference to the Document instance, so I can work on it from anywhere in the code, but I don't think that there is such a thing in Java as global variables. I thought that, maybe, I need to create a class, called Basic, to contain the references in the world, but I don't know if I'm not running in the same issue there either.

    Someone has an idea? Thank you

    PR

    It is not clear what exactly you're trying to do. If you want to keep track of documents (images) which currently manages your image processing system, you will need to add in some kind of a collection - Let's say a card openDocuments, which in turn is handled by another class - let's call it imageProcessingSystem. You should then be able to add and to remove documents from the collection and to keep track of documents course of treatment.

  • Question on the scope and the framework / time line

    Hello!

    I write a little app and have the buttons and sliders on a field 1 of the scene and then a help screen on frame 2 of the scene.

    I have event listeners attached to the objects of the first image.  When I go to the second image and then return to the first image, all event listeners are passed away and no longer work.  (at least that is what I think is happening).

    My question is what is the best way to deal with this.  I think the best way would be to add something like adding Event listeners. ADDED_TO_STAGE for each object and have the listener function add event listeners I want for each item.

    So I will:

    public function Document()

    {

    Super ();

    iSlider.addEventListener (Event.ADDED_TO_STAGE, added);

    iSlider.removeEventListener (Event.REMOVED_FROM_STAGE, withdrawn);

    myButton.addEventListener (Event.ADDED_TO_STAGE, buttonAdded);

    myButton.addEventListener (Event.REMOVED_FROM_STAGE, buttonRemoved);

    }

    In each of the listeners, I would add / remove listeners that respond effectively to the key / slider.

    Is the best way to do it, or I missed something.  Sorry about the silent nature of this question, but I'm gay.  I hope someone less gay can help out me.

    -Thank you

    you are probably missing when you move to the structure 2.  It is a problem when using as3.

    an appeal is to remove your objects in the scene (using code - NOT the timeline) in box 2.  (re) you can add them to the stage in frame 1.

Maybe you are looking for

  • Even on charge my battery is less

    Lately, I noticed that my battery is dying so fast, faster than normal I checked my battery use, and there is nothing out of the normal he, not new applications or additional usage etc. When I use my phone and he is in charge, the battery is still do

  • corrupt el Capitan download, how to erase it and re - download?

    My copy of el Capitan corrupted, and he tells me to remove the download and re - download from the App Store.  How can I delete the downloaded el Capitan?  I emptied my downloads folder, and it still gives me the error on install

  • Scanner does not work on photosmart 7520

    I have a Photosmart 7520, when I tried to scan on my PC, I clicked on the name of my PC on the printer screen, but then he said that it could not connect to my pc... I know that the wireless feature works because I was able to print from my ipad... I

  • Installed OR DAQmx 9.4 and modernized to LV 2009 - but no vi DAQmx in LV

    Hi as the title suggests above - installed NI DAQmx 9.4 and upgraded to LV 2009 - but no vi DAQmx in LV We have improved LV 8.5 for 2009. LV 8.5 don't daqmx forward vi. And even after the upgrade to 9.4 Daqmx we still do not have the screw daqmx or a

  • How we use a program in need of to MSVBVM50. DDL

    my (vista) version of the Microsoft DLL components obsolete is not compatible with this version of Windows. How we use a program in need of to MSVBVM50. DDL