Two different doubts that are one, perhaps - setting buttonMode? Getting loaded image width?

Hi everybody,
I'm quite a newbie using AS3 and as first pretentious learning project I'm creating a image multigallery.
At this moment I have two questions (between several future others) relative to the code I'm writing (and suffering):
How to correctly set the buttonMode in a dinamically created buttons?
and
How to get the width of the images that I'm dinamically loading? I'm planning to put them side by side, for this I need to know the width of each one.
In the thread title I wrote that it can be just one doubt despite the totally different purposes of the codes. Maybe.
Let me explain why: until now I could not understand completely the right way to direct the events inside dinamic functions.
Here's my code until now:
//// CREATE CONTAINERS ////
// CREATE MENU CONTAINER //
var menuContainer:MovieClip = new MovieClip();
menuContainer.x=10;
menuContainer.y=300;
addChild(menuContainer);
// CREATE IMAGES CONTAINER //
var imagesContainer:MovieClip = new MovieClip();
imagesContainer.x=100;
imagesContainer.y=10;
addChild(imagesContainer);
// IMAGE LOADERS //
var imagesLoader:Loader;
var bigImagesLoader:Loader;
//// LOAD XML ////
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, whenLoaded);
xmlLoader.load(new URLRequest("XML/roiaXML.xml"));
var xml:XML;
function whenLoaded(evt:Event):void {
     xml=new XML(evt.target.data);
     var mySetsList:XMLList=xml.children();
     //// MENU BUTTONS ////
     // POSITIONING BUTTONS INSIDE MENU CONTAINER//
     var rowsQuantity:Number=3;
     var columnsQuantity:Number=Math.ceil(mySetsList.length()/rowsQuantity);
     var cellWidth:Number=160;
     // CREATE BUTTONS //
     for (var i:int=0; i< mySetsList.length(); i++) {
          var newSetButtonMC:setButtonMC=new setButtonMC();
          var imageNodesArray:Array = new Array();
          for (var j:int=0; j<mySetsList[i].IMAGE.length(); j++) {
               imageNodesArray.push(mySetsList[i].IMAGE[j].attribute("smallURL"));
          newSetButtonMC.imageArray=imageNodesArray;
          newSetButtonMC.setButtonText.text=mySetsList.attribute("setTitle")[i];
          newSetButtonMC.setButtonText.autoSize=TextFieldAutoSize.LEFT;
          var cellX:Number=Math.floor(i/rowsQuantity);
          var cellY:Number=i%rowsQuantity;
          newSetButtonMC.x=cellX*cellWidth;
          newSetButtonMC.y=cellY*(newSetButtonMC.height+10);
          // I really don't know how to set the newSetButtonMC.buttonMode = true, nothing worked until now
          newSetButtonMC.addEventListener(MouseEvent.CLICK, onClickButton);
          menuContainer.addChild(newSetButtonMC);
     //// MENU BUTTONS ACTIONS ////
     function onClickButton(mevt:MouseEvent):void {
          // LOAD GALLERY IMAGES //
          var targetButton:setButtonMC=setButtonMC(mevt.currentTarget);
          for (i=0; i<targetButton.imageArray.length; i++) {
               imagesLoader = new Loader();
               imagesLoader.load(new URLRequest (targetButton.imageArray[i]));
               imagesLoader.addEventListener(Event.INIT, getImageWidth);
               imagesLoader.x=i*200;
               imagesContainer.addChild(imagesLoader);
               // LOAD BIG IMAGE WHEN CLICK IMAGE FROM GALERRY //
               imagesLoader.addEventListener(MouseEvent.CLICK, loadBigImage);
          function getImageWidth(evtImageWidth:Event):void {// FUNCTION TO GET IMAGE WIDTH //
               // I really don't know what to do here, i've tryed a lot
               trace(evtImageWidth.target.width);
               trace("ok");
     function loadBigImage(event:MouseEvent):void {
          trace("ok");
I've tryed (and searched for solutions) a lot, maybe someone can help me.
Thanks everybody . Abstrato

Something new happened in my life, and it's called "contentLoaderInfo".
<--- real happiness
With this:
imagesLoader.contentLoaderInfo.addEventListener(Event.INIT, getImageWidth);
plus this:
function getImageWidth(evt:Event):void {
trace(evt.target.width);
I was close to reach the supreme nirvana and I could trace the images widths.
But there is a problem: i don't know what to do with the values to load each image side by side.
Does someone know?
Thanks . Abstrato

Similar Messages

  • HT4061 How do I consolidate purchases from two different ids that are on the same bank account, and eliminate the extra id without losing any purchases?

    How do I consolidate purchases from two different ids that are on the same bank account, and eliminate the extra id without losing any purchases? I want my music to match on both ipad and computer.

    Purchases are forever tied to the AppleID they were bought with. There is currently no way to consolidate AppleIDs. Sorry.

  • Using values of two different applications that are from the same class

    Hi,
    See the following little program
    What I can't figure out is
    i) How to change the values if I add a button
    ii) How to print just app.x1 etc. The way I have it now, it will just print x1, y1 etc, from both app and app1, but I want to be able to distinguish between the two of them so I can use the values.....ie for example add app.x1 and app1.x2 (only using that as an example of what I want to use them for)
    I'd really appreciate if anyone could help me out, it's probably simple, but just cant figure it.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class drawLine extends JFrame{
    int x1, y1, x2, y2;
    JPanel topPanel;
    JButton button;
    public length l, l3;
    public drawLine(){
    super("drawLine");
    public drawLine(length l){
    this.l = l;
    topPanel = new JPanel();
    button = new JButton("Change");
    topPanel.add(button);
    getContentPane().add(topPanel, BorderLayout.NORTH);
    x1 = 100;
    y1 = 100;
    x2 = l.x2;
    y2 = l.y2;
    System.out.println(x1 + " " + y1 + " " + x2 + " " + y2);
    /*button.addActionListener(
    new ActionListener(){
    public void actionPerformed(ActionEvent e){
    l.length();
    repaint();
    public void hello(){
    System.out.println(x1 + " " + y1 + " " + x2 + " " + y2);
    public void paint(Graphics g){
    draw(g);
    public void draw(Graphics g){
    g.drawLine(x1, y1, x2, y2);
    public static void main(String args[]){
    length l1 = new length();
    length l2 = (length)l1.clone();
    l1.length();
    l2.length();
    drawLine app = new drawLine(l1);
    app.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    app.setSize( 300, 300 );
    app.move(0,0) ;
    app.setVisible( true );
    drawLine app1 = new drawLine(l2);
    app1.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    app1.setSize( 300, 300 );
    app1.move(300,0) ;
    app1.setVisible( true );
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class length implements Cloneable{
    String whatlength;
    int llength;
    int x1 = 100;
    int y1 = 100;
    public int x2, y2;
    public void length(){
    whatlength = JOptionPane.showInputDialog("What is the length of the line");
    llength = Integer.parseInt(whatlength);
    x2 = x1 + llength;
    y2 = y1;
    public Object clone() {
    Object object = null;
    try {
    object = super.clone();
    catch (CloneNotSupportedException exception) {
    System.err.println("AbstractSpoon is not Cloneable");
    return object;
    }

    I've tried it like this, ie by adding an int to drawLine and trying to keep an array of lengths, which sortof works, but see the code I have commented out in the button actionListener class. What I thought I'd ba able to do is access the arrays like that.....how come it gives me an exception?
    public class drawLine extends JFrame{
    int x1, y1, x2, y2;
    JPanel topPanel;
    JButton button;
    public length[] linelength = new length[2];
    public drawLine(final length l, final int k){
    super("drawLine");
    this.linelength[k] = l;
    topPanel = new JPanel();
    button = new JButton("Change");
    topPanel.add(button);
    getContentPane().add(topPanel, BorderLayout.NORTH);
    x1 = 100;
    y1 = 100;
    x2 = linelength[k].x2;
    y2 = linelength[k].y2;
    button.addActionListener(
    new ActionListener(){
    public void actionPerformed(ActionEvent e){
    //Update the length object int's
    linelength[k].getLineLength();
    // Copy these ints back to the drawline object
    x2 = linelength[k].x2;
    y2 = linelength[k].y2;
    System.out.println(k + " " + linelength[k].x1 + " " + linelength[k].y1 + " " + linelength[k].x2 + " " + linelength[k].y2);
    repaint();
    /*********This bit gives me a null pointer exception ********
    linelength[0].x1 = linelength[1].x1;
    linelength[0].x2 = linelength[1].x2;
    linelength[0].y1 = linelength[1].y1;
    linelength[0].y2 = linelength[1].y2;
    public void paint(Graphics g){
    g.clearRect( 0, 0, getWidth(), getHeight() );
    draw(g);
    public void draw(Graphics g){
    g.drawLine(x1, y1, x2, y2);
    public static void main(String args[]){
    length l1 = new length();
    length l2 = (length)l1.clone();
    l1.getLineLength();
    l2.getLineLength();
    drawLine app = new drawLine(l1, 0);
    app.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    app.setSize( 300, 300 );
    app.move(0,0) ;
    app.setVisible( true );
    drawLine app1 = new drawLine(l2, 1);
    app1.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    app1.setSize( 300, 300 );
    app1.move(300,0) ;
    app1.setVisible( true );
    }

  • HT1364 I used these instructions to move my i-tunes library to the external hard drive that two different home pc's access. My playlists do not show on both Is it possible to have one i-pod synch amid two different computers that use the same library?

    I have a sole i-pod and two pc's, used the instructions for "iTunes for Windows: Moving your iTunes Media folder" in the hope that I could synch my one i-pod between two different computers that are sharing the same library. Is it possible to have two seperate computers that only share an external hard drive (one wireless, one not) ? When I am looking at a shared library should it appear the same on both machines (ie: playlists/ purchased list etc)?

    If it is moved correctly, playlists will display on both computers and it should be possible.
    Close iTunes.
    Hold <SHIFT> and launch iTunes.
    When prompted to create a new or open an existing iTunes library point iTunes to the iTunesLibrary.itl file on the external drive.
    The entire library should now show up with all playlists and playcounts.
    Do this on both computers.
    Keep in mind that only one computer can access iTunes at a time, otherwise errors will occur when each computer attempts to write to or update the iTunesLibrary.itl file.
    Syncing may work seemlessly with both computers, but honestly syncing is designed to work with one and only one computer.

  • I have an airport express and want to know how to set up two different wireless networks. One with 5GHZ and one with 2.4GHZ so different devices can connect to either.

    I have an airport express and want to know how to set up two different wireless networks. One with 5GHZ and one with 2.4GHZ so different devices can connect to either. I have an iphone 4 that will not connect to 5ghz.
    thank you!

    Your AirPort Express is already providing two separate 2.4 GHz and 5 GHz bands, but each band is using the same wireless network name.
    This is the default setup for the AirPort Express, which is recommended for most users. The theory here is that devices will automatically connect to the best quality signal based on their capabilities and distance in relation to the AirPort Express.
    It is possible to assign a different name to the 5 GHz band, and then "point" devices at that network to connect. Some users swear by this option.....(I am not one of them).... but you might want to give it a try to see how it works for you.
    Open Macintosh HD > Applications > Utilities > AirPort Utility
    Click on the AirPort Express
    Click Edit in the smaller window that appears
    Click the Wireless tab at the top of the next window
    Click Wireless Options near the bottom of the next window
    Enter a check mark next to 5 GHz Name.....which will automatically add "5 GHz" to the network name....so you can identify it
    Click Save, then click Update and wait a full minute for the Express to restart
    Now you will need to "point" your 5 GHz capable devices at the 5 GHz network name.  2.4 GHz devices will connect to your "other" network name.

  • I have two different apple id's, one on my computer and one on my phone. i connected my phone to sync music and i lost most of my music. i realised that the music i lost is from the apple id on my mac. how do i undo this mess? help anyone?

    i have two different apple id's, one on my computer and one on my phone. i connected my phone to sync music and i lost most of my music. i realised that the music i lost is from the apple id on my mac. how do i undo this mess? help anyone?

    The iphone will mirror the selected content of your computer.
    Make sure everything is on your computer.  Select what you want on your iphone, sync

  • Hello, I use photoshop cc 10 days and I did a lot of files with layers and channels. For two days in two different locations that only happens in some documents when you reopen the job done no more .. Example 6 channels on the facts I see only one .. Than

    Hello, I use photoshop cc 10 days and I did a lot of files with layers and channels.
    For two days in two different locations that only happens in some documents when you reopen the job done no more .. Example 6 channels on the facts I see only one ..
    Thank you for your attention.
    Annalisa 

    Don't understand what you writing here.  Screen shoots would be most helpful.
    Supply pertinent information for quicker answers
    The more information you supply about your situation, the better equipped other community members will be to answer. Consider including the following in your question:
    Adobe product and version number
    Operating system and version number
    The full text of any error message(s)
    What you were doing when the problem occurred
    Screenshots of the problem
    Computer hardware, such as CPU; GPU; amount of RAM; etc.

  • How can I set two different emails in only one contact form?

    How can I set two different emails in only one contact form?

    To enter multiple email address with the Contact Form Widgets:
    Click the Options icon for the selected widget, then
    In the Email to box, enter multiple emails by delimiting them with a semi-colon. For example: [email protected];[email protected]
    Cari

  • Their is two new Updates that are the same for the OS X Mountain Lion v10.8.5, except one has {Combo}. Which one do i download? The info on them are the same.

    Their is two new Updates that are the same for the OS X Mountain Lion v10.8.5, except one has {Combo}. Which one do i download? The info on them are the same.

    It appears Apple’s download servers are ‘overwhelmed’ today.  I couldn’t download the newest iTunes update or IOS 7 and there are a lot of discussions today about not being able to download. One poster said they had chatted with App Store support who confirmed the problem.

  • Do IMAQ Cast Image or IMAQ Linear averages give different results when using different computers that are running under Windows XP ?

    Hello
    I'm currently developping an image processing algorithm using Labview 7.1 and the associated IMAQ Vision tools. After several tests, I found a weird result. Indeed, I put the labview algorithm - including the IMAQ VI on the library to get sure that I use all the time the same VI - on my memory stick and used it on two different computers. I tested the same picture (still in my memory stick) and had two very different results.
    After several hours trying to understand why, I found that there were a difference between the results given by both computers at the very begining of the algorithm. Indeed, I used a JPEG file.
    To open it, I first create an Image with IMAQ Create (U8). Then, I open it.
    Then in my first sub-VI, I use IMAQ Cast Image to be sure that the picture is a U8 grayscale picture.
    Right after that, I use the IMAQ Linear Averages. The results of this VI are different on the two computers.
    I tried several time on the same picture : one computer always give me the same result but the two computers give me a different result. So there is no random variable on the results.
    So my question is : Do IMAQ Cast Image or IMAQ Linear averages give different results when using different computers that are running under Windows XP ?
    My bet is on IMAQ Cast Image but I'm not quite sure and I do not undestand why. The labview and IMAQ are the same on both computers.
    The difference between the two computer are above :
    Computer 1 :
    Pentium(R) 4 CPU 3.20GHz with a RAM of 1Go. The processor is an Intel(R).
    The OS is windows XP Pro 2002
    Computer 2 :
    Pentium(R) 4 CPU 2.80GHz with a RAM of 512Mo. The processor is an Intel(R).
    The OS is windows XP Pro 2002.
    If anybody can help me on this problem, it would be really helpful.
    Regards
    Florence P.

    Hi,
    Indeed it's a strange behaviour, could you send me your VI and your JPEG file, (or another file that reproduces) so that I could check this inthere ?
    I'll then try to find out what's happening.
    Regards
    Richard Keromen
    National Instruments France
    #adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
    >> Découvrez, en vidéo, les innovations technologiques réalisées en éco-conception

  • I am unable to update my apps... in my purchases page it appears as "update", then a message tells me to log on with the Apple ID I purchased the app with... Well I have tried my two different accounts and neither one will work, can someone help ??

    I am unable to update my apps... in my purchases page it appears as "update", then a message tells me to log on with the Apple ID I purchased the app with... Well I have tried my two different accounts and neither one will work, can someone help ??
    And is there any way to sync all my purchases and accounts to just have one... It is a bit stupid that you dont even get a list of something of what account you may of used, or some kind of hint, so you could log on to the right account. I am really stuck ...
    Please Advise......

    You can't merge accounts. But you can check your purchase history:
    iTunes Store & Mac App Store: Seeing your purchase history and order numbers
              http://support.apple.com/kb/HT2727
    Also, what may seem stupid to you... may be a protection of privacy to others.

  • How do I use two different apple IDs on one itunes?

    How do I use two different apple IDs on one itunes?

    This would be a violation of the terms of use of the itunes store and could result in the loss of your account.
    You cannot use the U.K. itunes store unless you are in the U.K

  • Using two external displays that are NOT mirrored

    i have a MBP early 2008, meaning the external display port is a dual DVI-I port. I have have two external displays, both samsung syncmaster xl2370 with native resolution 1920x1080. i have a dual dvi-i to vga splitter. when i connect both displays, they mirror one another, which is not what i want. rather, i want to have my MBP display, and two external displays that are not mirror images of one another. according to apple, if i buy a dual dvi-i to dvi splitter, i get the same effect. i've read on various forums about hardware alternatives, like buying a usb to dvi or usb to vga adapter, with some reasonable results (except a bit of sluggishness). the best one seems to be the diamond: http://www.diamondmm.com/BVU195.php
    it mostly gets good reviews, but is sluggish. does any know of any better options?
    many thanks, jovo

    Welcome to Apple Discussions!
    USB is slow partly because it is processor and driver dependent. Best to go with a straight video solution, such as Matroxes products like this one: http://www.matrox.com/graphics/en/products/gxm/dh2go/

  • Two different condition types in one report

    Hello,
    i have a problem with the conditional display of a report.
    I want to use two different condition types for one report.
    For example I want to show the report only when the page is not in printer friendly mode and when the value of an item is NULL.
    Is that possible?
    Has anyone a solution for this problem?
    Thank you,
    Tim

    Tim,
    you can use
    IF V('PRINTER_FRIENDLY') = 'YES' AND :P1_ITEM IS NOT NULL THEN RETURN FALSE;
    ELSE RETURN TRUE;
    END IF;
    in the Conditional Display picking PL/SQL Function Body returning a Boolean.
    Denes Kubicek

  • Can We Two Different Credit Control Area to 1 company code using cross comp

    Can We Two Different Credit Control Area to 1 company code using cross company code assignment.Tried but giving error at the time of bill release.Experts Can you help?

    Hi,
    It is not possible to have more than one credit  control are for a single company code.

Maybe you are looking for

  • Dynamic Creation of Objects using Tree Control

    I am able to Create Dynamic Objets using List control in flex,but not able to create objects using TreeControl,currently iam using switch case to do that iam embedding source code please help me how to do that <?xml version="1.0" encoding="utf-8"?> <

  • Booted from firewire external disk, internet slow

    Hi, My iMac is currently being booted from external disk via Firewire 800. I have to do this until I receive new install disks from apple to resore my machine. The computer is usable, however internet is very slow... I have other devides, windows mac

  • Google Calendar can only be read out but not modify

    hello,   i could set up my Google Calendar account in my playbook abd sync it. eveything is there. but... i can not add or modify appoitements.   is it a limitation? i wish to have full access to my calendar on my android phone and on my playbook.  

  • Fields in Value mapping function

    Hello, I am trying to use value mapping function in XI. I don't know how to input values from data type fields directly to agency or schema. Company "ABC" -> Agency "ABC" Code "XXX" -> Schema "XXX" There are too many different types of values to link

  • Using Japanese version of Adobe Reader (9 or 10) on English Windows XP?

    Our users have Windows XP SP3 English with the Windows XP Japanese MUI installed. Up until now we have been using the English Adobe Reader 8 with the Japanese Font pack. I am just curious if there would be any problems with using the Japanese version