All posts by Social marketing master

making a JSON from multiple input with angularjs

i’m new with ionic ,angular and firebase. this is maybe a ridiculous question :)

i’m working with ionic + firebase to make an app, i want to make a JSON from multiple input. i have an interface like below ( image).

enter image description here

what should i do to make a JSON from ‘Menu’ as key and ‘Price’ as value.
on the image above is show unexpected result, the result must be like this

[{"yakiniku":"2000","ramen":"1200"}]

View

<div class="row">
    <div class="col">
      <div class="item item-divider">
        Menu
      </div>
      <label class="item item-input">
        <input type="text" ng-model="menu_resto[0].menu1" name="menu_resto[]" placeholder="Menu">
      </label>
      <label class="item item-input">
        <input type="text" ng-model="menu_resto[1].menu2" name="menu_resto[]" placeholder="Menu">
      </label>
    </div>
    <div class="col">
      <div class="item item-divider">
        Price
      </div>
      <label class="item item-input">
        <input type="text" ng-model="menu_resto[0].price1" name="menu_resto[]" placeholder="Price">
      </label>
      <label class="item item-input">
        <input type="text" ng-model="menu_resto[1].price2" name="menu_resto[]" placeholder="Price">
      </label>
    </div>
  </div>
  {{menu_resto}}

read more

making a JSON from multiple input with angularjs

i’m new with ionic ,angular and firebase. this is maybe a ridiculous question :)

i’m working with ionic + firebase to make an app, i want to make a JSON from multiple input. i have an interface like below ( image).

enter image description here

what should i do to make a JSON from ‘Menu’ as key and ‘Price’ as value.
on the image above is show unexpected result, the result must be like this

[{"yakiniku":"2000","ramen":"1200"}]

View

<div class="row">
    <div class="col">
      <div class="item item-divider">
        Menu
      </div>
      <label class="item item-input">
        <input type="text" ng-model="menu_resto[0].menu1" name="menu_resto[]" placeholder="Menu">
      </label>
      <label class="item item-input">
        <input type="text" ng-model="menu_resto[1].menu2" name="menu_resto[]" placeholder="Menu">
      </label>
    </div>
    <div class="col">
      <div class="item item-divider">
        Price
      </div>
      <label class="item item-input">
        <input type="text" ng-model="menu_resto[0].price1" name="menu_resto[]" placeholder="Price">
      </label>
      <label class="item item-input">
        <input type="text" ng-model="menu_resto[1].price2" name="menu_resto[]" placeholder="Price">
      </label>
    </div>
  </div>
  {{menu_resto}}

read more

Tween move and changing direction

I’m attempting to make a ball drop down on stage and then changing direction upon impact of another object. In this scenario the ball falls on a slide and suppose to roll down the slide to the bottom of the stage. however before it continue down the slide, it jumps to another location and then slides down. I can’t put my finger on the problem. Also I want it to stop at the bottom left and not the center. Can you help me figuring it out?

Below is the code and a Gif that demonstrate the problem. I’m using BitmapData hitTest event listener to generate the impact effect. and I’m using localToGlobal variable to find the location of the ball to use in the tween for changing direction.

import fl.transitions.Tween;
import fl.transitions.easing.*;

var blueClip: objct2 = new objct2();
addChild(blueClip);
//blueClip.x = 196;
//blueClip.y = 73;

var tweenY: Tween = new Tween(blueClip, "y", Regular.easeIn, 73, 0, 0, false);
var tweenX: Tween = new Tween(blueClip, "x", Strong.easeIn, 196, 0, 0, false);

var redRect: Rectangle = redClip.getBounds(this);
var redClipBmpData = new BitmapData(redRect.width, redRect.height, true, 1);
redClipBmpData.draw(redClip);


var blueRect: Rectangle = blueClip.getBounds(this);
var blueClipBmpData = new BitmapData(blueRect.width, blueRect.height, true, 1);
blueClipBmpData.draw(blueClip);

Button.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event: MouseEvent): void {
  var tweenY: Tween = new Tween(blueClip, "y", Regular.easeIn, 100, 400, 1, true);

  addEventListener(Event.ENTER_FRAME, enterFrame);
}

function enterFrame(e: Event): void {

  if (redClipBmpData.hitTest(new Point(redClip.x, redClip.y),
  255,
  blueClipBmpData,
  new Point(blueClip.x, blueClip.y),
  255
  )) {
  var yourMC: DisplayObject = blueClip;
  var point1: Point = yourMC.localToGlobal(new Point(yourMC.getRect(yourMC).x, yourMC.getRect(yourMC).y));
  var point2: Point = yourMC.localToGlobal(new Point(yourMC.getRect(yourMC).x + yourMC.getRect(yourMC).width, yourMC.getRect(yourMC).y + yourMC.getRect(yourMC).height));

  var alef: Number = point1.x; //x position of the object.
  var bet: Number = point1.y; //y position of the object.
  //var gimel: Number = point2.x - point1.x; //width of the object.
  //var daled: Number = point2.y - point1.y; //height of the object.

redClip.filters = [new GlowFilter()];
  var tweenY: Tween = new Tween(yourMC, "y", Regular.easeIn, alef, 392, 1, true);
  var tweenX: Tween = new Tween(yourMC, "x", Regular.easeIn, bet, 0, 1, true);
  //tweenY.stop();
  trace("hit");
  trace("x" + alef);
  trace("y" +  bet);


  } else {
  redClip.filters = [];
  //trace("miss");
  }
}
tweenY.stop();


trace(tweenY.stop);
stop();

read more

Tween move and changing direction

I’m attempting to make a ball drop down on stage and then changing direction upon impact of another object. In this scenario the ball falls on a slide and suppose to roll down the slide to the bottom of the stage. however before it continue down the slide, it jumps to another location and then slides down. I can’t put my finger on the problem. Also I want it to stop at the bottom left and not the center. Can you help me figuring it out?

Below is the code and a Gif that demonstrate the problem. I’m using BitmapData hitTest event listener to generate the impact effect. and I’m using localToGlobal variable to find the location of the ball to use in the tween for changing direction.

import fl.transitions.Tween;
import fl.transitions.easing.*;

var blueClip: objct2 = new objct2();
addChild(blueClip);
//blueClip.x = 196;
//blueClip.y = 73;

var tweenY: Tween = new Tween(blueClip, "y", Regular.easeIn, 73, 0, 0, false);
var tweenX: Tween = new Tween(blueClip, "x", Strong.easeIn, 196, 0, 0, false);

var redRect: Rectangle = redClip.getBounds(this);
var redClipBmpData = new BitmapData(redRect.width, redRect.height, true, 1);
redClipBmpData.draw(redClip);


var blueRect: Rectangle = blueClip.getBounds(this);
var blueClipBmpData = new BitmapData(blueRect.width, blueRect.height, true, 1);
blueClipBmpData.draw(blueClip);

Button.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event: MouseEvent): void {
  var tweenY: Tween = new Tween(blueClip, "y", Regular.easeIn, 100, 400, 1, true);

  addEventListener(Event.ENTER_FRAME, enterFrame);
}

function enterFrame(e: Event): void {

  if (redClipBmpData.hitTest(new Point(redClip.x, redClip.y),
  255,
  blueClipBmpData,
  new Point(blueClip.x, blueClip.y),
  255
  )) {
  var yourMC: DisplayObject = blueClip;
  var point1: Point = yourMC.localToGlobal(new Point(yourMC.getRect(yourMC).x, yourMC.getRect(yourMC).y));
  var point2: Point = yourMC.localToGlobal(new Point(yourMC.getRect(yourMC).x + yourMC.getRect(yourMC).width, yourMC.getRect(yourMC).y + yourMC.getRect(yourMC).height));

  var alef: Number = point1.x; //x position of the object.
  var bet: Number = point1.y; //y position of the object.
  //var gimel: Number = point2.x - point1.x; //width of the object.
  //var daled: Number = point2.y - point1.y; //height of the object.

redClip.filters = [new GlowFilter()];
  var tweenY: Tween = new Tween(yourMC, "y", Regular.easeIn, alef, 392, 1, true);
  var tweenX: Tween = new Tween(yourMC, "x", Regular.easeIn, bet, 0, 1, true);
  //tweenY.stop();
  trace("hit");
  trace("x" + alef);
  trace("y" +  bet);


  } else {
  redClip.filters = [];
  //trace("miss");
  }
}
tweenY.stop();


trace(tweenY.stop);
stop();

read more