I have a project in Flash and I use a webserver with some data. I read that information (json) with:
var url:String = "URL REQUEST";
var request:URLRequest = new URLRequest(url);
var loader:URLLoader = new URLLoader();
loader.load(request);
and I use that information in a TextField. This works fine and show my data properly. But, when I publish my work or open the file .swf doesn't show the data.
Inside the Adobe Flash works fine.
Outside doesn't work.
I have a raspberry pi with a service in nodeJS running. The door is open in the router.
My nodeJS
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:true}));
const port = process.env.PORT || 3001;
const SERVER_ROOT = "http://localhost:" + port;
var messages = {};
messages["a1"] = blablabla;
--
messages["n"] = blablabla;
function buildMessage(newID, text, user){
const now = new Date();
return {
};
};
app.route("/message")
.get(function(req, res) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.json(messages);
});
app.param('messageID', function(req, res, next, messageID){
req.messageID = messageID;
return next();
})
app.listen(port, function() {
console.log("Listening on " + port);
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…