Publishing by Air Android Flash 5.5 , showing me an error - android

I'm creating an android app using AS3 Flash CS5.5
it'a about simple library contains images that are uploaded to a web page , and i'm using this code that someone help me `
//THIS DEFINES THE ARRAY WHERE YOUR LOADERS WILL GO
var pictureArray:Array = new Array;
//THIS CODE TARGETS THE BUTTONS -- WHEN YOU CLICK THEM THE FUNCTIONS 'nextpic' and 'lastpic' WILL FIRE
nextbtn.addEventListener(MouseEvent.CLICK, nextpic)
backbtn.addEventListener(MouseEvent.CLICK, lastpic)
//YOUR LOADERS. I'VE PUT 3 PICTURES IN THE LIBRARY
//THE LAST LINE FOR EACH LOADER 'PUSHES' THE LOADER INTO THE ARRAY
var loader1 = new Loader();
loader1.load(new URLRequest("banana.jpg"));
pictureArray.push(loader1);
var loader2 = new Loader();
loader2.load(new URLRequest("big apple.jpg"));
pictureArray.push(loader2);
var loader3 = new Loader();
loader3.load(new URLRequest("pineapple.jpg"));
pictureArray.push(loader3);
//WE ADD THE FIRST 'CHILD' HERE
//NOTE THAT ARRAYS HOLD OBJECTS IN CONSECTUTIVE POSITIONS: 0 - WHATEVER
//THE FIRST OBJECT IN THE ARRAY IS ADDRESSED AT: ARRAYNAME[0], THE SECOND OBJECT IS
//AT ARRAYNAME[1], ETC.
addChild(pictureArray[0]);
pictureArray[0].x = 110; pictureArray[0].y = 80;
//n IS JUST A COUNTER THAT WILL MAKE IT EASIER TO ADDRESS THE ITEMS IN THE ARRAY
var n:int = 0;
Function nextpic(e)
{
removeChild(pictureArray[n]);
n = n+1;
//HERE WE RESET THE POSITION IN THE ARRAY IF WE'VE GONE PAST THE NUMBER OF PICTURES THAT WE HAVE
if (n>pictureArray.length - 1)
n=0;
addChild(pictureArray[n]);
pictureArray[n].x = 110; pictureArray[n].y = 80;
}
function lastpic(e)
{
removeChild(pictureArray[n]);
n = n-1;
if (n<0)
n=pictureArray.length - 1;
addChild(pictureArray[n]);
pictureArray[n].x = 110; pictureArray[n].y = 80;
}`
it's working well , but when I publish it by Android Air , it shows me this error
Scene 1, Layer 'Layer 1', Frame 1, Line 39 1071: Syntax error: expected a definition keyword (such as function) after attribute Function, not nextpic.

re-write Function as function Easy!

Related

How to use an input array for drawing a graph in GraphView Library?

I am developing an Android application,which can take audio input from device mic and generate a graph in real time as an output.For generating a Graph on a view I am using GraphView library.
I am trying to convert a .wav audio file into an array.But I don't know where I have to use this array for drawing a graph?
i found this :
1 - create a WaveSimple (time, amplitude)
then i creat a Liste to add samples in this Liste;
Liste<WaveSample> pointListe = new ArrayListe<>();
and when i start recording i put this :
pointList.add(new WaveSample (Time, myAudioRecord.getMaxAmplitude ());
i want to create a lineGraph with this List but i couldn't ;
this what i write :
for(int i = 0; i<pointList.size(); i++){
x = (double) pointList.getTime();
y = (double) pointList.getAmplitude();
series.appendData(new DataPoint(x, y),true,pointList.size())
}
but doesnt work

Saving the value of a stepper in Corona SDK to a json file

I want to be able to pass the value from a stepper widget in corona into a json file. So far I've got my stepper to display and increment and decrement and display the current value on screen. I've written a function to save the value to a file as json, but i'm having trouble calling that function. I want to be able to have other setting on screen which have their values save to json. Here the code I have to save the setting:
local function saveSettings (e)
-- body
print("testtesttest")
if (file) then
local content = file:read("*a")
else
settings = {}
settings.houses = StepperNo
file = io.open(path, "w")
local json_setting = json.encode(settings)
file:write(json_setting)
io.close(file)
end
end
and then the code to display the stepper:
local StepperNo = 1
local displayNoOfHouses = display.newText("Number of houses: "..StepperNo,180,135, native.systemFontBold,16)
local function onStepperPress( e )
if ("increment" == e.phase) then
StepperNo = StepperNo + 1
elseif ("decrement") == e.phase then
StepperNo = StepperNo - 1
end
displayNoOfHouses.text = "Number of houses: "..StepperNo
end
local HouseStepper = widget.newStepper {left = 100, top = 100, minimumValue = 0, maximumValue = 9, onPress = onStepperPress}
I dont know how to call the savesetting function after the stepper is pressed. I think I might have done this incorrectly or may be missing something obvious, I am very new to Lua...
There is a very simple to implement table saver and loader presented in this tutorial:
http://coronalabs.com/blog/2014/10/14/tutorial-saving-and-loading-lua-tables-with-json/
It uses JSON to encode a Lua table to save and when needed, read the JSON back in and decode it to a Lua table.

Unity3d BootCamp Tutorial UnityScript Array Order Anomaly in ImageEffectsOrder.js

I am new to Unity and grabbed the BootCamp project and ran it within Unity 4.1.5f1 as a Windows Build without any modification
I then tried to build to Android and had a bunch of errors (mostly variables not being declared)
But I have one remaining that I just don't understand...
In the following code in the file ImageEffectsOrder.js the javascript references an order method of the array sorted[] as sorted[i].order
The compiler errors with 'order' is not a member of object.
So I'm a little confused as to why the windows build supports this member but not android.
This makes me wonder what other surprises await when converting from platform to platform.
But for now can anyone point me to a workaround for the order member? And I'm not quite clear on what it is actually returning...it seems the variable i should give you the order.
The order just seems intrinsic from the code, it is never set to any value, so what 'order' is it? I can't seem to find any docs on this 'member' of the Array class.
Here is the code:
var sorted : Array = new Array();
var i : int = 0;
for (var fx : PostEffectsBase in GetComponents(PostEffectsBase))
{
if(fx && fx.enabled)
{
sorted[i++] = fx;
}
}
while (sorted.length)
{
var indexToUse : int = 0;
var orderValue : int = -1;
for(i = 0; i < sorted.length; i++) {
if(sorted[i].order > orderValue) {
orderValue = sorted[i].order;
indexToUse = i;
}
}
...more code...
I solved it. The problem is not with the Array Class as the fx that is being assigned to the sorted[] array is an object of class PostEffectsBase.
So the actual problem is one of casting when we try to use sorted[i].order
I changed the reference from sorted[i].order to (sorted[i] as PostEffectsBase).order and it worked.
I have to remember this. It seems there are a lot of these casts that have to be done between platforms.

How to Spawn objects in corona sdk

hey i am new to the Corona sdk world i want to learn how to spawn some objects and make them move across the screen i try everything and it never work i read the forum on spawning the right way and try it but still end up with a error in my code help this is my code
local mRandom = math.random
local mAbs = math.abs
local objects = {"rocket02" ,"rocket01","coin01"}
local function spawnObject()
local objIdx = mRandom(#objects)
local objName = objects[objIdx]
local object = display.newImage("image/object_"..objName..".png")
object.x = mRandom (screenLeft +30,screenRight-30)
object.y = screenTop
if objIdx < 4 then
object.type = "food"
else
object.type = "other"
end
end
Also can some one tell me how to make it move across the screen
Please help Thanks
here's the media file for you to take a look at
I'll show you a method. For that, I have rewritten your code as follows:
local mRandom = math.random
local objects = {"rocket02" ,"rocket01","coin01"}
local objectTag = 0
local object = {}
local function spawnObject()
objectTag = objectTag + 1
local objIdx = mRandom(#objects)
local objName = objects[objIdx]
object[objectTag] = display.newImage(objName..".png") -- see the difference here
object[objectTag].x = 30+mRandom(320)
object[objectTag].y = 200
object[objectTag].name = objectTag
print(objectTag)
end
timer.performWithDelay(1,spawnObject,3)
Here I've used a timer for displaying the object. You can also use for loop for the same purpose.
Here you can call any object with tag as object[objectTag].
For your information:
display.newImage(objName..".png")
--[[ will display object named rocket02.png or rocket01.png or coin01.png
placed in the same folder where your main.lua resides --]]
And
display.newImage("image/object_"..objName..".png")
--[[ will display object named object_rocket02.png or object_rocket01.png
or object_coin01.png placed in a folder named 'image'. And the folder
'image' should reside in the same folder where your main.lua is. --]]
And for moving your object from top to bottom, you can use:
either
function moveDown()
object[objectTag].y = object[objectTag].y + 10
--replace 'objectTag' in above line with desired number (ir., 1 or 2 or 3)
end
timer.performWithDelay(100,moveDown,-1)
or
transition.to(object[objectTag],{time=1000,y=480})
--[[ replace 'objectTag' in above line with desired number (ir., 1 or 2 or 3)
eg: transition.to(object[1],{time=1000,y=480}) --]]
Keep coding.............. :)

Starling Feathers - Available features 101

New to Starling-Feathers, before I start to develop my mobile app, I would like to know what are the best practice to develop the following features using Feathers:
Partial view slide - A part of the next view is shown and the user can drag to see it all. Could this be done with Feathers ScreenNavigator?
Sliding menu from the top
Dragging text elements with title pushing the last items
Since it is hard to describe I've added an animated gif to describe my goals. Thanks for all your advices
I would like to maximize the use of Feathers built in widgets and will appreciate code examples :)
I think these are not that much hard to do in core flash or you can also do it in Starling feathers too. YOu can use list item to do the third point (Dragging text elements with title pushing the last items) .
First and second you can use it with tweening effect i think.
For the third one using feathers list.
(re formated post)
private function addFeatherList():void{
Flist = new List();
Flist.width = 250;
Flist.height = 300;
Flist.x = GAME_W/2 - Flist.width/2;
Flist.y = sampText.height + 5;
this.addChild( Flist );
fontArr = Font.enumerateFonts(true);
for (var i:int=0; i<fontArr.length; i++){
ListArr[i] = { text:Font(fontArr[i]).fontName }
}
var groceryList:ListCollection = new ListCollection( ListArr );
Flist.dataProvider = groceryList;
Flist.itemRendererProperties.labelField = "text";
FeathersControl.defaultTextRendererFactory=function():ITextRenderer{
var render:TextFieldTextRenderer=new TextFieldTextRenderer();
render.textFormat = new TextFormat("Verdana",8,0xFFFFFF,false);
return render;
}
Flist.itemRendererFactory = function():IListItemRenderer //list.itemRendererProperties.accessorySourceField list.itemRendererFactory
{
var renderer:DefaultListItemRenderer = new DefaultListItemRenderer();
renderer.addEventListener(Event.TRIGGERED, onListTriggered);
return renderer;
}
}

Categories

Resources