Error loading Variables stage.loaderInfo - AS3 - variables

I have a Document class that loads variables from Facebook with the use of stage.loaderInfo
var connect:FacebookConnectObject = new FacebookConnectObject( facebook, API_KEY, this.stage.loaderInfo );
But when I change the Document class (with another one responsible for the layout of my app), and try call the above from a movieclip that exists in my application with the use:
var facebook_class:FacebookAp = new FaceBppkApp
addChild(facebook_class) I get error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
I believe the error comes fro this line
this.stage.loaderInfo
since I changed the scope...
How I am supposed to fix that?

According to a post by Devonair: Seems 99 times out of a 100 when people have a problem with a 1009 error, it's because the stage property is inaccessible.
so I used this snippet
public function start() {
if
{(stage) init();}
else
{ addEventListener(Event.ADDED_TO_STAGE, init);
}
}
private function init(event:Event = null):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
// everything else...
}
In case sb has the same problem...

Related

Vue.JS object attribute has 2 values

I'm working on a Vue.JS project and I'm facing a strange error.
I got a WidgetDTO object filled by an axios.get request, it contains a WidgetParametersDTO object and it's defined like so:
export class WidgetParametersDTO {
[...]
public coverage: number = 0;
public colorOK: string = "";
public colorKO: string = "";
public constructor(parameters: any) {
this.coverage = parameters.coverage
this.colorOK = parameters.colorOK;
this.colorKO = parameters.colorKO;
}
}
export class WidgetDTO {
[...]
public id: string = null!;
public parameters: WidgetParametersDTO = null!;
public constructor(widgetDTO: any) {
this.id = widgetDTO.id;
this.parameters = new WidgetParametersDTO(widgetDTO.parameters);
}
When I print the full object widget.parameters, all attributes are correct, when I use widget.parameters.colorOK or widget.parameters.colorKO it works properly, but if I try to use widget.parameters.coverage, it shows 0 instead of the value printed earlier.
The type is correct (number) and I already tried several things to ensure the presence and correctness of the data, it's only acting like that when I use the attribute directly.
There's even more, I'm using npm run dev to be able to hot reload the changes as things progress. When I change some code and save, it reloads the page and prints the right value, but not when I'm hitting F5.
I tried to build the files and run the server with npm start but it didn't work.
Any advice ?
Thanks.

Understanding cakephp3 error handling

I want to create a maintenance Page for my cake website by checking a Database Table for a maintenance flag using a sub-function of my AppController "initilize()" method. If the flag is set, i throw my custom MaintenanceException(Currently containing nothing special):
class MaintenanceException extends Exception{
}
To handle it, I implemented a custom App Exception Renderer:
class AppExceptionRenderer extends ExceptionRenderer {
public function maintenance($error)
{
return "MAINTENANCE";
}
}
I am able to see this maintenance Text on my website if I set my DB flag to true, but I could not find any information in cake's error handling documentation (http://book.cakephp.org/3.0/en/development/errors.html) on how I can actually tell the Exception renderer to render view "maintenance" with Template "infopage".
Can I even us that function using the ExceptionRenderer without a custom error controller? And If not, how should a proper ErrorController implementation look like? I already tried this:
class AppExceptionRenderer extends ExceptionRenderer {
protected function _getController(){
return new ErrorController();
}
public function maintenance($error)
{
return $this->_getController()->maintenanceAction();
}
}
together with:
class ErrorController extends Controller {
public function __construct($request = null, $response = null) {
parent::__construct($request, $response);
if (count(Router::extensions()) &&
!isset($this->RequestHandler)
) {
$this->loadComponent('RequestHandler');
}
$eventManager = $this->eventManager();
if (isset($this->Auth)) {
$eventManager->detach($this->Auth);
}
if (isset($this->Security)) {
$eventManager->detach($this->Security);
}
$this->viewPath = 'Error';
}
public function maintenanceAction(){
return $this->render('maintenance','infopage');
}
}
But this only throws NullPointerExceptions and a fatal error. I am really dissapointed by the cake manual as well, because the code examples there are nowhere close to give me an impression of how anything could be done and what functionality I actually have.
Because I had some more time today, I spent an hour digging into the cake Source and found a solution that works well for me (and is propably the way it should be done, altough the cake documentation does not really give a hint):
Step 1: Override the _template(...)-Method of the ExceptionRenderer in your own class. In my case, I copied the Method of the parent and added the following Code at the beginning of the method:
$isMaintenanceException = $exception instanceof MaintenanceException;
if($isMaintenanceException){
$template = 'maintenance';
return $this->template = $template;
}
This tells our Renderer, that the error Template called "maintentance"(which should be located in Folder: /Error) is the Error Page content it should render.
Step 2: The only thing we have to do now (And its is kinda hacky in my opinion, but proposed by the cake documentation in this exact way) is to set the layout param in our template to the name of the base layout we want to render with. So just add the following code on top of your error template:
$this->layout = "infopage";
The error controller I created is actually not even needed with this approach, and I still don't know how the cake error controller actually works. maybe I will dig into this if I have more time, but for the moment.

ActivityProfile rest call when using TinCanAPI to update a leaderboard in tetris example

I am trying to update my LMS to be TinCanAPI compliant and while I have been able to capture the statements for the beginning and the end of the Tetris Example game I have been unable to update the ActivityProfile calls to highscores as I am unsure as to what exactly is required to be returned.
I have the following WebAPI controller:
public class ActivitiesController : ApiController
{
private XAPIBiz xvm;
public ActivitiesController()
{
MetaLearning.Data.MetaLearningContext dbcontext = new MetaLearningContext(System.Configuration.ConfigurationManager.ConnectionStrings["MetaLearningContext"].ConnectionString);
xvm = new MetaLearning.Biz.XAPIBiz(dbcontext);
}
// GET api/activity/5
public string Get([FromUri]string profileId, [FromUri]string activityId)
{
return "[{actor:{name:John Paul}, score:9921, date:2014-04-07T14:42:46.492Z},{actor:{name:John Paul}, score:4000, date:2014-04-07T14:42:46.492Z}]";
//var test = profileId;
//var test2 = activityId;
//return "value";
}
.......
}
If I try to view the leaderboard when the course is hosted on Cloud.Scorm.Com then I am able to see the request to /activities/profile?profileId=highscores&activityId=http%3A%2F%2Ftincanapi.com%2FJsTetris_TCAPI
I get the response of
"[{actor:{name:John Paul}, score:9921, date:2014-04-07T14:42:46.492Z},{actor:{name:John Paul}, score:4000, date:2014-04-07T14:42:46.492Z}]"
But If I try to return just the string value of this for testing purposes I get a list of 137 undefined on the leaderboard.
If I return void in this controller action then the leaderboard appears blank.
If I save the text in this file as a json file and save to blob storage and then try to return a URI pointing to the file I get an undefined list of 66 names.
Any help in furthering my understanding of how the ActivityProfile API works would be greatly appreciated. What is the implementation on SCORM cloud?

How to access methods from a class based wordpress plugin?

I have a plugin which registers a post type, taxonomy and handles some business logic.
I went ahead and made my perfectly working plugin OO based and now it only works some of the time.
Its set-up like the following:
class Fruit {
public function __construct() {
add_action('init', array(&$this, 'init'));
}
public function init() {
$this->the_apple();
}
public function the_apple() {
return print $apple = 'my apple';
}
}
$fruit = new Fruit();
Then in taxonomy.php, withing the loop the following works:
$fruit->the_apple();
But once I use get_template_part with loop.php, this no longer works
$fruit->the_apple();
I get the following notice:
Notice: Undefined variable the_apple();
My fix was to use:
global $fruit;
and now it works all the time, just fyi about globals they get a bad rep. and there's namespacing issues, along with dumping everything into globals vs. using a registry.
In production i would never use the name $fruit, instead i would call it,
global $skylar_fruit;

Unable to resolve this Compilation Error in Flex builder 3

I am new Web App development using Flex Builder 3 and currently I am facing the following problem:
Attached is a code snippet from the mxml file:
<mx:Script>
<![CDATA[
import com.bx.Char10;
import com.bx.A;
[Bindable] private var inputParam:A = new A()
inputParam.CustNumber.char10 = '0123456789'
}
]]>
</mx:Script>
This Gives a compile error
1120 Access of undefined property inputParam
However if I replace
inputParam.CustNumber.char10 = '0123456789'
with
private function set():void
{
inputParam.CustNumber.char10 = '0123456789'
}
The compile error goes away.
My Question is :
How can I remove this Compilation Error without using the workaround I did?
Hmm, I don't believe that one can execute arbitrary statements directly inside a class body. (The "Script" tag's contents are treated as if they were directly inside the class body).
Only function definitions or variable property definitions are allowed.
A different work-around to use is to pass the information through the constructor of the variable property you're interested in.
[Bindable] private var inputParam:A = new A('0123456789')