AS3: DisplayList and EventListeners

I was wondering if there's a way to monitor the DisplayList
so that you can see when items get removed/Garbage Collected.
And is there a way to monitor EventListeners so that you can
see if you're effectively removing them when they're no longer
needed?
Thanks...
Brenda

you can monitor the display list but that doesn't make much
sense in the present context: if you want something gc'd, it must
be removed from the displaylist. you surely won't detect something
being gc'd by monitoring the displaylist.
in general, you must know to what displayobjectcontainer you
added your display object or you can't remove it. and if you know
that, you must use removeChild() or removeChildAt() to remove it.
you could check the numChildren property of your
displayobjectcontainer, but that would be a pretty crude way to
determine if a particular object has been removed from that
displayobjectcontainer.

Similar Messages

  • I need to make a task with less as3 code and more timeline structure and event dispatcher !

    I went to an interview in a big company. I had to make a  task in which there is a wall with 3 lines and 5 columns filled with bombs.When you click on a bomb the bomb changes its scale, a robot enters, goes under the bomb and takes it, then goes to a smaller wall, makes the bomb smaller and place it at the same place it had been in the previous wall.I made the task with tween througout as3 code.The interviewer told me it was good but i need to make it with the less code possible and with more complex timeline structure and to use event dispatcher.What is the best way to do this ?

    The immediate thing that comes to mind is they might want to see that you can balance work between design teams and development teams.
    To do that, the robots movements (pick up bomb, bomb grows/shrinks, arms/treads/legs moving, sequences of 'doing things') can be timeline based so animators can work on those separate from code.
    Developers would be working on the logic of keeping score, moving the robot around to the correct spot with path detection, collision detection, etc.
    It's very similar to thinking in simple factories (which Flash is good at being automatically with timelines), and a bit of MVC (or just VC in some cases).
    Big companies have lots of different types of employees so you'll probably be very specific in your role so you're efficient.

  • Dynamic Photo Gallery in Flash using AS3.0 and XML, but it doesn't work and missed up my app.

    Hi,
    I am creating an iPad app using AS3. The app contains three sections.
    One of those sections (chocolate sources)contains Dynamic Photo Gallery using XML. The photos, thumbnails, and text in this section are loaded from XML.
    I faced may issue when I tried to run this app:
    The gallery photos didn't show up
    The thumbnails (buttons to navigate the photo gallery) didn't show up at all. (The thumbnails should show up under the photo gallery box.)
    The text doesn't show up (the text should be in every photo as describtion)
    I want to include Swipe in the photo gallery, how can I do that?
    When I click on "Chocolate Sources" button, the photo gallery appears in every section, here are print screens describe what I mean:
    The photo gallery covers the home screen too.
    Here is my XML:
    <?xml version="1.0" encoding="utf-8"?>
    <sources>
              <section>
                        <details>
                                            Cocoa tree exists in the tropics area, such as Central and South America.
                                  </details>
                                            <image>
                                                      <url>coca1.jpg</url>
                                                      </image>
                                                      </section>
              <section>
                        <details>
                        Cocoa is supplied in many countries such as Indonesia, Ghana, Brazil, Ecuador and Cameroon.
                        </details>
                                  <image>
                                  <url>coca2.jpg</url>
                                  </image>
                                            </section>
              <section>
                                  <details>
                                  Dark chocolate helps to relax and reduce the stress and blood pressure because it has antioxidants elements, which helps in vasodilatory process.
                                  </details>
                                            <image>
                                            <url>coca3.jpg</url>
                                                      </image>
                                                                </section>
              <section>
                        <details>
                        Chocolate provides energy and hyperactive sometimes because it contains high level of caffeine and sugar.
                        </details>
                                  <image>
                                  <url>coca4.jpg</url>
                                            </image>
                                                      </section>
              <section>
                        <details>
                        Chocolate could be mixed with many different flavors, such as mint, strawberry, orange, banana, vanilla, hazelnut, almond, coconut, and etc.
                        </details>
                                  <image>
                                  <url>coca5.jpg</url>
                                  </image>
                                            </section>
              <section>
                        <details>
                                  Chocolate is expressing of well hospitality and good time due to its lovely taste.
                                  </details>
                                            <image>
                                            <url>coca6.jpg</url>
                                                      </image>
                                                                </section>
    </sources>
    And here is my Action Script for "Chocolate Sources" section:
    stop();
    function Choco1(evt:MouseEvent): void {
              gotoAndStop('16');
    choco_btn.addEventListener(MouseEvent.CLICK,Choco1);
    function Souc1 (evt:MouseEvent): void {
              gotoAndStop ('31');
    souc_btn.addEventListener(MouseEvent.CLICK,Souc1);
    function ShopIn1 (evt:MouseEvent):void {
              gotoAndStop('46');
    shops_btn.addEventListener(MouseEvent.CLICK,ShopIn1);
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.display.MovieClip;
    import flash.display.Loader;
    import fl.motion.MotionEvent;
    import flash.events.MouseEvent;
    import flash.sampler.NewObjectSample;
    import flash.text.TextFormat;
    var xmlLoader: URLLoader = new URLLoader (new URLRequest("sources.xml"));
    xmlLoader.addEventListener(Event.COMPLETE, finishedXmlLoader);
    var xmlFile:XML;
    var xextend:int = 10;
    var gal:galary = new galary ();
              gal.x = 85;
              gal.y = 165;
              addChild(gal);
    var txfe: TextField = new TextField ();
    txfe.x = 25;
    txfe.y = 45;
    var tformat:TextFormat = new TextFormat ();
    tformat.bold = true;
    tformat.color = 0xFFFFFF;
    tformat.size = "18";
    tformat.font = "Arial";
    txfe.defaultTextFormat = tformat;
    addChild(txfe);
    function finishedXmlLoader (e:Event): void{
              xmlFile = new XML (xmlLoader.data);
              var leng:int = xmlFile.image.length();
              txfe.text = xmlFile.image.details[0];
              for (var i:int = 0;i<leng;i++){
                        var b:thumbs = new thumbs ();
                        b.x = xextend;
                        b.y = 480;
                        b.buttonMode = true;
                        b.details = (i+1).toString();
                        addChild(b);
                        b.addEventListener(MouseEvent.MOUSE_OVER, theMosover);
                        b.addEventListener(MouseEvent.MOUSE_OUT, theMosout);
                        b.addEventListener(MouseEvent.CLICK, onMosClick);
                        var bloader:Loader = new Loader();
                        bloader.load(new URLRequest("thumbs/" + (i+1) + ".jpg"));
                        b.addChild(bloader);
                        xextend += b.width + 50;
    var loader:Loader = new Loader ();
    loader.load(new URLRequest ("pictures/coca1.jpg"));
    gal.addChild(loader);
    function theMosover(m:MotionEvent):void{
              m.currentTarget.alpha = 0.5;
    function theMosout (m:MouseEvent):void{
              m.currentTarget.alpha = 1.0;
    function onMosClick(m:MouseEvent):void{
              var loader:Loader = new Loader();
              loader.load(new URLRequest("pictures/" + m.currentTarget.details + ".jpg"));
              gal.addChild(loader);
              txfe.text = xmlFile.image.details[int(m.currentTarget.details) -1];
    I need an urgent help to fix the errors and make this section work well.
    thanks.

    try:
    txfe.text = xmlFile.section[int(m.currentTarget.details) -1].details;
    instead of
    txfe.text = xmlFile.image.[int(m.currentTarget.details) -1];
    and add your thumbs to gal, not the stage.  when you're done with the gallery, remove gal.

  • GetImageReference and eventListeners

    Hi,
    Through a textField you can access images (or it's Loader
    object) with
    getImageReference( imgId ). This works fine.
    Now I want to add eventListeners to the Loader to detect
    mouseClicks on
    the images. But somehow that part won't work.
    Code from a quick test:
    In a function which loads the XML I have these lines:
    var img:Loader = Loader( html_txt.getImageReference( "img_0"
    img.contentLoaderInfo.addEventListener( Event.COMPLETE,
    loadedImage );
    the eventListeners are:
    function clickImage( evt:MouseEvent ):void
    trace( evt.target );
    function loadedImage( evt:Event ):void
    trace( evt.target.content, "is loaded" )
    var li:LoaderInfo = LoaderInfo( evt.target );
    li.content.addEventListener( MouseEvent.CLICK, clickImage );
    li.loader.addEventListener( MouseEvent.CLICK, clickImage );
    Al this traces:
    [object Bitmap] is loaded
    If I click on tha image in the textField however, nothing
    happens... Now
    I could go with the textField, have it listen to mouseEvents,
    get the
    bounds of all the images in it and see over which the mouse
    is at that
    moment, but that seems rather silly if I could get each image
    to
    register it's own listeners.
    Anybody?
    Thanks in advance.
    Manno
    Manno Bult
    http://www.aloft.nl

    Hi kglad and others,
    well, it works, but not as intended (at least, not my
    intention ;) ).
    addChild( img ); adds the image to the root (or parent of the
    textField) thereby removing it, like documentation states, from the
    textField itself. Ok, it becomes clickable, but not as part of the
    content of the textField.
    You cant issue addChild() on the textField in anyway so that
    won't work.
    Has anyone been able to do sort of the same thing as I'm
    trying now?
    Below is some simplified code working on this XML:
    <?xml version="1.0" encoding="utf-8"?>
    <rootnode>
    <p>Lorem ipsum... </p>
    <img src="plaatje.jpg" id="img_0" />
    <p>Donec malesuada, arcu eget tristique convallis...
    </p>
    </rootnode>
    Thanks,
    Manno

  • How to call webservices in as3 (flash) and get its response

    Hello
        I need to know how to call webservices in flash cs5 as3 and how to track its response. any example ?
    Thanks
    Avneet

    http://www.thetechlabs.com/tech-tutorials/xml/creating-a-as3-web-service-package-base-serv ice-class-and-simple-twitter-api/

  • AS3 Buttons and textfields

    Hi,
    I coming from an AS2 environment and trying to get my head around AS3.
    I have a dynamic Textfield on stage (instance name tfval)
    a movieclip named mcPlan, this contains a btn called s4
    but I cannot get the following to work:
    import flash.text.TextField;
    var tfval:String="Start";
    root.mcPlan.s4.addEventListener(MouseEvent.MOUSE_OVER,onOver);
    root.mcPlan.s4.addEventListener(MouseEvent.MOUSE_OUT,onOut);
    function onHover(event:MouseEvent):void{
    trace("dsds");
    root.tfval.text="Test From onOver";
    function onOut(event:MouseEvent):void{
    root.tfval.text="Test From onOut";
    Any help is apreciated!
    Thanks!

    aren't you seeing an error message about the lack of an onOver() function?  are you seeing any other error messages?

  • AS3 loadVars and arrays

    I have a text file with variables and an swf that a friend made for me. Unfortunately i dont have the .fla file and i am trying to recreate it.
    the file contains 3 variables with values, repeated 4 times and a final variable (called varDone) that tells it there are no more variables.
    The three variables are varImage, varURL, varText. These are used to load images that can be clicked to open a website and they have a textfield above them.
    The flash is a banner that we use on our site to display these images. Somehow, he reads the first set of variables into a movieclip i believe, where the image then fades in and stays on screen for 3 more seconds and then goes onto the next image. He keeps reading variables from the file until he hits that varDone=1 variable, then the banner starts all over. The file is such that I can add as many sets of variables as i want, and it will display all of them, it could be 3 or 10 or 30, as long as i add a new set of (varImage, varURL, varText) to the file ahead of the varDone variable. I thought maybe he might be loading those 3 variables into a two dimensional array and then processing them that way. This is the part I don't know how to do, how to read each set of variables, until i get to the varDone=1. I can do all the other stuff, I just don't know how to read this file.
    It looks like the following:
    &varImage=http://www.mofc-gaming.com/themes/CT_RN_GREYSCALE/images/spotlight1.jpg
    &varHeadline=RECRUITING BAD COMPANY 2 MEMBERS
    &varLink=http://badcompany2.ea.com/#/home
    &varImage=http://www.mofc-gaming.com/themes/CT_RN_GREYSCALE/images/spotlight2.jpg
    &varHeadline=Join MOFC in EVE Online
    &varLink=http://www.eveonline.com
    &varDone=1

    XML is what you want.  You would get a 1D array (not 2D - no need for 2D at all).  An xml file like this would suffice:
    <Pics>
         <image url="www.image1.jpg"> Text to display along with Image could go here.</image>
         <image url="www.image1.jpg"> Text to display along with Image could go here.</image>
         <image url="www.image1.jpg"> Text to display along with Image could go here.</image>
    </Pics>
    Then in Flash, you load the xml file and the resulting XML object you get can be parsed liek this:
    _xmlObject.image;   <-returns an XMLList of all 'image' nodes in the xml document.
    _xmlObject.image[0];      <-returns the first XML Object found in the XMLList described above.  When treated as a String it will output "Text to display along with Image could go here."
    _xmlObject.image.@url[0]    <- returns the string "www.image1.jpg"
    This will teach you everything you need to know: http://www.kirupa.com/developer/flashcs3/using_xml_as3_pg1.htm
    Hope this helps.  For AS3 nothing beats XML for loading dynamic data.

  • AS3 arrays and conditionals not working

    I'm working with CS4 and AS3 using timeline coding. I have three sets of movie clips in three different arrays. The idea is to have topArray and downArray movies make zeroArray movies visible. For instance, if topArray[0] and downArray[0] are clicked, then r0_0 becomes visible. PROBLEM: r0_0 becomes visible when EITHER topArray or downArray is clicked. How to make r0_0 wait until BOTH top and downArray movies are clicked?
    //movie clips holdings results -- all invisible
    var zeroRow:Array =[r0_0, r0_1, r0_2, r0_3, r0_4, r0_5, r0_6, r0_7, r0_8, r0_9, r0_10];
    for (var a:int=0; a<zeroRow.length; a++) {zeroRow[a].visible=false}
    //two sets of movie clips -- which will be multiplied
    var topArray:Array = [hor_0, hor_1, hor_2, hor_3, hor_4, hor_5, hor_6, hor_7, hor_8, hor_9, hor_10];
    var downArray:Array = [vert_0, vert_1, vert_2, vert_3, vert_4, vert_5, vert_6, vert_7, vert_8, vert_9, vert_10];
    for(var p:int = 0; p<topArray.length; p++){
    topArray[p].addEventListener(MouseEvent.CLICK, showResults);
    topArray[p].buttonMode=true;
    for(var q:int = 0; q<downArray.length; q++) {
    downArray[q].addEventListener(MouseEvent.CLICK, showResults); 
    downArray[q].buttonMode=true;
    function showResults(event:MouseEvent): void{
    if (downArray[0]&& topArray[0]) {r0_0.visible=true};
    }// function
    Sincerely,
    German

    kglad:
    Thansk for replying. No, movie clips don't get unclicked when clicked. I didn't think of that!
    I've been working on how to make the following code work, but I can get only the first zeroRow movie made visible=true; Can you please look at it and point me to the right direction?
    please keep in mind that topArray and downArray are movie clips that are clicked to make zeroRow movies visible.
    for (var p:int = 0; p<topArray.length; p++) {
        topArray[p].addEventListener(MouseEvent.CLICK, showResults);
        topArray[p].buttonMode = true;
        topArray[p].clicked = false;
    for (var q:int = 0; q<downArray.length; q++) {
        downArray[q].addEventListener(MouseEvent.CLICK, showResults);
        downArray[q].buttonMode = true;
        downArray[q].clicked = false;
    function showResults(event:MouseEvent):void {
        var clickedItem:MovieClip = MovieClip(event.currentTarget);
        var showedMovie:MovieClip= MovieClip(event.currentTarget);
        clickedItem.clicked = true;
        var clickedIndex:int = 0;
        var showedMovieIndex:int =0;
        if(topArray.indexOf(clickedItem) != -1) {
            clickedIndex = topArray.indexOf(clickedItem);
            if(downArray[clickedIndex].clicked == true) {
        zeroRow[showedMovieIndex].visible=true;
        } else if(downArray.indexOf(clickedItem) != -1) {
            clickedIndex = downArray.indexOf(clickedItem);
            if(topArray[clickedIndex].clicked == true) {
        zeroRow[showedMovieIndex]== true;
    }// function
    Sincerely,
    German

  • AS3 centering and resizing a background in existing code

    I have a code for a page I am using and I would like to add a background and have it resize with the screen like the rest of the page.  I have created a movie button named "pic" with the image in it but I don't know how to write the code and place it in the existing AS3 code file.  Could someone please help.  I am brand new to this so if someone could tell me how to place the code like i was in 3rd grade, that would be great. Here is the existing code.
    package com.modules
    import flash.display.*;
    import flash.events.*;
    import flash.net.*;
    import flash.text.*;
    import caurina.transitions.Tweener;
    import com.utils.*;
        public class About extends Sprite
    private var content_height:int;
    private var content_width:int;
    private var marginTop:int;
    private var marginBottom:int;
    private var content_y:int;
    private var _content:Content;
    private var news:News;
    private var array:Array;
    private var pan:Panning;
       public function About()
    // listen for when this is added to stage
    this.addEventListener(Event.ADDED_TO_STAGE, ini); 
    // listen for when this is removed from stage
    this.addEventListener(Event.REMOVED_FROM_STAGE, remove);
    private function ini(e:Event)
    stage.addEventListener(Event.ADDED, onStageResize);
    stage.addEventListener(Event.RESIZE, onStageResize);
    content_y = int(GlobalVarContainer.vars.CONTENT_Y);
    _content = new Content;
    addChild(_content);
    _content.visible=false;
    // load xml
    if((GlobalVarContainer.vars.XML_PATH!="") && (GlobalVarContainer.vars.XML_PATH!=undefined))
    var loadXml:LoadXml;
    loadXml = new LoadXml(GlobalVarContainer.vars.XML_PATH);
    loadXml.addEventListener(Event.COMPLETE, onXmlComplete);
    private function onXmlComplete(e:Event)
    // set up content
    content_width = e.target.returnData.attribute("width");
    marginTop = e.target.returnData.attribute("marginTop");
    marginBottom = e.target.returnData.attribute("marginBottom");
    var backgroundColor = e.target.returnData.attribute("backgroundColor");
    Tweener.addTween(_content.bg, {_color:backgroundColor, time:.1, transition:"linear"});
    _content.bg.width = content_width;
    _content.masc.area.width = (content_width -_content.masc.x)-20;
    _content.holder.txt.width = _content.masc.area.width -10;
    // write text
    _content.holder.txt.mouseWheelEnabled = false;
    _content.holder.txt.styleSheet = GlobalVarContainer.vars.CSS;
    _content.holder.txt.condenseWhite = true;
    _content.holder.txt.htmlText = e.target.returnData;
    _content.holder.txt.autoSize = TextFieldAutoSize.LEFT;
    onStageResize();
    _content.visible=true;
    // create new Panning instance;
    pan = new Panning(_content.holder, _content.masc, _content.bg, 4, true);
    pan.addEventListener(Event.ADDED, scInit);
    addChild(pan);
    // Initialize panning
    function scInit(e:Event):void
    pan.init();
    // resize contents
    private function onStageResize(e:Event = null):void
    resizeContent((stage.stageHeight - ((content_y + marginTop) + int(GlobalVarContainer.vars.BOTTOM_SHAPE_H)))-marginBottom);
    private function resizeContent(height_:int):void
    content_height = height_;
    _content.bg.height = content_height;
    _content.masc.area.height = (content_height -_content.masc.y)-20;
    _content.holder.mask = _content.masc;
    Tweener.addTween(_content, {x: Math.round(stage.stageWidth/2 - _content.width/2) , time:.5, transition:"linear"});
    _content.y=content_y+ marginTop;
    // used to change colors. here we not use
    public function changeTheme():void
    // remove listeners, images and unload panning;
    function remove(event: Event) : void
    pan.unload();
    stage.removeEventListener(Event.ADDED, onStageResize);
    stage.removeEventListener(Event.RESIZE, onStageResize);
    this.removeEventListener(Event.ADDED_TO_STAGE, ini); 
    this.removeEventListener(Event.REMOVED_FROM_STAGE, remove);
    trace("remove about");

    I just wanted to say that the above code works fine, I just need to add the resizing background code to it. Please help.  thanks

  • Help Converting AS2 to AS3 Drag and Drop Event

    Hi All,
    This is the second post on help for converting AS2 to AS3. This code is used in Captivate to allow a drag and drop action between two areas (User presses down, drags, and releases in a second area - They are not dragging any object). If anyone can help me convert this please let me know.
    Source for Drag and Drop: (Note: Single MovieClip)
    // pause the Captivate movie
    _root.rdcmndPause = 1;
    // when the user's mouse is let go check if there was a successful drop
    _root.onMouseUp = function(){
              // If the source area's center coordinate is nearby the destination area's center coordinate then advance the slide
              if ( Math.abs(_root.sourceX + _root.sourceWidth  / 2 + _root.sourceParentX - (_root.destX + _root.destWidth  / 2)) < (_root.destWidth  / 2) &&
                         Math.abs(_root.sourceY + _root.sourceHeight / 2 + _root.sourceParentY - (_root.destY + _root.destHeight / 2)) < (_root.destHeight / 2) )
                        _root.rdcmndNextSlide = 1;
              } else {
                        // show error movie clip for 2 seconds (60 frames at 30 frames per second)
                        _root.showErrorMessage = 60;
      mc.onEnterFrame = function(){
              // continuously update the source area's coordinates and size
              _root.sourceX = mc._x;
              _root.sourceY = mc._y;
              _root.sourceWidth = mc._width;
              _root.sourceHeight = mc._height;
              _root.sourceParentX = _parent._x;
              _root.sourceParentY = _parent._y;
    mc.onPress = function(){
              // Uncomment following line to have control click capabilities
              //if(key.isDown(Key.CONTROL))
              // when user clicks on the source area click start the drag
                        startDrag(this);
    mc.onRelease = function(){
              // stop drag when user releases the source area
              stopDrag();
    Source for Destination Area (Single MovieClip named destArea)
    // Set a root variable to control when the error message is displayed
    _root.showErrorMessage = -1;
    // Use setCoords variable so we only set the destination coordinates once
    var setCoords = 0;
    destArea.onEnterFrame = function(){
              if (setCoords == 0){
                        // set the destination x, y, width, and height
                        _root.destX = _parent._x;
                        _root.destY = _parent._y;
                        _root.destWidth = _parent._width;
                        _root.destHeight = _parent._height;
              // destination coordinates have been set, change setCoords so it doesn't get set again
              setCoords = 1;
    Code for the Error Message (Single MovieClip named errorMessage)
    // Don't display the error message initially
    errorMessage._alpha = 0;
    errorMessage.onEnterFrame = function (){
              // If the drag and drop method detects a missed drop
              // then show this error message by setting _alpha to 100
              if (_root.showErrorMessage > 0){
                        errorMessage._alpha = 100;
                        // decrementing this variable controls the time the
                        // error message will be displayed
                        _root.showErrorMessage--;
              } else {
                        // Don't display the error message
                        errorMessage._alpha = 0;

    use:
    MovieClip(parent.parent.parent).rdcmndPause=1;
    this.addEventListener(KeyboardEvent.KEY_DOWN,keydownF);
    function keydownF(e:KeyboardEvent):void{
    fscommand("KEYPRESSED", e.keyCode);
    if(e.keyCode==32){
    MovieClip(parent.parent.parent).rdcmndNextSlide=1;

  • AS3 images and colors

    I need some help with AS3. I got my color pickers working to change the image and background color. So everything is working like i want it for one image. I have about 10 images i need to be able to choose from. I want to be able to select an image from a drop down or something and that image replaces the image in the box. any help is much  appriciated.

    not sure what i'm doing with the loader, i went throught the tutorial and got it to work in the tutorial, but i don't know how i would incorporate that function to work with my script. i appriciate all your help.
    here is my script on the (turtle image layer).
    // theimage is a display object on the Stage.
    // blueBtn, redBtn, greenBtn, and blackBtn are buttons on the Stage.
    import flash.events.MouseEvent;
    import flash.geom.ColorTransform;
    // Get access to the ColorTransform instance associated with theimage.
    var colorInfo:ColorTransform = theimage.transform.colorTransform;
    // This function is called when blueBtn is clicked.
    function makeBlue(event:MouseEvent):void
        // Set the color of the ColorTransform object.
        colorInfo.color = 0x003399;
        // apply the change to the display object
        theimage.transform.colorTransform = colorInfo;
    blueBtn.addEventListener(MouseEvent.CLICK, makeBlue);
    blueBtn.addEventListener(MouseEvent.MOUSE_OVER, makeBlue);
    // This function is called when redBtn is clicked.
    function makeRed(event:MouseEvent):void
        // Set the color of the ColorTransform object.
        colorInfo.color = 0xFF0000;
        // apply the change to the display object
        theimage.transform.colorTransform = colorInfo;
    redBtn.addEventListener(MouseEvent.CLICK, makeRed);
    redBtn.addEventListener(MouseEvent.MOUSE_OVER, makeRed);
    // This function is called when greenBtn is clicked.
    function makeGreen(event:MouseEvent):void
        // Set the color of the ColorTransform object.
        colorInfo.color = 0x00CC00;
        // apply the change to the display object
        theimage.transform.colorTransform = colorInfo;
    greenBtn.addEventListener(MouseEvent.CLICK, makeGreen);
    greenBtn.addEventListener(MouseEvent.MOUSE_OVER, makeGreen);
    // This function is called when blackBtn is clicked.
    function makeBlack(event:MouseEvent):void
        // Set the color of the ColorTransform object.
        colorInfo.color = 0x000000;
        // apply the change to the display object
        theimage.transform.colorTransform = colorInfo;
    blackBtn.addEventListener(MouseEvent.CLICK, makeBlack);
    blackBtn.addEventListener(MouseEvent.MOUSE_OVER, makeBlack);

  • JAVA Events like AS3 dispatchEvent and addEventListener

    I've developed flash based content for years and have got into JAVA now. I've written a few programs now, but there is a feature of as3 I'd like to be able to use in JAVA. That feature is adding, removing, and dispatching Events.
    For example, in flash I could do this:
    public class example1 extends MovieClip {
    public example1() {
    public fireEvent() {
    this.dispatchEvent(new Event("somethingSpecialGoesHere"));
    Then I could call the class and listen for an event from a parent class like this:
    public class parentClass extends MovieClip {
    public parentClass():void {
    var tester:example1 = new example1();
    tester.addEventListener("somethingSpecialGoesHere", eventFunctionToFire);
    private eventFunctionToFire(evt:Event):void {
    trace("Event Fired");
    How can I apply this into java programs? Where say I have a parent class - Launcher, which instanciates the child class xmlRead. I want to add an event listener to the instanciated child in Launcher, and then dispatch the event from within the child xmlRead.
    How can I go about this? Any ideas? Thanks.

    I don't know Flash nor AS3, but an epdermic reaction is that you should study a technology, especially an established one, for what it's worth, and how it's generally used, and not necessarily try to force one language's idiom into another language.
    That being said I understand that it's easier t learn from something you're already familiar with. The closest to what you describe in terms of event listening, is described here. Such a event-generator idiom is explicitly supported only by a small number of built-in classes (especially, GUI classes), but can be implemented [fairly easily|http://www.artima.com/designtechniques/eventgen.html] in custom classes as well.

  • AS3 Flashvars and getURL urgent help

    I have never used flashVars, even in AS2, but the project I'm working on  requires that I use since my client is going to use dynamic urls  defined as expressions and he wants to have control without having to  edit a fla file. I have read a lot of tutorials and can't seem to come  up with a solution. Basically what I want is to load my Flashvars  defined in swfObject, each one holding an expression, for example:
    <script type="text/javascript">
                var flashvars = {
                 rutaMEX:"mainContainer.aspx?Country=pkbE5eknzMLhWZ5x+K3/tA=="
                var params = {};
                params.menu = "false";
                params.quality = "high";
                params.scale = "noscale"
                params.wmode = "transparent";
                params.seamlesstabbing = "true";
                params.allowfullscreen = "true";
                var attributes = {};
                attributes.id = "main";
                attributes.name = "main";
                swfobject.embedSWF("swf/landing.swf", "altContent", "100%", "100%", "10.0.2", "Scripts/expressInstall.swf", flashvars, params, attributes);
            </script>
    Right now, I have just one value pair, but I will add them as they  become available. I have 11 movieclip buttons which will take you to a  url defined by it's corresponding flashvar. If I was doing this is AS2, I  would just add this action to the button:
    button0.onRelease = function() {
        getURL(rutaMEX);, "");
    How will I accomplish the same thing in as3? I know you have to get  flashVars using .loaderInfo but that as far as i got.
    Any help will be greatly appreciated

    Redeclaring the click handler function in each loop through buttons is not necessary, you'd better do it like this, with click handler outside the loop:
    for (var i:Number=0; i<11; i++)
        menu_mc["button" +  i].addEventListener(MouseEvent.CLICK, clickHandler);
    And the second thing - click handler. For more flashvars (or if you don't know how many flashvars will be used) you can loop throug loaderInfo.parameters object with for-in loop. The problem here is that order in for-in loop is rather random ("not guaranteed" as they nicely call it :-) ), so it complicates assigning the urls to particular buttons. I would connect here name of a flashvar (this declared in HTML) with a button:
    function clickHandler(evt:MouseEvent):void
         for (var par:* in loaderInfo.parameters)
             if (evt.target.name == par) // checks if instance name of the clicked button is equal to the current flashvar, here par is NAME of the flashvar, NOT VALUE
                   var request:URLRequest = new URLRequest(loaderInfo.parameters[par]); // when the name of flashvar = name of button, the VALUE of this flashvar is retrieved in URLRequest constructor
                     navigateToURL(request,"_blank");

  • AS3 Masks and Transparency

    Hey one and all. Looking for a little insight on AS3 and its
    masks. I have a clip that I have applied a mask to. This mask is a
    gradient mask (linear - white 0%, black 100%, white 0%). I've set
    cacheAsBitmap to true for both the clip and the mask and applied
    the mask in AS3. However, the transparency in the mask isn't there.
    Has anyone had similar issues with AS3 applied masks and how do I
    go about getting this resolved?

    I see what you're saying chadder but I have another issue in
    my case. Let me explain.
    I'm masking an image reel here. The reel contains two things
    the moving reel and the mask. so..
    imgreel
    *imagereel
    *imagemask
    The imagereel is dropping in x number of loader instances
    (per image loaded). When I applied your technique, nothing
    occurred. I'd imagine because imagereel is updating the display
    after each load but I'm not 100% sure of that. Any idea what might
    be occuring here?

  • DisplayList and switching it all up or Z or what

    Yes or No
    addChild(a);
    a.addChild(square);
    a.addChild(circle);
    addChild(b);
    Is there a way to change the displaylist where
    a.square is 0
    b is 1
    a.circle is 2
    All the displaylist changing stuff seems like I can only affect either
    a and b
    or
    a.square and a.circle
    but not put a.square behind b and a.circle infront of b...
    Know what I mean?? sry im bad at forums -.-
    Do I have to do it all differently? I tried changing the z's and that don't work either!
    thx.

    So if I want to have 20 moons orbiting the Earth...
    I can't have 1 moons class and 1 earth class
    I will need 1 moon class and 1 earth class and use the moon class 20 times
    Cause there's no way to make some in front and some behind it's an all or nothing per class? damnnn i hate starting over

Maybe you are looking for

  • Duplex printing option no longer avaialble in Preview and TextEdit.

    I am no longer offered the option to select two-sided printing for .pdfs in Preview or for text documents in TextEdit when using my HP Officejet K550. The printing options no longer allow me to select Paper Type or Print Quality for these documents e

  • How to display the content of a region on a different page

    Hello, Does anyone knows how to display the content of a region on an other page. I try to make page that displays content that resides somewhere else in my portal, so I can give a summarization of some hot topics. I really want to display the whole

  • SP in delete/insert/modify trigger

    I have created a trigger which sends a notification email on deletes.inserts, or updates on a particular table.  Trigger works great.  While testing, I did a delete all - and sure enough the trigger fired on every row that was deleted and I got over

  • Multiple picture in picture images

    Hi, I am having problems adding a "picture in picture" text graphic to a background loop. The first insert seems to work fine. However any other inserts after the 1st insert do not work. When it gets to the preceeding "picture in picture" inserts, th

  • Crosscheck backup in RMAN - Oracle 9i

    Hi, I have scheduled RMAN backup in oracle 9i and it completed successfully. After backup, if i list backup, its status is available. #list backup by file; Then i ran a crosscheck to crosccheck the backup files and backup sets. #crosscheck backup; Ag