I am an artist, not a programmer, but I’ve been creating Flash sites for years and I am trying to move some my work over to iPhone.
( heres one of my sites: http://www.pima.gov/sdcp/Exploratorium/index.html )
At first, I first got several books on Objective C Programming and iPhone Development, and soon realized that I could learn Mandarin Chinese faster than I could learn all this. After all, I want to create Apps, and not spend years lost in the arcane world of C Programming.
I’ve found that Corona is the perfect fit for me. Lua is fairly easy and I’m already working on some pretty cool apps (soon to be published) with just the code I’ve picked up here from the Sample Code, the Ansca Forums and the Corona Programming Guide, - but I’m not really understanding how some Flash actionscript programming relates to Lua.
For instance: What is the Lua equivalent of a flash movie clip? How do you create a Lua movie clip and embed movie clips within movie clips like you do in Flash, or reference Flash type timelines in Lua? Is there a straightforward way to translate actionscript 2 to Lua? I need some sort of Rosetta stone to help me out here. Any help will be greatly appreciated.
Thanks. [import]uid: 2862 topic_id: 262 reply_id: 300262[/import]
For instance, here is a Flash example:
http://www.billsingleton.net/snow/snow.html
Below is the actionscript for the .fla file.
How would you translate it into Lua?
//code in the symbol:
onClipEvent (load) {
movieWidth = 576;
movieHeight = 622;
i = 1+Math.random()*2;
k = -Math.PI+Math.random()*Math.PI;
this._xscale = this._yscale=50+Math.random()*100;
this._alpha = 75+Math.random()*100;
this._x = -10+Math.random()*movieWidth;
this._y = -10+Math.random()*movieHeight;
}
onClipEvent (enterFrame) {
rad += (k/180)*Math.PI;
this._x -= Math.cos(rad);
this._y += i;
if (this._y>=movieHeight) {
this._y = -5;
}
if ((this._x>=movieWidth) || (this._x<=0)) {
this._x = -10+Math.random()*movieWidth;
this._y = -5;
}
}
//code on the timeline:
for (k=0; k<50; k++) {
duplicateMovieClip(this.snow, “snow”+k, k);
}
[import]uid: 2862 topic_id: 262 reply_id: 332[/import]
Another artist looking for similar advice - looking forward to an answer as well… [import]uid: 4258 topic_id: 262 reply_id: 486[/import]
soclean, look in the Sample Code Forum for some answers to this post - DGuy & Freshworks have been kind enough to help. [import]uid: 2862 topic_id: 262 reply_id: 488[/import]
Is there anything still out there for this? An example of Flash Action Script (2) to Lua would be really really helpful for comparison.
Thanks!! [import]uid: 6319 topic_id: 262 reply_id: 2088[/import]
I try to convert your code to lua but It’s not OO like your java script
local w,h = display.stageWidth, display.stageHeight
local seed = os.time()
math.randomseed(seed)
local collection = {}
local function random()
return math.random(1,9)/10
end
local function newLeaf()
local leaf = display.newImage("leaf.png",
(-10)+random()\*w,
(-10)+random()\*h)
leaf["rad"] = 0
leaf["i"] = 1+random()\*2
leaf["k"] = -math.pi+random()\*math.pi
leaf.x = -10 + random() \* w
leaf.y = -10 + random() \* h
leaf:rotate(random()\*100)
return leaf
end
for i = 1, 20 do
collection[i] = newLeaf()
end
function collection:enterFrame( event )
for \_, leaf in ipairs(collection) do
leaf["rad"] = leaf["rad"] + (leaf["k"]/180)\*math.pi;
leaf.x = leaf.x - math.cos(leaf["rad"]);
leaf.y = leaf.y + leaf["i"];
if leaf.y \>= h then
leaf.y = -5;
end
if ((leaf.x \>= w) or (leaf.x \<= 0)) then
leaf.x = -10+ random()\*w
leaf.y = -5
end
end
end
Runtime:addEventListener( "enterFrame", collection );
[import]uid: 6421 topic_id: 262 reply_id: 2347[/import]
Before you get all excited and think im going to say there is a flash lua i would like to say there isnt but. what im going to say that it would be good if there was a one, I also thought that maybe there is a chance to run lua or other code from the internet browser. There also maybe a chance of being able to use the internet browser to access code seing as you can access photos and music. People probally think im talking a load of bollocks people may think im onto something but whatever your opinion is i would like to hear it.
Website Design London
Web Design London
[import]uid: 8167 topic_id: 262 reply_id: 4790[/import]
This is really an informative post. [import]uid: 8167 topic_id: 262 reply_id: 4791[/import]