2015-05-08 29 views
0

我正在使用Flash和ActionScript 3编写移动应用程序,并且正在寻找使用后端数据库填充页面。使用数据库填充包含信息的移动应用程序

这是一张图像,解释了我想要填充的内容。

App Screen

我已经在ActionScript从对C库使这个页面,并要求在图像中,然后我做了一个动态文本字段,A,B和D

不过,我想最好喜欢为15种不同的汽车(G Wagon只是其中之一)分别提供信息“负载”,然后通过汽车选择屏幕将您引导至此页面。

我有权访问一个我可以使用的数据库,但是我在初学者级别上,并且不知道1.如何将我想要填充到数据库中的信息以及2.如何将数据库连接到我的应用程序

Database

所以原始图像中存在的信息的4位将被从数据库中取得的应用程序。这些屏幕中有15个都具有不同的图像和信息。

如果有人可以给我一些帮助,我会非常感激!

谢谢!


这是我用来构建上述屏幕截图的代码。

package com.james.mercedes //Location of the package! 
{ 

import flash.display.MovieClip; 

import flash.display.Stage; 

import flash.display.StageAlign; 

import flash.display.StageScaleMode; 

import flash.display.StageQuality; 

import flash.display.SimpleButton; 

import flash.events.Event; 

import flash.events.TextEvent; 

import flash.text.*; 

//import assets from the library 
import Background; 
import CarImage; 
import BackButton; 
import CarName; 
import CarDescription; 
import InformationTable; 
//import CarNameText; 
//import CarDescriptionText; 
//import InformationTableTitleText; 

//import classes in our package 
//import com.james.mercedes; 
import flash.events.MouseEvent; 

//Background color of the stage 
[SWF(backgroundColor="0x000000")] 
//chosen the actionscript file 
public class carInfo extends MovieClip 
{ 

//make an instance of the asset 
private var background:MovieClip = new Background(); 
private var carImage:MovieClip = new CarImage(); 
private var backButton:MovieClip = new BackButton(); 
private var carName:MovieClip = new CarName(); 
private var carDescription:MovieClip = new CarDescription(); 
private var informationTable:MovieClip = new InformationTable(); 
//private var carNameText:MovieClip = new CarNameText(); 
//private var carDescriptionText:MovieClip = new CarDescriptionText(); 
//private var informationTableTitleText:MovieClip = new InformationTableTitleText(); 

var CarNameText: TextField = new TextField; 


//main file to set up application 
public function carInfo() 
{ 

//wait for the stage to load before doing any calculations - good practice 

addEventListener(Event.ADDED_TO_STAGE, init) 

} 
function init(e:Event):void 
{ 

//trace(" Here "); 

//setup stage for mobile device 

stage.align = StageAlign.TOP_LEFT; 

//doesn't shrink or enlarge (no_scale) 
stage.scaleMode = StageScaleMode.NO_SCALE; 

stage.quality = StageQuality.HIGH; 


//call upon a public class of static variables (refer to folder structure to  locate Constants.as) 

stage.stageWidth = Constants.SCREEN_WIDTH; 

stage.stageHeight = Constants.SCREEN_HEIGHT; 


//add the linked instance from library to the stage 

addChild (background); 
addChild (carImage); 
addChild (backButton); 
addChild (carName); 
addChild (carDescription); 
addChild (informationTable); 
addChild (carNameText); 
addChild (carDescriptionText); 
addChild (informationTableTitleText); 

//scale accordingly before positioning it 


//background.scaleX *= Constants.SCREEN_SCALE; 

//background.scaleY *= Constants.SCREEN_SCALE; 


//position to a fixed x and y 


background.x = 0; 
background.y = 0; 

carImage.x = 0; 
carImage.y = 0; 

backButton.x = 18.30; 
backButton.y = 19.90; 

carName.x = 194.55; 
carName.y = 378.85; 

carDescription.x = 12.55; 
carDescription.y = 432.65; 

informationTable.x = 47.55; 
informationTable.y = 833.65; 

carNameText.x = 204.90; 
carNameText.y = 370.40; 

carDescriptionText.x = 43.85; 
carDescriptionText.y = 453.90; 

informationTableTitleText.x = 168.85; 
informationTableTitleText.y = 806.20; 


} 


} 

} 
+0

这有点宽泛。你有任何数据库经验?据推测你正在使用AIR?您可以使用本地SQL数据库或XML文件或序列化数据文件(如果您的数据库只是数据的静态转储),或者(假设您希望某个管理员可以更新数据库)访问某种类型的Web服务数据库并将数据发送到应用程序。如果你不想写自己的东西,就像Azure移动服务一样 – BadFeelingAboutThis

+0

对不起,我的坏哈哈我只是上个月左右这个数据库的东西很新。 是的我正在使用AIR for iOS。 这3个选项中的哪一个,本地SQL,CML或序列化数据文件最容易实现? 第一次发布后,数据不需要更新。 – user1888478

+0

XML可能是最简单的。您可以在任何文本编辑器中轻松更改它,并且很容易从XML文件解析AS3中的数据。如果你可以用你用来填充你的屏幕截图的代码来更新你的问题,这将有助于人们制定一个答案。 – BadFeelingAboutThis

回答

0

通常,应用程序(任何AIR或swf应用程序)可以通过常规表单POST(如html表单)将数据发送到后端。该应用程序还可以加载一个PHP页面并阅读其内容。所以应用程序POST数据到一个PHP页面并加载它的响应(XML)。您应始终使用XML将数据从后端发送到应用程序 - 封装它们(RESTful)。

或者你可以传递数据到PHP中的URL(查询字符串)并加载响应。

示例:getCars.php?sMake = Ford = sModel = Explorer - getCars.php可以使用sMake和sModel在xml中查询和写入结果。该应用程序加载xml。

所以您的XML看起来像:

<items> 
    <item> 
     <itemName>![CDATA[<G Wagon]]></itemName> 
     <itemDescription><![CDATA[The Mercedes-Benz G-Class or ...]]></itemDescription> 
     <itemPic>![CDATA[../images/pic_g_wagon.jpg]]></itemPic> 
    </item> 
</items> 

你会发现吨的代码示例,这样做喜欢写作的每个部分和解析XML或处理与PHP的帖子。

republicofcode.com有很多关于XML解析等基础知识的教程。

gotoandlearn.com有更高层次的视频教程。

相关问题