mercredi 31 août 2016

AS3 need open a new socket in every Message?

I made a conection between a nodeJS server and Flash socket client.

When I open the client, the conection with the server is successfull, but I can send only one message on this socket conection. if I want send more messages i need to open another conection for every message. if I don't open this new conection, the socket dont send more data.

note: I work in flashdevelop

Question:

This is the normal way to send data from the client socket to the server? if its not the way, can you show me how send more messages with only one conection socket?

my server code:

try {
    Security.allowDomain('xxx.xxx.x.xx');
    Security.loadPolicyFile("xmlsocket://xxx.xxx.x.xx:3000");
} catch (e) {

}

var net = require('net');


var server = net.createServer(function(stream) {
    stream.addListener("connect", function() {
        console.log("Client connected");
        stream.write("hello\r\n");
    });

    stream.addListener("data", function(data) {
        console.log(stream);
        console.log("Received from client: " + data);
        stream.write(data);
    });

    stream.addListener("end", function() {
        console.log("Client disconnected");
        stream.end();
    });
});

server.listen(3000, "xxx.xxx.x.xx");
console.log("running");

my AS3 client code:

package ejempo1
{    import flash.display.MovieClip;
     import flash.events.Event;
     import flash.events.MouseEvent;
     import flash.events.KeyboardEvent;
     import flash.external.ExternalInterface;
     import flash.text.*;
     import flash.utils.*;

     import flash.display.Sprite;
     import flash.events.ProgressEvent;
     import flash.net.Socket;

     public class Main extends MovieClip
    {
        private var socket:Socket;

        public function Main()
        {

            stage.addEventListener(MouseEvent.CLICK, clickHandler);


            //socket de conexion
            socket = new Socket();
            
            socket.connect("xxx.xxx.x.xx", 3000);
            socket.writeUTFBytes("Hello server");//this message work fine

            socket.addEventListener(Event.CONNECT, connectHandler);
            socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);

        }
        
        private function connectHandler(e:Event):void {
            trace(e);
            trace("connect");
        }
        
        private var toRead:int = 0;
        
        private function socketDataHandler(e:ProgressEvent):void {
            trace("socketDataHandler: " + e);
            var str:String = socket.readUTFBytes(e.bytesLoaded);
            trace("server say:"+str);
            
        }


        public function send(data:Object):void {
            socket.writeObject(data);
            socket.flush();
        }
        
        
        private function clickHandler(event:MouseEvent):void {
                socket.connect("xxx.xxx.x.xx", 3000);//if I delete this line, the next code line dont work when I make a click.
                socket.writeUTFBytes("pepe");
             
        } 
    }
}

TypeError: Cannot read property of instance

I'm trying to make eye following for cursor like this http://ift.tt/2bHI6wl in Adobe Animate 2015

function getMousePos(canvasDom, mouseEvent) {
  var rect = canvasDom.getBoundingClientRect();
  return {
    x: mouseEvent.clientX - rect.left,
    y: mouseEvent.clientY - rect.top
  };
}

canvas.addEventListener("mousemove", function (e) {
    mousePos = getMousePos(this, e);

    var xx = mousePos.x - this.Reye.x;
    var yy = mousePos.y - this.Reye.y;
    var radiusR1 = Math.atan2(yy, xx);
    var degreeR1 = radiusR1 / (Math.PI / 180);
    this.Reye.rotation = degreeR1;

}, false);

but i have error in browser

TypeError: Cannot read property 'x' of undefined

and this code is working fine

this.addEventListener("click", fl_MouseClickHandler.bind(this));
function fl_MouseClickHandler(evt)
{
    var xx = stage.mouseX - this.Reye.x;
    var yy = stage.mouseY - this.Reye.y;
    var radiusR1 = Math.atan2(yy, xx);
    var degreeR1 = radiusR1 / (Math.PI / 180);
    this.Reye.rotation = degreeR1;
}

in Flex/AS3 how can I highlight a datagrid row?

I am writing an application, using a datagrid. Various rows are differing colors based on the data. When the user selects a row the color becomes a few shades lighter.

Unfortunately one of the users doesn't think it is enough of a contrast and would like a more noticeable visual indicator. My two thoughts are to either;

A) Draw a rectangle around the entire row selected. B) Add a column with an image that I hide or make visible based on whether the row is selected.

I went down path A. for a while and got to the point where in the function;

override protected function drawHighlightIndicator

I was able to identify when I was looking at the specific row, but I couldn't determine how to draw the rectangle.

So I backtracked and looked into B. I am able to create an Item renderer with an arrow, but I can't figure out how to turn it on & off when selected. I have a click event in the main module, but no way to reference back to the Item renderer component.

I could set a value in the array collection, and do a refresh, which will probably work, but that tends to move the selected row to the top of the datagrid display area.

So if anyone can help I on A or B would appreciate it. This is a DataGrid, not an AdvancedDataGrid.

Accurate video seek: running a streaming server locally?

I've got a legacy Flex AIR desktop app which requires accurate video seek. The only way which I've got this to work is to render the video with a keyframe every frame. This results in massive file sizes.

I've done a lot of research on this from the AS3/Flex side and it seems the only other way to get accurate seek is to stream from a server which generates the requested frame on the fly. My app plays back only local files.

I am not a "video person" and don't know all the issues with codecs, rendering, keyframes, etc. I note that apps like VLC allow stepping frame-by-frame so I assume that it includes the code required to render frames on the fly. Flex obviously does not have this functionality.

Question: Is it possible to run a streaming server like red5 locally in the background to take advantage of this on-demand rendering?

My app is cross-platform, OSX and PC, and would need to run on systems without requiring additional configuration (e.g. opening ports, etc.). It seems like if this approach even worked, it would be fragile but I thought I would ask the brain trust.

Other suggestions or solutions also welcome.

ActionScript 3 Socket error 2031

I have a simple client socket as3 application I developed in Flash Develop but I cannot get my client to connect.

I have checked the firewall and the port is open but I cannot get the client to communicate. Does anyone have any ideas?

The Trace output is

enter image description here Server class is

package 
{
import flash.events.Event;
import flash.net.ServerSocket;
import flash.events.ServerSocketConnectEvent;
import flash.net.Socket;
import flash.events.ProgressEvent;

/**
 * ...
 * @author Quentin Samuelson
 */
public class Server 
{

    private var server:ServerSocket;
    private var clients:Vector.<Socket> = new Vector.<Socket>;

    public function create():Boolean
    {
        server = new ServerSocket(); 
        server.bind(8888);
        server.addEventListener(ServerSocketConnectEvent.CONNECT, serverConnectHandler);
        server.listen();
        trace("Server is listening");
        trace("Server is Bound : " + server.bound);
        trace("Server is Listening : " + server.listening);
        trace("Server is LocalAddress : " + server.localAddress);
        trace("Server is LocalPort : " + server.localPort);
        return true;
    }

    private function serverConnectHandler(e:ServerSocketConnectEvent):void 
    {
        var socket:Socket = e.socket;
        trace("Remote Address : " + e.socket.remoteAddress);
        clients.push(socket);
        trace("Remote Address : " + e.socket.remoteAddress);
        socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);
    }

    private function socketDataHandler(e:ProgressEvent):void 
    {
        var socket:Socket = e.currentTarget as Socket;
        var data:Object = socket.readObject();
        trace("Server Data received:", data);
    }

    public function send(data:Object):void 
    {
        var b:Boolean = false;
        trace("Attempt to send to all clients");
        for each(var client:Socket in clients)
        {
            client.writeObject(data);
            client.flush();
            trace("Sent to client");
            b = true;
        }
        if (!b) 
        {
            trace("Unable to send to all clients" + clients);
        }
    }
}

}

Client Class is

package
{
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.events.SecurityErrorEvent;
import flash.net.Socket;
import flash.errors.IOError;

/**
 * ...
 * @author Quentin Samuelson
 */
public class Client
{
    public var clientSocket:Socket;

    public function create():void
    {
        clientSocket = new Socket();
        clientSocket.addEventListener(Event.CONNECT, connectHandler,false, 0, true);
        clientSocket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler, false, 0, true);
    }

    public function connect(address:String):void
    {
        try
        {
            clientSocket.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
            clientSocket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
            clientSocket.connect(address, 8888);
            trace("client Connected : " + clientSocket.connected + " on local port : " + clientSocket.localPort + " on remote port : " + clientSocket.remotePort);
        }
        catch (ioError:IOError)
        {
            trace(ioError.message);
        }
        catch (secError:SecurityError)
        {
            trace(secError.message);
        }
    }

    private function ioErrorHandler(event:IOErrorEvent):void
    {
        trace("ioErrorHandler: " + event);
    }

    private function securityErrorHandler(event:SecurityErrorEvent):void
    {
        trace("securityErrorHandler: " + event);
    }

    private function connectHandler(e:Event):void
    {
        trace(e);
    }

    private function socketDataHandler(e:ProgressEvent):void
    {
        var data:Object = clientSocket.readObject();
        trace("Client Data received:", data);
    }

    public function send(data:Object):void
    {
        try
        {
            trace("Attempt to send from client");
            trace("client Connected : " + clientSocket.connected + " on local port : " + clientSocket.localPort + " on remote port : " + clientSocket.remotePort);
            clientSocket.writeObject(data);
            clientSocket.flush();
            trace("Sent from client");
        }
        catch (e:Error)
        {
            trace("ERROR SENDING : " + e.message);
        }
    }
}

}

Main Class is

package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.net.ServerSocket;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import flash.events.Event;
import flash.events.ServerSocketConnectEvent;
import flash.events.ProgressEvent;

/**
 * ...
 * @author Quentin Samuelson
 */
public class Main extends Sprite
{



    public function Main()
    {
        stage.scaleMode = StageScaleMode.NO_SCALE;
        stage.align = StageAlign.TOP_LEFT;
        stage.addEventListener(Event.DEACTIVATE, deactivate);

        // touch or gesture?
        Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

        // Entry point
        var s:Server = new Server();
        var c:Client = new Client();

        trace("Create Server");
        s.create();
        trace("Server Created");
        s.send("Server is Running");
        trace("Creating Client");
        c.create();
        trace("Client Created");
        trace("Client Connecting");
        c.connect("0.0.0.0");
        //trace("Client Connected");
        //c.send("Testing");
        //s.send("Server Message");





    }




    private function deactivate(e:Event):void
    {
        // make sure the app behaves well (or exits) when in background
        //NativeApplication.nativeApplication.exit();
    }

}

}

Compile FLA assets with AS2 actions and ActionScript into SWF

I am working on a legacy project that has FLA assets with AS2 actions and some ActionScript code and I have made some changes in the ActionScript code. I want to compile all files into a single SWF. Can you please suggest a possible way of achieving this?

I have tried to compile the entire code in IntelliJ as a Flex Web project. But after compilation the generated SWF does not contain the FLA assets. I did a bit of research and figured out that the FLA's can be imported as SWC library in IntelliJ. But Adobe Flash Pro is not allowing me to export the FLA as SWC since it has AS2 actions.

mardi 30 août 2016

Can't have 2 dynamic text fields AS3

This is not a specific situation, this is something that happens a lot to me.

Whenever I have dynamic text (that changes through code, of course) everything works fine. However, when I add a second Dynamic text, both of them do not show. An example scenario would be:

textfield1.text="hello";

and on the next frame

textfield2.text="goodbye";

no text would show. Something is wrong with flash, maybe. The problem starts when I add another textbox to the stage.

I do not want to upgrade to a newer flash, but I could if I have to.

If anybody knows how to fix my problem, please tell me.

Chrome is not reading my JSON code [Flash]

I've been working on a project using Flash for a while now, and this issue just cropped up. I'm used to working with using JSON in flash for game projects because I've done it several times in the past, but for some reason it isn't working correctly right now, consistently and it is very confusing.

So, the process is supposed to be like this:

  1. The title screen loads.
  2. The user presses begin and the game grabs level data from the single JSON file
  3. It loads but only shows 1 town and a window telling the player what to do.

It works perfectly in Firefox and internet explorer, it just doesn't work in chrome and I don't know why.

The swf is embedded using object tags and active x for internet explorer. Link Here

The AS3 code is here. It uses the JSON parser to load the levels. Link Here

It should look like this. It looks like this in firefox, IE and in the debugger. Link Here

In chrome it looks like this. All the missions are unlocked and none of the buttons work. Link Here

AS3 Cipher Decoder & Encoder (better answer?)

Over the past two years, I've been dependent on searching here for answers, and you guys just all seem amazing-- thank you so much to the whole community. Pretty nervous to ask my first question, phbft.

Last night, my little brother asked me if it were possible to make a program that would substitute every letter for another letter in the alphabet, to turn it into a code, and also turn it back to its normal state.

So I made this: http://ift.tt/2bPWabN

And by all accounts, it does the job, but I feel like, code-wise, it's clunky as all get-out, and I'd really love to improve my knowledge on things like loops...

I'm just going to post all the code here.

stop();

// SET-UP STUFF
inputText.alpha = .5;
outputText.alpha = .5;
inputText.borderColor = 0xCCCCCC;
outputText.borderColor = 0xCCCCCC;
var textinProgress:String;
textinProgress = inputText.text;
if (textinProgress.charAt(0) == "\r") {
    inputText.text = "";
}
stage.addEventListener(Event.ENTER_FRAME, refresh_frame1);
function refresh_frame1(e:Event):void {
    inputScroll.update();
    outputScroll.update();
}
// ORIGINAL ALPHABET
var letters_aArray:Array = new Array();
letters_aArray[0] = "a";
letters_aArray[1] = "b";
letters_aArray[2] = "c";
letters_aArray[3] = "d";
letters_aArray[4] = "e";
letters_aArray[5] = "f";
letters_aArray[6] = "g";
letters_aArray[7] = "h";
letters_aArray[8] = "i";
letters_aArray[9] = "j";
letters_aArray[10] = "k";
letters_aArray[11] = "l";
letters_aArray[12] = "m";
letters_aArray[13] = "n";
letters_aArray[14] = "o";
letters_aArray[15] = "p";
letters_aArray[16] = "q";
letters_aArray[17] = "r";
letters_aArray[18] = "s";
letters_aArray[19] = "t";
letters_aArray[20] = "u";
letters_aArray[21] = "v";
letters_aArray[22] = "w";
letters_aArray[23] = "x";
letters_aArray[24] = "y";
letters_aArray[25] = "z";
// NEW ALPHABET
var letters_bArray:Array = new Array();
letters_bArray[0] = "m";
letters_bArray[1] = "n";
letters_bArray[2] = "b";
letters_bArray[3] = "v";
letters_bArray[4] = "c";
letters_bArray[5] = "x";
letters_bArray[6] = "z";
letters_bArray[7] = "l";
letters_bArray[8] = "k";
letters_bArray[9] = "j";
letters_bArray[10] = "h";
letters_bArray[11] = "g";
letters_bArray[12] = "f";
letters_bArray[13] = "d";
letters_bArray[14] = "s";
letters_bArray[15] = "a";
letters_bArray[16] = "p";
letters_bArray[17] = "o";
letters_bArray[18] = "i";
letters_bArray[19] = "u";
letters_bArray[20] = "y";
letters_bArray[21] = "t";
letters_bArray[22] = "r";
letters_bArray[23] = "e";
letters_bArray[24] = "w";
letters_bArray[25] = "q";
// ENCODE BUTTON
encode_btn.addEventListener(MouseEvent.CLICK, encode_btnclick);

function encode_btnclick(event:MouseEvent):void
{
    textinProgress = inputText.text;
    outputText.text = "";
    for (var b=0; b<textinProgress.length; b++) {
        if (textinProgress.charAt(b).search(letters_aArray[0]) == 0) {
            outputText.appendText(letters_bArray[0]);
        } else if (textinProgress.charAt(b).search(letters_aArray[0].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[0].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[1]) == 0) {
            outputText.appendText(letters_bArray[1]);
        } else if (textinProgress.charAt(b).search(letters_aArray[1].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[1].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[2]) == 0) {
            outputText.appendText(letters_bArray[2]);
        } else if (textinProgress.charAt(b).search(letters_aArray[2].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[2].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[3]) == 0) {
            outputText.appendText(letters_bArray[3]);
        } else if (textinProgress.charAt(b).search(letters_aArray[3].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[3].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[4]) == 0) {
            outputText.appendText(letters_bArray[4]);
        } else if (textinProgress.charAt(b).search(letters_aArray[4].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[4].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[5]) == 0) {
            outputText.appendText(letters_bArray[5]);
        } else if (textinProgress.charAt(b).search(letters_aArray[5].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[5].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[6]) == 0) {
            outputText.appendText(letters_bArray[6]);
        } else if (textinProgress.charAt(b).search(letters_aArray[6].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[6].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[7]) == 0) {
            outputText.appendText(letters_bArray[7]);
        } else if (textinProgress.charAt(b).search(letters_aArray[7].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[7].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[8]) == 0) {
            outputText.appendText(letters_bArray[8]);
        } else if (textinProgress.charAt(b).search(letters_aArray[8].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[8].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[9]) == 0) {
            outputText.appendText(letters_bArray[9]);
        } else if (textinProgress.charAt(b).search(letters_aArray[9].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[9].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[10]) == 0) {
            outputText.appendText(letters_bArray[10]);
        } else if (textinProgress.charAt(b).search(letters_aArray[10].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[10].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[11]) == 0) {
            outputText.appendText(letters_bArray[11]);
        } else if (textinProgress.charAt(b).search(letters_aArray[11].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[11].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[12]) == 0) {
            outputText.appendText(letters_bArray[12]);
        } else if (textinProgress.charAt(b).search(letters_aArray[12].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[12].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[13]) == 0) {
            outputText.appendText(letters_bArray[13]);
        } else if (textinProgress.charAt(b).search(letters_aArray[13].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[13].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[14]) == 0) {
            outputText.appendText(letters_bArray[14]);
        } else if (textinProgress.charAt(b).search(letters_aArray[14].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[14].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[15]) == 0) {
            outputText.appendText(letters_bArray[15]);
        } else if (textinProgress.charAt(b).search(letters_aArray[15].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[15].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[16]) == 0) {
            outputText.appendText(letters_bArray[16]);
        } else if (textinProgress.charAt(b).search(letters_aArray[16].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[16].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[17]) == 0) {
            outputText.appendText(letters_bArray[17]);
        } else if (textinProgress.charAt(b).search(letters_aArray[17].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[17].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[18]) == 0) {
            outputText.appendText(letters_bArray[18]);
        } else if (textinProgress.charAt(b).search(letters_aArray[18].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[18].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[19]) == 0) {
            outputText.appendText(letters_bArray[19]);
        } else if (textinProgress.charAt(b).search(letters_aArray[19].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[19].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[20]) == 0) {
            outputText.appendText(letters_bArray[20]);
        } else if (textinProgress.charAt(b).search(letters_aArray[20].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[20].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[21]) == 0) {
            outputText.appendText(letters_bArray[21]);
        } else if (textinProgress.charAt(b).search(letters_aArray[21].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[21].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[22]) == 0) {
            outputText.appendText(letters_bArray[22]);
        } else if (textinProgress.charAt(b).search(letters_aArray[22].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[22].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[23]) == 0) {
            outputText.appendText(letters_bArray[23]);
        } else if (textinProgress.charAt(b).search(letters_aArray[23].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[23].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[24]) == 0) {
            outputText.appendText(letters_bArray[24]);
        } else if (textinProgress.charAt(b).search(letters_aArray[24].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[24].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_aArray[25]) == 0) {
            outputText.appendText(letters_bArray[25]);
        } else if (textinProgress.charAt(b).search(letters_aArray[25].toUpperCase()) == 0) {
            outputText.appendText(letters_bArray[25].toUpperCase());
        } else if (textinProgress.charAt(b) == "\r") {
            outputText.appendText("\n");
        } else {
            outputText.appendText(textinProgress.charAt(b));
        }
    }
}
// DECODE BUTTON
decode_btn.addEventListener(MouseEvent.CLICK, decode_btnclick);

function decode_btnclick(event:MouseEvent):void
{
    textinProgress = inputText.text;
    outputText.text = "";
    for (var b=0; b<textinProgress.length; b++) {
        if (textinProgress.charAt(b).search(letters_bArray[0]) == 0) {
            outputText.appendText(letters_aArray[0]);
        } else if (textinProgress.charAt(b).search(letters_bArray[0].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[0].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[1]) == 0) {
            outputText.appendText(letters_aArray[1]);
        } else if (textinProgress.charAt(b).search(letters_bArray[1].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[1].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[2]) == 0) {
            outputText.appendText(letters_aArray[2]);
        } else if (textinProgress.charAt(b).search(letters_bArray[2].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[2].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[3]) == 0) {
            outputText.appendText(letters_aArray[3]);
        } else if (textinProgress.charAt(b).search(letters_bArray[3].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[3].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[4]) == 0) {
            outputText.appendText(letters_aArray[4]);
        } else if (textinProgress.charAt(b).search(letters_bArray[4].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[4].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[5]) == 0) {
            outputText.appendText(letters_aArray[5]);
        } else if (textinProgress.charAt(b).search(letters_bArray[5].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[5].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[6]) == 0) {
            outputText.appendText(letters_aArray[6]);
        } else if (textinProgress.charAt(b).search(letters_bArray[6].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[6].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[7]) == 0) {
            outputText.appendText(letters_aArray[7]);
        } else if (textinProgress.charAt(b).search(letters_bArray[7].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[7].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[8]) == 0) {
            outputText.appendText(letters_aArray[8]);
        } else if (textinProgress.charAt(b).search(letters_bArray[8].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[8].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[9]) == 0) {
            outputText.appendText(letters_aArray[9]);
        } else if (textinProgress.charAt(b).search(letters_bArray[9].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[9].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[10]) == 0) {
            outputText.appendText(letters_aArray[10]);
        } else if (textinProgress.charAt(b).search(letters_bArray[10].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[10].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[11]) == 0) {
            outputText.appendText(letters_aArray[11]);
        } else if (textinProgress.charAt(b).search(letters_bArray[11].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[11].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[12]) == 0) {
            outputText.appendText(letters_aArray[12]);
        } else if (textinProgress.charAt(b).search(letters_bArray[12].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[12].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[13]) == 0) {
            outputText.appendText(letters_aArray[13]);
        } else if (textinProgress.charAt(b).search(letters_bArray[13].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[13].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[14]) == 0) {
            outputText.appendText(letters_aArray[14]);
        } else if (textinProgress.charAt(b).search(letters_bArray[14].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[14].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[15]) == 0) {
            outputText.appendText(letters_aArray[15]);
        } else if (textinProgress.charAt(b).search(letters_bArray[15].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[15].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[16]) == 0) {
            outputText.appendText(letters_aArray[16]);
        } else if (textinProgress.charAt(b).search(letters_bArray[16].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[16].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[17]) == 0) {
            outputText.appendText(letters_aArray[17]);
        } else if (textinProgress.charAt(b).search(letters_bArray[17].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[17].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[18]) == 0) {
            outputText.appendText(letters_aArray[18]);
        } else if (textinProgress.charAt(b).search(letters_bArray[18].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[18].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[19]) == 0) {
            outputText.appendText(letters_aArray[19]);
        } else if (textinProgress.charAt(b).search(letters_bArray[19].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[19].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[20]) == 0) {
            outputText.appendText(letters_aArray[20]);
        } else if (textinProgress.charAt(b).search(letters_bArray[20].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[20].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[21]) == 0) {
            outputText.appendText(letters_aArray[21]);
        } else if (textinProgress.charAt(b).search(letters_bArray[21].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[21].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[22]) == 0) {
            outputText.appendText(letters_aArray[22]);
        } else if (textinProgress.charAt(b).search(letters_bArray[22].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[22].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[23]) == 0) {
            outputText.appendText(letters_aArray[23]);
        } else if (textinProgress.charAt(b).search(letters_bArray[23].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[23].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[24]) == 0) {
            outputText.appendText(letters_aArray[24]);
        } else if (textinProgress.charAt(b).search(letters_bArray[24].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[24].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[25]) == 0) {
            outputText.appendText(letters_aArray[25]);
        } else if (textinProgress.charAt(b).search(letters_bArray[25].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[25].toUpperCase());
        } else if (textinProgress.charAt(b) == "\r") {
            outputText.appendText("\n");
        } else {
            outputText.appendText(textinProgress.charAt(b));
        }
    }
}
// RECODE BUTTON (scrambles, takes what's in the output and applies the cipher again)
recode_btn.addEventListener(MouseEvent.CLICK, recode_btnclick);

function recode_btnclick(event:MouseEvent):void
{
    textinProgress = outputText.text;
    outputText.text = "";
    for (var b=0; b<textinProgress.length; b++) {
        if (textinProgress.charAt(b).search(letters_bArray[0]) == 0) {
            outputText.appendText(letters_aArray[0]);
        } else if (textinProgress.charAt(b).search(letters_bArray[0].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[0].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[1]) == 0) {
            outputText.appendText(letters_aArray[1]);
        } else if (textinProgress.charAt(b).search(letters_bArray[1].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[1].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[2]) == 0) {
            outputText.appendText(letters_aArray[2]);
        } else if (textinProgress.charAt(b).search(letters_bArray[2].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[2].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[3]) == 0) {
            outputText.appendText(letters_aArray[3]);
        } else if (textinProgress.charAt(b).search(letters_bArray[3].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[3].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[4]) == 0) {
            outputText.appendText(letters_aArray[4]);
        } else if (textinProgress.charAt(b).search(letters_bArray[4].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[4].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[5]) == 0) {
            outputText.appendText(letters_aArray[5]);
        } else if (textinProgress.charAt(b).search(letters_bArray[5].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[5].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[6]) == 0) {
            outputText.appendText(letters_aArray[6]);
        } else if (textinProgress.charAt(b).search(letters_bArray[6].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[6].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[7]) == 0) {
            outputText.appendText(letters_aArray[7]);
        } else if (textinProgress.charAt(b).search(letters_bArray[7].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[7].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[8]) == 0) {
            outputText.appendText(letters_aArray[8]);
        } else if (textinProgress.charAt(b).search(letters_bArray[8].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[8].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[9]) == 0) {
            outputText.appendText(letters_aArray[9]);
        } else if (textinProgress.charAt(b).search(letters_bArray[9].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[9].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[10]) == 0) {
            outputText.appendText(letters_aArray[10]);
        } else if (textinProgress.charAt(b).search(letters_bArray[10].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[10].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[11]) == 0) {
            outputText.appendText(letters_aArray[11]);
        } else if (textinProgress.charAt(b).search(letters_bArray[11].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[11].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[12]) == 0) {
            outputText.appendText(letters_aArray[12]);
        } else if (textinProgress.charAt(b).search(letters_bArray[12].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[12].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[13]) == 0) {
            outputText.appendText(letters_aArray[13]);
        } else if (textinProgress.charAt(b).search(letters_bArray[13].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[13].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[14]) == 0) {
            outputText.appendText(letters_aArray[14]);
        } else if (textinProgress.charAt(b).search(letters_bArray[14].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[14].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[15]) == 0) {
            outputText.appendText(letters_aArray[15]);
        } else if (textinProgress.charAt(b).search(letters_bArray[15].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[15].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[16]) == 0) {
            outputText.appendText(letters_aArray[16]);
        } else if (textinProgress.charAt(b).search(letters_bArray[16].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[16].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[17]) == 0) {
            outputText.appendText(letters_aArray[17]);
        } else if (textinProgress.charAt(b).search(letters_bArray[17].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[17].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[18]) == 0) {
            outputText.appendText(letters_aArray[18]);
        } else if (textinProgress.charAt(b).search(letters_bArray[18].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[18].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[19]) == 0) {
            outputText.appendText(letters_aArray[19]);
        } else if (textinProgress.charAt(b).search(letters_bArray[19].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[19].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[20]) == 0) {
            outputText.appendText(letters_aArray[20]);
        } else if (textinProgress.charAt(b).search(letters_bArray[20].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[20].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[21]) == 0) {
            outputText.appendText(letters_aArray[21]);
        } else if (textinProgress.charAt(b).search(letters_bArray[21].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[21].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[22]) == 0) {
            outputText.appendText(letters_aArray[22]);
        } else if (textinProgress.charAt(b).search(letters_bArray[22].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[22].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[23]) == 0) {
            outputText.appendText(letters_aArray[23]);
        } else if (textinProgress.charAt(b).search(letters_bArray[23].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[23].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[24]) == 0) {
            outputText.appendText(letters_aArray[24]);
        } else if (textinProgress.charAt(b).search(letters_bArray[24].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[24].toUpperCase());
        } else if (textinProgress.charAt(b).search(letters_bArray[25]) == 0) {
            outputText.appendText(letters_aArray[25]);
        } else if (textinProgress.charAt(b).search(letters_bArray[25].toUpperCase()) == 0) {
            outputText.appendText(letters_aArray[25].toUpperCase());
        } else if (textinProgress.charAt(b) == "\r") {
            outputText.appendText("\n");
        } else {
            outputText.appendText(textinProgress.charAt(b));
        }
    }
}

Just gonna tell you why I did all the incredibly arbitrary and loopy stuff that I did...

  • If you do any of the other normal replace things other people have talked about here (from what I've FOUND, at least), you end up replacing your own work at a certain point. For example if you want B to be A, but then you want A to be C, then if you type "BA", you get back "CC" instead of "AC". So my code actually takes each character and spits them all out one at a time.
  • I did all that tedious ".toUpperCase()" stuff to make sure that this tool was case-sensitive-- so that if I typed in a lowercase or uppercase key, it would always generate the proper one in its place. That's why RegExp didn't quite work for me.
  • It also takes into account things like line breaks and random symbols not included in the alphabet.

I know for SURE there's simpler, more energy-efficient ways to code this, but I just have no idea how. I hope I'm not wasting anyone's time, I worked hard to Google this, and I'm PRETTY sure I'm breaking at least a LITTLE new question-ground here. Thank you so, so much, everybody!

AS3 making nested mc buttons/textinputs visible/unvisible during runtime

I'm looking for an efficient way to hide and unhide movie clip buttons/text inputs which are all within a main mc. My application has a "help popup" which when enabled should turn off any buttons/text inputs at that current frame and when the help popup is closed the buttons/text inputs should be re-enabled. I created the following function to disable/enable all buttons within my mainScreen mc which works great except my text inputs are not tabable any more after re-enabling them (It works 100% running the .swf file by itself but not within a browser): And not all buttons should be visible depending on which keyframe one is on. I've been just manually placing the buttons/text inputs I need on each frame but if I create a global function that hides them and unhides them shouldn't they all be on frame one and on?

function disableButtons():void
{
mainScreen.mouseChildren = false;
mainScreen.tabChildren = false;
}
function enableButton():void
{
mainScreen.mouseChildren = true;
mainScreen.tabChildren = true;
}

I've explored the idea of placing all buttons in an array and then making them not visible and visible with a loop but then how would I specify which ones should be the visible ones according to the frame they are at:

var bArray:Array = [mainScreen.b1,mainScreen.txt2];
//When help popup is on hide all buttons
function hideButtons():void
{
for (var i:int = 0; i<bArray.length; i++)
{
    bArray[i].visible = false; 
}
}
//When help popup is closed only make visible the needed buttons
function showButtons():void
{
for (var i:int = 0; i<bArray.length; i++)
{
    bArray[i].visible = true; //Somehow I need to specify which ones I want visible depending on the frame.  

}
}

I still have a lot to learn, I appreciate any pointers! Thanks.

Encrypt xml using as3Crypto for Air application built with flash

Is there any tutorials of how to use as3Crypto for encrypting xml files in an Air application? I browsed for a tutorial but I couldn't find any clear tutorial. I need a clear one, the most famous one is built with Flex, but i need one build with flash, any help?

AS3 How to call an existing function?

Im trying to call a function(s) from different places. Dont have any luck so far. This is the basic function. When i press a button it do something:

button.addEventListener(MouseEvent.CLICK, myFunction1);
function myFunction1(event:MouseEvent):void 
{
   ///dosomeThing1
}

I have more than one button (myFunction2..3...4... etc)

but i wanted to exactly the same (myfunction1..2 etc) happen when i get a specific random number. For example if random number = 1 >>> do myfunction1 if random number = 2 >>> do myfunction2

So i tried this:

function randomRange(minNum:Number, maxNum:Number):Number 
{
return (Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum);
}
var myrandomNumber = (randomRange(1, 6))
trace(myrandomNumber); //A number between 1 and 6
if (myrandomNumber == 1) {
    myFunction1(null); // i tried this (null) stuff
}
if (myrandomNumber == 2) {
    myFunction2();   // i tried also with just braces
}

the random number generation is alright, but i get errors all the time when i want to call a function (if i give a simple >> smthng.gotoAndStop(x) command (instead of a function) it is fine)

anybody any ideas? Really appreciate it!

Please leave examples! (Rookie programmer here! :-)

thanks Ben

ActionScript 3 PDF Cell text width

Can somebody help me, please? I want to set the PDF cell's text's width in AS3, because sometimes the text is longer than the cell's width, and it is ugly when the text appears on the next cell's text. :)

I hope forward somebody can help me. Thanks!

it is possible to change the width and height of an swf with AS3 onclick event?

it is possible to change the width and height of an swf with AS3 onclick event ?

as3 change stage size

lundi 29 août 2016

In action script 3, how can I dynamically include a file with certain name, based on a value of another variable?

I have a variable "level", and based on the value of that Number variable, I want a file included, with my level settings for THAT particular level. Level files are called "Level1Definition.as", "Level2Definition.as", "Level3Definition.as", and so on. When I try to form that line of code like this:

include "Level" + level + "Definition.as";

, I get an error:

Expecting semicolon before plus.

Set private var string from input text

I tried doing this:

private var name: String = fromthis.text;

and it doesn't work, anyone knows why?

Start and stop interval using button [as3]

I tried to make two buttons, one that starts an interval and one that stops it. This is my code:

            s_start.addEventListener(MouseEvent.CLICK, startspam);
            function startspam(e:MouseEvent):void {
                setInterval(spam,500);
            }
        s_stop.addEventListener(MouseEvent.CLICK, stopspam);
            function stopspam(e:MouseEvent):void {
                clearInterval(spam);
            }   

The start button works perfectly! but the stop button doesn't. 1067: Implicit coercion of a value of type Function to an unrelated type uint.

Thank you for your help in advance.

AS3 (AIR) Mobile App: Send user back to open browser tab

Scenario: An Android user clicks a link on browser page that emits an intent url that starts my app.

Question: Is there a way to direct the user back to that same open browser tab, without closing the app? If I use the AS3 function navigateToURL there is always a new tab regardless of what the target is set to, because the flash app is not contained in a web page. Also, I'm trying to avoid using the StageWebView because when the user is authenticated from outside the app, there is an issue with cookie-management. Any ideas?

vertical scrollbar issue in list item render in flex3

I have HBox in title window, in the Hbox am using list itemrenderer. the list of items areenter image description here displaying properly along with scrollbar, the problem is the two scrollers are displaying in the scrollbar. when mouse move on the scroll bar another one is hidden and working properly. how could we resolve this issue could you please help me.thanksin advance.

my code is

 abc.mxml

 <?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://ift.tt/1aBfKeP" layout="vertical" width="400" height="300"
            showCloseButton="false" title="Select">

<mx:HBox width="100%" height="100%" >
    <mx:List id="vehicleTypeList" width="50%" height="100%" dataProvider="{typeList}"
             itemRenderer="{new  ClassFactory(myitemrenderer)}"/>
</mx:HBox>

    <mx:Button id="btnOK" label="Ok"/>
    <mx:Button id="btnCancel" label="Cancel" c/>
</mx:TitleWindow>

myitemrenderer.mxml

  <?xml version="1.0" encoding="utf-8"?>
 <mx:HBox xmlns:mx="http://ift.tt/1aBfKeP" verticalAlign="middle"   horizontalGap="10">    
<mx:Image id="image" width="36" height="36" horizontalAlign="center" verticalAlign="middle" scaleContent="true" maintainAspectRatio="true"
          source="{xyz.jpg}" />
<mx:Label text="{text}" width="80%"/>
  </mx:HBox>

Esri map with flex show name on navigator instead of coordinates

I am using com.esri.ags.components.directions on esri map and I added the stops by coordinates. So how can I assign a name to the stop so it will be showing on screen and when printing instead of coordinates?

Can't select Optimized route from first time in esri maps with flex

I have a really weird problem. I am using esri maps with flex and navigating with com.esri.ags.components.directions component and I am adding the stops within the code. I have two options, optimize and return to start. If I selected optimize nothing happens. I have to check the return to start once to make them work properly. Even just to select it an deselect it again.

dimanche 28 août 2016

how to make if chains

im am making a game for my assignment in AS3.0 and this isn't working i have this on all the variables and buttons are there there are no format error it just dose not function
frame 2 layer 1

function CheckScene():void
{
    P_HP = 5
    E_HP = 1
    A_D = 1

    if(P_HP == 5)
        if(E_HP == 2)
            if(A_D == 1)
                q = 1

    if(P_HP == 5)
        if(E_HP == 1)
            if(A_D == 1)
                q = 2
        }

frame 2 layer 2

stop();

but.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void
{
    gotoAndStop(5);
}

frame 3 layer 2

button_2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_2);

function fl_ClickToGoToAndStopAtFrame_2(event:MouseEvent):void
{
if(q == 1)
    gotoAndStop(5)
if(q == 2)
    gotoAndStop(4)
}

basically it goes to frame 4 if it works and 5 if it dosnt and the if chain isnt working or i have no clue how to do this cuse this sort of thing worked in exel for checking multiple variables before doing something.

how to connect Adobe Flash with database PHPMyadmin using xml and as3

i want to display data from database, therefore i need to connect Flash into database. So i can display the data to database. Anyone can give me the php code and the actionscrip 3.0 code ?

Calling a function and receiving: "Incorrect number of arguments. Expected 1."

In a small project, I made a function to call another function under a condition.

import flash.events.Event;

var yspeed:Number=0;
var maxspeed:Number=5;
var accel:Number=.1;
stage.addEventListener(Event.ENTER_FRAME, code);
function code(codeevent:Event){
    if(sprite1.y>449){
        code2();
    }
}


function code2(code2event:Event):void{
    if(yspeed<5){
        yspeed+=.5
        yspeed-=accel
        }
    if(yspeed>5){
        yspeed=5
    }
    sprite1.y-=yspeed;
    trace(yspeed)
}

I get the error:Line 9 1136: Incorrect number of arguments. Expected 1. On line nine, which just has code2();

Note, I have tried doing

code2(Event);

code2(code2event:Event); 

code2(code2event); 

and all of them come up with different errors. I also tried changing names of the function, and adding :void after calling it.

Currently, sprite1's position is x=182 and y=482 on a stage that is 320x480

I do not have any clue on why this is happening.

RevMob Banner : adobe air - flash CS6 - Auto dismissing issue

In my adobe air application, i've managed to implement Revmob ads: Rewarded video and banners.
I'm still in my testing mode, so when i run the game i will get the blue Revmob Banner at the bottom of the screen as expected. The first problem is, whenever i click on the ad, it will popup a window, and in 2 seconds it disappears without even loading anything, and my game keeps running in the background!
I've tried to trace and see if the ad is getting dissmissed, but i didn't get any trace :

case RevMobAdsEvent.BANNER_DISMISSED:
                {

                    trace( "RevMob banner dismissed");
                    break;
                }

  • should i manually pause the game whenever the user clicks on the banner? or would it automatically pause? because it seems that the game continues!
  • When is BANNER_DISSMISSED called?
  • If i have to manually pause, how can i do so ? Note that i have timers running, and unsing stage.framerate = 0 will stop the game but not the timers.

how mak fill Rectangle without color ActionScript 3.0 to see behin it

hi friends i just start working on as3

i want to create Rectangle but without color fill

so i can see what behind it on stage .

i love to draw on that Rectangle but it never work without color fill

var Canvas_sp:Sprite =new Sprite();

this.addChild(Canvas_sp);

//here i love Rectangle be without collor fill not whit(FFFFFF)e color

//i love see what behind the Rectangle and draw over it

Canvas_sp.graphics.beginFill(0xFFFFFF);

Canvas_sp.graphics.drawRect(0,0,550,400);

thx for all

alebianco's ANE-Google-Analytics doesn't work with actionscript

I want to use alebianco's version of google analytic api for action script. (here)

I downloaded the code from this address and I added this directory to my as3 project:
ANE-Google-Analytics-master\source\actionscript\agnostic\src

Then I tried to use its code according to its example in github:

public class GoogleAnalyticsTracker {

    private static var ANALYTICS_ID:String = "XXXXX";
    private static var instance:GoogleAnalyticsTracker = null;

    public function GoogleAnalyticsTracker() {
    }

    public static function getInstance():GoogleAnalyticsTracker {
        if(instance == null) {
            instance = new GoogleAnalyticsTracker();
        }
        return instance;
    }

    public function sendStartAppEvent():void {
        if(Analytics.isSupported()) {

            var analytics:Analytics = Analytics.getInstance();
            var tracker:ITracker = analytics.getTracker(ANALYTICS_ID);

            tracker.buildEvent("StartApp", "AttentionApp").track();

            trace("analytics is supported");
        }

        trace("analytics is not supported");
    }

}

But I get this error:
ITracker.as, line 15 1045: Interface IDisposable was not found

and when I check this file and the line I see this line:

import eu.alebianco.core.IDisposable;

but there is no "core" folder in the code that I downloaded from alebianco from github. I don't know how to use Google Analytics in as3. There are other solutions but alebianco is the google's first result so I think this choice should work fine. What am I missing??

How To Create An Array of Movie Clip with number

I have multi movieclips in my stage and they have instanceName e.g. k1,k2,... . I want to createar=[k1,k2,k3,k4, ...] but show me

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

var ar:Array;
for(var i:int = 1; i < 4; i++)
{
ar[i-1] = "k"+i;
}
trace(ar)

Is it possible to open a server in ActionScript 3?

is it possible to open a client/server that can receive data for real-time multiplayer games? If it possible, so can you give me reference for this?

Thanks.

samedi 27 août 2016

AS3 : how can I store tiled map editor's data efficiently in an AS3 class

Please let me describe my question with details.

Lets say I will create a game with 500 different maps. Each of these maps are containing 80x40 16px tiles.(unfortunately it's necessary to parse per 16px)

But in game , I'm gonna create 32px tiles per 4 16px tiles.

I store every embedded tmx file in a class with static methods.

Here is my question, which of the following 2 options I should chose;

1- Should I convert the tmx data into as3 data ( into an array which contains tiles' data) each time player enters a different map.

2- Should I convert all maps' data at the beginning of the game, then whenever player enters a different map, I directly take the array and create the map from it.

I am asking this because I'm not sure if it's a problem to keep 500 arrays with the size of 80x40. (would it tire ram too much? )

Generating the same random number from a string across clients

I'm building a multiplayer desktop Air game, and I need to generate a random number that is the same in both clients.

I've been reading a bit about how other games do it, and apparently if I have the same seed in both clients, the random output will be the same.

However I never tried to do this, no idea where to begin.

How does it work?, how does this string (let's same player name) assures me that the random output in both clients will be the same?.

Get specific data from PHP in AS3

I have this echo in php:

[Username=Admin&c_x=0&c_y=0&c_talk=NULL],[Username=Admin2&c_x=0&c_y=0&c_talk=Hello],

So I loaded this URL to my flash site, and I want to trace only the First username (Admin) and the first c_talk (Null). How do I do this? I tried:

ServerVars = new URLVariables(e.target.data);
trace(ServerVars.Username);

but it didn't worked correctly.

Any help? :)

vendredi 26 août 2016

Error #2044: Unhandled NetStatusEvent:. level=error, code=NetConnection.Call.Failed

I am working on a web-application which has flash-based frontend and Python backend. A part of the application involves file browsing: on front-end we click on the file that we want to view. The backend gets the content of the file and sends that to the front-end.

This works perfect for text/ASCII files, but there are some data files with no extension. When I click those, the front loses the connection.

Below is the pertinent parts of the front-end code.

public function MyGatewayHelper(url:String, serviceName:String) {
    try {
        this.serviceName = serviceName;
        gateway = new NetConnection();
        gateway.connect(url);
    } catch(error:Error) {
            Alert.show("server error", "Unable to connect", Alert.OK);
    }
}
public function call(command:String, result:Function=null, status:Function=null, ...parameters):void {
    command = this.serviceName + "." + command;
    gateway.call(command, new Responder(result, status), parameters);
}

The back-end code, which corresponds to the command, works fine. I cannot post the back-end code here due to some copyright issues. I have thoroughly checked that code by putting various print statements; it returns the correct data. However the backend log shows the following error:

2016-08-26 17:28:45-0700 [-] "aa.bbb.cc.ddd" - - [27/Aug/2016:00:28:45 +0000] "POST /app HTTP/1.1" 500 21 "http://pp.qqq.rr.sss:tt/Application.swf" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0"

And the front end throws the following error:

Error #2044: Unhandled NetStatusEvent:. level=error, code=NetConnection.Call.Failed

PS: I have searched a lot. There are some questions where people are getting similar errors, but I could not use any of those for my problem given the scenarios are very different. Please write in the comments below if any other information is required.

Adobe Flash/ Animate muting particular audio

I am in desperate need of help! I have a mute toggle button that I made following a tutorial on youtube in Adobe Animate/Flash using action-script 3.0 and it mutes everything as it is supposed to. However, I now need it to only mute the background music as it is muting my videos as well! How can I alter the code to either make sure only the background sound is muted and not the video?

function setMute(vol)
{
        var sTransform:SoundTransform = new SoundTransform(1,0);
        sTransform.volume = vol; 
        SoundMixer.soundTransform = sTransform;
}


var Mute:Boolean = false;

mute_btn.addEventListener(MouseEvent.CLICK,toggleMute_btn);

function toggleMute_btn(event:Event){ if(Mute)
{
        Mute = false; setMute(1);
soundLines.gotoAndStop(1);
}
else
        { Mute = true; setMute(0);
soundLines.gotoAndStop(2); 
        }
}

ActionScrip3 get specific child from multiple nested containers

I would like to ask you for help with Actionscript 3. How to get access to one from two children (titleBannerPicture in concrete) call from function TitleBannerEffects() (parent is titleBannerContainer sprite object). Classical approach like titleBannerContainer.titleBannerPicture or this.titleBannerContainer.titleBannerPicture or this.titleBannerPicture return error or undefined status. This syntax works only in constructor TitleBanner() function. Please can someone help me with this banal problem.

Thank you.

Sample of code:

package myscript {
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.display.BitmapData
import flash.display.Bitmap;
import flash.filters.BitmapFilterQuality;
import flash.filters.GlowFilter;
import flash.filters.DropShadowFilter;
import Math;

public dynamic
class TitleBanner extends Sprite {
    // Premenne nastavania objektu
        public var pictureName_str: String = "Title_Banner_Picture";
        public var maskName_str: String = "Title_Banner_Mask";
    // Premenne tlacitok
        public var buttonActivation: Boolean = true;
    // Premenne efektu zmeny obrazku
        private var actualPicturePosition: String = "LeftUp";
        private var nextPicturePosition: String = "RightUp";
        private var titleBannerMaskWidth: Number;
        private var titleBannerMaskHeight: Number;

    // Konstruktor
    public function TitleBanner(): void {
        // Nacitanie Container-u
            var titleBannerContainer: Sprite = new Sprite();
            titleBannerContainer.name = "titleBannerContainer";
            this.addChild(titleBannerContainer);
        // Nacitanie masky do Container-u: titleBannerContainer
            var titleBannerMask_mc: Title_Banner_Mask = new Title_Banner_Mask();
            titleBannerMask_mc.name = "titleBannerMask_mc";
            titleBannerContainer.addChild(titleBannerMask_mc);
        // Nacitanie obrazku do Container-u: titleBannerContainer
            var titleBannerPicture: Bitmap = new Bitmap(new Title_Banner_Picture());
            titleBannerPicture.name = "titleBannerPicture";
            titleBannerContainer.addChild(titleBannerPicture);
        // Priradenie masky
            titleBannerPicture.mask = titleBannerMask_mc;
        // Nastavenie filtrov Container-u
            titleBannerContainer.filters = TitleBannerFilters();
        // Nastavenie efektu posuvania obrazkov
            titleBannerMaskWidth = Math.ceil(titleBannerMask_mc.width);
            titleBannerMaskHeight = Math.ceil(titleBannerMask_mc.height);   
            TitleBannerEffects();  
    }
    private function TitleBannerFilters(): Array {
        // Nastavenie Glow efektu
            var titleBannerGlowEffect: GlowFilter = new GlowFilter();
        //titleBannerGlowEffect.alpha = 1;          
            titleBannerGlowEffect.color = 0xffffff;
            titleBannerGlowEffect.blurX = 20;
            titleBannerGlowEffect.blurY = 20;
            titleBannerGlowEffect.inner = true;
            titleBannerGlowEffect.strength = 2;
            titleBannerGlowEffect.quality = BitmapFilterQuality.HIGH;
        // Nastavenie Shadow efektu
            var titleBannerShadowEffect: DropShadowFilter = new DropShadowFilter();
            titleBannerShadowEffect.alpha = 1;
            titleBannerShadowEffect.color = 0x666666;
            titleBannerShadowEffect.blurX = 4;
            titleBannerShadowEffect.blurY = 4;
            titleBannerShadowEffect.inner = true;
            titleBannerShadowEffect.angle = 45;
            titleBannerShadowEffect.distance = 4;
            titleBannerShadowEffect.strength = 1;
            titleBannerShadowEffect.quality = BitmapFilterQuality.HIGH;
        // Navratova premenna
            return [titleBannerGlowEffect, titleBannerShadowEffect];
    }
    private function TitleBannerEffects(): void {
        switch (actualPicturePosition) {
            // Prechod prveho obrazku
                case "LeftUp":
                    switch (nextPicturePosition) {
                        case "RightUp":
                            trace("LeftUp -> RightUp");
                            //trace(this.getChildAt(0).name].numChildren); 
                            trace(titleBannerPicture)                       
                        break;
                        case "LeftDown":
                            trace("LeftUp -> LeftDown");
                            break;
                        case "RightDown":
                            trace("LeftUp -> RightDown");
                            break;
                        default:
                            trace("No transition");
                            break;
                    }
                    break;
            // Prechod druheho obrazku
                case "RightUp":
                    switch (nextPicturePosition) {
                        case "LeftDown":
                            trace("RightUp -> LeftDown");
                            break;
                        case "RightDown":
                            trace("RightUp -> RightDown");
                            break;
                        case "LeftUp":
                            trace("RightUp -> LeftUp");
                            break;
                        default:
                            trace("No transition");
                            break;
                    }
                    break;
            // Prechod tretieho obrazku
                case "LeftDown":
                    switch (nextPicturePosition) {
                        case "RightDown":
                            trace("LeftDown -> RightDown");
                            break;
                        case "LeftUp":
                            trace("LeftDown -> LeftUp");
                        break;
                        case "RightUp":
                            trace("LeftDown -> RightUp");
                            break;
                        default:
                            trace("No transition");
                            break;
                    }
                    break;
            // Prechod stvrteho obrazku
                case "RightDown":
                    switch (nextPicturePosition) {
                        case "LeftUp":
                            trace("RightDown -> LeftUp");
                            break;
                        case "RightUp":
                            trace("RightDown -> RightUp");
                            break;
                        case "LeftDown":
                            trace("RightDown -> LeftDown");
                            break;
                        default:
                            trace("No transition");
                            break;
                    }
                    break;
        }


    }
}

}

jeudi 25 août 2016

Looping sound in AS3

Trying to loop a background soundtrack while my flash program is in use.

So far my code is this:

//turn off sound
btnOff.addEventListener(MouseEvent.CLICK, fl_stopsound);

function fl_stopsound(event:MouseEvent):void
{
    SoundMixer.stopAll();
}

//turns sound on
btnOn.addEventListener(MouseEvent.CLICK, fl_ClickToPlayStopSound_1);

var fl_SC_1:SoundChannel;

//keeps track of whether the sound should be played or stopped
var fl_ToPlay_1:Boolean = true;

function fl_ClickToPlayStopSound_1(evt:MouseEvent):void
{
        var mySound:Sound = new background(); 
        mySound.play();
    }

where btnOff turns off the sound and btnOn turns on the sound. My soundtrack is 1:50min long. Is it possible to loop the track within the program with these buttons?

Cheers

Regular expression to parse the time-stamp string in ActionScript3

I am working on a project in ActionScript3. I have this function that parses a time-stamp string.

private function convertTimestampToNumber(timestamp:String):Number {
    //YYYY-MM-DD HH:mm:SS:sss
    var re:RegExp = /(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})\s(?P<hour>\d{2}):(?P<min>\d{2}):(?P<sec>\d{2})\.(?P<msec>\d{3})/;
    var result:Array = re.exec(timestamp);
    Alert.show(timestamp, "Timestamp string", Alert.OK);

    return (10000000000000 * parseInt(result.year)
        + 100000000000 * parseInt(result.month)
        + 1000000000 * parseInt(result.day)
        + 10000000 * parseInt(result.hour)
        + 100000 * parseInt(result.min)
        + 1000 * parseInt(result.sec)
        + parseInt(result.msec));
}

This seems to work fine for all time-stamps except "2016-08-01 09:19:43.23". Here it throws an error:

[Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference.

I thought since the millisecond part of this time-stamp is only 2 chars long, it was throwing error. To fix this I changed the millisecond part of the regular expression to (?P<msec>\d{2|3}) thinking that now it would consider both 2-character and 3-character long millisecond as valid, but now it throws the same error on "2015-11-19 15:28:29.737".

What will be the correct regular expression that can consider both scenarios as valid?

Training Code Not working

So I am going through the book "ActionScript 3.0 Animation ~ Making Things Move" by Keith Peters, and one of the examples is teaching Parent Boxs... I have written this code out, and upon execution, it runs, but provides no Errors, nothing happens, none of the Sprites are drawn, its a blank canvas..? Using Flash Pro CS 6, 12.0.2.529. I haven't had issues with any other examples as of yet, and the .as "ParentBox" runs fine, when I try to run ParentBox2 is when I am encountering this issue.... Thoughts? (sorry, pretty new to OOP, trying to learn as much as I can, and this website in particular has ben AMAZING so far for the vast wealth of knowledge....

ParentBox.as

package {
    import flash.display.Sprite;
    public class ParentBox extends Sprite {
        public function ParentBox()
        {
            init();
        }
        private function init():void{
            graphics.lineStyle(1, 0);
            graphics.drawRect(-50, -50, 100, 100);

        }
    }}

ParentBox2.as Code....

package {
    import flash.display.Sprite;
    import flash.events.MouseEvent;

    public class ParentBox2 extends Sprite {
        private var parent1:ParentBox;
        private var parent2:ParentBox;
        private var ball:Sprite;

    public function Reparenting2 (){
        init();
    }
    private function init():void{
        parent1 = new ParentBox();
        addChild(parent1);
        parent1.x = 60;
        parent1.y = 60;

        parent2 = new ParentBox();
        addChild(parent2);
        parent2.x = 170;
        parent2.y = 60;

        ball = new Sprite();
        parent1.addChild(ball);
        ball.graphics.beginFill(0xff0000);
        ball.graphics.drawCircle(0, 0, 40);
        ball.graphics.endFill();
        ball.addEventListener(MouseEvent.CLICK, onBallClick);
    }
    public function onBallClick(event:MouseEvent):void{     
        parent2.addChild(ball);
    }
}}

scrolling text field help as3

Currently got text off stage that I would like to come onto the stage and stop at a certain position (97, 233.10) on my stage. I'm a little confused on where to stop it and what code to use?

addEventListener(Event.ENTER_FRAME, mcInfo);

 function mcInfo (e:Event):void {

//check position of logo
//if inside the stage move left to right
//if outside stage reposition

if (info.x<stage.stageWidth) {
    info.x+=30;
    stop();
    } else {
        //reset position
        info.x=-450;
    }
}

Cheers!

mercredi 24 août 2016

Adobe Animate/Adobe Flash/Action Script 3.0 Buttons within buttons

I am currently working in Adobe Animate with Action Script 3.0 and I have created three buttons - one is a pop up quit screen, a back button and a mute button. The pop up quit screen has coded a movie clip to appear and the mute button has a movie clip inside it and it's all very confusing.

The problem is that I want to have these buttons revealed by an options button. For example, if the user rolled over or clicked the options button the three buttons would appear. Every time I try to code the buttons inside the options button/movie clip it never works. Is it possible to have buttons inside of buttons? Can someone please come up with potentially some code or ANYTHING for me to try?

//Buttons for Main Menu 

Back_btn.addEventListener(MouseEvent.CLICK,backClick);

function backClick(event:MouseEvent):void
{
        gotoAndPlay("home")
        
}

//Pop up Quit Screen

var Quit_mc = new quit_mc(); 
quit_btn.addEventListener(MouseEvent.CLICK, quitClick);
function quitClick(event:MouseEvent):void
{
addChild(Quit_mc);
Quit_mc.x=113.5;
Quit_mc.y=134.5;
}

Quit_mc.yes_btn.addEventListener(MouseEvent.CLICK, yesClick);
function yesClick(event:MouseEvent):void
{
fscommand("quit");
}

Quit_mc.no_btn.addEventListener(MouseEvent.CLICK, noClick);
function noClick(event:MouseEvent):void
{
removeChild(Quit_mc);
}

//Mute Button

function setMute(vol)
{
        var sTransform:SoundTransform = new SoundTransform(1,0);
        sTransform.volume = vol; 
        SoundMixer.soundTransform = sTransform;
}


var Mute:Boolean = false;

mute_btn.addEventListener(MouseEvent.CLICK,toggleMute_btn);

function toggleMute_btn(event:Event){ if(Mute)
{
        Mute = false; setMute(1);
soundLines.gotoAndStop(1);
}
else
        { Mute = true; setMute(0);
soundLines.gotoAndStop(2); 
        }
}

Actionscript 3 How to generate a notepad .txt file from score in dynamic txt box

I am creating an Adobe Flash actionscript 3 game (to be deployed in Adobe Air Android). I want the score generated in dynamic text box (accumulated thru correct choices by the user) to be saved in a notepad (.txt) file once the user pressed/tap the last button that will lead him to his score page.

The notepad (.txt) file will be saved in the local storage of the Android tablet/phone. However, the app user will be unaware that a notepad file is generated and still his final score will appear in last frame. The notepad file will be for reference purpose only by the game creator. It can accessed by searching through the local storage of the android tablet/phone.

Optional: And is it possible to generate one notepad file (.txt) that shows the scores of the users that used the game? I am planning that in the start of the game, there will be name and age login page (e.g. Sayrell 25). The leader-board will have the Name Age and his/her Score. If it's not possible, then I think there will be separate .txt file for each user. Thanks!

Can you package an Adobe AIR app as UWP using Project Centennial?

I'm trying to complete a proof-of-concept, but I have hit a snag. With Adobe AIR able to support iOS and Android, I wanted to see if I could use the Project Centennial workflow to convert an Adobe AIR .exe installer, into a UWP app for x86 Windows 10.

I have been able to follow the directions for the latest version (0.1.24) and have been able to get the conversion started:

.\DesktopAppConverter.ps1 -Installer '..\AIR2UWP Example\AIR2UWP.exe' -InstallerArguments "-silent" -Destination C:\ -PackageName "MyApp" -Version 0.0.0.1 -MakeAppx -Verbose -Publisher "CN=dougwinnie"

But when I use this, I get the following error:

C:\Users\dougw\Desktop\DesktopAppConverter_new\DesktopAppConverter.ps1 : DesktopAppConverter : error 'E_BAD_INSTALLER_EXIT_CODE': Installer returned '10' when valid exit codes were '0' At line:1 char:1 + .\DesktopAppConverter.ps1 -Installer '..\AIR2UWP Example\AIR2UWP.exe' ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,DesktopAppConverter.ps1

It seems that there is an installer error, but I can't seem to find any references to an AIR installer code 10 to help me troubleshoot further.

Thanks in advance...

adding score and displaying as3

I'm trying to implement a score to my quiz.

Currently how it works is when the user clicks the correct answer (which is a button), it displays to the frame where it says the answer is correct and displays the score.

if the user gets the answer wrong (again a button), it will go to the frame where it says the answer is wrong and the score will stay the same.

My code is as follows for the quiz buttons:

//locates answer a to either being correct/incorrect
btnanswera_1.addEventListener(MouseEvent.CLICK,    fl_ClickToGoToAndStopAtFrame_1);

function fl_ClickToGoToAndStopAtFrame_1(event:MouseEvent):void
{
    gotoAndStop(53);
}

//locates answer b to either being correct/incorrect
btnanswerb_1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_2);

function fl_ClickToGoToAndStopAtFrame_2(event:MouseEvent):void
{
    gotoAndStop(52);
}

//locates answer c to either being correct/incorrect
btnanswerc_1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_3);

function fl_ClickToGoToAndStopAtFrame_3(event:MouseEvent):void
{
    gotoAndStop(52);
}

When it goes to the correct frame the code looks like this so far:

//incorporated when the quiz question is correct, it takes the user back to the next question
 btnnextq.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_20);

function fl_ClickToGoToAndStopAtFrame_20(event:MouseEvent):void
{
    gotoAndStop(54);
}


var score;

    function updateScore():void{
     score += 10;
     scorecounter.text = scorecounter.toString();
        updateScore();
}

I've got static text that says score, and dynamic text next to it that's blank and called scorecounter, where I'd like the score to go up by one.

What am I missing so it displays?

I'd also like to implement it to the wrong answer, where the score stays the same.

Cheers!

AS3 and youtube API

I have been working with starling framework and AS# for about a year. I am still new to a lot of things so some of my questions might be a little too obvious, I am sorry about that.

My question is, How can I play youTube videos in AS3 ? I know the youtube API has been deprecated but I have been looking a way to integrate in my AS3 code but so far I have had no luck. I have not tried using the youTube API yet, but to be honest I have no Idea how to start. I tried following the "tutorial" in youTube API page and some others but nothing seems to work. Can someone explain simply how can I start using this API please?

I dont have an embedded player so chromeless player would be what I would be using.

Thank you!

I hope my question is not too confusing.

show pages with animate cc

How to with "addchild(page2)" animate showing with Tweening!

This is my simple class of actionscript to make that,MovieClip did not play animation when using addChild(), do you have any suggestions?

my page1..3 are MovieClips!

package
{

    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.events.TouchEvent;

    Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

    public class Main extends MovieClip
    {
        var page1: Page1;
        var page2: Page2;
        var page3: Page3;


        public function Main()
        {
            page1 = new Page1;
            page2 = new Page2;
            page3 = new Page3;
            addChild(page1);
            //


            //
            page1.clip2.addEventListener(TouchEvent.TOUCH_BEGIN, onClip2ButtonClick);
            page2.clip.addEventListener(TouchEvent.TOUCH_BEGIN, onClipButtonClick);
        }

        function onClipButtonClick(event: TouchEvent): void
        {
            addChild(page3);
            removeChild(page2);
        }

        function onClip2ButtonClick(event: TouchEvent): void
        {
            addChild(page2);
            removeChild(page1);
        }

    }

}

mardi 23 août 2016

patching actionscript without constantly rebuilding swf

How can I patch actionscript without constantly rebuilding sfw? There is a fairly large actionscript project that I need to modify and resulting swf is used on a live site. The problem I have is that I need to make quick small updates to the swf and it's not acceptable to update the swf on live site ten time a day (I don't control that part, I need to ask another person to put the result on live site). What options do I have to workaround that issue? I'm a complete noob when it comes to actionscript and all flash related stuff and I'm not even sure what is possible and what isn't. I'm thinking about the following approaches, which ones are possible/acceptable?

Imagine that live site is on http://ift.tt/2bxlj6y and this page loads www.livesite.com/flashgame.swf. In that flashgame.swf among many others there is a class com/livesite/Magic.as that gets instantiated and instance of that class has a member variable xxx123 of class com/livesite/MagicWork.as. I only need to modify this MagicWork class. Now, I simply modify it, build and ask to put updated flashgame.swf live. So, I want to avoid that manual step.

All my ideas can be split in two basic approaches: 1) keep flashgame.swf totally unmodified and then load flashgame.mod.swf that contains alternative implementation of that MagicWork class, then using javascript access internals of instance of that Magic class and update its xxx123 member to be an instance of MagicWork class from flashgame.mode.swf. I'd need to modify game.html to load my javascript so that my js file would load flashgame.mod.swf and patch code inside flashgame.swf. By patching I mean javascript-style overwriting of Magic.xxx123 to a new value. flashgame.mode.swf would ideally reside on my own host that I control. Is that kind of stuff possible, if not what's not possible? 2) I could make one-time change in flashgame.swf so that it would effectively load itself my own code at runtime and patch it's xxx123 member. Is that possible?

Can sqlite databae be used with as3 air app for android devices?

My App and Sqlite connection works on simulator but does not work when publishes on android device.

Below are the sample codes, I have tried, all work on simulator but not on android phone

 // SAMPLE-1
 var conn:SQLConnection = new SQLConnection();
 conn.addEventListener(SQLEvent.OPEN, openSuccess);
 conn.addEventListener(SQLErrorEvent.ERROR, openFailure);

 var fileLocation:File      =   File.applicationStorageDirectory.resolvePath("assets/weddingsql.sqlite"); ; 
 conn.openAsync(fileLocation, SQLMode.READ);    






  // SAMPLE-2
  var fileLocation:File         =   File.applicationStorageDirectory.resolvePath("assets/weddingsql.sqlite"); ; 
  var storageDbFilePath:File    =    File.applicationStorageDirectory.resolvePath("weddingsql.sqlite");
  fileLocation.copyToAsync(storageDbFilePath, true);
  fileLocation.addEventListener(Event.COMPLETE, fileCopiedHandler);

  function fileCopiedHandler(event:Event):void {
     trace("File Copied....");
     conn.openAsync(storageDbFilePath, SQLMode.READ);
  } 


 // Used in both the samples
 private function openSuccess(evt:SQLEvent):void{
    trace(" can not make connection to Database "); }

 private function openFailure(evt:SQLErrorEvent):void{
    trace(" can not make connection to Database ");}

And lastly, I suggest all as3 air developer to move on to native android if possible.

Flex window - clicking on empty space

There are flex icons arranged as described in picture provided:

flex icons

Whenever user clicks somewhere in the empty space (marked red) the icon (marked 'A') gets clicked. Is this common flex issue? Any idea how to solve this?

lundi 22 août 2016

AS3 Tween a variable inside an array

I have the following code which works perfectly:

    updaterVariable = 0;
    Tweener.addTween(this, {time:2, transition:"linear", updaterVariable:1000, onUpdate:tweenerUpdate});

I will get the value of updaterVariable tweened from 0 to 1000 in 2 seconds. My question is whether there is a similar way to tween a variable in an array, for example:

    updaterVariable[10] = 0;
    Tweener.addTween(this, {time:2, transition:"linear", updaterVariable[10]:1000, onUpdate:tweenerUpdate});

I tried the above code, and its not working. Can anyone help?

Browse file and store on default path local disc (without browse window) in as3(AIR APP)

I need some help to store browsed file in native path of AIR APP. where I can select file by browsing from locale and then it will store to fixed path without save window.

batch file return bytes to actionscript3

I have a batch file that takes an encrypted zip file, and decrypts it:

SET file=%1
CALL enc -aes-128 -nopad -in %1 -k key123 -d -nosalt
:end

I would like to return the bytes of my call statement back to my external actionscript3 program, i am not sure how to do this. I am trying some combination of SET bytes = CALL and echo %bytes% to no avail.

AS3 - iOS app crashes at breakpoint

I have a very annoying problem with debugging AIR apps on iOS devices and simulators. Simply put, the app crashes when I'm debugging application and it stops at a breakpoint. Then the line with breakpoint is selected for a second or less and then the app is gone.

Here's some logs I got from simulator after last flash trace:

assertiond[30178]: assertion failed: 15G31 13E230: assertiond + 16726 [1BD9E3D0-5485-3412-86B2-4BE50C825E80]: 0x1

SpringBoard[30174]: HW kbd: Failed to set (null) as keyboard focus

SpringBoard[30174]: BSXPCMessage received error for message: Connection invalid

--- last message repeated 1 time ---

com.apple.CoreSimulator.SimDevice.EE317320-40C9-4513-9BE9-02611D6DD722.launchd_sim[30158] (UIKitApplication:com.my.app.id[0x31d1][30651]): Service exited due to signal: Segmentation fault: 11

assertiond[30178]: assertion failed: 15G31 13E230: assertiond + 16726 [1BD9E3D0-5485-3412-86B2-4BE50C825E80]: 0x1

SpringBoard[30174]: Application 'UIKitApplication:com.my.app.id[0x31d1]' crashed.

assertiond[30178]: assertion failed: 15G31 13E230: assertiond + 16726 [1BD9E3D0-5485-3412-86B2-4BE50C825E80]: 0x1

assertiond[30178]: notify_suspend_pid() failed with error 7

And that's it.

Funny thing is that it can not happen for months, than suddenly every breakpoint causes a crash. From what I've noticed, the device, iOS version, AIR version don't matter.

Have you guys ever faced this problem? Do you have any solution for this?

TypeError: Error #1034 could not solve this very strage

i've been making a presentation in flash CS5. It has 5 Pages there for 5 Keyframes which are on the main timeline. I have 2 animated navigation buttons (Movieclips) for left and right. Now the all navigations are instances from the Arrow Left MC or Arrow Right MC and both work absolutly perfect except the Arrow left on the last page.

Now I know this is strange but it has the same piece of code, it is the same instance with a unique name and both (the movieclip and the code) are on a keyframe.

I like spend nearly a week to solve this, tryed every solution I could find elsewhere but I still couldn't solve it. I'm really jumping in triangles right now.

This is the error message(I use the german version so I translated it):

TypeError: Error #1034: Typecast failed: flash.display::MovieClip@3e817d91 can not be converted to fl.motion.AnimatorFactory.

at flash.display::MovieClip/gotoAndPlay()
at Presenting_v9_noFS_fla::MainTimeline/leClick_p5()

And this is the piece of code:

//Button FX previous ----------------------------------------------------##
INS_Previous_MC_p5.addEventListener(MouseEvent.ROLL_OVER, leOver_p5);
INS_Previous_MC_p5.addEventListener(MouseEvent.ROLL_OUT, leOut_p5);
INS_Previous_MC_p5.addEventListener(MouseEvent.CLICK, leClick_p5);

function leOver_p5(event:MouseEvent):void
{   INS_Previous_MC_p5.gotoAndPlay("PreviousOver"); }

function leOut_p5(event:MouseEvent):void
{   INS_Previous_MC_p5.gotoAndPlay("PreviousOut");  }

function leClick_p5(event:MouseEvent):void{
    gotoAndPlay(129);
}
//Button FX previous end-------------------------------------------------##

As you can see the roll_over and roll_out events trigger the animation in the Instance and the click event just jumps to a frame in the main timeline. The exact same setup like on the other 4 pages, really. This is action script 3.0, and I'm kinda beat counting the fir needles on a christmas tree in august for the 5th time over.

Any help that is greatly appreciated. Bishop

dimanche 21 août 2016

MoPub interstitial ads fail to load with new ANE but loads with old one

I'm using Adobe Flash CS6 to build an Android Game. I could successfully integrate and display MoPub Ad banners and interstitials using OLD MoPub ANE but when security warning was detected by GP I had to use NEWER one but then Interstitial Ads fail to load... when I build the APK it gives warning "Resource values-xx/SOME_FILE.xml has been skipped because of mismatch with supported languages information in application descriptor" does this warning have anything to do with not loading ads?

samedi 20 août 2016

Multiple Buttons Not Working? Actionscript 3

In actionscript 3 (flash cs6), I am trying to make multiple buttons (I am somewhat of a beginner). I do the code right (I think), because 1 button works, but the other button (when I add it in) shows 2 error messages. 1023: Incompatible override. 1021: Duplicate function definition.

I added a separate event listener and a separate function for both of these buttons. I do have import flash.events.MouseEventin the beginning, and I do not know if I have to do anything with this. Here is all my code for both buttons (note: they are on the same frame, but I split them for ease): http://ift.tt/2bGrmYr

Adobe Animate errors

I'm trying to create a token that will disapear when the player touches it. I created an action for the token with the following code

package 
{
    import flash.display.MovieClip;

    public class TokenFish extends MovieClip
    {
        public var isToken:Boolean;
        public function TokenFish()
        {
            isToken = true;
        }
    }
}

However each time I try to run the scene to test it I will get the following errors.

Scene 1, Layer 'game_Stage', Frame 1, Line 5, Column 15 1131: Classes must not be nested.

Scene 1, Layer 'game_Stage', Frame 1 1159: The return statement cannot be used in package initialization code.

Any suggestions will very much be appreciated.

AS 3 Seconds Looping

Well, I'm making a little flash game (a clicker) and I need to make a upgrade that give you points per second, the part of the button, points and upgrade is easy to do, but how can I create a second infinite loop? All that I find was making a loop using for or while, but as u already knows for and while don't execute again in a second, I don't know, maybe in a milisecond. However, how can I do a seconds loop?

How to install as3 corelib to activate png encoder

I want to add a save option to a coloring book app bu so far I've been absolutely stumped with how to activate the as3 corelib even though I downloaded it. Now be clear i'm a novice in the world of programming so any help would be greatly appreciated.

Dinamid AS3 Score System

Well, I'm making a brazilian clicker, and, I need to show to the player the amount of "BIRLS", so I tried this:

import flash.events.MouseEvent;

var Birl:BirlSound = new BirlSound();
var BIRLS:Number  = 0;

this.BIRL.addEventListener(MouseEvent.CLICK, addBirl);

function addBirl(e:MouseEvent){
    BIRLS = BIRLS + 1;
    this.BirlsText.text = "BIRLS: " + BIRLS;
    Birl.play();
    trace(BIRLS);
}

And, It doesn't show any number without 0, like: Its supoded to be: "17,18,19,20,21", and it is " , , , 0, ".

vendredi 19 août 2016

Flash image control source representing issue

When I put source for image control as /images/logo.png it won't load the image. But when I use dot before path means it now loads the image ./images/logo.png. Is there any way to load successfully by using first method?

Why am I suddenly getting stream error while using URLLoader?

I've been working on an android app project for an year and I implemented this feature in the very beginning. The app is a expense/savings management app, and it has a feature that converts the currencies in the background if user is currently in a different country. I am using geonames API to find out the name of the country. Here is the relevant code:

countryURLRequest = new URLRequest('http://ift.tt/1wAIVhS'+latitudes+'&lng='+longitudes+'&username=fatninja');
countryURLLoader = new URLLoader();

countryURLLoader.load(countryURLRequest);

Today, when I sent lat and lng values from the simulator I got the said stream error at this line:

countryURLLoader = new URLLoader();

What's weird is that this feature has been working fine since the beginning. I thought it might have been a bug in the code so I ran the project from backup (from 3 months ago), it's giving the same error. I know for a fact that it was working 3 months ago. What could be the problem?

YouTUBE API for Flash not working

We have a browser flash application which loads the YouTube Embedded AS3 Player to play some YouTube videos (http://ift.tt/2badogN)

Yes I know the Flash API is deprecated, Flash is dying, etc. but it is currently the only practical platform for our complex 3D graphic authoring tool, which just as one feature plays YouTube videos; and it would be crazy to force our customers to host their videos on Vimeo to answer this problem.

Everything has been working fine so far (no changes in code or server), until 2 weeks ago, where we were not able to play YouTube videos from the app.

I found that the url format we were using so far was giving a file not found error:

http://www.youtube.com/v/<my video code>?version=3&autoplay=1

After investigating a bit, it seems that Google updated their API Services terms of service (http://ift.tt/2bICsOz).

So following some directions in their page, I changed http to https:

https://www.youtube.com/v/<my video code>?version=3&autoplay=1

When my app tries to load the YouTube player using that url, the "Event.COMPLETE" event is fired and the player data seems to be loaded fine, but in this part where the YouTube player is assigned to a var:

private function onLoaderComplete(e:Event):void {
    var player = e.currentTarget.content;
    ....
}

It throws the following error:

*** Security Sandbox Violation ***
SecurityDomain http://<my app url> tried to access incompatible context 'https://www.youtube.com/v/<my video code>?version=3&autoplay=1'
SecurityError: Error #2121: Security sandbox violation: LoaderInfo.content: http://<my app url> cannot access https://www.youtube.com/v/<my video code>?version=3&autoplay=1. This may be worked around by calling Security.allowDomain.

I have set all the "Security.allowDomain" and "Security.allowInsecureDomain" I can think of (*.youtube.com, *.ytimg.com, https ://www.youtube.com, https ://s.ytimg.com, etc. and any variation of http and https I can think of). So I don't think this is the problem.

I tried the solution in this thread (stackoverflow.com/questions/5594647/flash-as3-getting-security-sandbox-violation-when-trying-fetch-an-external-swf), where it recommends to use this line to solve Error #2121:

loaderContext.securityDomain = SecurityDomain.currentDomain;

Now it doesn't even fire the "Event.COMPLETE" event. Only a "SecurityErrorEvent.SECURITY_ERROR" event, so no content is loaded:

*** Security Sandbox Violation ***
Connection to https://www.youtube.com/v/<my video code>?version=3&autoplay=1 halted - not permitted from http://<my app url>
httpStatus (error): [HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=0 redirected=true responseURL=null]
SecurityError: 
[SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048: Security sandbox violation: http://<my app url> cannot load data from https://www.youtube.com/v/<my video code>?version=3&autoplay=1."]

So I think this is a step backwards.

I thought it may be an HTTP to HTTPS issue, but on the other hand, loading the YouTube Chromeless AS3 player API directly (without play/stop and time line controls), works fine:

https://www.youtube.com/apiplayer?version=3&video_id=<my video code>

Any useful hint will be appreciated.