Can I add children through functions?

I'm working on my first basic Flash game, essentially a platformer with obstacles determined by a random number generator. The idea is that when the player character reaches a certain coordinate, the next obstacle will be created. However, I'm having some problems creating new children by functions. For practice, I was just trying to add a square through a mouse event.
import flash.events.MouseEvent;
import flash.display.MovieClip;
var square:Square = new Square();
square.x = 100;
square.y = 100;
this.addEventListener(MouseEvent.CLICK, _mouse);
function _mouse(e:MouseEvent):void {
          this.addChild(square);
          trace("Trace");
The symbol is called "square" and is exported as a class called "Square". When I click, I want it to create the square while tracing a message, but when I click, absolutely nothing happens, not even the tracing. When I move the this.addChild(square) outside of the function, the child is added where it should, at x = 100 and y = 100 and the mouse event works and the message is traced. When I place the addChild inside the function, neither works, neither the addChild or the trace.
I'm flying completely blind here and have no idea what I'm doing, or what to search to look for help, so I figured this would be the best place to look.

Don't attach the event listener to "this". Use a defined object, in this case "stage" will work. Inside the function, which is connected to the stage through the event listener, the line "this.addChild(square);" the "this" refers to the stage and so it will add the child object "square" to the stage. But you don't really need to use the reference to either stage or this when adding that child.
Here's a lengthy discussion of "this": http://stackoverflow.com/questions/5321199/this-and-stage-in-as3

Similar Messages

  • How can i add videos,movies and tv shows episodes to my ipod nano?I want to know whether i can directly add them through my pc or not without downloading them from i tunes store?

    how can i add videos,movies and tv shows episodes to my ipod nano?I want to know whether i can directly add them through my pc or not without downloading them from i tunes store?

    Yes, you can add your own videos to iTunes, then sync them to your nano, subject to supported max resolution limit and file type.  The specs for the 7th gen nano says (I don't know which nano model you have), Video Format Support
    "H.264 video: 720 by 576 pixels, 30 frames per second; Baseline, Main, and High-Profile level 3.0 with AAC-LC audio up to 256 Kbps; 48kHz; stereo audio in .m4v, .mp4, and .mov file formats
    MPEG-4 video: up to 2.5 Mbps, 720 by 576 pixels, 30 frames per second; Simple Profile with AAC-LC audio up to 256 Kbps; 48kHz; stereo audio in .m4v, .mp4, and .mov file formats"
    http://www.apple.com/ipod-nano/specs.html
    (earlier nanos have lower max resolution limits)
    So, "HD" video is too high resolution, so iTunes will not sync such videos to the iPod (although they play in iTunes).  If you are asking how to set up iTunes to sync videos in general (regardless of source), please post back.

  • How can i add a new function to the Basic IVI class vi's?

    I need to use the IVI vi's to control some instruments, let's say a DC Power Supply.
    Since there's a DC Power supplyclass, i can used those VI's but waht if one of the VI's does not contains all the functions that i need?. How can i add more functions to the IVI classes?. What do i need to do to add a new function to the iviFGen class?

    If you would like to try developing your own instrument driver (or modify the existing one), we have documentation, model instrument drivers, and driver templates to help at :
    http://www.ni.com/devzone/idnet/development.htm
    We also have a syndicate of third party vendors that specialize in National Instruments' products and services. Some of the vendors specialize in driver development. I would suggest contacting one of the Alliance members at:
    http://www.ni.com/alliance

  • How can i add waveform datasaving functions to 2 channels oscillosco​pe demo

    How can I add waveform datasaving options to my .vi for example Oscar Gomez Fuentes 2channel oscilloscope demo, So that i can later on read the data and print graph.
    Mikko

    Look at the example Export Waveforms to Spreadsheet File Example.vi that ships with LabView 6 or 7. For your purposes, look at the first two file operations, Write Waveforms to File.vi and Read Waveform from File.vi. You can wire the output of Read Waveform from File.vi directly to a waveform graph. For your application, you don't actually need to call Export Waveforms to Spreadsheet File.vi (unless you're planning on using Excel to manipulate the data).

  • How can I add customer partner function entries in LSMW?

    I am using SAP ECC 6.0 with best practices installed. I am able to create sold-to customers using the batch input program RFBIDE00. 
    When I try to add partner function entries using structure BKNVP, it appears that the partner ID stored in KTONR is not populating SAPMF02D screen 324 after it is entered on screen 2324. I receive a “Data is incomplete; check” error.  I could not find an SAP note or other solution to correct this problem. 
    While searching for a solution, I found a few recommendations to use the IDOC message DEBMAS to create the partners function entries instead of batch input.  When I try to use this approach, I am receiving an error “Deletion is not allowed: SP is mandatory function”.  I was trying to add an SH (WE Ship-To) at the time. I found a reference that explained that all partners were replaced when this IDOC message is used.  It further explained that this should work if all partner references were included in the message.  This approach did not work either. I still receive this error if I omit or include an SP (AG Sold-To) record.
    Does anyone have a solution to either problem or another approach?

    Hi
       You can use LSMW :-
    1) Create a project , sub project and an object.
    2) execute it from 1 st screen to enter the object.
    3) You will find proces steps.
    4) In Maintain Object Attributes  choose Program Name RFBIDE00.
    or I-DOC or the way you want the input to be.
    5) You can proceed from there following the instruction..

  • Can you add seek handle/function to a progress Bar?

    I've got a nice little brogress bar working for my AS3 app,
    but I also want to provide a seek/scrub function. I haven't been
    able to figure out how to make one yet, let alone add it to the
    progress display. But I did what I want to do (provide a great
    little scrubber/progress bar combination) at
    http://www.gotoandlearn.com
    (video basics 5). The problem is it's in AS2 and I can't seem to
    figure out the equivalent functionality in AS3 - I'm having issues
    understanding the migration of components/functions in AS3.
    The code for the AS2 example is below:(it sits on frame 1 of
    the .fla rather than in a package/.as file)
    Any ideas where to find/adapt what would be "equivalent"
    using AS3 classes?

    But I don't want that the user actually sees the dummy page, I want them to get directly to the external page. is it possible to make clicking on the dummy page immediately send the user to the external page?

  • When building a vacation leave holiday system using SharePoint Foundation 2010 and SharePoint Designer workflows how can I add half day functionality?

    Hi,
    I have built a vacation leave holiday system for SharePoint Foundation 2010 using SharePoint Designer workflows and Javascript. Everything works perfectly but I'm struggling to design a solution for users to specify half day requests that span over dates
    greater than 1 day, i.e. my half day solution works but only when the start and end date are the same. How would I change the user interface to allow users to choose which day they want the half day to be requested when the vacation leave holiday request is
    from, say,  6th - 10th Jan 2014?
    Thanks.

    Hi ,
    I have a test on my machine with a custom approval workflow and it can work normally .Here are the detailed steps :
    1.      
    Open the site in SharePoint Designer .Create a workflow to associate with the document library .Set the workflow to start when an item is created and when an item is changed
    .Also allow the workflow to start manually .
    2.      
    Choose ‘Collect Data from a user’ .
    3.      
    Click on the data and give a name to the Task created .
    4.      
    Define the custom form field name as ‘Approve ?’ .Set the information type as Choice .
    5.      
    Set the choices as ‘Approve’ and ’Reject’ .Display as Checkboxes .Uncheck the ‘Allow fill-in values’ and ‘Allow blank values’
    .Click finish to save .
    6.      
    Click on users and add the users who will approve the documents .
    7.      
    Keep the output to variable as collect .
    8.      
    Add a new step .Choose ‘If any value equals value ’ .Set the any value ‘Data source’ as  workflow variables and parameters .Set the ‘Field
    from source’ as Variable: collect .
    9.      
    Set the value behind ‘equals ’ as ‘Approve’ .
    10.  
    Add a new action ‘Update list item ’ .Set the item as current item .Add the field Approval status as Approved .
    11.  
    Add an Else-if branch to update the Approval status as Rejected .
    12.  
    Publish the workflow and test in your site .
    Thanks,
    Entan Ming

  • Can you add decent "Search" functionality to the Mozilla Support website?!

    One of my biggest frustrations with Firefox is trying to make use of the Mozilla Support website. Almost every search I enter in the Search box yields 1000+ results. String delimiters (") to define phrases and operators like AND and OR appear not to work at all, and results seem to include ANY article that contains ANY of the words in the search box. This is next-to-useless, and I usually exhaust my patience sifting through unrelated articles, exiting the support site again with just a little less respect for Firefox/Mozilla.

    This is a well known issue.
    The search is even hardcoded into crash stats pages where it results in meaningless or misleading results.
    Regulars know to use an external search engine because of this shortcoming. There are numerous instances where a string is useful the name of software or a feature for instance, but if one of the words is commonly used results max out and bury the real hits.
    Compare for instance
    *'''''Ask Toolbar''''' (Problematic software)
    ** [https://www.google.co.uk/search?q=%22ask+toolbar%22site%3Asupport.mozilla.org&hl=en&btnG=Google+Search&sourceid=Mozilla-search&start=0#hl=en&q=%22ask+toolbar%22site:support.mozilla.org&start=290 Google] I only scrolled the first 30 pages, all would appear good hits.
    ** [https://support.mozilla.org/en-US/search?q=ask+toolbar&esab=a&page=3 sumo] maxed out 1000 results maybe two proper hits per page in the first few pages
    I know I have often mentioned this. Including in the contributors forums <sup>[/forums/contributors/709812?last=55863#post-55708 (most recent)]</sup>. There are old & current bugs
    * ''[https://bugzilla.mozilla.org/show_bug.cgi?id=791200 Bug 791200] - Switch to AND search in advanced search ''
    * ''[https://bugzilla.mozilla.org/show_bug.cgi?id=791250 Bug 791250] - [tracker] Add way to be specific with the advanced search ''
    * ''[https://bugzilla.mozilla.org/show_bug.cgi?id=794083 Bug 794083] - add query_string support to advanced search ''
    * https://bugzilla.mozilla.org/page.cgi?id=voting.html
    * https://bugzilla.mozilla.org/page.cgi?id=etiquette.html
    Bugs are a workplace for developers rather then a discussion forum, and so it is usual practice to discuss matters elsewhere, but anyone may register and then express an interest by voting, or add themselves to the cc list (by default just click [Save Changes] ). <br />N.B. email addresses used are displayed in public.

  • Can you add macros through Netconfig?

    I have been trying to deploy a macro using netconfig but get the following result:
    Command(s) failed on the device TFTP: Failed on the device. Insufficient no. of interactive responses(or timeout) for command: macro name av. Could not synchronize CONFIG archive with Device Config.
    I had this problem once before and opened a discussion, but failed to follow through on it.
    Our configuration is as follows:
    Server is running Windows 2008 R2 with 8Gig of RAM and 300Gb free disk space.
    We are running LMS 4.1
    The switches I am trying to deploy on are 3750s running 12.2(55)SE4. Note: this previously happened with earlier versions of the IOS.

    Yes. A hard disk connected to your Extreme's USB port will appear in a Finder Sidebar under "shared". You can read and write its contents, at speeds limited to that of your wireless network.

  • Can't add apps through iTunes

    Hey people,
    So this evening I updated my ipod touch to iOS5 or whatever the **** the latest OS is. Anyway, I backed-up the pod and transfered all of my recent purchases onto my desktop computer. Now, however, when I try to rearrange or even add apps to the pod, I am unable to. They appear on itunes as a sort translucent icon but I cannot move them etc etc. Refer to the image below.
    Also, having just updated my my desktop PC, I added it to my authorised list. I change computers quite frequently and it says I have only 1 more computer left to authorise. How do I remove authorisation from other computers (whose where abouts and ownership are now unknown).
    Cheers people.

    - To deauthorize unavailable computers you have to Deauthorize All but you have to have already used up all five authorizations and you can only do that one a year.  See:
    About iTunes Store authorization and deauthorization
    - For the apps problem,  you changed syncing computr and you can only sync with one comutr/iTunes library.  To change syncing computers:
    - Make sure that all apps and music are in the iTunes library.
    - The make a backup of the iPOd by connecting the iPod to the computer and right clicking on the iPod under Devices in iTunes and selecting Back Up
    - Restore the iPod from that backup

  • Can't activate the COMPARE function for object DNL_CUST_TVAST for Adapter

    Hello
    I've applier OSS note 866824 to enable the exchange of the sales area flag deletion. I had to do the initial download for the customizing object DNL_CUST_TVAST but it failed because the no intial load was permitted as the data distribution was active. So I've applied note 887696 to enable the intial load for this object : I've deleted the COMPARE function for this object with transaction R3AC3. I've done the initial load for this object and now I can't add the COMPARE function : the error message is enter linked bdoc type for synchronisation load. and I don't know what to do...
    if somebody can help me...
    thanks a lot

    Thanks for your tip but it does not work, I need to fill this field.
    I just have an answer from SAP support, this value COMPARE is relevant for loading data in CDB.
    there no sense to add the compare value for this object : the compare load can never be used for this object. It was a delivery error
    Edited by: Jerome Munier on Dec 5, 2008 7:13 PM

  • How to add user defined functions in Menu bar of a Selection Screen?

    Hi,
    Can anybody please suggest me that how can I add user defined functions in the menu bar of a Selection Screen?
    Regards
    s@k

    Dear Amit,
    I am referring to the standard SAP program: RIEQUI20.
    On the initial screen, there are 3 tabs.
    Code:
    SELECTION-SCREEN BEGIN OF TABBED BLOCK tab FOR 25 LINES.
    SELECTION-SCREEN TAB (20) tab1 USER-COMMAND ucomm1
                         DEFAULT SCREEN 001.
    SELECTION-SCREEN TAB (20) tab2 USER-COMMAND ucomm2
                         DEFAULT SCREEN 002.
    SELECTION-SCREEN TAB (20) tab3 USER-COMMAND ucomm2
                         DEFAULT SCREEN 003.
    SELECTION-SCREEN END OF BLOCK tab.
    AT SELECTION-SCREEN.
      CLEAR gv_okcode.
      gv_okcode = sy-ucomm.
      CLEAR sy-ucomm.
      CASE gv_okcode.
        WHEN 'IH08'.
          CALL TRANSACTION 'IH08'. "Equipment Selection
        WHEN 'IW29'.
          CALL TRANSACTION 'IW29'. "Notification Selection
        WHEN 'IW39'.
          CALL TRANSACTION 'IW39'. "Order List Selection
        WHEN OTHERS.
      ENDCASE.
    *   Check date:                                         
      IF NOT datuv IS INITIAL                            
      AND NOT datub IS INITIAL.                         
        IF datub >= datuv.                              
        ELSE.                                           
          MESSAGE e884(ih) WITH datuv datub.            
        ENDIF.                                           
      ENDIF.                                             
      IF variant IS INITIAL AND
         dy_vari IS INITIAL.
        PERFORM get_default_variant_f14 USING variant.
      ENDIF.
      PERFORM variant_existence_f14 USING variant.
      IF datuv IS INITIAL.
        datuv = sy-datum.
      ENDIF.
      IF datub IS INITIAL.
        datub = sy-datum.
      ENDIF.
      IF sy-ucomm = 'ADDR'.
        PERFORM adress_sel_f01 USING 'EQUIR'.
      ENDIF.
      PERFORM check_parnr_f76.
    *  AT SELECTION SCREEN OUTPUT
    AT SELECTION-SCREEN OUTPUT.
      STATICS: l_slset TYPE sy-slset.
    *--- Set initial variant
      PERFORM variant_init_f14 USING 'INST' 'INST' 'INST' 'RIEQUI20'.
      IF variant IS INITIAL AND
         dy_vari IS INITIAL AND
        gv_variant_flag IS INITIAL.
        PERFORM get_default_variant_f14 USING variant.
        gv_variant_flag = 'X'.
      ENDIF.
    *--- Set Icon for adress-button
      PERFORM set_icon_f01 USING dy_adrfl ad_icon text-ad0 text-ad1.
    *--- get classification data from select option
    *--- (if new variant or if called via submit or F3)
      IF ( l_slset NE sy-slset ) OR
         ( s_comw[] IS NOT INITIAL AND gt_clsd_comw[] IS INITIAL ).
        l_slset = sy-slset.
        gv_class_old = dy_class.
        gv_klart_old = dy_klart.
        PERFORM copy_selopt_comw_f79 TABLES gt_clsd_comw s_comw.
        PERFORM class_search_init_f77 USING 'EQUI'.
      ENDIF.
    *--- set Icon for classification
      LOOP AT gt_clsd_comw TRANSPORTING NO FIELDS          
                          WHERE atcod > '0'.               
        EXIT.                                              
      ENDLOOP.                                             
      IF sy-subrc IS INITIAL.
        gv_comw_flag = 'X'.
      ELSE.
        CLEAR gv_comw_flag.
      ENDIF.
      PERFORM set_icon_f01 USING gv_comw_flag cl_icon text-cl0 text-cl1.
      CALL METHOD cl_uid_cust=>selection_screen_output.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR variant.
      PERFORM variant_inputhelp_f14 USING variant 'RIEQUI20'.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR dy_parnr.
      PERFORM f4_for_parnr_f76.
    AT SELECTION-SCREEN ON BLOCK clse.
      IF dy_class NE gv_class_old
        OR dy_klart NE gv_klart_old.
        gv_class_old = dy_class.
        gv_klart_old = dy_klart.
        CLEAR gv_comw_flag.
        REFRESH gt_clsd_comw.
        REFRESH s_comw.
      ENDIF.
      PERFORM class_exist_f77 USING dy_klart dy_class 'DY_CLASS'.
      IF sy-ucomm = 'COMW'.
        CALL FUNCTION 'IHCLSD_VALUATION_POPUP'
          EXPORTING
            i_klart               = dy_klart
            i_class               = dy_class
            i_language            = sy-langu
            i_key_date            = sy-datum
            i_also_subclasses     = dy_subcl
          TABLES
            ct_comw               = gt_clsd_comw
          EXCEPTIONS
            exc_no_class          = 1
            exc_klart_not_allowed = 2.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    *--- fill classification data in select option
        PERFORM copy_comw_selopt_f79 TABLES gt_clsd_comw s_comw.
      ENDIF.
      IF sy-ucomm = 'ONLI'.
        sscrfields-ucomm = sy-ucomm.
      ENDIF.
    Regards
    s@k
    Edited by: siemens.a.k on Jan 15, 2010 10:10 AM

  • I want to add one Continuous function in Producer consumer event??

    Hello,
    producer consumer event vi is base example for me ,I have design my system according to it.
    Now I am dealing with photo sensor in that its measure continuous data according to intensity of light,for continuous function I have make while structure for photo sensor but the problem is that I don't know how to add this while loop in producer consumer event ,if I add then its run continuously and then my operation is stuck there.
    Will you please guide me that how can I add this continuous function in this structure so simultaneously I can do other function like pause reset..Etc...
    Here in attachment I have attaché one example regarding to this in that I have add simply increment function in case structure and when I execute my vi then execution is stuck at while loop until it manually stop.
    Thank you very much...
    Attachments:
    ProducerConsumerEvents 1.vi ‏15 KB

    Hi AnkitRamani,
    I made a simple example with a UI queue and a second producer which is pushing data into its own consumer, displaying the signal and its spectrum.
    Maybe this is what u need.
    Marco Brauner NIG
    Attachments:
    ProducerConsumerEventsData.vi ‏70 KB

  • Can not add function to pages-document created with Applescript

    If I create new document using the GUI (New document) I can place the cursor within any table-cell, type "=" (equal sign) and f.e. "2+2" which will result in a cell showing a "4".
    If I create a document with Applescript, I can not add new functions (neither by typing = nor by using Insert >> Function (may be different, I have German version here). Already existing functions (which already were in the template) can still be used and work as expected but can not be altered.
    Any idea?
    I use Pages '08, Version 3.03
    Code I used to create the document:
    tell application "Pages"
    launch
    make new document at front with properties {template name:templateName}
    # Angebotsnummer ins Dokument schreiben
    tell body text of front document
    make new paragraph at after paragraph 1 with data angebotsNr
    set paragraph style of paragraph 2 to "Überschrift"
    end tell
    # Datei abspeichern
    set dateiName to missing value
    repeat until dateiName is not equal to missing value
    set dateiName to text returned of (display dialog "Datei Name:" default answer angebotsNr & "_" & kundenName) as text
    end repeat
    save front document in angebotsOrdner & dateiName
    end tell

    I apologize but the given script can't run.
    The variable templateName is undefined.
    The variable angebotsNr is undefined too.
    About the described behavior, it's a bug which I never discover before.
    It's always striking in Pages '09.
    Here is the report which I filed :
    Bug ID# 8704270
    Summary:
    +Odd behavior of tables in Pages documents created by a script+
    +Steps to Reproduce:+
    +Run this huge script+
    +tell application "Pages"+
    +make new document at front with properties {template name:"Blank"} (* "Vierge" on French systems *)+
    +end tell+
    +Insert a table+
    +try to insert a formula+
    +Expected Results:+
    +I assumed that I will get the formula editor which I get when the document is created by hand+
    +Actual Results:+
    +There is no way to get the editor, no way to insert the equal character.+
    +This odd behavior strike in all versions of Pages '09 and Pages '08+
    Regression:
    +None to my knowledge+
    Yvan KOENIG (VALLAURIS, France) dimanche 28 novembre 2010 11:30:29

  • Can you add items to your iPad from your iTunes library through home sharing?

    Sorry I'm a novice to this.
    Say I have a video in my iTunes library and I would like to add it to my iPad so I can watch it when I'm not at home without hooking the iPad up to my PC and syncing.
    Can I do this through home sharing?
    Thanks

    Sorry, I miss-typed in my previous post. I meant to say you can't use homesharing to transfer content. (dictation got it wrong, but I should have checked). In order to transfer content from your iTunes library to your iPad, you would need to connect it to your computer via USB or Wi-Fi if you have Wi-Fi syncing enabled.
    To enable Wi-Fi syncing you must first connect your iPad to your computer with the USB cable and then turn Wi-Fi syncing on in the settings within iTunes.

Maybe you are looking for

  • IDoc nos and SD doc no / item no tables

    Hello Experts ! I need to do some BW sales reporting. To get to those fields, I need to access EDIDC table. But it only gives iDoc info. How do I get to sales document (header and item) level details from iDOC nos. Please give me name of tables, I ne

  • Get component closest to point x, y

    Here is a fun one... I have a JPanel with various Components in it that are layed out manually (ie.. null layout). When the user clicks in this JPanel I would like to know which of these Components is closest to the point where the user clicked. Does

  • Cisco Security Manager Appliance bundle

    I have a customer subscribed to the Security ELA, so all security related licenses and subscriptions are free.  It is possible to order this product as an appliance without the bundled licenses?

  • Formatting Variable into Currency Format INSIDE script

    Hello,  I was wondering if someone could give me insight on why I'm running into some problems. So, in my script, I'm trying to display my [decimal]$Variable into currency format ( $x.xx )  By looking around online, I found two different ways; "{0:C2

  • Airport utility base station indicator conflict

    After upgrading firmware to 7.6, I'm having an odd issue with the Airport Utility.  I have a dual base-station setup, connected together via twisted pair so that the second unit is in bridge mode.  It has been working well for over a year. From the e