why my spinner code is not working

Hi all,

I just read the api regarding to the spinner method, after research and follow to what it said nothing appear on the simulator,

I am trying to create a spinner to display on my device, here is the code:

local widget = require( “widget” )

– Create a default spinner (using widget.setTheme)

local spinnerDefault = widget.newSpinner

{

    left = 150,

    top = 150,

    sheet = “refresh.png”,

    data = { width = 44, height = 44, numFrames = 1, sheetContentWidth = 44, sheetContentHeight = 44},

    width=44,

    height=44,

    startFrame = 1, frameCount = 1,

    time = 1000

}

spinnerDefault:start();

spinnerDefault:stop();

what’s wrong with this code

Keat

Hi Keat,

Where is the “data” setting coming from? Did you create an actual image sheet with your “refresh.png” image on it?

Brent

Hi Brent,

I am new to the spinner widget 

I just create one image only with the size 44

and what’s wrong with my code,

would you please show me?

is there any tut related to spinner?

thanks in advance

Keat

Hi Keat,

I haven’t tested this, but try creating the image sheet first, then referencing it in the Spinner:

[lua]

local mySheet = graphics.newImageSheet( “refresh.png”, width=44, height=41, numFrames=1, sheetContentWidth=44, sheetContentHeight=44  )

local spinnerDefault = widget.newSpinner

{

    left = 150,

    top = 150,

    sheet = mySheet,

    width=44,

    height=44,

    startFrame = 1, frameCount = 1,

    time = 1000

}

[/lua]

Brent

Hi Brent,

I tried to test this code many time but still got an error in corona simulator output said that:

main.lua"1: ‘)’ expected near ’ = ’

what does it mean?

I tried to check the syntax of imagesheet and found nothing error.

Pls help me to test this code

Many thanks

Keat 

Hi Keat,

My fault on that… the options/parameters for the image sheet must be contained in a table:

[lua]

local mySheet = graphics.newImageSheet( “refresh.png”, { width=44, height=41, numFrames=1, sheetContentWidth=44, sheetContentHeight=44 }  )

[/lua]

Hi Brent,

Just the curly bracket and make the code ok.

I really love for the community and the fast respond to my question,

You deserved the best.

Still say thank you again,

Keat

Hi Keat,

Where is the “data” setting coming from? Did you create an actual image sheet with your “refresh.png” image on it?

Brent

Hi Brent,

I am new to the spinner widget 

I just create one image only with the size 44

and what’s wrong with my code,

would you please show me?

is there any tut related to spinner?

thanks in advance

Keat

Hi Keat,

I haven’t tested this, but try creating the image sheet first, then referencing it in the Spinner:

[lua]

local mySheet = graphics.newImageSheet( “refresh.png”, width=44, height=41, numFrames=1, sheetContentWidth=44, sheetContentHeight=44  )

local spinnerDefault = widget.newSpinner

{

    left = 150,

    top = 150,

    sheet = mySheet,

    width=44,

    height=44,

    startFrame = 1, frameCount = 1,

    time = 1000

}

[/lua]

Brent

Hi Brent,

I tried to test this code many time but still got an error in corona simulator output said that:

main.lua"1: ‘)’ expected near ’ = ’

what does it mean?

I tried to check the syntax of imagesheet and found nothing error.

Pls help me to test this code

Many thanks

Keat 

Hi Keat,

My fault on that… the options/parameters for the image sheet must be contained in a table:

[lua]

local mySheet = graphics.newImageSheet( “refresh.png”, { width=44, height=41, numFrames=1, sheetContentWidth=44, sheetContentHeight=44 }  )

[/lua]

Hi Brent,

Just the curly bracket and make the code ok.

I really love for the community and the fast respond to my question,

You deserved the best.

Still say thank you again,

Keat