mardi 25 avril 2017

Adobe AIR call SoftKeyboardType Phone IOS

is it possible to call phone (not number but phone) keyboard from adobe air on ipa IOS? or is there any ANE?

enter image description here

How to load a SharedObject from another Swf file in actionScript 3.0

This code works, but when I put the loadBtn and the function 'loadNames' in another swf file, the program traces this: "saved names: undefined", in addition I'd like to specify the path of the object saved:how can i do that?

var SO:SharedObject=SharedObject.getLocal("mySave");

var archive:Array=new Array(); var counter:Number=-1;

saveBtn.addEventListener(MouseEvent.CLICK, saveName); loadBtn.addEventListener(MouseEvent.CLICK, loadNames);

function saveName(event:Event) {

counter++;

archive[counter]=input.text;

SO.data.arrSaved=archive;

SO.flush();

}

function loadNames(event:Event) {

trace("saved names: "+SO.data.arrSaved);

}

How do I overwrite a delay in TweenMax?

I am working in actionscript 3 using a Greensock TweenMax timeline. I have a one page scroller with two buttons (back to the top, and stop/play button). The scroller automatically plays onLoad with a delay of 4 seconds. When I press stop/play button, it doesn't stop the delay. I have to wait the full four seconds before it functions. Also the 4 second delay only happens when the scroller runs for the first time. How can I get the 4 second delay to happen everytime the scroller repeats? How can I get the stop/play button to override the delay and play? I have worked on this for two days, and tried various techniques (for loops, timers, delayed calls, etc.) with no success. If anyone has ideas I will greatly appreciate it.

1) Code that starts the timeline:

myTween = new TweenMax(content_mc, 60, {delay:4, y:22, ease: Power0.easeNone, onComplete: restartFromTop });

2) This function controls the stop/play button

    private function toggler(e:MouseEvent = null):void 
    {           

           if (playState == true){  
           toggleBtn.gotoAndStop(2);
           myTween.pause();
           playState = false;
           trace("MC is now paused and stopped");
        }

           else if(playState == false) {
           myTween.resume();
           toggleBtn.gotoAndStop(1);
           playState = true;
           trace("MC is resumed from pause");  
        }
    }

3) This function controls the restarting of the scroller when it repeats.

private function restartFromTop():void 
        {       
            myTween.restart()
            playState = true;
        }

4) This function controls the back to the top button

private function backToTop(event:MouseEvent):void 
        {
            myTween.reverse();

            if (playState == true){
                myTween.restart();
                myTween.resume();//stop animation
                //toggleBtn.gotoAndStop(2);//changes button to pause
                toggleBtn.buttonMode = true;
                trace("page is scrolling");
            }

            if (playState == false){
                myTween.restart();
                myTween.pause();//stop animation
                trace("play button is paused");
                trace(timer);
            }

//Adds a hand cursor on the button and adds a click event to the button. 
            toggleBtn.buttonMode = true;
            toggleBtn.addEventListener(MouseEvent.CLICK, toggler);
        }

actionscript 3 when i click on object to go to another scene

I am designing a simple drag and drop dressing game I have two classes first on is DragDrop class that I assigned for dressing objects and back class that I assigned for back button that return me to main scene.

The problem that when I start drag object and drop it and press back button I get an error saying :

"TypeError: Error #1009: Cannot access a property or method of a null object reference.

and the objects that I dragged and dropped move to the main scene at

Dressing_fla::MainTimeline/frame1()[Dressing_fla.MainTimeline::frame1:61]
at flash.display::MovieClip/gotoAndPlay()
at Dressing_fla::MainTimeline/fl_ClickToGoToScene_12()[Dressing_fla.MainTimeline::frame2:15]"

I don't know what is the problem

DragDrop class:

package  {
        import flash.display.*;
        import flash.events.*;
        public class DragDrop extends Sprite {

        public function DragDrop() {
                this.addEventListener(MouseEvent.MOUSE_DOWN,drag);
        }

        function drag(evt:MouseEvent):void{
            stage.addEventListener(MouseEvent.MOUSE_UP,drop);               
            this.startDrag();
            parent.addChild(this);


        }

        function drop(evt:MouseEvent):void{

            this.stopDrag();
            stage.removeEventListener(MouseEvent.MOUSE_UP,drop);

        }           
      }

  }

Back class:

package  {
import flash.display.*;
import flash.events.*;  
public class Back extends Sprite  {

    public function Back() {
        this.addEventListener(MouseEvent.CLICK,clicked);
    }

    function clicked(evt:MouseEvent):void{


        MovieClip(this.root).gotoAndPlay(1, "main");

       }



    }

 }

the game is here

Import flash.net.SecureSocket throwing error "Definition XXX could not be found"

My requirement is to make connection using SSL and TLS from my flexbuilder AS code. I google it and found that SecureSocket() will be used to communicate with SSL and TLS from the below url,

http://ift.tt/1QulXAn

While trying to implement the same in my code, I am not able to import the namespace SecureSocket (import flash.net.SecureSocket;) and while referring it throws the error as "Definition flash.net.SecureSocket could not be found"

FYI - I'm using Flex Builder version 3

Please advice

lundi 24 avril 2017

How to stop a movable object (which moves via the arrow keys) from going off the stage in Adobe Flash Professional CS6 Action Script 3.0

Hey I'm currently creating a game in Adobe Flash Professional CS6. I have a character, with an instance name of "alien". So far, I've only been able to code my game so that the alien can't go off the top or left sides of the stage. I can't figure out how to code it so that the alien can't go off the bottom or right sides of the stage. The coding I have is as follows:

if((alien.x) < (alien.width/2)){
      alien.x += 10;
}
if((alien.y) < (alien.width/2)){
      alien.y += 10;
}

Thank you for your time.

how to save different arrays in a DB and load them

In few words, I'm building an application divided in two parts: in the first part, I can create an array of display Objects and it should be saved somewhere, for example in a database. In the second I've the possibility to load all the arrays saved in the database and to see them. I'm searching a solution to store the arrays, firstly giving them an Id, and second storing them on a server, or in local if it seems to much complicated. I've thought to use the class shared Object, but i don't know perfectly how it works. I've also tried without success to save the array, but i really don't know how to use this class, thanks

Color Picker using camera in Adobe flash

Someone can help me make android apps, how to make color picker take color from camera with action script 3.0?, i really hope someone can help me, thanks

hitTestObject with arrays, loops and if statements

I have the minion running after the bananas and it's being controlled by the arrow keys. I also have a life bar and I keep track of it based on if the minion drops the bananas. The problem that I have right now is that when a banana (from the array) hits the ground, my life bar drops entirely. I would like it to have it decreased gradually with each banana that hits the ground. I tried using a dispatch event but it doesn't work.

This is what I have in the main program:

 import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.events.Event;

var leftKey:Boolean;
var rightKey:Boolean;
var upKey:Boolean;
var downKey:Boolean;
var jump:Boolean = false;
var xvelocity:int = 9;
var yvelocity:int = 3;
var gravity:Number = 7;

stage.addEventListener(Event.ENTER_FRAME, changeVelocity);
stage.addEventListener(KeyboardEvent.KEY_UP, checkKeyUp);
stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKeyDown);

  function changeVelocity(evt:Event){
        moveMinion();
        yvelocity += gravity;
    }

    function moveMinion(){

        if (leftKey == true){
           sideMinion.x -= xvelocity;
            sideMinion.left();

        }
        if (rightKey == true){
            sideMinion.x += xvelocity;
            sideMinion.right();
        }
    }

    function checkKeyDown(e:KeyboardEvent){
        if (e.keyCode == Keyboard.LEFT){
            leftKey = true;
        }
        else if (e.keyCode == Keyboard.RIGHT){
            rightKey = true;
        }

    }

    function checkKeyUp(e:KeyboardEvent){
        if (e.keyCode == Keyboard.LEFT){
            leftKey = false;
        }
        else if (e.keyCode == Keyboard.RIGHT){
            rightKey = false;
            }
    }

    btnStart.addEventListener(MouseEvent.CLICK, makeItFall);

    function makeItFall(e:MouseEvent){
    var numBananas = 6;
    var theBananas: Array = new Array();
    theBananas = [];
    for (var i = 0; i < numBananas; i++) {
    var aBanana: banana = new banana();
    theBananas.push(aBanana);
    btnStart.visible=false;
    aBanana.y=100;
    theBananas[i].setSpot(Math.random()*450,Math.random()*200);
    theBananas[i].setSpeed((Math.random()), 1);
    stage.addChild(aBanana);

}   

var health: Number= 100;
var healthPercent: Number= 1;
var lives:Event= new Event("lifeDrops")

addEventListener(Event.ENTER_FRAME, pickUpBananas);

function pickUpBananas(event:Event){

    for (var i:int = theBananas.length-1; i>-1; i--){

            if (sideMinion.hitTestObject(theBananas[i])){
                stage.removeChild(theBananas[i]);
                theBananas.splice(i,1);

        }

            if (info.hitTestObject(theBananas[i])){
            dispatchEvent(lives);   
            health=health-10;
            healthPercent=health/100;
            trace(healthPercent);
            life.scaleX= healthPercent;
            text.text=String(health);


        }

        if (health<0){
            gotoAndStop(5);
        }
    }
}   
    }

stop();

And in the banana class:

    package {
    import flash.display.MovieClip;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.events.Event;

    public class banana extends MovieClip {

        var velX: Number = 0;
        var velY: Number = 0;
        var falling: Boolean = false;
        var gravity: Number = 2;

        public function banana() {
            var timing: Timer = new Timer(25, 0);
            timing.addEventListener(TimerEvent.TIMER, moveMe);
            timing.start();

        }

         private function moveMe(event: TimerEvent)
    {
        x += velX;
        y += velY;

        if (falling) velY += gravity;

       /* trace("[BANANA] position:", x, y, "speed:", velX, velY);*/
    }


        public function setSpeed(dx,dy) {
            velX = dx;
            velY = dy;
        }

            public function setSpot(atX,atY){
            this.x=atX;
            this.y=atY;
        }


        public function makeItFall (){
            falling=true;
        }


    }

}

When I'm move to the next frame the text box is still selected as3?

I am doing a mental calculation game and it is the following the game consume in has the accounts to do and the user has to write with the keyboard in android the number until then I have now what I want to do is when I pass from level to Textinput is soon selected so that the users can only enter the numbers (I am also in doubt as to put only the numerical keyboard for andorid keyboards).

This is the game code:

            conta.restrict = "0-9\n";
            conta.maxChars = 3;
            conta.background = true;
            conta.backgroundColor = 0x4DFF67;
            conta.border = true; // Terá borda
            conta.borderColor = 0xFFCD70; // Cor da borda
            conta.text = "Nº";


            vala.addEventListener(MouseEvent.CLICK, tobias);

            function tobias(MouseEvent){
                if (conta.text == "12"){
                    trace("Acertou");
                    nextFrame();
                }else{
                    trace("Errou");
                    conta.text = "";
                    conta.backgroundColor = 0xFF4D40;
                }
            }

            conta.addEventListener(KeyboardEvent.KEY_DOWN, function(e:KeyboardEvent):void
            {
            if(e.keyCode == Keyboard.ENTER)
            {
                if (conta.text == "12"){
                    trace("Acertou");
                    nextFrame();
                }else{
                    trace("Errou");
                    conta.text = "";
                    conta.backgroundColor = 0xFF4D40;
                }
            }
            });
            conta.addEventListener(KeyboardEvent.KEY_UP, function(e:KeyboardEvent):void
            {
                if(e.keyCode == Keyboard.ENTER)
                {
                    conta.text = "";
                }
            });


            conta.addEventListener(FocusEvent.FOCUS_IN, clearBox);
            function clearBox(evt:FocusEvent):void
            {
                conta.text="";
            }

Text Input

dimanche 23 avril 2017

Swipe Gesture Error in Flash CS6

Hey everyone so been trying to fix this and can't figure out how.

When i set up my listeners for a Swipe gesture I get this error in Flash CS6 using AIR 22.0 for Android:

ReferenceError: Error #1056: Cannot create property velocity on runtime.simulation.TransformGestureSimEvent.

I Know the code isn't wrong. Here is how It is setup:

//MultiTouch added for touch gestures
    Multitouch.inputMode = MultitouchInputMode.GESTURE;
startScreen.addEventListener(TransformGestureEvent.GESTURE_SWIPE, onSwipe);
private function onSwipe(e:TransformGestureEvent):void 
    {
        if (e.offsetY == 1)
        {
            //Swipe towards bottom 
            startScreen.gotoAndStop(2);
            trace("Swipe down");
        }

        if (e.offsetY == -1)
        {
            //Swipe towards top
            startScreen.gotoAndStop(1);
            trace("Swipe UP");
        }
    }

Any help would be appreciated. Thank you!

How to adjust the position of an image in an HGroup aligned vertically by baseline

I have a HGroup with a few Labels and an Image. The HGroup has verticalAlign set to baseline. All the Labels line up correctly. The Image does not. The Image is much too low.

Is there a property or style to adjust the vertical position of the Image? It looks like the HGroup uses baseline or baselinePosition to position the Labels. It looks like Image has that property and style as well but it doesn't seem to do anything when I change it.

Example code:

<s:HGroup verticalAlign="baseline"
          top="10"
          right="10"
          left="10">
    <s:Button label="Previous"/>

    <s:Label text="Total results:" />

    <s:Image height="28" width="100"
             source="myImage.png"
             baseline="14"
             />

    <s:Spacer width="100%"/>

    <s:Button label="Next" />
</s:HGroup>

HorizontalLayout has a method called calculateBaselineTopBottom(). It seems it is doing something with baseline and baselinePosition. It also seems to use alignmentBaseline.

AS3 hitTestObject==false

I have a life bar in my game and whenever the minion doesn't catch the bananas, I would like to have the life bar decrease. Right now my life bar is increasing! I am almost positive that is because of my for loop, but I need to have it in there since my objects are into an array.

Main program:

import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.events.Event;

var leftKey:Boolean;
var rightKey:Boolean;
var upKey:Boolean;
var downKey:Boolean;
var jump:Boolean = false;
var xvelocity:int = 9;
var yvelocity:int = 3;
var gravity:Number = 7;


stage.addEventListener(Event.ENTER_FRAME, changeVelocity);
stage.addEventListener(KeyboardEvent.KEY_UP, checkKeyUp);
stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKeyDown);

  function changeVelocity(evt:Event){
        moveMinion();
        yvelocity += gravity;
    }

    function moveMinion(){

        if (leftKey == true){
           sideMinion.x -= xvelocity;
            sideMinion.left();

        }
        if (rightKey == true){
            sideMinion.x += xvelocity;
            sideMinion.right();
        }

    }

    function checkKeyDown(e:KeyboardEvent){
        if (e.keyCode == Keyboard.LEFT){
            leftKey = true;
        }
        else if (e.keyCode == Keyboard.RIGHT){
            rightKey = true;
        }

    }

    function checkKeyUp(e:KeyboardEvent){
        if (e.keyCode == Keyboard.LEFT){
            leftKey = false;
        }
        else if (e.keyCode == Keyboard.RIGHT){
            rightKey = false;
        }

    }

    btnStart.addEventListener(MouseEvent.CLICK, makeItFall);

    function makeItFall(e:MouseEvent){



    var numBananas = 6;
    var theBananas: Array = new Array();
    theBananas = [];
    for (var i = 0; i < numBananas; i++) {
    var aBanana: banana = new banana();
    theBananas.push(aBanana);
    btnStart.visible=false;
    aBanana.y=100;
    theBananas[i].setSpot(Math.random()*450,Math.random()*200);
    theBananas[i].setSpeed((Math.random()), 1);
    stage.addChild(aBanana);

}   

var health: Number= 100;
var healthPercent: Number= 1;

addEventListener(Event.ENTER_FRAME, pickUpBananas);

function pickUpBananas(event:Event){

    for (var i:int = theBananas.length-1; i>-1; i--){

            if (sideMinion.hitTestObject(theBananas[i])){
                stage.removeChild(theBananas[i]);
                theBananas.splice(i,1);

        }
        else if (sideMinion.hitTestObject(theBananas[i])==false){
            health=health-10;
            healthPercent=health/100;
            trace(healthPercent);
            life.scaleX= healthPercent;

        }
    }
}

    }


stop();

And banana class:

    package {
    import flash.display.MovieClip;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.events.Event;

    public class banana extends MovieClip {

        var velX: Number = 0;
        var velY: Number = 0;
        var falling: Boolean = false;
        var gravity: Number = 2;

        public function banana() {
            var timing: Timer = new Timer(25, 0);
            timing.addEventListener(TimerEvent.TIMER, moveMe);
            timing.start();

        }

         private function moveMe(event: TimerEvent)
    {
        x += velX;
        y += velY;

        if (falling) velY += gravity;

       /* trace("[BANANA] position:", x, y, "speed:", velX, velY);*/
    }


        public function setSpeed(dx,dy) {
            velX = dx;
            velY = dy;
        }

            public function setSpot(atX,atY){
            this.x=atX;
            this.y=atY;
        }


        public function makeItFall (){
            falling=true;
        }


    }

}

Save image JPG captured by the camera

I'm using the code below to open the camera for an Android device. How do I save a image JPG, captured by this camera? What code/Button should I add to my programming AS3/AIR?

public class Test_Cam extends Sprite {
private var cam: Camera;
public function Test_Cam() {
cam = Camera.getCamera();
connectCamera();
function connectCamera(): void {
var vid: Video = new Video(cam.width, cam.height);
vid.x = 100;
vid.y = 200;
vid.attachCamera(cam);
addChild(vid);
}
}
}

:( I could not implement my code: Saving and masking webcam still AS3 AIR IOS

AS3: create template for XML file

I need to create DB report as excel file. The best (and simplest) way I can see - create the XML representation and save it as XLS. The Header and Footer parts of this file should be constant, so I'd prefer to load them from config (or template) file instead of hard coded string constants. And it has no sense to use the XML per se - the "string" will be more than enough. The question is: how I can do it? I mean - load XML content as string, or as a last resort - create string constant. I've tried what was recommended for multi-line constants in one of stackoverflow answers (use CDATA). But seems, for XML content it doesn't work.

Thanks in advance.

samedi 22 avril 2017

AS3 ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller

I am making a minions game. My minion's instance name is sideMinion. The bananas are falling and everything works fine, but my removeChild() doesn't work properly. The error I'm getting is Error #2025: The supplied DisplayObject must be a child of the caller. The removeChild() or the hitTestObject doesn't work properly.

This is what I have in my banana as. class:

    package {
    import flash.display.MovieClip;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.events.Event;

    public class banana extends MovieClip {

        var velX: Number = 0;
        var velY: Number = 0;
        var falling: Boolean = false;
        var gravity: Number = 0;

        public function banana() {
            var timing: Timer = new Timer(25, 0);
            timing.addEventListener(TimerEvent.TIMER, moveMe);
            timing.start();

        }

         private function moveMe(event: TimerEvent)
    {
        x += velX;
        y += velY;

        if (falling) velY += gravity;

       /* trace("[BANANA] position:", x, y, "speed:", velX, velY);*/
    }


        public function setSpeed(dx,dy) {
            velX = dx;
            velY = dy;
        }

            public function setSpot(atX,atY){
            this.x=atX;
            this.y=atY;
        }


        public function makeItFall (){
            falling=true;
        }


    }

}

And in my main program:

import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.events.Event;

var leftKey:Boolean;
var rightKey:Boolean;
var upKey:Boolean;
var downKey:Boolean;
var jump:Boolean = false;
var xvelocity:int = 9;
var yvelocity:int = 3;
var gravity:Number = 7;


stage.addEventListener(Event.ENTER_FRAME, changeVelocity);
stage.addEventListener(KeyboardEvent.KEY_UP, checkKeyUp);
stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKeyDown);

  function changeVelocity(evt:Event){
        moveMinion();
        yvelocity += gravity;
    }

    function moveMinion(){

        if (leftKey == true){
           sideMinion.x -= xvelocity;
            sideMinion.left();

        }
        if (rightKey == true){
            sideMinion.x += xvelocity;
            sideMinion.right();
        }

    }

    function checkKeyDown(e:KeyboardEvent){
        if (e.keyCode == Keyboard.LEFT){
            leftKey = true;
        }
        else if (e.keyCode == Keyboard.RIGHT){
            rightKey = true;
        }

    }

    function checkKeyUp(e:KeyboardEvent){
        if (e.keyCode == Keyboard.LEFT){
            leftKey = false;
        }
        else if (e.keyCode == Keyboard.RIGHT){
            rightKey = false;
        }

    }

    btnStart.addEventListener(MouseEvent.CLICK, makeItFall);

    function makeItFall(e:MouseEvent){



    var numBananas = 6;
    var theBananas: Array = new Array();
    theBananas = [];
    for (var i = 0; i < numBananas; i++) {
    var aBanana: banana = new banana();
    theBananas.push(aBanana);
    btnStart.visible=false;
    aBanana.y=30;
    theBananas[i].setSpot(Math.random()*450+50,Math.random()*200+20);
    theBananas[i].setSpeed((Math.random()), 1);
    stage.addChild(aBanana);

}   

var health: uint= 1;

addEventListener(Event.ENTER_FRAME, pickUpBananas);

function pickUpBananas(event:Event){
    for( var i= 0; i<theBananas.length; ++i){
        if (sideMinion.hitTestObject(theBananas[i])){
            removeChild(theBananas[i]);
            health=health+1;
            trace(health);
        }
    }

}

    }


stop();

Target instance object by using a variable value in Actionscript 3

I have a series of objects each with instance names such as:

object1 object2 object3

going up in numerical order. I want to access each one depending on the value of a variable. For example

myVar:Num = 2;

I would like to use this value to select the appropriate object. In javascript or JQuery would be written like this:

object + myVar

Which would return me object2. However, this approach is obviously not working in AS3. Can anybody help me put please?

Flash AS3: Blitting performance at 1080p/4k resolution?

When I started my Flash project, I didn't know anything about blitting. I intended for it to play at 60 FPS, but it frequently dips into the 40s on a high-end machine and worse on lower-end machines. All of the game artwork is vector because I liked how it's perfectly scalable, for cases where you want to zoom in, or if the user is playing full screen on a high resolution display.

Then I learned about blitting and did some experimenting with positive results. But before I write a blitting engine, I was wondering what kind of performance I could expect. My Flash is set to 60 FPS and I'm going to use an EVENT.ENTER_FRAME to call my blit function, which would then go through each of my background, midground, and foreground vector art Sprite layers and create bitmaps by using BitmapData.drawWithQuality before copypixeling them onto my canvas bitmap. I plan on scaling my vector layers and canvas bitmap resolution up to the user's full screen resolution, which could be something huge like 4k. Those could be some huge bitmaps with huge draws occurring at a high rate. Can I really expect to get 60 FPS if I go through all this effort?

vendredi 21 avril 2017

Game fla file missing from Starling build - possible recovery or decompile?

I've been working with a programmer on an app and we've since gone our separate ways. I was passed on a copy of what was supposed to be the source code of everything at the end. However, I believe I'm missing a crucial file from the app build.

It's a pretty cool, but fairly basic 2D game. Built with Starling (gamua.com/starling) in ActionScript 3.

My question is, with all the files and assets mentioned below, is it possible to recover, reverse engineer, perhaps decompile, what I need to complete the app. Or will this project's code need to be re-written from scratch?

In my game 'build' I have following folders: assets, bin-debug, extensions, libs, src, and system.

I am a bit of a noob in coding (as you've probably gathered), but it looks like I'm missing the .fla file from the 'src' folder. The contents of that src folder is: com, utils (folders), Constants.as, Game.as, Main-app.xml, Main.as, Menu.as, Root.as

I was hoping that there is enough information in the .as files intact, that the restoring of the .fla to compile the build is not a big ask?

If other questions stand out to you, please ask. Thanks!

Math random in action script3

I am making a game and I am trying to create an array of the same object falling in multiple spots. I would also like to have them fall at different spots, using the math random. The problem that I am encountering is that the objects (bananas) don't show up on the screen at all. Can math random be used on the y-axis in action script 3? If so, could someone give me an example? This is what I have in the main program:

var numBananas = 20;
var theBananas: Array = new Array();
theBananas = [];
for (var i = 0; i < numBananas; i++) {
var aBanana: banana_fall = new banana_fall();
aBanana.y=-10;
theBananas.push(aBanana);
theBananas[i].setSpeed(-(Math.random()), 5);

And this is what I have in the action script class:

package {
    import flash.display.MovieClip;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.events.Event;

    public class banana_fall extends MovieClip {

        var velX: Number = 0;
        var velY: Number = 0;
        var falling: Boolean = false;
        var gravity: Number = 2;

        public function banana_fall() {
            var timing: Timer = new Timer(20, 0);
            timing.addEventListener(TimerEvent.TIMER, moveMe);
            timing.start();

        }

        private function moveMe(event: TimerEvent) {
            this.x = this.x + velX;
            this.y = this.y + velY;

            if (falling) {
                falling=true;
                velY = velY + gravity;
            }
        }


        public function setSpeed(dx, dy) {
            velX = dx;
            velY = dy;
        }

    }

}

AS3 Property 0 not found and there is no default value

I am building a game in Flash, but I am having issues with an array (I believe). I have a minion going after bananas but for some reason, the bananas don't s fall as expected. I am not sure where is the issue and how should I try to fix it.

This is what I have in my main game:

import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.events.Event;

var leftKey:Boolean;
var rightKey:Boolean;
var upKey:Boolean;
var downKey:Boolean;
var jump:Boolean = false;
var xvelocity:int = 9;
var yvelocity:int = 3;
var gravity:Number = 7;


stage.addEventListener(Event.ENTER_FRAME, changeVelocity);
stage.addEventListener(KeyboardEvent.KEY_UP, checkKeyUp);
stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKeyDown);

  function changeVelocity(evt:Event){
        moveMinion();
        yvelocity += gravity;

        /*for (var i:int = 0; i < 10; i++){
            if (!line.length.hitTestObject(sideMinion)){
                sideMinion.y+=yvelocity;
                }

            if (line.length.hitTestObject(sideMinion)){
                yvelocity = 0;
                sideMinion.y--;
            }
        }*/
    }

    function moveMinion(){

        if (leftKey == true){
           sideMinion.x -= xvelocity;
            sideMinion.left();

        }
        if (rightKey == true){
            sideMinion.x += xvelocity;
            sideMinion.right();
        }


    }

    function checkKeyDown(e:KeyboardEvent){
        if (e.keyCode == Keyboard.LEFT){
            leftKey = true;
        }
        else if (e.keyCode == Keyboard.RIGHT){
            rightKey = true;
        }

    }

    function checkKeyUp(e:KeyboardEvent){
        if (e.keyCode == Keyboard.LEFT){
            leftKey = false;
        }
        else if (e.keyCode == Keyboard.RIGHT){
            rightKey = false;
        }

    }

    var numBananas = 20;
    var theBananas: Array = new Array();
    theBananas = [];
    for (var i = 0; i < numBananas; i++) {
    var aBanana: banana_fall = new banana_fall();
    theBananas.push(aBanana);
    theBananas[i].setSpot(Math.random() * 450 + 50, Math.random() * 200 + 20);
    theBananas[i].setSpeed(-(Math.random()), 0);
    addChild(aBanana[i]);


    }

stop();

I also have a class for the banana and this is what is in there:

   package {
    import flash.display.MovieClip;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.events.Event;

    public class banana_fall extends MovieClip {

        var velX: Number = 0;
        var velY: Number = 0;
        var falling: Boolean = false;
        var gravity: Number = 2;

        public function banana_fall() {
            var timing: Timer = new Timer(20, 0);
            timing.addEventListener(TimerEvent.TIMER, moveMe);
            timing.start();

        }

        private function moveMe(event: TimerEvent) {
            this.x = this.x + velX;
            this.y = this.y + velY;

            if (falling) {
                velY = velY + gravity;
            }
        }

        public function setSpot(atX, atY) {
            this.x = atX;
            this.y = atY;
        }

        //
        public function setSpeed(dx, dy) {
            velX = dx;
            velY = dy;
        }

    }

}

AS3 Classes Public Atributte

I am getting an error whenever I try running the game. I get errors for every class saying that the public attribute can only be used inside a package and on this line with "private function moveMe" "the private attribute may only be used on class functions". I verified if I have the as file linked properly. I am not sure what the issue is.

package  {
        import flash.display.MovieClip;
        import flash.utils.Timer;
        import flash.events.TimerEvent;
        import flash.events.MouseEvent;
        import flash.events.Event;
        import flash.events.Event;

        public class banana_fall extends MovieClip {

            public function banana_fall (){
            var velX:Number=0;
            var velY:Number=0;
            var falling:Boolean=false;
            var gravity:Number=2;


                public function banana() {
                var timing:Timer = new Timer(20,0);
                timing.addEventListener(TimerEvent.TIMER,moveMe);
                timing.start();

                }

                private function moveMe(event:TimerEvent){
                this.x=this.x+velX;
                this.y=this.y+velY;

                if (falling) {
                    velY=velY+gravity;
                }
            }

                public function setSpot(atX,atY){
                this.x=atX;
                this.y=atY;
            }

            //
            public function setSpeed(dx,dy){
                velX=dx;
                velY=dy;
            }

                }

        }

    }

Cant work out why my fading script won't work

I've run across a piece of code that I'm really struggling to get working... It's meant to wait three seconds before fading an object (swslogo), however when I test it, it doesn't seem to work.. anyone know why this might be

    var GameMode:Number = 0;
    swslogo.alpha = .0;
    var IntroTimer = new Timer(4000,1); //add a 4 second timer
    IntroTimer.addEventListener(TimerEvent.TIMER_COMPLETE,swsfadein);
    intro();
    swsfadein ();
    function intro(e:Event=null):void
    {
      IntroTimer.reset()
      IntroTimer.start();
    }
    function swsfadein(e:Event=null):void
    {
      IntroTimer.stop();
      swslogo.addEventListener(Event.ENTER_FRAME, fadein)
    }
      function fadein(e:Event=null){
        if(swslogo.alpha <=0){
          this.alpha +=0.1;
          if(swslogo.alpha >=1){
            this.removeEventListener(Event.ENTER_FRAME, fadein);
          }
        }
      }

Animate CC tag support in dynamic text box

I am loading in data/text dynamically in Animate CC (Actionscript 3) from a JSON file. I am using html tags to help format the text, however, there a tags within the text. Does Animate CC still not support these tags? The only method I could find is to use superscript fonts, but for this project I have to use brand particular fonts, so I cannot go down this route.

Can anybody help please?

AS3: BitmapData.draw with alpha and blendmode has incorrect result

I have a sprite that contains overlapping shapes. The sprite itself will have it's alpha set to .5, so I have to set the sprite's blendmode to "layer" to keep the overlapping parts from looking transparent with each other. In this screenshot taken from here, it's supposed to look like the one on the right.

enter image description here

Now I want to draw a bitmapData from my sprite, but I can't get the resulting bitmap to look like the image on the right. It ends up looking like the image in the middle.

spriteBMD.draw(mySprite,null,mySprite.transform.colorTransform,"layer");

Does anyone know what I'm doing wrong?

How to clone an object in as3

I'm quite new to as3, but the game I'm making requires the use ofclones. How would I make them (I know it involves using the child thing but I don't know how to make them)? I also need to make a function that sets their location to random places on screen, how would I do this? I'm not sure how i would refer to the clone's x and y locations without it moving all 50 of them. Thanks

Google translater like converter in adobe flex

I am trying to create translator in adobe flex. Which can convert English text to other selected text.

I have two textarea.

<s:HGroup gap="10" paddingLeft="2">
   <s:TextArea id="txtarea1" width="200" heightInLines="3" />
   <s:ComboBox id="cmbBox" dataProvider="{langList}" change="onChange(event)"/>
   <s:TextArea id="txtarea2" width="200" heightInLines="3" />
</s:HGroup>

langList contains languages name like Spanish, French etc.

I want to convert text, which user enter in txtarea1 into txtarea2 in which language user have selected in combobox on combobox change handler.

I have reviewed many documents but, didn't get any proper. like: This and This. But, there is written like i have to insert converted languages in .properties file. But, i want that automatically.

And yes i have entered added all compiler arguments for required languages. like: -locale en_US de_DE.

Any help would greatly appreciated which give me right track to move forward.

Fading an object in as3

I'm relatively new to as3 and am rewriting a game I have previously written in another language in it. In the intro animation, that leads up to the menu, there is lots of images fading in and out. I know how to make an object transparent using the .alpha, but seem to be struggling to get it to fade back in. I have the image starting off faded out, then I want it to fade in gradually over the course of about .1 of a second, stay there for 4 seconds then fade out.... Thanks.

jeudi 20 avril 2017

send data to server from swf

I'm creating a presentation slide using flash cc. There's play button in it and when the user hit the play button, it sends some text data to the server. I'm new to communication between swf and server. I used post method to send data to server and it works fine when tested in flash. But when I run swf alone it shows security error. So, in publish setting I change local playback security to access networks only. It works fine when swf file is played alone. But when the file is uploaded in web, it doesn't work. I googled about it and it looks like I need place crossdomain.xml file.I'm really new to working with server. So please someone guide me how to achieve this.

Can't get dynamic text to display

Here's the link to the whole project including all the dependencies if needed. http://ift.tt/2pIVpXO

Basically trying to clean up some script I was left to deal with and have been banging my head against the wall as to why this isn't working. I don't get any debug errors, everything seems to be linked where it needs to be linked. My font seems to be embedded, all my instance names seem to be right... the only thing I can think of is I'm missing something silly in the code. Any help would be really appreciated! Nothing like being left a mess and having to fix it.

Basically the text box is supposed to have a countdown timer based on what race is approaching (e.g Race X is in xxx minutes) and If there isn't a race approaching, it should show some default text. At the moment, It doesn't seem to want to change the dynamic text at all!

package  {

    import flash.display.MovieClip;
    import flash.events.TimerEvent;
    import flash.ui.Mouse;
    import flash.utils.Timer;
    import com.boo.CustomDate;
    import com.boo.ScreensaverSimple;
    import com.RaceRibbon;

        // This sections is for the image slides and Hour Of Power setting.
    public class Generic extends MovieClip {

        // This is where you can set the Hour of Power time start and end time (in 24 hour format e.g. 1330 for 1:30pm)
        // If there is no hour of power, simply set both numbers to 0
        private var HourOfPowerStartTime:Number = 0;
        private var HourOfPowerEndTime:Number = 0;
        private var HourOfPower1StartTime:Number = 0;
        private var HourOfPower1EndTime:Number = 0;


        public var race_ribbon:RaceRibbon;      
        private var ss:ScreensaverSimple;
        public var time_check_timer:Timer;
        public var is_race_time:Boolean;
        public var current_state:String;
        public var next_race:Date;
        public var race_time_arr:Array;
        public var race_num:int;
        private var ss_time_arr:Array;      
        private var delay_add_timer:Timer;

        //Set default text
        private var default_ribbon_text:String = "THERACES.COM.AU";

        // Set Race Times
        private var r1:Date = new Date(2017,5,5,12,15);
        private var r2:Date = new Date(2017,5,5,12,50);
        private var r3:Date = new Date(2017,5,5,13,25);
        private var r4:Date = new Date(2017,5,5,14,00);
        private var r5:Date = new Date(2017,5,5,14,35);
        private var r6:Date = new Date(2017,5,5,15,15);
        private var r7:Date = new Date(2017,5,5,15,55);
        private var r8:Date = new Date(2017,5,5,16,35);
        private var r9:Date = new Date(2017,5,5,17,15);



        // Hide the mouse
        public function Generic() {
            Mouse.hide();

        // Set Race Ribbon
            race_ribbon = new RaceRibbon;
            race_ribbon.x = 1109;
            race_ribbon.y = 983;

            race_time_arr = [r1,r2,r3,r4,r5,r6,r7,r8,r9];

        // Display Slideshow
            ss = new ScreensaverSimple;
            ss.setScreensaver(screens);

        // Make sure Hour of Power is not visible
            HOP1.visible = false;
            HOP2.visible = false;



            time_check_timer = new Timer(1000);
            time_check_timer.addEventListener(TimerEvent.TIMER, checkTime);

            delay_add_timer = new Timer(1,1);
            delay_add_timer.addEventListener(TimerEvent.TIMER, addAllChildren);
            delay_add_timer.start();    
        }


        public function addAllChildren(evt:TimerEvent=null):void {
            delay_add_timer.removeEventListener(TimerEvent.TIMER, addAllChildren);
            delay_add_timer.stop();
            delay_add_timer = null;

            addChild(race_ribbon);

            time_check_timer.start();
            checkTime();
        }


        public function checkTime(evt:TimerEvent=null):void {
            setDatesToCurrent(race_time_arr);// This makes every day race day
            setDatesToCurrent(ss_time_arr);// This makes all screensaver dates current

            checkNextRace();

            if(next_race  != null && is_race_time == false)// If it isn't race time
            {
                setCountdown();
            }
            if(next_race  == null && is_race_time == true)// If it's race time
            {
                setDefaultText();
            }

            checkHOP1();
            checkHOP2();
        }

        //Call to make Hour Of Power 1 visible/invisible based on set times
        private function checkHOP1():void {
            HOP1.visible = (HourOfPowerStartTime || HourOfPowerEndTime);
            if (!HOP1.visible) return;
            var CurrentTime:Number = CustomDate.return24HourNumber();
            HOP1.visible = (CurrentTime >= HourOfPowerStartTime && CurrentTime <= HourOfPowerEndTime);
        }

        //Call to make Hour Of Power 2 visible/invisible based on set times
                private function checkHOP2():void {
            HOP2.visible = (HourOfPower1StartTime || HourOfPower1EndTime);
            if (!HOP2.visible) return;
            var CurrentTime:Number = CustomDate.return24HourNumber();
            HOP2.visible = (CurrentTime >= HourOfPower1StartTime && CurrentTime <= HourOfPower1EndTime);
        }

        public function setDatesToCurrent(arr:Array):void {// This makes every day race day
            var cd:Date = new Date();// Current Date

            for(var i:int=0;i<arr.length;i++){
                arr[i].fullYear = cd.fullYear;
                arr[i].month = cd.month;
                arr[i].date = cd.date;
            }
        }       

        public function checkNextRace():void {
            var ct:Date = new Date();// Current Time as a Date
            next_race = null;
            is_race_time = false;

            // FOR LOOP THIS... one day
            if(ct < r1) {
                next_race = r1;
            } else if(raceTimeSpan(r1) == true) {
                is_race_time = true;
                race_num = 1;
            } else if(ct > raceTimeSpan(r1) && ct < r2) {
                next_race = r2;
            } else if(raceTimeSpan(r2) == true) {
                is_race_time = true;
                race_num = 2;
            } else if(ct > raceTimeSpan(r2) && ct < r3) {
                next_race = r3;
            } else if(raceTimeSpan(r3) == true) {
                is_race_time = true;
                race_num = 3;
            } else if(ct > raceTimeSpan(r3) && ct < r4) {
                next_race = r4;
            } else if(raceTimeSpan(r4) == true) {
                is_race_time = true;
                race_num = 4;
            } else if(ct > raceTimeSpan(r4) && ct < r5) {
                next_race = r5;
            } else if(raceTimeSpan(r5) == true) {
                is_race_time = true;
                race_num = 5;
            } else if(ct > raceTimeSpan(r5) && ct < r6) {
                next_race = r6;
            } else if(raceTimeSpan(r6) == true) {
                is_race_time = true;
                race_num = 6;
            } else if(ct > raceTimeSpan(r6) && ct < r7) {
                next_race = r7;
            } else if(raceTimeSpan(r7) == true) {
                is_race_time = true;
                race_num = 7;
            } else if(ct > raceTimeSpan(r7) && ct < r8) {
                next_race = r8;
            } else if(raceTimeSpan(r8) == true) {
                is_race_time = true;
                race_num = 8;
            } else if(ct > raceTimeSpan(r8) && ct < r9) {
                next_race = r9;
            } else if(raceTimeSpan(r9) == true) {
                is_race_time = true;
                race_num = 9;
            } else if(ct > raceTimeSpan(r9)) {// If all races are finished
                setDefaultText();
            }
        }

        public function raceTimeSpan(d:Date):Boolean {
            var race_mins:int = 2;
            var race_on:Boolean = false;
            var ct:Date = new Date();
            if(ct.hours == d.hours) {
                var max_mins:int = d.minutes + race_mins;
                if(ct.minutes >= d.minutes && ct.minutes < max_mins) {
                    race_on = true;
                }
            }
            return race_on;
        }

        public function setCountdown():void {
            var hours_left:int = int(String(CustomDate.countdownTime(next_race)).split(":")[0]);
            var mins_left:int = int(String(CustomDate.countdownTime(next_race)).split(":")[1]);
            mins_left = (60*hours_left)+mins_left;
            is_race_time = false;
            if(mins_left > 2) {
                race_ribbon.setText("NEXT RACE IN <font color='#000000' letterspacing='-1'>"+(mins_left+1)+" MINUTES</font>");
                race_ribbon.setBG(0);
            } else if(mins_left < 3) {
                if((mins_left+1) <= 1) {
                    race_ribbon.setText("NEXT RACE IN <font color='#fdb913' letterspacing='-1'>"+(mins_left+1)+" MINUTE</font>");
                } else {
                    race_ribbon.setText("NEXT RACE IN <font color='#fdb913' letterspacing='-1'>"+(mins_left+1)+" MINUTES</font>");
                }
                race_ribbon.setBG(1);
            }
        }

        public function setDefaultText():void {
            race_ribbon.setText("<font color='#fdb913' letterspacing='-1'>"+default_ribbon_text+"</font>");
            race_ribbon.setBG(1);
        }       

    }

}

And just in case you don't want to go through the files individually the com.RaceRibbon code is

package com {

    import flash.display.MovieClip;
    import fl.motion.Color;
    import flash.display.Sprite; 
    import flash.text.*; 

    public class RaceRibbon extends MovieClip {

        private var c1:Color;
        private var c2:Color;

        public function RaceRibbon() {
            c1 = new Color();
            c1.setTint(0xfdb913,1);

            c2 = new Color();
            c2.setTint(0x000000,1);
        }



        public function setText(str:String=""):void {
            str = str.toUpperCase();
            this.tb.htmlText = str;
        }

        public function setBG(p:int=0):void {
            switch(p){
                case 0:
                    bg.transform.colorTransform = c1;
                break;
                case 1:
                    bg.transform.colorTransform = c2;
                break;
            }
        }

    }

}

Adobe Air for iOS: MovieClip Animation runs at high framerate / FPS

Having a strange issue with an Air for iOS project built with Adobe Animate (Flash) where a MovieClip [preload] animation is playing at a really high framerate while a netstream/netconnection video is loading.

The project itself has a framerate set to 17fps, and I've also attempted to set the framerate via as3 (using stage.frameRate=17) but for whatever reason, this animation always seems to play at a really high framerate (800-3000fps!) but will eventually level out down to 17. This only seems to happen when I first open the app on the iOS device, if I call the same function again to play the video, then the animation plays back at 17fps.

I used the code at http://ift.tt/2pJ2RT4 to determine the actual FPS it was playing back at (which is where I found out it was at around 3000fps in some cases!) and I've also tried using various code for framerate limiting/throttling to no avail (such as the class found here: http://ift.tt/2oVCB4R) and am running out of ideas..

The Air for iOS render mode is set to GPU, but changing to anything else has the same issue. I've read a lot about low FPS issues with Air for iOS apps, but haven't come across anything similar to this issue (yet) and need to find out if anyone has had a similar problem and might know of a solution!

Any help is appreciated!

SWFLoader Working in Air Project but not Web Project

I have been developing a Web type Flex project in Flash builder. In this project I have been trying to load a swf file using the SWFLoader. I have had trouble getting the debugger working, so I have instead created an identical Air project that I can run and debug with (I keep it up to date with a script). I have successfully loaded the swf file in my Air project with no trouble. But, when I went to test this in my Web project, the SWFLoader does not seem to work, I just get a blank area where my SWFLoader element should display the loaded swf file.

private function get_swf_file_binary_amf(event:ResultEvent):void {
            Alert.show("SWF Returned");
            var decoder:Base64Decoder=new Base64Decoder();
            decoder.decode(event.result);
            var swf_bytes:ByteArray=decoder.toByteArray();

            var context:LoaderContext=new LoaderContext();
            context.allowLoadBytesCodeExecution=true;
            context.parameters = {myval: "test_string"};

            swf_loaded_file.loaderContext = context;
            swf_loaded_file.addEventListener(Event.COMPLETE, loadComplete);
            swf_loaded_file.load(swf_bytes);
        }

private function loadComplete(completeEvent:Event):void{
    trace("load Complete")
}

Above is the code that works in my Adobe Air project. I am receiving the binary data of my swf file and converting it into a ByteArray, not using the URLLoader like so many example suggest. Could this be the cause of my problems when I try to run this in my Web project?

Adobe Air aapt tool failed:ERROR: Platform AndroidManifest.xml not found

This might be simple but this is my first time attempting to use Adobe Air to create a mobile app.

I just created a brand new flex mobile project in Adobe Air. I then proceeded to run as an android application on an android device.

When I do this, I get the following error:

Error occurred while packaging the application:


aapt tool failed:ERROR: Platform AndroidManifest.xml not found

I'm using Flash Builder 4.7 with a newly updated Adobe Air 25.0. In the SDKs folder of Flash Builder I see flex is 4.6 and air is 3.6.

The only thing I've done is I've copied aapt, adb and dx.jar from android SDK 25 into my /lib/android/bin folder of Flex 4.6 per the recommendation found here.

Before I did that Adobe Air could not detect my device.

Worth noting - the new project will run on a simulator.

Any ideas why it can't find a manifest? Is that something I need to create? Seems like it should just work for a brand new Adobe Air project?

Actionscript 3 drag and drop multiple objects to target with well done

The drag and drop works however, I have no idea how to create an if statement that goes to the next scene when all movieclips have been placed on the target. Ive tried placing the instance names in an if statement with the hittestobject however, no luck.

import flash.events.TouchEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import flash.display.MovieClip;

/* Touch and Drag Event
Allows the object to be moved by holding and dragging the object.
*/
var objectoriginalX:Number;
var objectoriginalY:Number;
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

var lemons:Array = [lemon1_mc, lemon2_mc, lemon3_mc, lemon4_mc, lemon5_mc];

for each(var lemonMC:MovieClip in lemons)
{
lemonMC.buttonMode = true;
lemonMC.addEventListener(TouchEvent.TOUCH_BEGIN, pickobject);
lemonMC.addEventListener(TouchEvent.TOUCH_END, dropobject);

lemonMC.startX = lemonMC.x;
lemonMC.startY = lemonMC.y;

}
var fl_DragBounds:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);


function pickobject(event:TouchEvent):void
{
    event.target.startTouchDrag(event.touchPointID, false, fl_DragBounds);
    event.target.parent.addChild(event.target);
    objectoriginalX = event.target.x; 
    objectoriginalY = event.target.y;


}

function dropobject(event:TouchEvent):void
{
    if(event.target.hitTestObject(target_mc)){
        event.target.buttonMode = false;
        event.target.x = target_mc.x;
        event.target.y = target_mc.y;
        event.target.visible = false;


    }




else{
    event.target.x = event.target.startX;
    event.target.y = event.target.startY;
    event.target.buttonMode = true;
}


}



var melons:Array = [melon1_mc, melon2_mc, melon3_mc, melon4_mc, melon5_mc, melon6_mc, melon7_mc];
for each(var melonMC:MovieClip in melons)
{
melonMC.buttonMode = true;
melonMC.addEventListener(TouchEvent.TOUCH_BEGIN, pickobject2);
melonMC.addEventListener(TouchEvent.TOUCH_END, dropobject2);

melonMC.startX = melonMC.x;
melonMC.startY = melonMC.y;

}
var fl_DragBounds2:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);


function pickobject2(event:TouchEvent):void
{
    event.target.startTouchDrag(event.touchPointID, false, fl_DragBounds2);
    event.target.parent.addChild(event.target);
    objectoriginalX = event.target.x; 
    objectoriginalY = event.target.y;


}

function dropobject2(event:TouchEvent):void
{
    if(event.target.hitTestObject(target_null)){
        event.target.buttonMode = false;
        event.target.x = target_mc.x;
        event.target.y = target_mc.y;
        event.target.visible = false;


    }

    else{
    event.target.x = event.target.startX;
    event.target.y = event.target.startY;
    event.target.buttonMode = true;
}
}

external swf no longer loading in modern browsers - security issue?

Years ago, I created a swf that upon init, loads an external swf. It worked reliably for years. Now, it's been brought back, but no longer loads the swf in more modern browsers, like in its heyday. It now fails in Chrome 57 and IE11, but worked around IE8 and Chrome 20ish. I'm thinking this might be a security issue. I tried setting compatibility mode in IE but that didn't help. Am I missing a security setting somewhere?

when all the lemon movie clips hit the target I want it to go to a well done screen however im unsure how to

Im using Actionscript 3 in Adobe Flash. Ive tried numerous if statements some have slightly worked however,the one at the moment only considers the fifth movieclip. It should be when all movieclips have hut the target the next scene should play. can you please help? Thanks.

import flash.events.TouchEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import flash.display.MovieClip;

 /* Touch and Drag Event
 Allows the object to be moved by holding and dragging the object.
 */
var objectoriginalX:Number;
var objectoriginalY:Number;
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

var lemons:Array = [lemon1_mc, lemon2_mc, lemon3_mc, lemon4_mc, lemon5_mc];

for each(var lemonMC:MovieClip in lemons)
{
lemonMC.buttonMode = true;
lemonMC.addEventListener(TouchEvent.TOUCH_BEGIN, pickobject);
lemonMC.addEventListener(TouchEvent.TOUCH_END, dropobject);

lemonMC.startX = lemonMC.x;
lemonMC.startY = lemonMC.y;

 }
 var fl_DragBounds:Rectangle = new Rectangle(0, 0, stage.stageWidth, 
 stage.stageHeight);


 function pickobject(event:TouchEvent):void
 {
event.target.startTouchDrag(event.touchPointID, false, fl_DragBounds);
event.target.parent.addChild(event.target);
objectoriginalX = event.target.x; 
objectoriginalY = event.target.y;


}

function dropobject(event:TouchEvent):void
{
if(event.target.hitTestObject(target_mc)){
    event.target.buttonMode = false;
    event.target.x = target_mc.x;
    event.target.y = target_mc.y;
    event.target.visible = false;


  }

 if (lemonMC.hitTestObject(target_mc))
{
    gotoAndPlay(0,"Scene 2");
}

else{
event.target.x = event.target.startX;
event.target.y = event.target.startY;
event.target.buttonMode = true;
}
}

Creating a cross platform runtime AIR app

I am compiling an AIR application from Animate CC (mac version) with runtime embedded. No issues on the mac, but when i transfer the app file to a PC (running windows obviously), the app icon displays as a folder instead, and there is nothing within this folder that I can click on to run the app.

I was under the impression that Adobe AIR is cross platform compatible, so am I doing something wrong when compiling, or do I have to compile on a PC to create a runtime embedded app that will run on Windows?

mercredi 19 avril 2017

Action Script Character jump and falls

I am trying to make a minion game. I want to make it jump, and fall back down. At the moment it jumps, but no matter what I do it doesn't fall back down. What am I doing wrong?

import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.events.Event;


stage.addEventListener(KeyboardEvent.KEY_DOWN, moveMinionLeft);

function moveMinionLeft (e:KeyboardEvent):void{
    if (e.keyCode == Keyboard.LEFT){
    sideMinion.x -=10; 
        sideMinion.left();

    } 

    if (e.keyCode == Keyboard.RIGHT){
    sideMinion.x +=10;
        sideMinion.right();
} 

}
var gravity:Number = 1.5;
var jump:Number = 10;
var ySpeed:Number = 0;
var falling:Boolean=false;

stage.addEventListener(KeyboardEvent.KEY_UP, jumpMinion);

function jumpMinion(e:KeyboardEvent):void{

    if(e.keyCode == Keyboard.SPACE){
        ySpeed=-jump;
        sideMinion.y=ySpeed;
        if(falling){
        ySpeed+=gravity;
        trace("jump");
         }
        }
}

ActionScript3.0 Stopping character animation after button is pressed

I have a character (myHero) with several animations in him, idle, walking, turning, jump, attack, and dance. With the code I'm using now I need to keep the button pressed for the whole animation to work (it was fine for when you're walking but when i want to attack for example, i want the button to pressed once and the whole animation would play ONCE too) As of now the button needs to be continuously pressed for the animation to play. This is my code:

var keyRight:Boolean=false;
var keyLeft:Boolean=false;
var keyUp:Boolean=false;
var keyAttack:Boolean=false;
var keyDance:Boolean=false;


myHero.gotoAndStop(1);//the idle animation

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDown_Handler)
function keyDown_Handler(event:KeyboardEvent):void
{

    if(event.keyCode == Keyboard.X)
    {
        keyAttack=true;
    }
//theres more code for the other keys all similar to this

}

stage.addEventListener(KeyboardEvent.KEY_UP, keyUp_Handler)
function keyUp_Handler(event:KeyboardEvent):void
{

    if(event.keyCode == Keyboard.X)
    {
        myHero.gotoAndStop(1);//the idle animation
        keyAttack=false;
    }
//theres more code for the other keys all similar to this

}

With this i have to continue having to press down the key. So I tried to adding this into the keyDown_Hander:

if(event.keyCode == Keyboard.X)
{
    if(myHero.Attack.currentFrame==8)//the animation is 8 frames long
    {
        myHero.gotoAndStop(1);//the idle animation
        keyAttack=false;
    }   
}

But now the animation loops forever when I press the key unless I cancel it with another key. I've also tried adding stop(); to the last frame of the animation but then it just freezes on the last frame and doesn't return to the idle state like I want it to.

Any help?

Difference game in ActionScript3 with text box anwser AIR for Andoird

I'm want to make a game where I have two images and I have to see the differences. And I want it when I finish the time I have to check (text box) the number of differences that exist. (If they decide to move to the next level, in case they miss trying again) All in ActionScript3 for andoird Here is a part of the code:

            stop();

            var myTimer:Timer = new Timer(1000,7); // every second for 60 seconds
            myTimer.addEventListener(TimerEvent.TIMER, onTimer);
            myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onComplete);
            myTimer.start();

            function onTimer(e: TimerEvent):void {
                tempo.text = String(myTimer.repeatCount - myTimer.currentCount);
                info.text = "Tens 6 segundos para decorar as diferenças";  
            }

            function onComplete(e: TimerEvent):void{
               trace("Acabou");
               carta.gotoAndStop(2);
               carta1.gotoAndStop(2);
                info.text = "Quantas diferenças existem?"; 
                errado.addEventListener(MouseEvent.CLICK, clicked);
                errado1.addEventListener(MouseEvent.CLICK, clicked);
                errado2.addEventListener(MouseEvent.CLICK, clicked);
                certo.addEventListener(MouseEvent.CLICK, clicked1);
            }

            function clicked(MouseEvent){
                gotoAndStop("perdeu");
            }

            function clicked1(MouseEvent){
                nextFrame();
            }

Like this

AS3: Access variable outside of function

This issue is driving me nuts and I don't know what I'm missing here. This is my code:

package  {
        
        import flash.display.*;
        import flash.text.*;
        import flash.events.*;
        import flash.net.*;
        import flash.xml.*; 
        
        public class PopUp extends Sprite {
                
                public var container:Array = new Array();

                public function PopUp() {
                        
                        var contentXML:XML = new XML(); 
                        var XML_URL:String = "./content/content.xml"; 
                        var contentXMLURL:URLRequest = new URLRequest(XML_URL); 
                        var contentLoader:URLLoader = new URLLoader(contentXMLURL); 
                        contentLoader.addEventListener("complete", FuncXML);
                        
                        function FuncXML(event:Event):void { 
                                contentXML = XML(contentLoader.data);
                                for each (var item in contentXML.item) {
                                        
                                        var txtbox:Sprite = new Sprite();
                                        txtbox.graphics.beginFill(0x444444, 0.9);
                                        txtbox.graphics.drawRoundRect(0, 0, 100, 100, 15, 15)
                                        txtbox.graphics.endFill();
                                        txtbox.name = "txtbox_"+item.settings.target;
                                        addChild(txtbox);
                                        container.push(txtbox);
                                }
                                trace(container.length); // Returns 2
                        }
                trace(container.length); // Returns 0
                }

        }
        
}

The final version of this code should create text boxes from the contents of an xml file, but I can't get the content out of the function "FuncXML". I tried this with trace. The trace inside the function returns the correct length of "container", which is 2. Outside the function, the trace returns 0. Could you please tell me what's wrong here?

How to create a EASY custom seekbar for music player in actionscript 3.0

Code in the form of connecting a melody and creating instances ..

import flash.events.Event;
var mySound:Sound = new MyFavSong();
var myChannel:SoundChannel = new SoundChannel();
var lastPosition:Number = 0; 
var myTransform = new SoundTransform();
myChannel = mySound.play();
myTransform.volume = 1; 
myChannel.soundTransform = myTransform; 
stop();

And then play buttons, pauses, sound stops + volume Stop

 stop_btn.addEventListener(MouseEvent.CLICK, onClickStop);
    function onClickStop(e:MouseEvent):void{
    myChannel.stop();
    lastPosition = 0;
    stop();
    }

Pause

pause_btn.addEventListener(MouseEvent.CLICK, onClickPause);
function onClickPause(e:MouseEvent):void{
lastPosition = myChannel.position;
myChannel.stop();
stop();
}

Play

 play_btn.addEventListener(MouseEvent.CLICK, onClickPlay);
    function onClickPlay(e:MouseEvent):void{
    myChannel = mySound.play(lastPosition);
    myChannel.soundTransform = myTransform;
    play();
    }

Volume

up_btn.addEventListener(MouseEvent.CLICK, onClickUp);
function onClickUp(e:MouseEvent):void{
myChannel.soundTransform = myTransform;
myTransform.volume = myTransform.volume + 1;
}

Please, help me

mardi 18 avril 2017

Tween functions for series of menus wont work after the 1st

I am having a problem with a series of drop down menus i'm trying to make. I have 3 buttons, each of which when hovered over, drops down a sub menu with options. The problem I'm running into is that the first menu works, it drops down as it should. The second and third menus however do not work, and I don't understand why. I'm not getting an error code, and some googling directed me to people who were having similar problems suggesting flash garbage collection might be what is causing my issue. i'm not sure how to structure it so that this wont happen. I should also add that this is my first time posting so I apologize for any format issues in the post, and I'm very new to coding so any help will be much appreciated, I don't really know the questions to ask to get me going in the right direction.

Thankyou for your time

The code I have so far is as follows

import fl.transitions.Tween;
import fl.transitions.easing.Regular;

stop();

menu_cont.paint_rect.alpha = 0;
menu_cont.trim_rect.alpha = 0;
menu_cont.wheels_rect.alpha = 0;

menu_cont.paint_btn.addEventListener(MouseEvent.ROLL_OVER, paintRollOver);
menu_cont.paint_rect.addEventListener(MouseEvent.MOUSE_OUT, paintMouseOut);
menu_cont.trim_btn.addEventListener(MouseEvent.ROLL_OVER, trimRollOver);
menu_cont.trim_rect.addEventListener(MouseEvent.MOUSE_OUT, trimMouseOut);
menu_cont.wheels_btn.addEventListener(MouseEvent.ROLL_OVER, wheelsRollOver);
menu_cont.wheels_rect.addEventListener(MouseEvent.MOUSE_OUT, wheelsMouseOut);

var paintMenuTween:Tween = new Tween (menu_cont.paint_menu, "y", 
Regular.easeOut,menu_cont.paint_menu.y, 50, .5, true);
var paintMenuTween2:Tween = new Tween (menu_cont.paint_menu, "y", 
Regular.easeOut,menu_cont.paint_menu.y, -15, .5, true);
var trimMenuTween:Tween = new Tween (menu_cont.trim_menu, "y", 
Regular.easeOut,menu_cont.trim_menu.y, 50, .5, true);
var trimMenuTween2:Tween = new Tween (menu_cont.trim_menu, "y", 
Regular.easeOut,menu_cont.trim_menu.y, -15, .5, true);
var wheelsMenuTween:Tween = new Tween (menu_cont.wheels_menu, "y", 
Regular.easeOut,menu_cont.wheels_menu.y, 50, .5, true);
var wheelsMenuTween2:Tween = new Tween (menu_cont.wheels_menu, "y", 
Regular.easeOut,menu_cont.wheels_menu.y, -15, .5, true);

function paintRollOver (event:MouseEvent):void {
    paintMenuTween = new Tween (menu_cont.paint_menu, "y", 
Regular.easeOut,menu_cont.paint_menu.y, 50, .5, true);
    trace ("paint over")
}

function paintMouseOut (event:MouseEvent):void {
    paintMenuTween2 = new Tween (menu_cont.paint_menu, "y", 
Regular.easeOut,menu_cont.paint_menu.y, -15, .5, true);
trace ("paint out")
}

function trimRollOver (event:MouseEvent):void {
    trimMenuTween = new Tween (menu_cont.trim_menu, "y", Regular.easeOut,menu_cont.trim_menu.y, 50, .5, true);
    trace("trim over")
}

function trimMouseOut (event:MouseEvent):void {
    trimMenuTween2 = new Tween (menu_cont.trim_menu, "y", Regular.easeOut,menu_cont.trim_menu.y, -15, .5, true);
    trace("trim out")
}

function wheelsRollOver (event:MouseEvent):void {
    wheelsMenuTween = new Tween (menu_cont.wheels_menu, "y", Regular.easeOut,menu_cont.wheels_menu.y, 50, .5, true);
    trace ("wheels over")
}

function wheelsMouseOut (event:MouseEvent):void {
    wheelsMenuTween2 = new Tween (menu_cont.wheels_menu, "y", Regular.easeOut,menu_cont.wheels_menu.y, -15, .5, true);
    trace ("wheels out")
}

Sending some data to server

I'm trying to send some data to my server. Unfortunately I received an error: Access of undefined property readSocketData. What should I do to make it works?

package {
import flash.net.*;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.ProgressEvent;

public class HelloWorld extends Sprite {

    public function HelloWorld() {
    }
    var s:Socket;
    private function init():void {

    s=new Socket();
    s.addEventListener(ProgressEvent.SOCKET_DATA, readSocketData);
    s.connect("127.0.0.1", 3333);
    }
    private function sendSocketData(string:String):void {
    s.writeMultiByte("someData\n", "UTF-8");
    }

    }
}

Error 1009 in AS3 Adobe Animate

I'm debugging my work, and later on, the "Error 1009" appears. I really don't know how to solve that error and tbh, I don't really understand the error that I've always encountered. So here's my code:

import flash.text.*;
import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.DisplayObject;
import flash.geom.Point;
import flash.display.Stage;
import flash.display.Sprite;
import flash.utils.Timer;
import flash.events.TimerEvent;

nohint.visible = false;
txtSkor.text = String(iskoru);
txtLives.text = String(buhay);
txtHints.text = String(hinto);


txtHint.visible = false;
var gamestage: int = 0;
var gameTimer:Timer = new Timer(1000);


gameTimer.addEventListener(TimerEvent.TIMER, countDown);


gameTimer.start();
function countDown(event: TimerEvent): void {
  **txtSec.text = String(sec);**
  sec--;
  if (sec < 0) {
  gameTimer.stop();
  gameTimer.removeEventListener(TimerEvent.TIMER, countDown);
  maliWin.visible = true;
  quizquest.visible = false;
  ans11.visible = false;
  ans12.visible = false;
  ans13.visible = false;
  btnHint.visible = false;
  tim.visible = false;
  }


  ans11.addEventListener(MouseEvent.CLICK, buttones1);
  ans12.addEventListener(MouseEvent.CLICK, buttones2);
  ans13.addEventListener(MouseEvent.CLICK, buttones3);


  function buttones1(event: MouseEvent): void {
  corekWin.visible = true;
  iskoru += 10;
  //txtSkor.text = String(iskoru);
  trace("click successful");
  }
  function buttones2(event: MouseEvent): void {
  maliWin.visible = true;
  buhay -= 1;
  //txtLives.text = String(buhay);
  trace("click successful");
  }


  function buttones3(event: MouseEvent): void {
  maliWin.visible = true;
  buhay -= 1;
  //txtLives.text = String(buhay);
  trace("click successful");
  }
  maliWin.btnGobak.addEventListener(MouseEvent.CLICK, bey);


  function bey(event: MouseEvent): void {
  maliWin.visible = false;
  }


  corekWin.btnGo.addEventListener(MouseEvent.CLICK, gura);


  function gura(event: MouseEvent): void {
  corekWin.visible = false;
  quizquest.visible = false;
  ans11.visible = false;
  ans12.visible = false;
  ans13.visible = false;
  btnHint.visible = false;
  txtSec.visible = false;
  tim.visible = false;
  playergril.visible = true;
  stage.addEventListener(Event.ENTER_FRAME, loofa);
  }
}
function loofa(event: Event): void {
  if (doorOpen == false) {
  if (playergril.hitTestObject(pinto)) {
  pinto.gotoAndStop(2);
  playergril.visible = false;
  doorOpen = true;
  trace("door open");
  gotoAndStop(77);
  }
  }
}
btnHint.addEventListener(MouseEvent.CLICK, wee);
function wee(event: MouseEvent): void {
  hinto -= 1;
  txtHint.visible = true;
  if (hinto == 0) {
  nohint.visible = true;
  }
}

Note: the line with two asterisks each side is the main cause of it or pointed error.

And the error says:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
  at RECOVER_dmgamedemover_fla::MainTimeline/countDown()[RECOVER_dmgamedemover_fla.MainTimelin e::frame76:27]
  at flash.utils::Timer/_timerDispatch()
  at flash.utils::Timer/tick()

When I look at the side (Debug Console) contains some variables and objects. The other dynamic texts have been declared (flash.text.TextField) while the txtSec, the another dynamic text, is null. I have no idea on what's going on it. What would be the best solution for it? Any suggestions or ideas are appreciated. Thanks!

how to migrate a Flex-based application to html5/JS?

Please, I need to know wether it exists any tool to convert MXML to XML and XML to HTML5 (MXML to HTML5), Also a converter from Actionscript to javascript, Or should I develope my own converters? Actualy, I want to migrate a flex-based application to HTML5/JS , do you have any idea in a such subject? :) Regards,

lundi 17 avril 2017

What is the minimum qualification to work adobe gaming SDK?

I am a web developer. I am interested to the adobe gaming SDK. As a web developer can I start to build a game with adobe gaming SDK.

My questions

  1. What is the minimum qualification to work adobe gaming SDK?
  2. What type of code want to know necessary for work with gaming SDK?
  3. How works that?
  4. Where is the tutorial for beginner level (like me)?
  5. What application suitable for except adobe gaming SDK?

Thanks

streaming and downloading flashed on mobile

I would like to make my flash file working on adobe air to be streamed online and while it is streaming, it is downloaded for further calls to be working offline, any body can guide in this?

• If the file is on the mobile device it will work

• If the file is not on the mobile device, it will be streamed to work and downloaded to the mobile memory to be working offline when it is called later.

How do I assign values to a class using its parameters? - Basic

so I'm using flash punk to work on a game and i've created a base class that contains the characters stats based on the type of character the player chooses. this is what that class looks like so far.

public class Stats extends Entity
{
        public var ATK:Number;
        public var ARM:Number;
        public var SPD:Number;
        public var WIS:Number;
        public var CRG:Number;
        public var STM:Number;

    public function Stats(ATK:Number=0, ARM:Number=0, SPD:Number=0, WIS:Number=0, CRG:Number=0, STM:Number=0)
    {

    }
    override public function update():void 
    {
        super.update();

    }
}

and in another class when a button is clicked i would like it to make a new stats class with the parameters (2, 6, 2, 2, 4, 4) so i do

public var SkelStats:Stats = new Stats(2, 6, 2, 2, 4, 4);

and then assign that object (SkelStats) to the players boss type varriable. I do this

public static var BossType:Stats;

and then in the button class under the click function I add

Player.BossType = SkelStats; trace(Player.BossType.ATK)

and the trace always puts out 0 unless i change the varriable (ATK) in the stats class itself. Why doesn't it change when I enter it in the parameters for the instance of the class?(SkelStats)

Sorry if this is all too confusing, I can answer any questions about my code if anything is unclear. I'm just not sure what I'm doing wrong here.

Is it possible to generate a shape in an flv file using a script?

I am starting with Adobe Flash CS3(I know it's old but bear with me).

I want to know if it is possible to generate a shape directly in the flv canvas without dragging/dropping anything, by simply running a script.

I know that I can generate it by adding a document class such as following:

package 
{
    import flash.display.*;
    import flash.geom.*;

    public class Script extends MovieClip
    {
        public function Script()
        {
            var r : Shape = new Shape();
            r.graphics.beginFill(0x00ff00);
            r.graphics.drawRect(0, 0, 50, 50);
            r.graphics.endFill();
            this.addChild(r);
        }
    }
}

But is it possible to do this directly to the .flv file immediatly with some kind of a run-once script(eg, insert an exactly 800x300 red rectangle into my current scene at x=30, y=30)?; so that it appears on the document I am currently working on without running Control>Test Movie?

If so, how can I accomplish this?

Subarrays disappearing in Amfphp, Actionscript 3 data integration

I recently upgraded to php 5.6 and amfphp 2.2.2 and I'm trying to modify the way the data is handled in an Actionscipt 3 animation that I wrote several years ago (I haven't worked with AS3 for a long time so that may well be part of the problem here).

The amfphp site (Silex Labs) says to simply use PDO for your data and AS3 and amfphp will handle it properly, but that's not working.

The AS3 "Responder" class handles the incoming data from amfphp and it no longer uses "responds.serverInfo.initialData". So AS3 can no longer process the data the way it did with amfphp 1.9.

So I wrote a script to parse the data. I apparently don't understand the structure of the data object that amfphp provides to the AS3, but I was able to extract the data from the object and store in an array.

I can trace the data in the triple loop in the AS3 script, but outside of the loop the subarrays are undefined.

I must be doing something wrong in the AS3. Can anyone see what it is?

The php:

<?php
function getConnection() {
    return new PDO('mysql:host=localhost;dbname=db-name', 'root', '',
    array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
}

function getData() {
    $pdo = getConnection();
    $tsql = "SELECT col0, col1, col2, col3, col4, col5, col6, col7 
           FROM somedata ORDER BY index_num ASC"; 

    $stmt = $pdo->prepare($tsql);
    $stmt->execute();
    $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
    return $results;
}

?>

The AS3:

        public class GetSomeData extends Sprite {
    private var gw:NetConnection = new NetConnection();
    private var getRes:Responder = new Responder(onResult, onFault);
    private var someData:Array = new Array();
    private var colList:Array = new Array();

    public function GetSomeData() {}

    public function refreshSomeData():void {
        gw.connect("http://localhost/Amfphp/");         
        gw.call("GetSomeData.getData", getRes);
    }


    private function onResult(responds:Object):void {
        /****** THIS IS OUTDATED AS OF amfphp 2.x *******/
        //responds is an arrayCollection which includes .serverInfo.initialData
        //someData = responds.serverInfo.initialData;

        //this is because amfphp returns the columns in the SELECT statement out of order
        colList = ["col0", "col1", "col2", "col3", "col4", "col5", "col6", "col7"];

        for (var j:uint=0; j < colList.length; j++) {
            for (var k:uint=0; k < responds.length; k++) {
                    for(var x in responds[k]){//put columns in correct order
                        if (x.toString() == colList[j]){
                            someData[k] = new Array();
                            someData[k][j] = responds[k][x];
                            //this trace reports all of the data correctly
                            trace(someData[k][j].length);//
                        }
                    }
           }
        }

        trace(someData.length);//49
        trace(someData[0].length);//8
        trace(someData[0][0].length);//undefined

    }
}

How to merge audio video file in mac system using action script?

I am creating a screen recording application using action script. I am able to record the screen and audio files separately but the issue i am facing is that i am not able to merge these audio and video files in Mac.

For windows version i have used the ffmpeg and it is working fine But for Mac system it is not working. Do you guys have any other suggestions or any way to run the ffmpeg from the action script directly for Mac ?

Game assets not loading in Kongregate

I just created my first game, and am having some problems. I uploaded to Kongregate(but didn't publish yet), and in the preview the external files(music and three pictures) don't load. The rest of the game works fine.

If I try to change it so there is a zip with the assets in it and change the directory in the code, it falls apart.

I'm using FlashDevelop, so everything is programatic. I noticed the swf is only a few kb large, so is there anyway to compile the assets into the swf file and load them that way, or do I need to do something else?

Please help, and thanks in advance.

AS3: Sending empty Content-Type header in urlrequestHeader

I want to download file from dropbox api. Below is the snippet of my code.

        var oauthHeader:URLRequestHeader = OAuthHelper.buildRequestHeaderWithToken(config.accessTokenKey);
        var urlRequest:URLRequest = new URLRequest();
        var jsonPath:String = JSON.stringify(params);
        var requestHeader:URLRequestHeader = new URLRequestHeader("Dropbox-API-Arg",jsonPath);

        urlRequest.requestHeaders = [oauthHeader,requestHeader];
        urlRequest.contentType = "";
        urlRequest.method = httpMethod;
        urlRequest.url = url;

I get the following error when making request.

Error in call to API function "files/download": You provided a non-empty HTTP "Content-Type" header ("application/x-www-form-urlencoded"). This API function requires that the header be missing or empty.

How can I send empty 'Content-Type' header.

dimanche 16 avril 2017

Actionscript 3 play sound on calling

this is the scenario. I make a call, then open my app with some button that play a sound when pressed, so the called must ear my sound Like I'm talking to the microphone.how can i achieve this? How can i pass audio to the microphone?

INTEGRATE A SHORT-RANGE P2P SYSTEM TO AN ACTIONSCRIPT3 APP

I have built an actionscript app (flash pro) and would like to add/integrate a short range p2p system (10 meter range). How do I go about it?

AIR Stagewebview not displaying youtube videos

I have trying to load youtube videos using stagewebview on AIR Desktop. (windows 10) Code below:

var SWV:StageWebView = new StageWebView(true);
SWV.addEventListener(ErrorEvent.ERROR, swvErrorHandler);
var swvHeight:Number = stage.stageHeight - (75);
var swvWidth:Number = stage.stageWidth;
var swvYCoord:Number = 75;
SWV.stage = stage;
SWV.viewPort = new Rectangle(0, swvYCoord, swvWidth, swvHeight);
var vId:String = 'QowwaefoCec';
var urlToLoad:String = "http://www.youtube.com/embed/"+vId+"?rel=0&amp;controls=1&amp;showinfo=0&amp;autoplay=0";
SWV.loadURL(urlToLoad);

Running the code gives a window with black background. Right clicking on it pops up the adobe flashplayer menu stating "Movie not loaded". Flash version is 25.0.0.148

If i use urlToLoad="https://www.youtube.com/watch?v="+vId; i get a malformed youtube page with majority of elements missing.

Tried with number of videos. result is always the same.

Can any one help please? I remember having tried out the above code a year or so back (when i was testing something else). It had definitely worked then. Cant fathom why it doesnot work now. Any help will be highly appreciated.

samedi 15 avril 2017

Is it possible to take a screenshot of the stage in AS3 using a button?

I was wondering if it is possible to take a screenshot of the stage in AS3. I tried looking everywhere online and found out nothing. If it is possible, can you link me to a code I can try to use? Thank you for your time!

vendredi 14 avril 2017

Stopping rnd = Math.floor(Math.random() * 3) + 1;

I want to be able to get a different number from

rnd = Math.floor(Math.random() * 3) + 1;

but it keeps giving me a number every time causing different statements to be true.

if (rnd == 1) {
        chest1.gotoAndStop("chest");
    }
    if (rnd == 2) {
        chest2.gotoAndStop("chest");
    }
    if (rnd == 3) {
        chest3.gotoAndStop("chest");
    }

I want it so it does it once, and then gives me another number after i successful returned the chest causing another chest to appear. But its not, just makes the same chest appear :(

How do I get images to update dynamically with a slider in actionscript 3?

Here is my dilemma. We use image stacks a lot here with alpha channels. I want to call up images in series using a slider. I am getting a concatenated string a pull up an image from my folder. But I can get the images to load dynamically when I slide the slider bar. I am using the frame number to change the file name to pull up the next frame. I can get the image to show up if I put the loader outside of the function, but when I put the loader in the function I get error after error saying the file cannot be located. I would really appreciate any help. I have a fear of coding and I am hoping a forum like this will help me break through in areas like this where I always fall on my face. Here is the code as it currently stands.

var imgLoader = new Loader();
var str1 = String (".jpg");
var sliderValue:uint = mySlider.sliderKnob.x / 3;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(event:Event):void {
    sliderValue = mySlider.sliderKnob.x / 3;
    status_txt.text = "Slider position is: "+sliderValue;
    fileText.text = "Sketch_0"+sliderValue+".jpg";
    imgLoader.load( new URLRequest ( "Sketch_0"+sliderValue+".jpg"));
addChild(imgLoader);
setChildIndex(imgLoader, 0); 
}

Thanks in advance. It's embarrassing to put code on the web and reveal my ignorance.

H

Please help me with pop up button (actionscript)

so i want to make after i clicked all my buttons and disappear,and there's a button popup so i can proceed to next scene. this is my current AS codes:

    addEventListener(Event.ENTER_FRAME, fadeOut);
}

function fadeOut(event:Event):void
{
    var a:Number = myButton.alpha-0.05;
    if (a<=0)
    {
        a = 0;
        removeEventListener(Event.ENTER_FRAME, fadeOut);
    }
    myButton.alpha = a;
}

thanks in advance

How can i hitTesObject a movieclip inside a movieclip AS3?

I want my zombie to collect the brains(g1b1,g1b2,g1b3,g1b4). These brains are inside my movieclip 'platform1' because i need it to have a scrolling background effect. Well my zombie character can walk however he can't collect the brains.

import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.events.Event;
import flash.ui.Keyboard;
import flash.display.Sprite;

public class z extends MovieClip {

    private var score:int=0;
    private var zombieSpeed:int=7; //speed for zombie
    private var gravity:int=1;
    private var jumpSpeed:int=0;//current speed for the jump
    private var jumpSpeedLimit:int=15; //how quick the jump

    private var jump, left, right, down, mainJump:Boolean=false; //zombie is not jumping

    public function z() {

    }

    public function Game1() {
        stop();
        stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
        stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
        zombie.addEventListener(Event.ENTER_FRAME, moveCharacter1);
        gamePlay1();
    }

    private function keyPressed(e:KeyboardEvent) {
        if (e.keyCode==Keyboard.LEFT) {
            left=true;
            zombie.gotoAndPlay("left");
        }
        if (e.keyCode==Keyboard.RIGHT) {
            right=true;
            zombie.gotoAndPlay("right");
        }
        if (e.keyCode==Keyboard.SPACE || Keyboard.UP) {
            jump=true;
        }
        if (e.keyCode==Keyboard.DOWN) {
            down=true;
        }
    }

    private function keyReleased(e:KeyboardEvent) {
        if (e.keyCode==Keyboard.LEFT || Keyboard.D) {
            left=false;
            zombieSpeed-=5;
            zombie.gotoAndStop("idleLeft");
        }
        if (e.keyCode==Keyboard.RIGHT || Keyboard.A) {
            right=false;
            zombieSpeed+=5;
            zombie.gotoAndStop("idleRight");
        }
        if (e.keyCode==Keyboard.SPACE || Keyboard.UP || Keyboard.W) {
            jump=false;
        }
        if (e.keyCode==Keyboard.DOWN || Keyboard.S) {
            down=false;
        }
    }

    private function moveCharacter1(e:Event) {
        if (left) {
            if (platform1.x<1000 && zombie.x==870) {
                platform1.x+=5;
            }
            else {
                if (zombie.x>120) {
                    zombie.x-=zombieSpeed;
                    trace(platform1.x);
                }
            }
        }
        if (right) {
            if (platform1.x>0 && zombie.x==870) {
                platform1.x-=5;
            }
            else {
                if (zombie.x<880) {
                    zombie.x+=zombieSpeed;
                    trace(platform1.x)
                }
            }
        }
        if (jump) {
            goJump();
    }

    function goJump() {
        if(jumpSpeed > 0 && jumpSpeed <= jumpSpeedLimit){
            jumpSpeed *= 1 + jumpSpeedLimit/50;
        }
        zombie.y += jumpSpeed;      
        for (var i=0;i<5;i++) {
            if(platform1.hitTestPoint(zombie.x,zombie.y,true)) {
                zombie.y--;
                jumpSpeed=0;
                mainJump=false;
            }
        }
    }

    **private function gamePlay1() {
        if(zombie.hitTestObject(platform1.g1b1)){
            platform1.g1b1.visible = false;
            score+=10;
        }
        if(zombie.hitTestObject(this.platform1.g1b2)){
            platform1.g1b2.visible = false;
            score+=10;
        }
        if(zombie.hitTestObject(platform1.g1b3)){
            platform1.g1b3.visible = false;
            score+=10;
        }
        if(zombie.hitTestObject(this.platform1.g1b4)){
            platform1.g1b4.visible = false;
            score+=10;
        }       
   }**

}

(Flash/Animate CC AS3) Getting multiple images to turn on/off at particular times not working with second MovieClip

Ok this has been driving me insane. My AS3 knowledge isn't the best in the world, but I'm trying to work out where I'm going wrong with all of this.

Basically, What I'm trying to do is at certain times, make visible/invisble two different MovieClips.

The weird thing is, one is responding. And the other isn't. They are both identical aside from jpeg contents and names. Is there a setting I'm missing? Both have matched MovieClip names and Instance names... but when I use the code below, HOP1 turns off/on, but HOP2 refuses to! Am i just missing some stupidly obvious preference?

I will mention, I'll have to modify the code to work with two different MovieClips, but right now I just want both files to turn off!

package  {

    import flash.display.MovieClip;
    import flash.events.TimerEvent;
    import flash.ui.Mouse;
    import flash.utils.Timer;
    import com.boo.CustomDate;
    import com.boo.ScreensaverSimple;

    public class Generic extends MovieClip {

        // This is where you can set the Hour of Power time start and end time (in 24 hour format e.g. 1330 for 1:30pm)
        // If there is no hour of power, simply set both numbers to 0
        private var HourOfPowerStartTime:Number = 0;
        private var HourOfPowerEndTime:Number = 0;

        private var ss:ScreensaverSimple;

        public var time_check_timer:Timer;

        private var delay_add_timer:Timer;

        public function Generic() {
            Mouse.hide();

            ss = new ScreensaverSimple;
            ss.setScreensaver(screens);

            HOP2.visible = false;

            time_check_timer = new Timer(1000);
            time_check_timer.addEventListener(TimerEvent.TIMER, checkTime);

            delay_add_timer = new Timer(1,1);
            delay_add_timer.addEventListener(TimerEvent.TIMER, addAllChildren);
            delay_add_timer.start();    
        }

        public function addAllChildren(evt:TimerEvent=null):void {
            delay_add_timer.removeEventListener(TimerEvent.TIMER, addAllChildren);
            delay_add_timer.stop();
            delay_add_timer = null;

            time_check_timer.start();

            checkTime();
        }

        public function checkTime(evt:TimerEvent=null):void {
            checkHOP2();
        }

        private function checkHOP1():void {
            if(HourOfPowerStartTime == 0 && HourOfPowerEndTime == 0)
            {
                if(HOP2.visible == true)
                {
                    HOP2.visible = false;
                }

                return;
            }

            var CurrentTime:Number = CustomDate.return24HourNumber();

            if(CurrentTime >= HourOfPowerStartTime && CurrentTime <= HourOfPowerEndTime)
            {
                if(HOP2.visible == false)
                {
                    HOP2.visible = true;
                }
            }
            else
            {
                if(HOP2.visible == true)
                {
                    HOP2.visible = false;
                }
            }
        }

    }

}

Actionscript 3 - Why is this variable increasing?

I am trying to create a general class to use in my flash projects : a "GameSceneSprite" which is basically a movieClip which manages the 3 phases a display object usually has : the intro, the active/interactive time, the outro. Should be very useful to make menus, for instance.

It seemed to work fine, until an unexpected problem came. Here is the part that poses a problem, it's in the outro part.

    //ACTIVATE CLICK
    //----------------------------------------
    override public function makeInteractive() {
        (this.parent as MAIN).addEventListener( MouseEvent.MOUSE_UP , clickOnParent );
    }

    //REACT TO CLICK
    //----------------------------------------
    protected function clickOnParent (e:MouseEvent) {

        //Only react to clic if interface clip wasn't the one clicked
        var commonsMenu = (parent as MAIN).getChildAt(2) as MovieClip;

        if ( !commonsMenu.contains( e.target as DisplayObject ) ) {
            stopInteractive();
        }

    }

    //STOP INTERACTIVE PHASE
    //----------------------------------------
    override protected function stopInteractive() {

        (this.parent as MAIN).removeEventListener( MouseEvent.MOUSE_UP , clickOnParent );
        startOutro( 0.01 );

    }

    //------------------------------------------------------------------------------------------------------------------------------
    //------------------------------------------------------- OUTRO ----------------------------------------------------------------
    //------------------------------------------------------------------------------------------------------------------------------    

    //START L'OUTRO
    //----------------------------------------
    override public function startOutro( _duration:Number ) {

        trace ( this , " - OUTRO STARTED" );

        this.mainTimer.start();
        this.TIMECODES_mainTimer = new Array();
        this.TIMECODES_mainTimer.push( _duration*1000 );

        this.currentTimeCode = 0;

        this.currentStatus = CONFIG.CONST_FILE.GAMESCENESPRITE_CODE_OUTRO;
        this.addEventListener( Event.ENTER_FRAME , playOutro );

        //Define event timecodes
        this.TIMECODES_mainTimer.unshift( );
        //***TO DO : ADD ACTUAL INTRO WITH ACTUAL TIMECODES***

    }

    //PLAY CLIP OUTRO
    //----------------------------------------
    override protected function playOutro( e:Event ) {

        var hasReached_Timecode:Boolean = ( this.mainTimer.getElapsed() >= this.TIMECODES_mainTimer[currentTimeCode] );

        //If we reach a timecode, go to next. If it was the last timecode, end function there.
        if ( hasReached_Timecode ){

            this.currentTimeCode++;
            if ( this.currentTimeCode >= this.TIMECODES_mainTimer.length ) { outroEnds(); return; }

        }

        //TO DO : ADD TIMECODE CODE

    }

    //END OF OUTRO
    //----------------------------------------
    override public function outroEnds() {

        if ( this.currentStatus == CONFIG.CONST_FILE.GAMESCENESPRITE_CODE_OUTRO && this.hasEventListener( Event.ENTER_FRAME ) ) {

            trace ( this , " - OUTRO ENDED" );
            this.removeEventListener( Event.ENTER_FRAME , playOutro );

            removeThisAndLoadNext("MAIN_MENU_CLIP");
        }

    }

For some reason, when the outro runs, the variable "currentTimeCode" increases to 1 without the "hasReached_Timecode" boolean ever being true! Since there is nothing in TIMECODES_mainTimer[i], this leads to a comparison with undefined, and the outro just NEVER ENDS.

What could possibly cause this variable to increase?!! There is no occurrence of an increase besides the one that happens when the test is true... which it never is right now.

...I can not figure it out. Please help me!

I can provide extra code for the other parts and answers if needed. Just ask.