pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luiz Gustavo <luizgustav...@gmail.com>
Subject Re: Image Path
Date Thu, 09 Dec 2010 01:41:48 GMT
Hi Greg,

I use the image in the memory game that I've sended to you.
I created a specialized ButtonData that receives two Strings in its
constructor. One of then is de default image, that apears when the button is
"closed" and the another is the image that apears when the user clicks the
button.
I have to do it programmatically 'cause I have to randomize the image
locations.

I knew about the "@" symbol in the bxml file... but I just had the error
mentioned... in the source using Pivot 1.5.2 I didn't have to use the
leading "/" in the path:


...
private String defaultImage = "/img/default.gif";
...

for(int aux = 0; aux < 36; aux++){
             // *images36[aux]* contains the randomized images
             buttons[aux].setButtonData(new MemGameButtonData(*defaultImage*,
*images36[aux]*));
             buttons[aux].setEnabled(true);
         }

...




public class MemGameButtonData extends ButtonData{

    private String defaultURL;
    private String buttonURL;

    public MemGameButtonData(String URLPadrao, String URLBotao){

        super();
        this.buttonURL = URLBotao;
        this.defaultURL = URLPadrao;
        setDefaultURL();
    }

    public void setDefaultURL(){
        this.setIcon(defaultURL);
    }

    public void setButtonURL(){
        this.setIcon(buttonURL);
    }

    public Image getButtonURL(){
        return this.getIcon();
    }
}


Cheers,
Luiz Gustavo






2010/12/8 Greg Brown <gk_brown@verizon.net>

> The leading slash is now required in BXML. A leading "@" symbol means
> "relative to the current file", whereas a leading "/" means relative to the
> class path (i.e. absolute).
>
> However, you appear to be loading your images programmatically rather than
> in markup - what exactly are you doing with the defaultImage value? There
> may be an easier way to accomplish what you need.
>
> G
>
>
> On Dec 8, 2010, at 7:21 PM, Luiz Gustavo wrote:
>
> Hi,
>
>
> I had writen an application using Pivot 1.5.2 that used a gif image for a
> button, and in the Java source I used the path without a "/" in the begining
> of the path, like this:
>
> private String defaultImage = "img/default.gif";
>
> Now, rewriting the application in Pivot 2.0 I had to put the "/" in the
> begining of the path (otherwise I receive a NullPointerException that tells
> me the IconURL is null):
>
> private String defaultImage = "/img/default.gif";
>
> Are the images referenced by an absolute path now, and not relative to the
> bxml script?
>
> --
> Luiz Gustavo S. de Souza
>
> http://luizgustavoss.wordpress.com
> http://luizgustavoss.blogspot.com
> http://twitter.com/lugustso
>
>
>


-- 
Luiz Gustavo S. de Souza

http://luizgustavoss.wordpress.com
http://luizgustavoss.blogspot.com
http://twitter.com/lugustso

Mime
View raw message