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

Similar Messages

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

  • Using Linkbar objects and EventListeners

    The code:
    Note, I left out most object specific details, like width and
    height etc...
    var pl:Panel = new Panel();
    var lb:LinkBar = new LinkBar();
    lb.addEventListener(MouseEvent.CLICK, httprequestObject);
    var vs:ViewStack = new ViewStack();
    var cv:Canvas = new Canvas();
    cv.label = "navigation button";
    vs.addChild(cv);
    lb.dataProvider = vs;
    pl.addChild(lb);
    this.addChild(pl);
    public function httprequestObject(e:MouseEvent):void{
    Alert.show("success!");
    For whatever reason this doesn't work. Suggestions,
    thoughts.

    Actually here is the complete code incase anyone is
    interested in trying it...
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" creationComplete="init()">
    <mx:Script>
    <![CDATA[
    import mx.containers.Canvas;
    import mx.containers.ViewStack;
    import mx.controls.LinkBar;
    import mx.containers.Panel;
    import mx.controls.Alert;
    public function init():void{
    var pl:Panel = new Panel();
    pl.width = 200;
    pl.height = 200;
    var lb:LinkBar = new LinkBar();
    lb.percentWidth = 100;
    lb.addEventListener(MouseEvent.CLICK, httprequestObject);
    var vs:ViewStack = new ViewStack();
    vs.percentWidth = 100;
    var cv:Canvas = new Canvas();
    cv.percentWidth = 100;
    cv.label = "navigation button";
    pl.addChild(lb);
    lb.dataProvider = vs;
    vs.addChild(cv);
    addChild(pl);
    public function httprequestObject(e:MouseEvent):void{
    Alert.show("success!");
    ]]>
    </mx:Script>
    </mx:Application>

  • Textfield and eventlisteners

    Hi guys, i fee im plauging this forum sometimes, this code lets a user input text and click a button which outputs it to a textfieldand also adds a number to another textfield. Another button removes this text and also subtracts the same number. It all works fine when there is text in the input field but when it is empty and you click the button that adds the text it still adds to the number.
    [AS]
    var textAdd01 : Number;
              textAdd01 = 3;
    LBtextMenu.LBtxtSubmit.addEventListener(MouseEvent.MOUSE_UP, LBtypedChar);
    function LBtypedChar(evt:MouseEvent):void
    LBTxt.LBOutput.text = LBtextMenu.LBInput.text;
    LBtextHotspot.gotoAndStop(2);
    trace (LBTxt.LBOutput.text.length)
    ///----------------------Add Price---------------------------------------
    LBtextMenu.LBtxtSubmit.addEventListener(MouseEvent.MOUSE_UP, LBtxtAddPrice);
    function LBtxtAddPrice(evt:MouseEvent):void
    priceOutput.text = String(textAdd01 + Number(priceOutput.text));
    if (LBTxt.LBOutput.text.length >0){
              LBtextMenu.LBtxtSubmit.removeEventListener(MouseEvent.MOUSE_UP, LBtxtAddPrice);
              LBtextMenu.LBtxtRemove.addEventListener(MouseEvent.MOUSE_UP, LBtxtRemovePrice);
    LBtextMenu.LBtxtRemove.addEventListener(MouseEvent.MOUSE_UP,LBtxtRemoveTxt);
    function LBtxtRemoveTxt(e:MouseEvent)
      LBTxt.LBOutput.text = "";
              LBtextHotspot.gotoAndStop(1);
              LBtextMenu.LBtxtSubmit.addEventListener(MouseEvent.MOUSE_UP, LBtxtAddPrice);
              trace (LBTxt.LBOutput.text.length)
    ///----------------------Remove Price---------------------------------------
    LBtextMenu.LBtxtRemove.addEventListener(MouseEvent.MOUSE_UP, LBtxtRemovePrice);
    function LBtxtRemovePrice(evt:MouseEvent):void
    priceOutput.text = String(Number(priceOutput.text) - textAdd01);
    if (LBTxt.LBOutput.text.length ==0){
              LBtextMenu.LBtxtRemove.removeEventListener(MouseEvent.MOUSE_UP, LBtxtRemovePrice);
    [/AS]
    Thanks for any help in advance.

    Thanks for reply Ned, yes everything is tracing as it should.   "LBtextMenu.LBtxtSubmit"  is the add button which takes the text from the inputfield "LBtextMenu.LBInput.text" outputs to the output field "LBTxt.LBOutput.text" and also adds the number "textAdd01" to "priceOutput.text".
    "LBtextMenu.LBtxtRemove" is the remove button which removes the text from "LBTxt.LBOutput.text" and subtracts "textAdd01" from "priceOutput.text"
    Dont know if that has made it clearer?

  • RMI and EventListeners

    i am creating the desktop sharing gadget via rmi,, every thing is fine apart from it does not respond to key events..i don't understand where i am lacking..
    here's server code.
    public class ServerInterface extends UnicastRemoteObject implements System_Behav {
    private static final long serialVersionUID = 1L;
    public static Robot robo=null;
    public static int height;
    public static int width;
    protected ServerInterface() throws RemoteException {
       super();
    public static void main(String[] args) {
       // TODO Auto-generated method stub
       if(System.getSecurityManager()==null)
       System.setSecurityManager(new RMISecurityManager());
      height=Toolkit.getDefaultToolkit().getScreenSize().height;
      width=Toolkit.getDefaultToolkit().getScreenSize().width;
       try{
       System_Behav system_server=new ServerInterface();
       Registry r=LocateRegistry.createRegistry(1099);
      r.bind("system_server", system_server);
    GraphicsEnvironment g=GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd=g.getDefaultScreenDevice();
      robo=new Robot(gd);
       System.out.println("server bound");
       }catch(Exception e)
       System.err.println("Computeappengine exception"+e.getMessage());
      e.printStackTrace();
    public void MouseMove(int x,int y,int w,int h) throws RemoteException {
       // TODO Auto-generated method stub
      x=x*(height/h);
      y=y*(width/w);
      robo.mouseMove(x, y);
    public void Mousepress(int a) throws RemoteException {
       // TODO Auto-generated method stub
    robo.mousePress(a);
    public void MouseRelease(int a) throws RemoteException {
       // TODO Auto-generated method stub
      robo.mouseRelease(a);
    @Override
    public void KeyPress(int a) throws RemoteException {
      robo.keyPress(a);
    @Override
    public void KeyRelease(int a) throws RemoteException {
       // TODO Auto-generated method stub
      robo.keyRelease(a);
    @Override
    public byte[] getScreen() throws RemoteException {
       Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
       Rectangle rectangle = new Rectangle(dim);
       BufferedImage bi= robo.createScreenCapture(rectangle);
       ByteArrayOutputStream bytes = new ByteArrayOutputStream();
       try {
       ImageIO.write(bi, "PNG", bytes);
       } catch (IOException e) {
       // TODO Auto-generated catch block
      e.printStackTrace();
       return bytes.toByteArray();
    here's client code
    public class ClientInterface{
    private static final long serialVersionUID = 1L;
    public  static JPanel contentPane;
    public static System_Behav sb=null;
    * Launch the application.
    public static void main(String[] args) {
       if(System.getSecurityManager()==null)
       System.setSecurityManager(new RMISecurityManager());
       try{
       String name="rmi://192.168.1.5:1099/system_server";
      sb=(System_Behav)Naming.lookup(name);
       try {
       JFrame frame = new JFrame();  
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setBounds(100, 100, 450, 300);
      contentPane = new JPanel();
      contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
      contentPane.setLayout(new BorderLayout(0, 0));
      frame.setContentPane(contentPane);
      frame.setVisible(true);
       new screen(contentPane,sb);
       new command(contentPane,sb);
       } catch (Exception e) {
      e.printStackTrace();
       }catch(Exception e)
       System.err.println("Computeappengine exception"+e.getMessage());
      e.printStackTrace();
    public ClientInterface() {
    public class command implements KeyListener,
    MouseMotionListener,MouseListener {
    public JPanel cPanel=null;
    public System_Behav system_behav=null;
    //public byte by[];
    public command()
    public command(JPanel j,System_Behav b)
      system_behav=b;
      cPanel=j;
      cPanel.addKeyListener(this);
      cPanel.addMouseListener(this);
      cPanel.addMouseMotionListener(this);
    @Override
    public void mouseClicked(MouseEvent e) {
       // TODO Auto-generated method stub
    @Override
    public void mousePressed(MouseEvent e) {
       // TODO Auto-generated method stub
       int a=e.getButton();
       if (a==3)
      a=4;
       else a=16;
       try {
      system_behav.Mousepress(a);
       } catch (RemoteException e1) {
       // TODO Auto-generated catch block
      e1.printStackTrace();
    @Override
    public void mouseReleased(MouseEvent e) {
       // TODO Auto-generated method stub
       int a=e.getButton();
       //System.out.println(a);
       if (a==3)
      a=4;
       else a=16;
       try {
      system_behav.MouseRelease(a);
       } catch (RemoteException e1) {
       // TODO Auto-generated catch block
      e1.printStackTrace();
    @Override
    public void mouseEntered(MouseEvent e) {
       // TODO Auto-generated method stub
    @Override
    public void mouseExited(MouseEvent e) {
       // TODO Auto-generated method stub
    @Override
    public void mouseDragged(MouseEvent e) {
       // TODO Auto-generated method stub
    @Override
    public void mouseMoved(MouseEvent e) {
       // TODO Auto-generated method stub
       try {
    system_behav.MouseMove(e.getX(),e.getY(),cPanel.getWidth(),cPanel.getHeight());
       } catch (RemoteException e1) {
       // TODO Auto-generated catch block
      e1.printStackTrace();
    @Override
    public void keyTyped(KeyEvent e) {
       // TODO Auto-generated method stub
    @Override
    public void keyPressed(KeyEvent e) {
       // TODO Auto-generated method stub
       try {
      system_behav.KeyRelease(e.getKeyCode());
       } catch (RemoteException e1) {
       // TODO Auto-generated catch block
      e1.printStackTrace();
    @Override
    public void keyReleased(KeyEvent e) {
       // TODO Auto-generated method stub
       try {
      system_behav.KeyPress(e.getKeyCode());
       } catch (RemoteException e1) {
       // TODO Auto-generated catch block
      e1.printStackTrace();
    public class screen extends Thread {
    public JPanel cPanel=null;
    public System_Behav system_behav=null;
    //public byte by[];
    public screen()
    public screen(JPanel j,System_Behav b)
      system_behav=b;
      cPanel=j;
      start();
    public void run()
       byte[] by=null;
       while(true){
    try {
       Thread.sleep(100);
      by=system_behav.getScreen();
    } catch (RemoteException e) {
       // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (InterruptedException e) {
       // TODO Auto-generated catch block
      e.printStackTrace();
    BufferedImage bi=null;
    try {
    bi=ImageIO.read(new ByteArrayInputStream(by));
    } catch (IOException e) {
       // TODO Auto-generated catch block
      e.printStackTrace();
    ImageIcon imageIcon=new ImageIcon(bi);
    Image image = imageIcon.getImage();
    System.out.println(cPanel.getWidth());
    System.out.println(cPanel.getHeight());
    image = image.getScaledInstance(cPanel.getWidth(),cPanel.getHeight()
       ,Image.SCALE_FAST);
    //Draw the recieved screenshot
    Graphics graphics = cPanel.getGraphics();
    graphics.drawImage(image, 0, 0, cPanel.getWidth(),cPanel.getHeight(),cPanel);

    Crossposted and answered at StackOverflow.

  • Tidying up objects and listeners (basic)

    A newbie wannabe-AS3 question. My difficulty is (I think)
    removing unwanted objects and listeners as I move from one mode to
    another in my project ... altho my difficulty behind that is
    probably inadequate understanding of Display List basics.
    In one 'mode' of my project I have 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............. Several 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 displayCard Sprite
    calls a function intended to tidy-up the unwanted objects and
    eventListeners and then shift the activity to a different mode,
    defined by another function.
    There is only one child on the stage. I assume this will be
    my reviewPage with all the objects it holds. However when I trace
    it, and it's name, I get "root1 [object MainTimeline]". Using
    stage.removeChildAt(0) removes all the visible objects from the
    Display List and leaves me with no children on the stage.
    I've tried to 'explore' my structure by writing a small
    function to identify each object/container and the hierarchy of
    objects attached to them ... but have as yet been spectacularly
    unsuccessful in that effort and overwhelmed with error messages.
    I have a couple of concerns / questions:
    1. Do I remove all the 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 are using
    memory after I've attempted a clean-up like this?
    3. How do I remove just one of the TextField objects, say
    answerBox_212, or one of the eventListeners attached to one of the
    "displayCard" Sprites, from the Display List and/or from memory?
    Any guidance would be greatly appreciated.
    Cheers
    Dougal

    Hi John,
    Many thanks for your reply, where can I find out what the default setting is? In the style sheet, margin is set to 0. Do you mean the  <p> </p> on the first line of text? The code for that section is below, do I not need the <p> </p>?
    <h6>Heding 1</h6>
        <p>An image placeholder was used in this layout in the .header where you'll likely want to place  a logo. It is recommended that you remove the placeholder and replace it with your own linked logo. </p>
        <h3>Logo Replacement</h3>
        <p> Be aware that if you use the Property inspector to navigate to your logo image using the SRC field (instead of removing and replacing the placeholder), you should remove the inline background and display properties. These inline styles are only used to make the logo placeholder show up in browsers for demonstration purposes. </p>
        <p>To remove the inline styles, make sure your CSS Styles panel is set to Current. Select the image, and in the Properties pane of the CSS Styles panel, right click and delete the display and background properties. (Of course, you can always go directly into the code and delete the inline styles from the image or placeholder there.)</p>
    Many thanks for your help.
    Regards
    Nick

  • Observable vs Custom Events

    Hi.
    I'm creating a project that uses the MVC design pattern, and being eager to make sure I follow the best practices I have a couple of questions. When notifying a 'View' of changes to the 'Model' is it preferable to effect this notfication using the Observer/Observable pattern, or through a custom eventListener? I can understand that the Observer/Observable way of doing things allows the View to be completely independant of the Model. However if I were to use custom events and eventListeners it would certainly make things easier to read and implement (my model is quite a large beast, comprising of multiple sub-models), as I would be able to provide more information about the change with each notification.
    Is the answer to this just personal preference, or is there a convention?
    Thanks in advance.

    EventListener is an example of the [Subject] Observer
    pattern.
    If you are using swing/awt then use EventListener, if
    you wish to decouple your implementation from
    swing/awt, then implement your own solution based on
    the [Subject] Observer pattern.I disagree. Swing/awt have nothing to do with this. EventListener, EventObject, Observer, and Observable all belong to java.util. In theory you could do this without using any of these classes and making the event and listeners yourself without extending anything from java.util.
    Observer and Observable is good for a one to one relationship. It is quick, easy to do, and you don't have a lot to worry about. Multiple Observers watching one Observable is also nice. It is when you start watching multiple Observable classes that things get messy. Observer has one method that all Observable classes call. You have to do a lot of checking to see which class the Observable is before you know how to handle it.
    IMO the biggest disadvantage to Observer and Observable, is that something must extend Observable. This is bad if the class you want to observe extends something else. Instances of Observer and Observable are also bound tightly together.
    Events and Listeners are not bound together. Typically once the event is processed, it is disposed unless you want to save it and use it over and over. When using multiple listeners and events, you would implement each listener (or make anonymous) and it would have its own methods for a specific event, and not one large update method that handles everything. The events would be constructed as needed, and passed to the listeners.
    You are not limited to extend Event like you are with Observable. If you tried to handle an Observable the same way as an Event, you would have to register the Observable with the Observer, notify the Observer, then remove the Observable.
    Event/Listener is awesome for multithreading. You could write a Thread and Queue to manage all of your events (Similar to the AWTEventQueue). A class could put an event into the queue to be processed at a later time (or right away) by another thread. The Observer/Observable relationship cannot support this easily.
    The disadvantage is that you have to handle sending an event to each listener manually, where the Observer/Observable handles that on its own.
    In summary, Observer/Observable is a slightly more limitted version of Event/Listener, but it handles notifying the Observer/Listener on its own.

  • Handling EDT issues when listening to model events with ModelViewPresenter

    I'm planning on using model-view-presenter (passive screen/humble dialog variant) http://martinfowler.com/eaaDev/PassiveScreen.html as the basis for my Swing application.
    view <-> presenter <-> model
    The view is very thin and dumb and only shows what presenter tells it to. Presenter listens to UI events from the view, updates the model based on them, listens to model update events, and reads view state and updates view state.
    I'm now searching for a good practise for handling EDT-threading problem. The model is inherently multithreaded in the sense that we have several threads running concurrently. They for example fetch data from different sources and update the model accordingly. An event is created, presenter listens to it and updates the view.
    There's also operations that the user initiates. Those start in EDT, presenter does some actions on the model and possibly updates the view state as a result. If the action is fast, the whole thing can be done in EDT. If the operation takes a long time, the processing needs to jump out of EDT at some point to not block the UI.
    When thinking about the events that are created from model due to some background thread, where should we jump back to EDT? There's options:
    a) jump to EDT when presenter updates the view
    view (EDT) <- presenter (either EDT or other thread) <- model (either EDT or other thread)
    b) jump to EDT when moving to presenter layer
    view (EDT) <- presenter (EDT) <- model (either EDT or other thread)
    a)
    - could be implemented by creating an AOP aspect for all View interfaces(?) The aspect would jump to EDT if not there yet always when any method of the interface is called
    - if one ModelEvent is received in non-EDT thread in Presenter, and 15 different View setters need to be called to update the view state, causes 15 separate SwingUtilities.invokeLater() calls...problem?
    - model events and eventlisteners are straight forward to implement. Presenter and model do not need to be aware of Swing (existence of event dispatch thread)
    - Presenter is multithreaded and presenter objects need to be implemented so that threading problems do not occur
    b)
    - could be implemented for example by creating special model EventListener implementations that jump back to EDT when event is received
    - model events and eventlisteners are not as straightforward to do as with a). Somewhere the events need to jump to EDT (event source or listener) and you cannot code just "simple plain" listeners and event sources
    - Presenter needs to be aware of Swing (existence of event dispatch thread and need to jump back to it when events come from model) at least in the sense that it uses the correct EventListener implementations
    - View interface could still check that thread = EDT when methods are called (using similar AOP) to ensure threading rules are not broken
    - Presenter can be single threaded (always in EDT) and presenter implementer does not need to worry as much about threading
    - note that above point requires that user-initiated long running operations, that can't be run in EDT, need to jump from EDT the model layer. If view initiates new non-EDT threads (for example using SwingWorker), Presenter still does have multiple threads running on it (although only "one way", from view to model) and needs to be made threadsafe. This is starting to sound bad, but even if Presenter is single threaded only "one way", it may still be easier to implement than presenter that is completely multithreaded?
    I think major point in deciding is the difficulty of creating thread safe Presenters. Thread safe code is notoriously difficult to implement and even things that seem trivial at first sight can cause big problems. I can't help thinking that since the application's core is already multithreaded by nature, how much more difficult can it be to make the Presenters thread safe as well? Presenters should be quite simple in any case, can receiving events from model and calling a few setters on the view cause threading problems?
    Note that this problem is not limited to programs where background threads update the data....any program where some long running operations are run outside of EDT, and may cause events that are listened to in some presenter, has to solve this issue.
    Any views or ideas?

    RickyT wrote:
    Hello Helpful Nokia Users,
    When I am using my BH 103 blue tooth stereo earphones to listen to music on my N900, the sound drops out for about half a second (or less) then the music sounds slower (like a record player that has been slowed down) for about 4 seconds, then goes back to normal. This sometimes happens on each song, one after the other, sometimes it is just @ random times.
    This NEVER happens when using plug in head phones or when I hook it up to my stereo.
    The BH 103 are about 2 years old.... would the battery be failing? Causing them to run out of power super quickly? My N95 8GB used to beep when the battery in the earphones was low, would the N900 be "pausing" instead?
    Are the BH 103 not compatiable with the N900.... even though Nokia store lists them as accessories. Would I be better off with a newer model of ear phones?
    Cheers for your help!
    i think its the battery issue .
    Reality is wrong....dreams are for real... 2pac .
    don't forget to hit that green kudos

  • Commnunication swf to swf with Listeners

    Hi,
    am currently testing different approach to see what would be
    the best way to load 1 swf inside another swf (with loadClip
    method). The way I would prefer would be with EventDispatcher and
    EventListeners. But is it event possible? What would be the scope
    of listeners with multiples swf. Even if I create.delegate my new
    clip, will he catches the event of the loaded swf.
    Thank you in advance

    Once you load one swf into another you should have access to
    the functions, variables, listeners within that movie.

  • Understanding ActionScript 3

    I have spent hours trying to understand ActionScript 3.0
    I've watched tutorials from Lynda.com and did more research reading blogs and conversations. I've downloaded ActionScript Reference document which by the way wasn't easy to find and can't make heads or tails of it.
    I hear terms like "functions" and "EventListeners". Everything is so complicated and though I'm sure there is a logic to it I'm still trying to get a feel for it.
    I want to be able to reference a dictionary and a grammar document for ActionScript 3. In other words, I would like to have a document designed to define the components and help me to write appropriate statements. Adobe's help files are so frustrating to use and are structured like a maze.
    More often than not I hit a wall and can't find a solution.
    I was told about Adobe Air and I've since downloaded it. I understand that it can do things that Flash alone can't. All I've wanted to do with Actionscript and Flash was to create a menu / catalogue of my movies that could also play my movie files in Windows Media Player. Adobe Air is supposed to make that possible but I can't refer to anything that makes sense to make it happen. I've played around with ActionScript 3 mind you and have gotten around understanding the language by copying and pasting code snipets. I don't like doing it this way because I feel it's like speaking in a foreign tongue not knowing what I'm talking about. It's also very limiting... I don't even see why Adobe doesn't provide more help to it's customers.
    I've noticed that CS5's Flash actually comes with some code samples... seems like a no brainer to me that this should have been developed further.
      So my question is... how to understand ActionScript 3.0 - where to get definitions for the components and what are the rules or what is the structure of this language? I'm a graphic artist not a programmer but I can't get my projects off the ground until I master this stuff.
    A little help please?

    You're on the right track. Understand what a class is, a constructor, functions (private, public protected, static), event listeners, variables (private, public, protected, static) and how a for loop works and you can write a majority of applications.

  • Bean Introspection

    A class containing some methods and EventListeners.By introspection I want to get only the methods and EventListeners.
    But MethodDescriptor is returning all the things while EventSetDescriptor returning nun of these.
    How to get name of the EventListener ???
    //this is the Bean Class
    public interface MySampleResource
    extends Resource
    // Properties
    // =============================================================================================
    * Return the value of the PropertyX property, which has an integer value.
    * This is a read only property and has one to one relationship with a
    * field.
    * <p>
    * Although the resource exposes a normal getter, the application programmer
    * has to keep in mind, that the property value might be unavailable in a
    * distributed environment (for various reasons) and that the
    * ResourceExceptions thrown have to be handled in the proper way.
    * @throws ResourceException - if the value is not immediately available.
    public int getPropertyX ()
    throws ResourceException;
    * Return the value of PropertyY. This is a read/write property and has one
    * to one relationship with a field.
    public int getPropertyY ()
    throws ResourceException;
    * TODO SAUK: add a function abstract.
    public int getPropertyZ ()
    throws ResourceException;
    // public int setPropertyZ (int x)
    // throws ResourceException;
    * Set the value of PropertyY property.
    * <p>
    * Setting a property value (like other method calls also) in a distributed
    * environment is only possible in the backend end (provider side), i.e. the
    * setter has to be relayed to that end.
    * <p>
    * Since during that remote invocation things can go wrong with the call
    * itself (not the backend function as such) the setter might throw related
    * ResourceExceptions.
    public void setPropertyY (int aValue)
    throws ResourceException;
    // Method calls
    // =============================================================================================
    * TODO SAUK: add a function abstract.
    public void functionX (int anIntArgument)
    throws ResourceException;
    * TODO SAUK: add a function abstract.
    public String functionY (String aStringArgument)
    throws ResourceException;
    * TODO SAUK: add a function abstract.
    public void functionZ (int anIntArgument, String aStringArgument)
    throws ResourceException;
    // Event Generation Infrastructure
    // =============================================================================================
    * Add aListener to the list of all listeners for this resource.
    public void addMySampleResourceListener (MySampleResourceListener aListener);
    * Remove aListener from the list of listeners of this resource.
    public void removeMySampleResourceListener (MySampleResourceListener aListener);
    //while I am attempting the following code
    BeanInfo beanInfo = Introspector.getBeanInfo(c);
    EventSetDescriptor[] eventSetDescriptor = beanInfo.getEventSetDescriptors();
    for (int i = 0; i < eventSetDescriptor.length; i++)
    System.out.println("Event Name: " + eventSetDescriptor.getName());
    //why it is not working ????

    Okay, that would be your problem.
    Your interface MySampleResourceListener MUST extend EventListener or some other subinterface of EventListener, or the Introspector will simply ignore it. You can check this yourself. The method of the introspector that checks this is called getTargetEventInfo. You should be able to find it in the source for the introspector.
    It contains an if structure on the line isSubclass(listener, EventListenerType), where listener is the type of listener it's inspecting (i.e. the MySampleResourceListener), EventListenerType is EventListener.class, and isSubclass is a routine to check if listener is a subclass (or subInterface) of EventListenerType.
    The solution is this: simply extend EventListener.
    From Java API: (EventListener is) A tagging interface that all EventListeners MUST extend.
    Give that a try, and see if it works for you. Good Luck!

  • Button issue...new to flash

    I am just learning flash and actionscript...bear with me.
    I'm building a very basic flash website using buttons and the
    goToAndStop method, and I'm currently working on navigation between
    the various pages (frames). The site consists of a main page
    (frame1) and six other pages (frames 2-7). Frame 1 has 6 buttons
    that trigger event listeners which navigate to their respective
    frames. Frames 2-7 also have those 6 buttons, plus and additional
    button that should navigate back to frame 1.
    In testing the site, the 6 buttons (for frames 2-7) work
    properly on all frames, but the additional button (for frame 1)
    doesn't work consistently. The button appears all the proper
    frames, its mouseover and click properties work properly, but it
    doesn't navigate to frame 1 every time, only rarely and
    sporadically.
    My actionscript is as follows:
    on frame 1 I have all the functions and eventlisteners for
    buttons 2-7
    then on frame 2 (through 7) I have the function and
    eventlistener for button 1
    There are no errors reported in the actionscript.
    Why would that button only work on frame 2? If the script
    covers all the frames, it should remain functional, no? Is this a
    problem with my scripting/design, or is the Flash movie tester
    glitchy?
    Thanks

    The reason it only works sporadically is if you've hit frame
    2 before clicking that button. if you hit frame 5, the listener for
    that button never registered.
    Keep the additional "go home" button, and its listeners and
    handlers (functions) as well, all on frame 1. Just move the "go
    home" button off the stage (out of sight) on frame 1. That way you
    ensure all your listeners are registered and listening on the start
    of the movie, and that the object exists on the display list,
    albeit out of bounds.

  • Passing a function argument into LoadListener

    Hi, I was wondering if you could help me, imagin that I have
    a function. This function gets an argument like this:
    function PMFUpdate(PMID){
    Spry.Utils.loadURL("GET", "test/update.php?id="+PMID, true);
    Now, I want to use LoadListener and EventListeners, like
    this:
    Spry.Utils.addLoadListener(function(){
    Spry.Utils.addEventListener("element", "click",
    PMFUpdate(PMID), false);
    But I know this dosn't work! How can I pass PMFUPDATE()
    argument into LoadListener and use it in EventListener.
    Another question, how can I load certain amount of records in
    a XMLDataSet without PagedView.
    Oh, Last question, I bet, How can I stop loading
    XMLDataSet???
    Thanks in advance!

    maby this is what u are looking for in stopping the xml from
    loading;
    http://labs.adobe.com/technologies/spry/articles/data_api/apis/dataset.html#cancelloaddata
    loading data pieces with out paged;
    http://labs.adobe.com/technologies/spry/articles/data_api/apis/dataset.html#getdata
    element selector; maby this will help u out a bit.
    Spry.Utils.addEventListener("element", "click", function(e)
    var PMID = (how ever u where gonna get the id)
    PMFUpdate(PMID);
    return false;
    }, false);

  • Glitch with tween class?

    Hey everyone, I have a site that incorprerates several different tweens, one tween running on a timer in the main movie(scrolling text), another intitiated with a button click (scrolling images) within a movie thats loaded into the main movie. My issue is that the tweens sometimes freeze, especially the scrolling text and once in a while, at random images, the scrolling pictures tween freezes. I should mention that I have several different EventListeners going off in the background for mouse clicks, and I have small (15k) swfs being loaded into the movie every 3.5 seconds.. Would anyone know why the tweens freeze at times? could it have something to do with all the loading and EventListeners or is this something I have to live with?
    Thanks for reading and any suggestions you may have;
    The rough copy of the site is www.sunnysideosc.ca (select Gallery > Pictures)

    Sorry, I got ahead of my self, how do I make my tween not eligible for garbage collection?
    this is wad I'm using :
    function fFunction(passX:Number):void {
          var myTweenX:Tween=new Tween(mMC,"x",Elastic.easeInOut,mMC.x,passX,3,true);
          var myTweenA:Tween=new Tween(mMC,"alpha",Elastic.easeInOut,.3,1,3,true);
          myTweenX.addEventListener(TweenEvent.MOTION_STOP, mStopT);
          function mStopT(e:TweenEvent):void {
           mCL.addEventListener(MouseEvent.CLICK,startScrollXL);
           mCR.addEventListener(MouseEvent.CLICK,startScrollXR);
           mCL.alpha=1;
           mCR.alpha=1;
           if (xValue==4) {
            mCL.alpha=.3;
            mCL.removeEventListener(MouseEvent.CLICK,startScrollXL);
    Thanks for your posts! (SORRY for the double post, laptop froze, didn't think it went through)

  • Best practice for adding and removing eventListeners?

    Hi,
    What is the best practice in regards to CPU usage and performance for dealing with eventListeners when adding and removing movieclips to the stage?
    1. Add the eventListeners when the mc is instantiated and leave them be until exiting the app
    or
    2. Add and remove the eventListeners as the mc is added or removed from the stage (via an addedToStage and removedFromStage listener method)
    I would appreciate any thoughts you could share with me. Thanks!
    JP

    Thanks neh and Applauz78.
    As I understand it, the main concern with removing listeners is to conserve memory. However, I've tested memory use and this is not really an issue for my app, so I'm more concerned if there will be any effect on CPU (app response) if I'm constantly adding and removing a list of listeners every time a user loads an mc to the stage, as compared to just leaving them active and "ready to go" when needed.
    Is there any way to measure CPU use for an AIR app on iOS?
    (It may help to know my app is small - I'm talking well under 100 active listeners total for all movieclips combined.)

Maybe you are looking for

  • RTF Template Issues.

    Hi, I have 2 issues with a custom rft template for Printing POs from EBS 11.5.10.2 using XML Desktop ver 5.6 Build 45. 1 I have 2 tables on the template corresponding to 2 different groups.. I will display only one table of data dynamically based on

  • How to configure HTTPS in the receiver HTTP adapter ?

    Hi Guys, How to configure HTTPS in the HTTP receiver adapter and where i need to mention the QOS=BE in the receiver adpter. any suggestions or help would be appreciated Thanks, Srini

  • Question about "Linked" pictures and how to get rid of them?

    I have recently upgraded from a 2011 MacBook Pro to a 2013 MacBook Pro and there is a picture under Users & Groups when you go to change the display picture under "Linked" that I can't get rid of, while that isn't really an issue even though I would

  • MDT - Can I disable the Administrator account

    I found threads on how to turn it on and maybe some on how to turn it off. I already see how to have my task sequence *NOT* enable the administrator account. I just remove the corresponding line in the unattend.xml file. However, are there any reperc

  • Directional Antennas for CMX analytics?

    Hi there, I am in the process of planning AP placements for a large scale outdoor CMX Analytics project. Unfortunately the client that owns the outdoor space, does not own the buildings that run parallel to certain areas and RF bleed to nearby busine