Copy link to clipboard
Copied
hello all,
I need helping ASAP. I have been trying to create a game for Android mobile app for my class and i keep getting the below error message
”mobile game.swf-177739 bytes after decompression. I have NO IDEA what this means. I have tried creating it on both my Mac and Windows and the same error is coming up. I asked my teacher and she doesn't know either.
HELLLLLLLLP
Hi again.
Thanks.
I found out two issues in your project and after fixing them I was able to deploy to my Android phone.
Issues:
- Your code is referencing a statusMsg text field. But in your FLA the text field is called StatusMsg (with capital S). So I changed the text field name in the fla to statusMsg;
- Your JSON file is not human readable or corrupted. If you try to open it in a text editor like Visual Studio, you're gonna get a message telling you that it is either binary or uses an unsupported
...Copy link to clipboard
Copied
Hi.
This is not an error. It's just informing you the size of the exported SWF.
Regards,
JC
Copy link to clipboard
Copied
thank you, however, my game questions wont populate/ do you know how I can correct this?
Copy link to clipboard
Copied
Is there any error being shown in the Window > Compiler Errors panel (Option/Alt + F2) or in the Window > Output panel (F2)?
Copy link to clipboard
Copied
No, that is the only thing that it says.
Copy link to clipboard
Copied
Can you post a link to your FLA? Because we need to see your code.
Copy link to clipboard
Copied
how do you post a link?
Quiz Game
package com.josephlabrecque {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.display.SimpleButton;
import flash.events.Event;
import com.josephlabrecque.QuestionBank;
import flash.events.MouseEvent;
import flash.utils.setTimeout;
public class QuizGame extends MovieClip {
public var trueBtn:SimpleButton;
public var falseBtn:SimpleButton;
public var questionText:TextField;
public var statusMsg:TextField;
private var questionBank:QuestionBank;
private var questionArray:Array;
private const questionMax:int = 5;
private var questionCount:int = 0;
private var currentAnswer:String;
private var currentScore:int = 0;
public function QuizGame() {
statusMsg.text = "";
questionArray = new Array();
questionBank = new QuestionBank();
questionBank.addEventListener(Event.COMPLETE, dataReady);
trueBtn.addEventListener(MouseEvent.CLICK, truePressed);
falseBtn.addEventListener(MouseEvent.CLICK, falsePressed);
}
private function truePressed(e:MouseEvent):void {
if(statusMsg.text == ""){
if(currentAnswer == "true"){
currentScore += 100/questionMax;
statusMsg.text = "CORRECT!";
}else{
statusMsg.text = "WRONG";
}
setTimeout(newQuestion, 1000);
}
}
private function falsePressed(e:MouseEvent):void {
if(statusMsg.text == ""){
if(currentAnswer == "false"){
currentScore += 100/questionMax;
statusMsg.text = "CORRECT!";
}else{
statusMsg.text = "WRONG";
}
setTimeout(newQuestion, 1000);
}
}
private function dataReady(e:Event):void {
questionArray = questionBank.buildBank();
grabQuestion();
}
private function newQuestion():void {
statusMsg.text = "";
trace(currentScore);
grabQuestion();
}
private function grabQuestion():void {
if(questionCount < questionMax){
var max:int = questionArray.length-1;
var rq:int = Math.floor(Math.random() * (max - 0 + 1));
var ta:Array = questionArray.splice(rq, 1);
questionText.text = ta[0].q;
currentAnswer = ta[0].tf;
questionCount++;
}else{
gameOver();
}
}
private function gameOver():void {
statusMsg.text = currentScore+"/100 points";
questionText.text = "Game Over!";
}
}
}
Question Bank
package com.josephlabrecque {
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.Event;
import flash.events.EventDispatcher;
public class QuestionBank extends EventDispatcher {
private const JSON_URL: String = "data/questions.json";
private var jsonRequest: URLRequest;
private var jsonLoader: URLLoader;
private var questionArray: Array;
public function QuestionBank() {
questionArray = new Array();
loadJSON();
}
private function loadJSON(): void {
jsonRequest = new URLRequest(JSON_URL);
jsonLoader = new URLLoader();
jsonLoader.addEventListener(Event.COMPLETE, jsonLoaded);
jsonLoader.load(jsonRequest);
}
private function jsonLoaded(e: Event): void {
var jsonData: Object = JSON.parse(e.target.data);
for each(var question: Object in jsonData.questions) {
questionArray.push(question);
}
dispatchEvent(new Event(Event.COMPLETE));
}
public function buildBank(): Array {
var b: Array = new Array();
var max: int = questionArray.length;
for (var i: int = 0; i < max; i++) {
b.push({
q: questionArray.q,
tf: questionArray.tf
});
}
return b;
}
}
}
Copy link to clipboard
Copied
Hi. Thanks.
But can you share the actual FLA? You can upload it to Google Drive, Dropbox, WeTransfer, One Drive, or another file sharing service of your choice and post the link here.
But before investigating your file, I see that you're loading a JSON file. Are you including the JSON file in the AIR properties?
Copy link to clipboard
Copied
No, I never knew I had to upload this file there. I never got to the publish part I just kept doing test as that’s how the book did it. So was I supposed to do this after I wrote all of the code?
Copy link to clipboard
Copied
You can do this at any moment. You can do this now.
It's because if you don't do this, Animate CC won't include the JSON file in the app directory/bundle.
Also mobile platforms are not like desktop platforms. You can't just put your files anywhere and save/load them from any place.
You have specific folders that you're allowed to access.
Copy link to clipboard
Copied
Okay, I just loaded the file and still nothing. Stand by and I will upload them to google dropbox
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I just posted the link
Copy link to clipboard
Copied
Hi again.
Thanks.
I found out two issues in your project and after fixing them I was able to deploy to my Android phone.
Issues:
- Your code is referencing a statusMsg text field. But in your FLA the text field is called StatusMsg (with capital S). So I changed the text field name in the fla to statusMsg;
- Your JSON file is not human readable or corrupted. If you try to open it in a text editor like Visual Studio, you're gonna get a message telling you that it is either binary or uses an unsupported text encoding. So I created a temp JSON file called questions_temp.json to test the game.
Another thing I had to do was to include the data folder that contains the JSON files like I described in comment #7.
Here is a link with the corrected files and structure, and also with an APK if you want to test in a Android device right away.
PierreLawsonGame.zip - Google Drive
I hope this helps.
Regards,
JC
Copy link to clipboard
Copied
Oh wow, I truly appreciate it, I didn't realize that I messed up so much. I will try it now. Thank you so much.