Author Topic: Using Flixel 2.55 and Mochi Live Updates  (Read 2454 times)

MRKSTWRT

  • Active Member
  • ***
  • Posts: 116
  • Karma: +0/-0
    • View Profile
Using Flixel 2.55 and Mochi Live Updates
« on: Tue, Sep 6, 2011 »
Okay after a bit of fiddling tonight I got this to work. The source Flash Develop project is located here https://github.com/MRKSTWRT/Live-Updates-Example and compiles to:

<a href="http://www.mrkstwrt.com/LiveUpdatesExample.swf" target="_blank" rel="noopener noreferrer" class="bbc_link bbc_flash_disabled new_win">http://www.mrkstwrt.com/LiveUpdatesExample.swf</a>

The main thing you need to be looking at is liveUpdates.as:

Code: [Select]
package {

import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.events.Event;
import flash.utils.getDefinitionByName;

[SWF(width = "400", height = "300", backgroundColor = "#000000")]

public dynamic class liveUpdates extends Sprite
{
public function liveUpdates():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}

private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);

Main; //Change to your FlxGame class
var mainClass:Class = Class(getDefinitionByName("Main")); //Change this one too
if(mainClass)
{
var app:Object = new mainClass();
addChild(app as DisplayObject);
}
}
}
}

Basically just had to get rid of the preloader stuff and the [Factory(frame=...] line.

This can be used out of the box if you'd like, all you need to do is change both instances of "Main" in liveUpdates.as to the name of your FlxGame class and make sure you have:

Code: [Select]
var _mochiads_game_id:String = "YOUR_GAME_ID";

somewhere in your game (obviously with your game ID from the mochi dashboard instead).

Note: I'm just a hobbyist programmer and this might be a bit hackish so I'd love for some of the more experienced guys here to give some feedback and see if this can be improved, seems to work for my current project though.
« Last Edit: Tue, Sep 6, 2011 by MRKSTWRT »

dkwmfkdof

  • Member
  • **
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Using Flixel 2.55 and Mochi Live Updates
« Reply #1 on: Wed, Jan 18, 2012 »
wow! thanks your open source and guideline!!! so usefullllllllllllllll  :-*

Esti

  • Active Member
  • ***
  • Posts: 104
  • Karma: +0/-0
    • View Profile
Re: Using Flixel 2.55 and Mochi Live Updates
« Reply #2 on: Mon, Oct 15, 2012 »
Thanks!, this works like a charm.

Check it out on Mochi!

axcho

  • Active Member
  • ***
  • Posts: 174
  • Karma: +0/-0
    • View Profile
    • Evolution Live!
Re: Using Flixel 2.55 and Mochi Live Updates
« Reply #3 on: Mon, Oct 15, 2012 »
Thanks for sharing. This is something I've also had to deal with a number of times.

If you want to use various APIs through Mochi Live Updates (which is a bit of a hassle normally), you can use my handy FlxAPI plugin, with built-in support for Mochi, Kongregate, Newgrounds, and Playtomic APIs:
https://github.com/axcho/The-Love-Letter/blob/master/src/org/flixel/plugin/axcho/FlxAPI.as