dimanche 31 juillet 2016

AS3 function for array.sort() to organize Sprites by column (x and y position)

I have a grid of Sprites / MovieClips and am moving one around by drag-n-drop. I'd then like to rearrange the items on the grid column wise like this:

enter image description here

I have an array with my elements

private var buttons:Array=[mc1,mc2,mc3,mc4,mc5,...];

and I'd like to sort the array using sort() with a custom function based on their X and Y position like this:


So, the question is what goes into my sortByYX function:

    private function sortByYX(a,b):Number
        // ???

Recognizing swiping diagonally (TransformGestureEvent.GESTURE_SWIPE)

For my application I need to recognize swiping gestures as diagonal OR the swipe needs to update while it is being handled in which direction it is going. Unfortunately, it seems using GESTURE_SWIPE you can only recognize swipes that go either left, right, up or down.

Multitouch.inputMode = MultitouchInputMode.GESTURE;

stage.addEventListener(TransformGestureEvent.GESTURE_SWIPE, fl_SwipeHandler);

function fl_SwipeHandler(event: TransformGestureEvent): void {
                // swipe right
                   case 1:
                            // execute swipe right
                   // swipe left
                   case -1:
                            // execute swipe left

                switch (event.offsetY) {
                    // swipe down
                    case 1:
                             // execute swipe down
                    // swipe up
                    case -1:
                             // execute swipe up

This is annoying because when wanting to swipe up while your swipe ends up going right at the last second, it won't be recognized as a 'swipe up' but as a 'swipe right' (I hope I'm being clear here).

I've tried updating the swipe gesture as it is being executed, but since the gesture swipe does not track the event by multiple phases*, I couldn't get it to work. I've searched the web multiple times and didn't find much of use.

Any ideas? It would be greatly appreciated.

*: http://ift.tt/2aj5b9x

custom object which is related list to Opportunity (Look up Relationship). custom obj update automatically update

trigger UpdateHandoffAttached on Top_X_Designation__c (after insert, after update,after delete) { List listoppUpdate=new List(); List listopp=new List(); Set setOppId=new Set(); Set setOppDelete=new Set(); map mapDocAttchTrue = new map(); map mapDocAttchFalse = new map(); map mapDelete = new map(); if(Trigger.isInsert || Trigger.isUpdate){ for(Top_X_Designation__c ada:Trigger.New){ if(ada.Document_Attached__c == True && ada.Type__c == 'ContractFlowDownHandoff'){ mapDocAttchTrue.put(ada.Opportunity,ada.id); setOppId.add(ada.Opportunity); } else mapDocAttchFalse.put(ada.Opportunity,ada.id);enter code here setOppId.add(ada.Opportunity); } } if(Trigger.isDelete){ for(Top_X_Designation__c ada:Trigger.old){ mapDelete.put(ada.Opportunity,ada.id); setOppId.add(ada.Opportunity); setOppDelete.add(ada.Opportunity); } } listopp = 'select id,Handoff_Attached__c from Opportunity where id in: setOppId'; if(listopp.size()>0 && listopp !=null){ for(Opportunity opp:listopp){ if(mapDocAttchTrue.containskey(opp.id)){ opp.Handoff_Attached__c='Yes'; } if(mapDocAttchFalse.containskey(opp.id)){ opp.Handoff_Attached__c='No'; } if(setOppDelete.contains(opp.id)){ opp.Handoff_Attached__c='No'; } listoppUpdate.add(opp); } } if(listoppUpdate.size()>0 && listoppUpdate!=null){ update listoppUpdate; system.debug('ppppppppp'+listoppUpdate); } }

Converting an XMLDocument to E4X in AS3?

I'm attempting to convert some AS2 XML code to E4X. I have the following code original XML (now XMLDocument) syntax below:

//temp var used to access createElement and creatTextNode 
var tempXML:XML = new XML(); 

//make an element:  <myNodeName> 
var myNode:XMLNode = tempXML.createElement("myNodeName"); 

//make a text node: "myValue" 
var myTextNode = tempXML.createTextNode("myValue"); 

//put the text node into the element: <myNodeName>myValue</myNodeName> 
myNode.appendChild( myTextNode ); 

//test it 
trace( myNode.toString() ); 

What would the equivalent be if I were to write it in E4X?

I'm specifically looking to reproduce the createElement() and createTextNode() functions in E4X.

samedi 30 juillet 2016

ActionScript 3 Link to button resource using a string

I'm trying to make an interactive quiz using Adobe Flash and AS3. On the scene, each question has 3 specific resources, for example:


I don't want all resources for each question to be visible. How can I enable the visibility of the buttons, but instead of: 'question1_correct_btn.visible = false', I can do something like: ''question' + questionNum + '_correct_btn'.visible = false'' ?

AS3 - Cannot access a property or method of a null object reference on gotoAndPlay

I have a scene that contains a movie clip. That movie clip has a button that controls the y position of a symbol in the scene. What I tried to do is move on to the next scene when the symbol reaches certain y values. I used gotoAndPlay when the desired y position was reached, the new scene was switched to but an error appeared on output as indicated by the title. This is the code that appears in the movie clip:

launch_btn.addEventListener(MouseEvent.CLICK, init_launch)

function init_launch(evt:MouseEvent):void
    var k = setTimeout(launch, 1);

function launch():void

    if(MovieClip(root).rkt.y != null)
        //progressively changing the y position
        if(MovieClip(root).rkt.y != null)
            if(MovieClip(root).rkt.y < 600)
                MovieClip(root).rkt.y -=0.3
            if(MovieClip(root).rkt.y < 500)
            setTimeout(launch, 1);

            if(MovieClip(root).rkt.y < -150)
                MovieClip(root).gotoAndPlay(1, "Scene 3")

Currently, as compile this code the error points to the line "trace(MovieClip(root).rkt.y);".

What I don't get is why rkt suddenly becomes null when I try to go to a different scene. I tried checking if the property is null but that doesn't help.

I tried removing eventListener, and calling functions that resided in the actions layer of the scene itself (the original one) instead of directly going to the scene from the movie clip.

All in vain.

Any ideas?

Gesture zoom depending on the center of touch points

When I use gesture zoom myMC object (movie clip) scaling depending on center of touch points. How can I make this?

function zoom(e:TransformGestureEvent):void if (myMC.scaleX < 2 && myMC.scaleX > 0.5) { myMC.scaleX *= e.scaleX * e.scaleY; myMC.scaleY *= e.scaleX * e.scaleY; } else if (myMC.scaleX>=2) { myMC.scaleX = myMC.scaleY = 1.99; } else if (myMC.scaleX<=0.6) { myMC.scaleX = myMC.scaleY = 0.61; } }

How to know when the screen is locked in adobe air on iphone?

I am aware of Stage.ACTIVATE and Stage.DEACTIVATE but this will fire when the app is in background.

Is there a way to know when the device screen is locked, from the background running app and from the foreground?

vendredi 29 juillet 2016

How do I fake a iOS device rotation in Flash

I need to fake a device rotation in my app, so that in Quick Time movie mode it rotates for presentations.

I've tried several options, but the one that seems most promising is allowing autoOrient to stay true but preventing any changes to screen orientation. The issue is, I can't figure out a way to to do this. I have been using e.preventDefault() but it has had no effect. Any suggestions?

Creating a video from Flex

I am using a Flex program where user can use drop their images and move , rotate or scale , well everything is done using tweening and i have a timeline. so i am using greensock to do everything , so now i can able to run it and i can see a video,

now i want to export this to a video, i mean capture that, i just wanna know how that can be done , same as goanimate .

any help would be really appreciate

please help am so desperate
right now

Editable datefield focus issue in iexplorer

I have one textinput and beside that there is datefield which is editable="true".
Now, when i enter something in textinput and press tab then it focus on datefield but, not remove focus from <s:TextInput.

This happens only in internet explorer. Not any other browser having that issue.

enter image description here

I have just simple textinput and datefield.

<s:TextInput width="100" />
<mx:DateField width="100" editable="true" selectedDate="{new Date()}" />

jeudi 28 juillet 2016

Storing the result of blended images in AS3.0

I am making an interactive animation which background images are masked by a shape captured in a camera. In the every frames, camera changes images into black and white images and then it's used to mask background images.

In the code, "now" is the images captured by camera, "P1" is the back ground image.

After I masked by using blend mode multiply, I wish to store the result image which is masked and use for other things. I don't understand when I use blendmode function, how the result is defined well. Can I capture, copy or store the result image?

var P1:MovieClip = new p1();
var mskimg:MovieClip = new maskimage();

var bitmap_obj:Bitmap = new Bitmap(now);

P1.blendMode = BlendMode.LAYER;
bitmap_obj.blendMode = BlendMode.MULTIPLY;

enter image description here

Drawing sprite onto bitmapData without padding

I have a sprite which is a primitive rectangle rotated by 45 degrees. I'd like to create a Bitmap using BitmapData which will copy it exactly. I thought that BitmapData#draw will operate only on my sprite, so I tried naive approach:

var a = new Sprite();
a.graphics.drawRect(0, 0, 200, 100);
a.x = 100;
a.y = 100;
a.rotation = 45;


var bitmapData = new openfl.display.BitmapData(1500, 1500, false, 0x00000000);

var bitmap = new openfl.display.Bitmap(bitmapData);
bitmap.x = 500;
bitmap.y = 100;

However the result surprised me: Weird padding

It seems it preserves transformation matrix (which in fact makes sense, otherwise rotation would be lost). So I tried more robust approach:

var bitmapData = new openfl.display.BitmapData(1500, 1500, false, 0x00000000);

var rect = a.getBounds(a.parent);
var matrix = a.transform.concatenatedMatrix;
matrix.translate(-rect.left, -rect.top);
bitmapData.draw(a, matrix);

And still, same result as in the image provided. I've tried clipRect param, but even more weirdly, no matter how big the rectangle is, object is not copied at all (only black space remains).

var bitmapData = new openfl.display.BitmapData(1500, 1500, false, 0x00000000);
var clip = new openfl.geom.Rectangle(1500, 1500);
bitmapData.draw(a, clip);

Am I misusing BitmapData#draw? Any help appreciated

OpenFL 4.0.0
Tested with Cpp, Neko and HTML5

Thank you.

Stop embedded music AS3

In my application, i have used the following lines to embed music and run in on actual devices through adobe air :

[Embed(source = '/inspiration.mp3')]
        private var MyBack:Class;
        private var back:Sound;

Later on, whenever i want to play it, i use the following code :

back = (new MyBack()) as Sound;

It works perfectly, the problem is when i want to stop that music! I've used

back.stop(); but it's always telling me

1061: Call to a possibly undefined method stop through a reference with static type flash.media:Sound.

What am i doing wrong?

After end of MouseMove or drag event menu keeping from release menu items

I am having a problem with draggable menu including menu button items. At the end of drag operation (when I lift my finger from the screen) a button sub item works because of its MOUSE_UP code.

I need drag end drop my menu. After drop menu button items listeners should start for release (MOUSE_UP). How can I separete them?

I read some similar messages but I couldnt solve my problem.


mercredi 27 juillet 2016

Fill in the blanks questions in flex using action script

I need to create a fill in the blanks component dynamically. Question text will be retrieved from XML. For Example (some text ____________ some text). The Underline portion should have a text input. The question text will be dynamically loaded and the position should be aligned based on resolution. Give me some examples and which components should be used for achieving this.

JSON Parsing Query in AS3

I'm creating an application that uses a License Plate Recognition System.

The API that I'm using is rest based and returns a JSON to my application, a JSON which I parse and which basically looks like this:

{"data_type": "alpr_results", "epoch_time": 1469660951857, "img_height": 288, "img_width": 432, "results": 
[{"plate": "MBR527D", "confidence": 88.891518.....

This is what my parse looks like when I load it into Actionscript:

var ThePlate:Object = JSON.parse(e.target.data)

The Issue I'm having is that I'm unable to trace the Plate entitled "MBR527D" within results, basically because I'm a noob when it comes to JSON.

This is what I try when I attempt to trace the plate and I know I'm doing something wrong:


It returns "undefined", however when I try to trace the image height:


It returns the 288 just fine, so I know I'm making a basic error but would appreciate any help you guys have! Thanks!

Flex Currencyformatter automatically rounds off the larger values

We are working with Amounts of which value are higher. We are displaying the formatted amount in the respective spark TextInput. We are using the simple mx CurrencyFormatter for formatting the amount values. We dont have any problems till 16 digits . But after crossing 16 digits , the numbers are automtically rounded off. We are using the CurrencyFormatter with the following configurations,

<mx:CurrencyFormatter id="formateer" thousandsSeparatorTo="," decimalSeparatorTo="."
                              precision="2" currencySymbol="" rounding="none" />

My output: We dont have any problem upto 16 digits


Erroneous output:


Here the last digit 7 is rounded to 8.

Erroneous output:


I have debugged the code and had gone into the format() method CurrencyFormatter . There actually the problem occurs from the Number conversion. I am wondering since the Number.MAX_VALUE is 1.79769313486231e+308 .

Please suggest me how to solve this issue or suggest me a workaround method.

Thanks in advance. Vengatesh s

NodeJS Writing JPG from Byte Array

I have an AS3 application sending me a jpeg-encoded byte array from an http post. My node application is to take that, and save it on the local filesystem as a jpg.

the as3 jpeg-encoder is from as3 core lib


var results = new Object();
    results.success = false;
    results.message = debugWrite("Post Recieved \r\n");
    processPost(request, response, function() {

        results.message += debugWrite("path: " + FILEPATH + "\r\n");

        //save jpg
        var buffer = new Buffer(request.post, 'binary');
        fs.writeFile(FILEPATH, buffer, "binary", function(error){
            if(error != null){
                results.message +=debugWrite("Error: "+ error + "\r\n");
                results.message += debugWrite("OK - Saved");
                results.success = true;

        response.writeHead(200, "OK", {'Content-Type': 'application/json'});

var processPost = function(request, response, callback) {
    var queryData = "";
    if(typeof callback !== 'function') return null;

    if(request.method == 'POST') {
        request.on('data', function(data) {
            queryData += data;
            if(queryData.length > 1e6) {
                debugWrite("Request To Large");
                queryData = "";
                response.writeHead(413, {'Content-Type': 'text/plain'}).end();

        request.on('end', function() {
            request.post = queryData;

        } else {
            response.writeHead(405, {'Content-Type': 'text/plain'});

Currently it is saving a file, however, the file isn't view-able. Any tips are really appreciated.

php accomplished the task using "file_put_contents", but i needed to move the functionality to a node server.

Dynamic positioning of text area and text input in flex

I need to create a fill in the blanks question where the question text will be loaded dynamically through xml. I don't know the length of the question. I have to place a text area for question and text input for answer. The positioning of these controls should be aligned based on the input.

Any tips on how to achieve this using flex air application?

mardi 26 juillet 2016

Adobe Flash ActionScript 3.0 ERROR 1009 When using UILoader

I did a lot of search and can't find the answer, please kindly help me. So I created one flash game called Snake Games and then another Flash which I use UILoader to load the snake game, however when I try to run that Flash game and check whether that flash will load the snake game, I encountered error

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

at Main/addFood()

at Main/init()

at Main()

Here's the Main.as script inside the Snake Games http://ift.tt/2ath3Ih

Please kindly help me.

Thank you.

Query Regarding JavaScript, AS3 HTMLLoader, JQuery

recently I've been experimenting with OpenALPR (A License Plate Recognition Library) for an app I've been working on.

The app of mine is currently built using Adobe Air and ActionScript 3.0.

This recognises a problem for me as the version of OpenALPR is currently written in JavaScript with JQuery.

I didn't see this as a major issue as I could just work with the Javascript within Adobe Air by simply using a URLRequest. But unfortunately there is a bit of a problem that comes about when I try.

Basically I'll present the code first:


<script src="http://ift.tt/1ROJ5xx"></script>

<script src="src/model/AlprPlate.js"></script>
<script src="src/model/Classification.js"></script>
<script src="src/model/Coordinate.js"></script>
<script src="src/model/InlineResponse200.js"></script>
<script src="src/model/InlineResponse400.js"></script>
<script src="src/model/PlateCandidate.js"></script>
<script src="src/model/PlateDetails.js"></script>
<script src="src/model/RegionOfInterest.js"></script>
<script src="src/api/DefaultApi.js"></script>


    function HelloWorld(value123) {
        var img_url = value123;
        openalpr_api = new DefaultApi();
        openalpr_api.recognizePost("(securitykeyforopenalpr)", "plate,color,make", "", "", 
            "eu", "", 0, 10, "", function(data, textStatus, jqXHR) {
                // callback function on completion

                return data.plate.results[0].plate;


I realise not much can be made from this but the real problem arises when I use Flash. Here's my AS3 code.

function onLoaded(e:Event) :void

So basically the "URLTOCAR" is value123 in the Javascript. But whenever I run the application this is the response I'm met with:

"Result of expression '$' [undefined] is not a function."

Now I presume this is a problem related to Jquery or the DefaultApi js file, but the reason I'm posting the problem here for the help of you guys is because this problem doesn't present itself when I run this as a HTML file in my browser using a manually entered Car URL, the system works fine. So I realise this must be a problem related strictly to Flash.

So I realise I must be making some sort of error when I'm adjusting my code to be supported within Flash, so I'm not asking for help with the Physical API itself, but basically If I'm putting somewhere in the wrong place and doing something I'm not supposed to be.

Would be extremely grateful with any responses pointing me in the right direction! Thanks so much!

How do I outdent by a certain amount?

I'm trying to create a function that I can use to outdent (versus indent) a specific amount.

Here is what I have so far. This removes all tabs at the beginning of the lines. I think I need to create a dynamic pattern or use a function but I'm stuck:

var outdentPattern:RegExp = /([\t ]*)(.+)$/gm;

function outdent(input:String, outdentAmount:String = "\t"):String {

    var outdentedText:String = input.replace(outdentPattern, outdentAmount + "$2");
    return outdentedText;

Here is test data:

        var test:Boolean = true;
        test = "string";

The test would be remove one tab, remove two tabs, etc.

Expected results at one tab would be:

    var test:Boolean = true;
    test = "string";

And two tabs:

var test:Boolean = true;
test = "string";

Interesting note:
The editor on SO is outdenting when you click code button when the code is already indented.

.fla published as AIR is super slow; works fine as FlashPlayer 21

I know that without posting code, no body can completely help me, but...

I think I'm starting to realize that changing my flash publish settings to "AIR for iOS" or "AIR for Desktop" is not the same thing as writing AS3 for iOS. ugh. Can someone confirm this?

The Problem

When I first was building my app, it worked fine whether I published it to the FlashPlayer 21 or to the AIR for Destop etc. At that time, it was a simple platform game with a few vector drawn sprites and a basic physics "engine". But because I intended to publish to the Apple Store, I changed my vector drawings to bitmaps using spritesheets. Now that I have a couple dozen sprites moving around, it is almost completely frozen (down from 40 fps to about 0.5 fps!) when running in AIR, but runs as smooth as butter in Flash Player 21.

Are there some simple settings I need to change? Has anyone else run across this and found what type of problem could cause this? I've read that AIR has a bunch of its own API's... do I need to maybe use those instead?


Another thing I'll mention, is that I am in the middle of tweaking a spritesheet class that I made. Because my end target is iOS, I decided to use bitmaps instead of vector drawings because bitmaps are easier on mobile devices' CPU's. But it seems that ever since I started working with bitmaps, that is when this problem started.

I suspect maybe my problem has to do with how I'm loading my bitmap data. Or is there a problem with with publishing in AIR from the Flash IDE?

I'd really appreciate a prod in the right direction of where to look (either in my code, or on the web). I've not published anything to the apple store yet. Much thanks!!

AS3 KeyboardEvent won't add eventListener after NetStream has been stopped

I have a Flash SWF set up to play a netstream in response to keyboard commands. There are several very short video clips that are triggered by the number pad. Since there are so many (in this unfinished example there are only a few), two numbers must be pressed to play the video.

The first number triggers the videoArray function, and inside the videoArray function a new eventListener is created to play a video, while the old event listener is removed. Once the video finishes, I used NetStatusEvent to remove the netstream and add the videoArray eventListener again.

All of this works fine, however, There is a stopVideo function that is triggered by the S key. It has the same code as the NetStatusEvent to remove the netstream and re-ad the eventListener, but only the netstream is removed. The eventListener is not added.

Am I missing something that's stopping the eventListener from being added, or should I be doing this differently? Is it possible to skip to end of the video and trigger the NetStatusEvent to stop it?

import flash.ui.Keyboard;
import flash.events.KeyboardEvent;

// Create a NetConnection object
var nc:NetConnection = new NetConnection(); 

// Create a NetStream object with NetConnection object as a parameter
var ns:NetStream = new NetStream(nc); 
var vid:Video = new Video();

// Play control

function preStop(event:KeyboardEvent):void {
    if (event.keyCode == 97) {
        trace("O Stop");
    else if (event.keyCode == 98) {
        trace("P Stop");

function videoArray(event:KeyboardEvent):void {

    if (event.keyCode == 97) { 
    else if (event.keyCode == 98) { 

    // PLAY 1
    function play1(event:KeyboardEvent):void { 
        if (event.keyCode == 97) { 

            // Play video
            ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler); 

            // Create a new Video object and attach NetStream object
        else if (event.keyCode == 98) { 

            // Create a NetStream object with NetConnection object as a parameter
            ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler); 

            // Create a new Video object and attach NetStream object

    // PLAY 2
    function play2(event:KeyboardEvent):void { 
        if (event.keyCode == 97) { 

            // Create a NetStream object with NetConnection object as a parameter
            ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler); 

            // Create a new Video object and attach NetStream object
        else if (event.keyCode == 98) { 

            // Create a NetStream object with NetConnection object as a parameter
            ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler); 

            // Create a new Video object and attach NetStream object

    function asyncErrorHandler(event:AsyncErrorEvent):void { 
        // ignore error 

// Stop at end of video
ns.addEventListener(NetStatusEvent.NET_STATUS, statusHandler);

function statusHandler(event:NetStatusEvent):void 

    if (event.info.code == 'NetStream.Buffer.Empty') {

// Pause control

function togglePauseHandler(event:KeyboardEvent):void { 
    if (event.keyCode == Keyboard.SPACE) { 

// Stop control

function stopVideo(event:KeyboardEvent):void {
    if (event.keyCode == Keyboard.S) {

lundi 25 juillet 2016

what is the easy way to write code(AS3) like this?

I need help to make this code easy

button b1 button b2

there is C button clear_btn

adobe air android how to share file(txt file) from phone storage or sd card to another device

Hi everyone Please help me!!! How to send files with share menu to another device? I used some native extensions, but I can't send a file. Thank everyone

Actionscript Checkbox with MouseClick Position

So i am new in AutoIT and i tried to make something for beginners. So i was thinking about making a login bot for a game. Now, i would do this with the MouseClick("left",,) Now, i was thinking about adding a menu from Koda. Where i would CHECK a CHECKBOX and my mouse would go to the right place where it needs to click. And when i uncheck the box, it has to do nothing.

So all together. I really want the code where i check a checkbox and my mouse goes to the position i want. But at the mean time, when i uncheck the box it would say nothing. Does anyone know the right code for this?

Even more specific in general. I want the code for the checkbox where i would check it and that my MouseClick position goes to the right spot. Anyone can help me with this?


public class FlagSecureTestActivity extends Activity {

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);



} }

dimanche 24 juillet 2016

HIghlight row in red border in AdvancedDataGrid in Flex 4

I want to highlight the row in red border in AdvancedDataGrid without selecting the row. My selected item is different from the highlight row. Please see the following image :

enter image description here

My selected index is where Territory is Neveda but my highlighted row is different(in Red Border) based on some condition.

So please tell me how can i implement it.

Thanks in Advanced !!!

How to convert Actionscript SortField() and Sort() function to Javascript?Thanks in advance

This is my actionScript. Need to convert to javascript:

var MarketDataSortField:SortField = new SortField(); var StateDataSort:Sort = new Sort();

how to identify a frame loaded completely in Flash by AS3?

this is my function on frame 1:

function check_pose(y_pose:Number)
    if (y_pose>d1.y && y_pose<d1.y+d1.height )

and this is the code on frame 3 & 4:

stage.addEventListener(Event.ENTER_FRAME, onEnterF5);
function onEnterF5(e:Event)
    stage.removeEventListener(Event.ENTER_FRAME, onEnterF5);
    cm1.visible = false;

there is a big text on each frame 3 & 4 and it cause take some seconds to show that big text on stage . and the movieclip "cm1" never shown ! how can identify frame 3 or 4 load completely ? a code like this:

stage.addEventListener(Event.FRAME_LOADED_COMPLETELY, onEnterF5);

memory issue in Removing an external swf from stage

I had 28 swf files, which are connected with a main swf, and the main swf is loaded external to a blank swf. On the main swf there a 26 buttons which are linked to 26 swf and each 26 swf have a back button which will return to the main swf. All are working fine accept the memory issue. Please help me with this

The script I used in the main swf to go to the other 26 swf is

var loader_mc : Loader = new  Loader();

btn_main_apple.addEventListener(MouseEvent.CLICK,  buttonClick)
function  buttonClick(e:MouseEvent):void
} catch(e:Error) {
      var urlRequest : URLRequest = new  URLRequest("FitzroySound_A.swf");

btn_main_bird.addEventListener(MouseEvent.CLICK,  buttonClick2bird)
function  buttonClick2bird(e:MouseEvent):void
} catch(e:Error) {
      var urlRequest : URLRequest = new  URLRequest("FitzroySound_B.swf");

btn_main_cat.addEventListener(MouseEvent.CLICK,  buttonClickCat)
function  buttonClickCat(e:MouseEvent):void
} catch(e:Error) {
      var urlRequest : URLRequest = new  URLRequest("FitzroySound_C.swf");

and so on....

And the script I used on the other 26 swf to return to the main swf is

var loader_mc : Loader = new  Loader();

logout_btn_drw_z.addEventListener(MouseEvent.CLICK,  buttonClick)
function  buttonClick(e:MouseEvent):void
} catch(e:Error) {
      var urlRequest : URLRequest = new  URLRequest("FitzroySound_mainScreen.swf");

Please help me

gotoAndPlay to a scene from a different AS3 Class

I am developing an adobe air AS3 game using the following scenes Structure :
- Intro
- Game
- GameOver
I don't have any code written in the timeline, i am constantly creating AS3 Classes. The situation i'm facing is the following
The user starts in the "Intro"scene, in which he goes to "Game" Scene. After loosing the game, he goes to "GameOver". The original fla file has a document class named : introClassToUse.as
Once the user goes to "GameOver", he has a button to replay the game, as in go back to scene "Intro". I am using the following code for the replayGame.as :

    import flash.display.MovieClip;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.events.MouseEvent;
    import flash.display.Screen;
    import flash.system.Capabilities;
    import flash.geom.*;
    import flash.display.Stage;
    import flash.display.*;
    import flash.display.DisplayObject;
    import flash.display.MovieClip;

    import baseCode;
    import introClassToUse;
    import flash.events.Event;
    public class replayGame extends flash.display.MovieClip

        var replayButToUse:replayBut= new replayBut();

        public function replayGame()
            replayButToUse.x = 0.127 * introClassToUse.STAGE.stage.stageWidth;
            replayButToUse.y = 0.91 * introClassToUse.STAGE.stage.stageHeight;
            replayButToUse.addEventListener(MouseEvent.CLICK, gotoIntro);

        function gotoIntro(event:MouseEvent):void

            replayButToUse.removeEventListener(MouseEvent.CLICK, gotoIntro);


            var reload:introClassToUse = new introClassToUse();




This code creates the replay button in "GameOver" Scene. My goal is to navigate back to "Intro" Scene once it's clicked and after navigating to that scene, re-calling the introClassToUse.as and restart the actual game. The problem is, the scene isn't found! ( the error flash cs6 shows). I'm guessing that i don't have the proper understanding of the navigation in case you are navigating from a different AS3 class. I've searched all over the internet, and tried several snippets like :


And several other internet suggestions, i always end up with the same error. How can i fix this situation?

samedi 23 juillet 2016

create windows(.exe) file using adobe flash

I've create an app using flash cc for android. It works great but now my goal is to publish it in windows. I know I can use air for windows. I've tried it and it works. But the problem with that is, you can see all the swf files on installed folder. That makes my files vulnerable for theft. So I want to know if there's any methods or converter to convert my whole air application in exe so that it doesn't expose all the included swf files. I think game like machinarium was created using flash. But when I got the setup file it include exe files and non of flash files or any other files were exposed. Is it possible to achieve with flash as3? Any help would be much appreciated.

How well does Flash work for this specific project?

I am beginning a long-term project, an industry-specific drawing/layout app that relies quite a bit on graphics and needs to be cross-platform (iOS, Android, desktop)

I am looking for help deciding if Flash is best platform to use (despite its recent drop in popularity). Given a few specific needs, I'm hoping to get an idea if its the best fit or not. I have little to no knowledge about developing Flash apps.

Learning Curve - for someone with front-end javascript & native app dev experience

Simplicity - will a lot of time/effort need to be spent on optimizing/memory management... away from the conceptual tasks I'll be working on

Performance - How well will a Flash app perform working with bitmaps, i.e. bitmap textures on odd shaped objects in 2d space? How about in 3d space?

Long-term support - is the community optimistic it will not fall in disrepair in the near future

If Flash doesn't appear to be a good option, I would consider Cocos2dX game engine or WebGL, I looked at HTML5 Canvas, but too slow on mobile devices.

Flash Game Actionscript-3 Output Error #1009

I am making my own game using Actionscript 3 for coding in Flash. The game is about a Runner Character just like Super Mario and Stickyman, who just run, jump, dies.. and so on.. After being very organized by dividing each window of the game in a different Scene, I was still having the problem of executing the piece of code "gotoAndStop()".. That's why I decided to make it much simple by using only one Scene, but each wind of the game in a different frame in the Main Timeline. So I worked on the root, but still getting the same problem that stuck in a white screen!

Anyways, one of the main problem that I am facing here is the Error #1009. Even when I tried to read other topics with the same issue but I didn't find the answer that suites my case.

This is the Error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at HR4_fla::MainTimeline/movePlayer()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at Apple/update()

Here is the Code:

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

import flash.geom.Rectangle;

var KeyThatIsPressed:uint;
var rightKeyIsDown:Boolean = false;
var leftKeyIsDown:Boolean = false;
var upKeyIsDown:Boolean = false;
var downKeyIsDown:Boolean = false;

var score:int = 0;
var lives:int = 3;
player_mc.health = 100;
player_mc.dead = false;
//var TouchRestartBox:Boolean = false;

var playerSpeed:Number = 8;
var gravity:Number = 2;
var yVelocity:Number = 0;
var canJump:Boolean = false;
var canDoubleJump: Boolean = false;

//var appleCount:int;

stage.addEventListener(KeyboardEvent.KEY_DOWN, PressAKey);
stage.addEventListener(KeyboardEvent.KEY_UP, ReleaseAKey);

stage.addEventListener(Event.ENTER_FRAME, cameraFollowCharacter);

function cameraFollowCharacter(event:Event):void
 scrollRect = new Rectangle(player_mc.x - stage.stageWidth/2, player_mc.y - stage.stageHeight/2, stage.stageWidth, stage.stageHeight);

//PressKey function here
function PressAKey(event:KeyboardEvent):void
    if(event.keyCode == Keyboard.RIGHT)
    rightKeyIsDown = true;
    if(event.keyCode == Keyboard.LEFT)
    leftKeyIsDown = true;
    if(event.keyCode == Keyboard.UP)
    upKeyIsDown = true;
    if(event.keyCode == Keyboard.DOWN)
    downKeyIsDown = true;

//ReleaseKey function here
function ReleaseAKey(event:KeyboardEvent):void
    if(event.keyCode == Keyboard.RIGHT)
    rightKeyIsDown = false;
    if(event.keyCode == Keyboard.LEFT)
    leftKeyIsDown = false;
    if(event.keyCode == Keyboard.UP)
    upKeyIsDown = false;
    if(event.keyCode == Keyboard.DOWN)
    downKeyIsDown = false;

//stage.addEventListener(Event.ENTER_FRAME, GameOver);

stage.addEventListener(Event.ENTER_FRAME, movePlayer);

function movePlayer(event:Event):void

if(!rightKeyIsDown && !leftKeyIsDown && !upKeyIsDown)

player_mc.x+= playerSpeed;
player_mc.scaleX = 0.59;

player_mc.x-= playerSpeed;
player_mc.scaleX = -0.59;

if(upKeyIsDown && canJump)
yVelocity = -15;
canJump = false;
canDoubleJump = true;

if(upKeyIsDown && canDoubleJump && yVelocity > -2)
    yVelocity = -13;
    canDoubleJump = false;

yVelocity +=gravity;

if(!floor_mc.hitTestPoint(player_mc.x,player_mc.y, true))

if(yVelocity > 20)
yVelocity =20;

for(var i:int=0; i<10; i++)
    if(floor_mc.hitTestPoint(player_mc.x, player_mc.y, true))
    yVelocity = 0;
    canJump = true;

for(var j:int=0; j<=2; j++)
    if(rb.hitTestPoint(player_mc.x, player_mc.y, true))
        player_mc.x = -1703.35;
        player_mc.y = 322.1;
        player_mc.scaleX = 0.59;
        lives = lives - 1;

    if(lives == 0)
//          GameOver();
    // remove all the event listeners
//  stage.removeEventListener(Event.ENTER_FRAME, GameOver);
    stage.removeEventListener(Event.ENTER_FRAME, movePlayer);
    stage.removeEventListener(KeyboardEvent.KEY_DOWN, PressAKey);
    stage.removeEventListener(KeyboardEvent.KEY_UP, ReleaseAKey);
    stage.removeEventListener(Event.ENTER_FRAME, cameraFollowCharacter);
//(root as MovieClip).gotoAndStop(124);

//  appleCount_txt.text = "Apples:" + appleCount;

/*function GameOver()
//  lives = 3;

// remove all the event listeners
stage.removeEventListener(Event.ENTER_FRAME, GameOver);
stage.removeEventListener(Event.ENTER_FRAME, movePlayer);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, PressAKey);
stage.removeEventListener(KeyboardEvent.KEY_UP, ReleaseAKey);
stage.removeEventListener(Event.ENTER_FRAME, cameraFollowCharacter);

//  player_mc.stop();
gotoAndStop(1); // this has your "dead" screen on it.

Can anyone help me solving this problem please? Thanks

Moving a movie clip while user keeps touching it AS3

I am developing a game in adobe air, in which i have a movie clip at the center. When the user touches this movie clip and moves around the stage, the movie clips needs to change its "x" accordingly to the touch's position. I am using the following code, which is doing exactly what it intended to do :

    MC.addEventListener(TouchEvent.TOUCH_MOVE, touchDownMC);
function touchDownMC(e:TouchEvent):void {
    MC.x = e.stageX;

The MC is moving correctly, but the problem is, after 10-15 seconds while the user is pressing the MC and moving it around, the MC just stops responding for the current touch event, and the user needs to re-touch it and move back around. It seems like it's loosing the TouchEvent. How can i make the MC constantly move as long as i have my finger on it, keep it listening and moving?

vendredi 22 juillet 2016

I want to disable screenshot functionality for my android air app

I want to disable screenshot functionality for my android air 22 AS3, live video streaming app

Bitmap problems when making a background class AS3

So I'm updating my text adventure engine by making the document class smaller by shoving all the functions that could be put in a separate class into a separate class to save on space since the main class was having an excess of 1000 lines. (mostly from the array that held the story and such)

Currently, I'm in the process of moving the background changing function into it's own class and have run into some problems.

public class Background extends Bitmap

    public function Background(part:Object,width:Number,height:Number)

        // add new background
        this.height = width
        this.width = height



I have no idea how to set an image to this. part is part of an object array that kind of looks like this


Assets is just a class that holds all the embeds for the backgrounds.

Does anyone know how I can set the image of the part to the background class? Should I even be extending Bitmap?

AS3 removeChild and collisions : issue

I'm working in a little shooting game with Flash and AS3. I'm still beginning for using Class documents, but I managed to understand thanks to tutorials. So here's how it works : I used the HitTestObject when the Enemy MovieClip hits a bullet, shot by the user :

//checking if it is touching any bullets
//we will have to run a for loop because there will be multiple bullets
for(var i:int = 0;i<_root.bulletContainer.numChildren;i++){
    //numChildren is just the amount of movieclips within
    //the bulletContainer.
//we define a variable that will be the bullet that we are currently
//hit testing.
var bulletTarget:MovieClip = _root.bulletContainer.getChildAt(i);

//now we hit test

    gotoAndPlay(4); //the Enemy MC is removed after 4 hits(parent.removeChild(this))
    removeEventListener(Event.ENTER_FRAME, eFrame);
    //the Bullet MC is removed with its Listeners


    if(hit > 4)
        hit = 0;

So after 4 hits, it is completely removed from the screen. The eFrame function remove the Enemy MC if it goes off the stage :

    private function eFrame (event:Event):void{
        if(this.x > stage.stageWidth + 50){
            removeEventListener(Event.ENTER_FRAME, eFrame);

I also put a command that detects collisions between the Enemy MC and the Player (that I gave the "craft" instance name) :

if(hitTestPoint(_root.craft.x -203.25, _root.craft.y - 44.9, collide)) 
       _root.dmg.width+=8;//reduce the life bar
        removeEventListener(Event.ENTER_FRAME, eFrame); 
    if(hitTestPoint(_root.craft.x -210.6, _root.craft.y - 32.9, collide))
        removeEventListener(Event.ENTER_FRAME, eFrame);

    if(hitTestPoint(_root.craft.x -210.6, _root.craft.y - 6, collide))
        removeEventListener(Event.ENTER_FRAME, eFrame);
    if(hitTestPoint(_root.craft.x -211.4, _root.craft.y + 20, collide))
        removeEventListener(Event.ENTER_FRAME, eFrame);
...//There is a lot of other points with the same results...

So the Enemy MC is also removed if it hits the craft MC (Player). But I encountered an issue : when the Enemy MC is hit (4 times by the Bullet movieclips "shot" by the user which removes it) but also collided by the player, it is not removed as it ought to be... It is instead still displayed on the screen, and is static : it can't be hit neither by a bullet MC, neither by the player MC...

I think this is because of the parent.removeChild(this) executed from gotoAndPlay(4) of the Enemy MC, which causes that issue : it is executed a twice (because the Enemy MC is destroyed by the Bullet MC AND by the Player)... Anyone has an idea to solve that double execution of removeChild ? If you want to have more info, you can download the source : http://ift.tt/2amCBar

Thank you for your help.

Function does not return a value actionscript guessing game

I am very new to programming in actionscript. I just recently learned about functions and my assignment was to create a guessing game where the user inputs a range and the computer will generate a random number within this range. The user then guesses what the number is.

My main problem is that I get the error "Function does not return a value" for the function guessCorrect(). I do not understand why this happens or how to fix it. Also, if you by chance happen to see any other errors please let me know. Your help is greatly appreciated.

Here is my code:

btnGuess.addEventListener(MouseEvent.CLICK, guessNumbers);

//Global Variables
var count = 0;

var myGuess:int;
var Answer:int;
var highNumber:int;
var lowNumber:int;

function guessNumbers(e:MouseEvent):void {
//Set Variables
 highNumber = int(txtinHighValue.text)
 lowNumber = int(txtinLowValue.text)

Answer = randomWholeNumber(highNumber, lowNumber);

myGuess = int(txtinGuess.text);

lblOutput.text = guessCorrect(myGuess, Answer, count);


function randomWholeNumber(highNumber:int,lowNumber:int):int

return Math.floor((highNumber - lowNumber + 1) * Math.random() + lowNumber);


**function guessCorrect(myGuess:int, Answer:int, count:int):String {
while (myGuess != Answer) {
    if (myGuess < Answer) {
        lblOutput.text = "Guess to low - try again!"
        count ++
    else if (myGuess > Answer) {
        lblOutput.text = "Guess to high - try again!"
        count ++
    else if (myGuess == Answer){
        lblOutput.text = "It's a match - you win!"
        count ++

lblGuesses.text = "Guessess: " += count

btnNewGame.addEventListener(MouseEvent.CLICK, guessNumbers); {
    count = 0;
    highNumber = 0;
    lowNumber = 0;

SharedObject appears to be caching

I have a slightly unusual situation with SharedObject:

The situation: where we have a SWF (browser) based application running on a single local machine. The SWF accesses local content and is reloaded every XX number of seconds/minutes/hours.

The state of application has to be stored within a single SharedObject (this is using the '/' parameter to force it to global) in a JSON style.

The SWF loads the SO before it makes any state updates and correctly calls flush() immediately after to save state.

The Problem: Everything runs fine BUT occasionally there is a situation where by 2 instances of the same SWF are existing at the same in different instances and both are accessing the same SharedObject.

The 2nd has to take control of the SO from the 1st, by each SWF instance setting it's instance state to an incremented number (SWF Idx) stored in the SO.

Both are loading the file before any update is made, version number checked, and will disable themselves if the saved SWF Idx is above it's own. Unfortunately the 1st SWF instance somehow isn't loading the latest version of the SharedObject because it traces out the original number (e.g. 22) instead of the now updated one (e.g. 23). While the 2nd SWF is tracing out 23 and the SO contains 23.

Is there any way that the browser could possibly be caching the SO?

Testing I'm currently testing the situation by running one browser instance locally then launching a 2nd. Making copies of the SO before and after each state. I've also run the 1st and 2nd via IntelliJ and can see that SharedObject.getLocal is being called and checked each time.

I've included the basics of the code I'm using below where:

  • __so = is the public SharedObject variable
  • _thisSWFIdx = is the private variable inside AS3 storing the current instances SWF Index
  • __so.data.activeSWFIdx = the latest SWF Index

The SO 'get' I'm using is:

SharedObject.getLocal(_SO_ID, "/");

The check i'm doing is:

if (_thisSWFIdx < __so.data.activeSWFIdx) {
    __amActiveSWF = false;

The saving of the variable to SO:

__so.data.activeSWFIdx  = _thisSWFIdx;

Additonal info:

  • This is running on both mac & windows
  • FlashPlayer 10.3
  • Pure AS3
  • compiled in IntelliJ
  • same issue in FF, Chrome and IE
  • primary machine Macbook

I can't find anything within the documentation or existing threads so any help will be much appreciated.

NetConnection.Connect fail even after IP included in Global security setting manager

Hello I wrote a simple video chat app with Actionscript 3. The strange thing is that seems the app's NetConnection.connect call to the RTMP server can only be successful on one particular of my machines at hand. Other computers all fail with NetConnection.Connect.Failed so following actions couldn't proceed. I have verified all of these computers run the same version of Flash Player - v22.0.0.209 and all running Chrome, and have added the same URL location to the Global Security Setting manager - a LAN IP address, i.e. "".

A side note may or may not be related here is that on the working machine, I've tried 3 browsers - Chrome, Edge and IE. Chrome and IE are working. Edge is not.

These seems really strange behavior so any hints would be appreciated.


Calling C++ code from ActionScript

Here's the problem: I'm creating my new game which has some inapp items. I am using the Starling Framework for the game so I develop on AS3. I want to protect the game from genius(!) players who may attempt to break into inapp purchase process.

AS3 calls an in-app ANE (Milkman's), when a success returns from the ANE, my AS3 code sends an acknowledgement to my game server. So a malicious player can always send this acknowledgement info to my server without completing the in-app purchase process as if it was completed successfully.

So I thought of creating my own ANE which will also send this acknowledgement after it completes the process, so no AS3 code to mess with. I also don't want to use Java on Android to make things a little harder so I wonder if it's possible to call C++ code (which calls JNI for in-app purchases) from AS3.

How to prevent a drag action to affect the childrens of a MovieClip

My problem is: I have a MovieClip (obj) that users can drag to both sides to navigate, the code I use for this:

import flash.events.MouseEvent;
import flash.geom.Point;
import flash.events.Event;
import flash.geom.Rectangle;

var destination: Point = new Point();
var dragging: Boolean = false;
var speed: Number = 10;
var offset: Point = new Point();
var bounds: Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);

obj.addEventListener(MouseEvent.MOUSE_DOWN, startdrag);
stage.addEventListener(MouseEvent.MOUSE_UP, stopdrag);
obj.addEventListener(Event.ENTER_FRAME, followmouse);

function startdrag(e: MouseEvent): void {
    offset.x = obj.mouseX * obj.scaleX;
    dragging = true;

function stopdrag(e: MouseEvent): void {
    dragging = false;

function followmouse(e: Event): void {
    if (obj) {
        if (dragging) {
            destination.x = mouseX;

        obj.x -= (obj.x - (destination.x - offset.x)) / speed;

        if (obj.x > bounds.left) {
            obj.x = bounds.left;

        if (obj.x < -obj.width + bounds.right) {
            obj.x = -obj.width + bounds.right;

So far so good, the problem comes up when I put some clickable elements inside that MovieClip (obj), here are the code for the clickable elements:

objA.addEventListener(MouseEvent.CLICK, objATrigger);
objB.addEventListener(MouseEvent.CLICK, objBTrigger);
objC.addEventListener(MouseEvent.CLICK, objCTrigger);

function objATrigger(event: MouseEvent): void {
    MovieClip(this.parent).gotoAndPlay(1, "Main");

function objBTrigger(event: MouseEvent): void {
    MovieClip(this.parent).gotoAndPlay(1, "Main");

function objCTrigger(event: MouseEvent): void {
    MovieClip(this.parent).gotoAndPlay(1, "Main");

The problem is: When I drag the MovieClip (obj) there is a conflict with the event, when release the mouse after the drag, the event Click of MovieClips inside the MovieClip (obj) is fired, how can I fix this? They should only be triggered when there is no drag action.

AlievePdf create dashed line

I need to create a schema to pdf. This schema contains a lot of dashed lines. If I paint it like not dashed lines: enter image description here

But if I try to paint it by using dashed lines will paints next: enter image description here

Don't paint constant bar length and constant distance between bars. String example:

    pdfItem.lineStyle(new RGBColor(color), 0.5, 1, 1,null, null, new DashedLine ([ 6 ]) );
    pdfItem.moveTo(firstPoint.x, pointsOnY-firstPoint.y);
    pdfItem.lineTo(secondPoint.x, pointsOnY-secondPoint.y);

I think this is why lines in the schema composed of several shorter lines фтв and it affects the display if line is dashed. How can I fix this trouble?

Moving A MovieClip to Left/Right Using Touch Events with simultaneous touches

I am Developing a game, AS3 Adobe air targeted for both android and ios, in which you have a movie clip in the center, and two buttons ( left and right ) that should move that movie clip. My goal is to make the shift between the left/right as smooth as possible :
- if the player is touching the left button, the movie clips moves left. if he removes he's finger from the left button, and touches immediately the right button, the movie clip won't move, it's until he re-touches the right button , that the movie clips moves right. I have tried to implement multitouch events, but i seem to have something wrong since this is the behavior i'm getting.
- if the player is touching the left button, the movie clips moves left as expected, if he touches the right button, the movie clip stops as expected, but if he removes his finger from the left button while keeping it on the right button, the movie clip still freezes and don't move, it should move then to the right
This is the code i am using :


function mouseDown(e:TouchEvent):void

            //listen for mouse up on the stage, in case the finger/mouse moved off of the button accidentally when they release.;
            addEventListener(Event.ENTER_FRAME,myButtonClick);//while the mouse is down, run the tick function once every frame as per the project frame rate

        function mouseUp1(e:TouchEvent):void

            removeEventListener(Event.ENTER_FRAME,myButtonClick);//stop running the tick function every frame now that the mouse is up

        function mouseDown2(e:TouchEvent):void

            //listen for mouse up on the stage, in case the finger/mouse moved off of the button accidentally when they release.;
            addEventListener(Event.ENTER_FRAME,stopDragging);//while the mouse is down, run the tick function once every frame as per the project frame rate

        function mouseUp2(e:TouchEvent):void

            removeEventListener(Event.ENTER_FRAME,stopDragging);//stop running the tick function every frame now that the mouse is up

    function stopDragging(ev2:Event):void

        if (MC.x <= rightButtonCreated.x)
            MC.x = MC.x + 10;


    function myButtonClick(ev:Event):void

        if (MC.x > leftButtonCreated.x)
            MC.x = MC.x - 10;




The Code was initially set for mouseEvents, so i tried to shift to touch events so i could fix this problem, and the code above is what i got. Thank you for your time.

flex apache sdk 4.15+ an example on how to use event:elementRemove

I am looking for an example on how to use the event:elementRemove listner for flex apache sdk 4.15+

The adobe actionscript reference page does not give an example and I have tried a few different guesses without success.

I have added an element with

var container:UIComponent = new UIComponent();    

<s:Group width="100%" height="100%" id="myGroupContainer">

then removed it with


Now I would like to get a notification that it has been successfully removed.

How do i use the event:elementRemove function? is it an addEventListener(event.type, xxx), if so what do I insert in the event.type & xxx spaces, or do I have to implement in a different manner.

Thanks Art

SecurityError: file

am using a adobe air application. The main file "A", working fine and its downloading a swf "B" and places in system folder. Then am loading the file "B" from "A. The file "B" also wants to download and save swf "C" to another location. But when am trying to access it from file "B", its giving me error "securityerror: file"

Am using the method,

var file:File = new File(); 
var temp:String= File.applicationDirectory.nativePath;

How can I fix this ? I have to use the file method from the dynamically loaded swf "B".


jeudi 21 juillet 2016

Seemingly inconsistent behaviour when assigning dataProvider to Flex's PopUpMenuButton

I'm trying to get two different test dropdowns working in the same fashion.

<mx:HBox x="10" y="50" >
    <mx:PopUpMenuButton id="associativeDD"/>
<mx:HBox x="100" y="50" >
    <mx:PopUpMenuButton id="indexedDD"/>

When I use actionscript to assign the dataProvider values however, I seem to get two different results depending on whether I use an associative array or an indexed one.

var arr1:Array = new Array();
arr1['1'] = ({label: "test1"});
arr1['2'] = ({label: "test2"});
arr1['3'] = ({label: "test3"});
associativeDD.dataProvider = arr1;

var arr2:Array = new Array();
 arr2.push({label: "test1"});
 arr2.push({label: "test2"});
 arr2.push({label: "test3"});
indexedDD.dataProvider = arr2;

Here is what it looks like:

flex dropdowns

There is an empty spot in the beginning of the one where I assigned the dataProvider using an associative array, is there any way to do this "properly" so that it looks correct like the indexed one does?

SharedObject: can receive event from other clients but never fires event after saving data

I'm using a SharedObject to create a simple chat app. The SharedObject was created fine and my app could receive the sync event when other clients updates the data on the SO. However, the problem comes when my app tries to saves the data on the SO to signal other clients. I've verified that the data was changed using the following code:

so.data.chatMessage = msg.text;

It said "before:abc" and "after:def". Unfortunately no clients received the sync event after the data on the SO changed including the client that made the data change itself. So this means this client can receive other client's message but itself message never gets out.

Anybody has seen such issue before? Thanks, Jack

Show border color in AdvancedDataGrid selected row in Flex

How can I show the borderColor of selected row in AdvancedDataGrid in Flex 4.6. You can see the following image for your reference.

enter image description here

Thanks in Advanced !!!

hitTestObject working on PC but not on android device

I am building an AIR ActionScript 3.0 application. Whenever i am trying it on the pc, by doing Command + Enter and testing the movie, the app will work fine, and a collision between two movie clips is working fine. However, when i try to publish it and get the appropriate apk, the app will run normally, but no collision will take place! as if the two movie clips just fly above each other and nothing happens ! While on the PC, its working perfectly! I am new to AS3, so anyone can point out where am i going wrong? This is the code i am using for the collision :

function ifHitAct(e:Event):void

            for each (var obstacle in runNow.manyObs)
                //trace("the obstacle Index Created is" , parent.getChildIndex(runNow.obstacle));
                //parent.setChildIndex(runNow.obstacle ,1)
                if (MC1.hitTestObject(obstacle))

                    runNow.manyObs.splice(runNow.manyObs.indexOf(obstacle), 1);

                    scoreField.text = String(score);
                    obstacle.alpha = 0;



Minimum EmptyMovieClipSize for RAM

I want to create about 5000 Empty Movie Clip in a movieClip that has ability of drag and drop. But processor goes slow down. Drag movement occures slowly.

Why EmptyMovieClip causes some retardations?

AS3 socket: how to get server data to display in client window

I have a "chat" type program which consists of 2 separate projects in FlashBuilder: 1 class for myServer, and 1 class for myClient, bound by socket connection. Messages that are sent from myClient are displayed on the window (serverMessageBox) of myServer. What I want to know, is how do I get the reply message sent from myServer to myClient, so it displays in a TextField (named 'myClientTextBox') in myClient?

Here is the code for the server socket data handler (from myServer class):

socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);

private function socketDataHandler(event:ProgressEvent):void 
    var socket:Socket = event.target as Socket;
    var messageFromClient:String = socket.readUTFBytes;
    serverMessageBox.appendText("Received from client: " + messageFromClient);

    // echo the received message
    messageFromServer = messageFromClient;
    // display the 'sending' message
    serverMessageBox.appendText(">>> Reply from server, to client: You said >>>" +

Here is the code for the client socket data handler (from myClient class):

socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);

private function socketDataHandler(event:ProgressEvent):void {
    trace("socketDataHandler: " + event);

private function readResponse():void {
    var str:String = readUTFBytes(bytesAvailable);
    response += str;
    trace("response: " + response);
    myClientTextBox.appendText(response); // *** this does not work ***

The debug console for myClient correctly displays the "trace" response (obtained from the socket), but for some reason, I have not been able to get that data into the TextField named myClientTextBox in myClient. I tried appending text to myClientTextBox, but it does not display anything.

mercredi 20 juillet 2016

AS3 / Animate CC: user can edit table contents

This question relates to strategy rather than specific code. I'm struggling to think of a viable approach and I'm hoping somebody may have encountered a similar challenge.

I'm building an Animate program that will:

  1. Enable the user to draw a line on the stage (by means of a series of mouse clicks).

  2. Capture the coordinates of each mouse click in an array, and add them to a table that is displayed and updated in the UI.

  3. Display the resulting line.

  4. Enable the user to edit any of the coordinates, and update all of (1) (2) and (3) accordingly.

The first three steps are working OK, but darn ... how should I make that data editable? I've put a listener on the textfield that holds the set of coordinates, but I think that's a dead end. It's just a string with line breaks, so it would be hard to edit a particular few characters and have AS3 / Animate detect what had changed.

Is there a good technique for this?

Background: was comfortable with AS1, skipped AS2 completely, and now (12 years later), I'm grappling with AS3. It's been frustrating, but ... I've built a package and it's working.

Defining movement of both a DisplacementMapFilter and the filtered image from the stage

Using Adobe Animate CC, I animated a DisplacementMapFilter from the stage, but can't seem to do the same with the filtered image. The only technique I’ve found to animate the filtered image is this Adobe tutorial, except, the movement of the filtered image is defined from ActionScript. I’m trying to define the movement of both the DisplacementMapFilter and the filtered image using reference objects on the stage so that I can see how all the different parts move together on the stage and easily adjust them without having to export the video, watch from the beginning, and make adjustments based on what I just watched. I would be eternally grateful for any ideas on how to achieve this. Also, I’m not concerned about code efficiency at all since I already need to convert my .swf into a video in order to view at a smooth frame rate.

AS3 Code from my animated filter:

import flash.display.BitmapData
import flash.geom.Point
import flash.filters.DisplacementMapFilter
import flash.filters.DisplacementMapFilterMode
import flash.events.Event

var bmp = new BitmapData(image_mc.width, image_mc.height); // this is how I animated the filter from the stage. Its coordinates are referenced from a movie clip on the stage.
lens_mc.visible = false

function myEnterFrame(event:Event) {
var offset = new Point(lens_mc.x, lens_mc.y);
var displaceFilter = new DisplacementMapFilter(bmp, offset, 1, 2, 100, 100, "ignore");
image_mc.filters = [displaceFilter];

AS3 Code from the Adobe tutorial

package com.example.programmingas3.moon
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.BitmapDataChannel;
    import flash.display.Loader;
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.TimerEvent;
    import flash.filters.BitmapFilterQuality;
    import flash.filters.DisplacementMapFilter;
    import flash.filters.GlowFilter;
    import flash.geom.Point;   
    import flash.geom.Rectangle;
    import flash.net.URLRequest;
    import flash.utils.Timer;

    public class MoonSphere extends Sprite 
        // The Bitmap containing the moon map that's actually displayed on the screen.
        private var sphere:Bitmap;

        // The moon map "source" -- pixels from this map are copied onto sphere
        // to create the animated motion of the moon.
        private var textureMap:BitmapData;

        // The radius of the moon.
        private var radius:int;

        // The current x position on textureMap from which the pixels are copied onto sphere.
        private var sourceX:int = 0;

        // MoonSphere constructor
        // Starts loading the moon image.
        public function MoonSphere() 
            var imageLoader:Loader = new Loader();
            imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoadComplete);
            imageLoader.load(new URLRequest("moonMap.png"));

        // Movement (a'la rotation) routine
        private function rotateMoon(event:TimerEvent):void
            sourceX += 1;
            if (sourceX >= textureMap.width / 2)
                sourceX = 0;

                                                  new Rectangle(sourceX, 0, sphere.width, sphere.height),
                                                  new Point(0, 0));


        // Creates the displacement map image that's used to create the fisheye lens effect
        private function createFisheyeMap(radius:int):BitmapData
            var diameter:int = 2 * radius;

            var result:BitmapData = new BitmapData(diameter,

            // Loop through the pixels in the image one by one
            for (var i:int = 0; i < diameter; i++)
                for (var j:int = 0; j < diameter; j++)
                    // Calculate the x and y distances of this pixel from
                    // the center of the circle (as a percentage of the radius).
                    var pctX:Number = (i - radius) / radius;
                    var pctY:Number = (j - radius) / radius;

                    // Calculate the linear distance of this pixel from
                    // the center of the circle (as a percentage of the radius).
                    var pctDistance:Number = Math.sqrt(pctX * pctX + pctY * pctY);

                    // If the current pixel is inside the circle,
                    // set its color.
                    if (pctDistance < 1)
                        // Calculate the appropriate color depending on the
                        // distance of this pixel from the center of the circle.
                        var red:int;
                        var green:int;
                        var blue:int;
                        var rgb:uint;
                        red = 128 * (1 + 0.75 * pctX * pctX * pctX / (1 - pctY * pctY));
                        green = 0;
                        blue = 0;
                        rgb = (red << 16 | green << 8 | blue);
                        // Set the pixel to the calculated color.
                        result.setPixel(i, j, rgb);
            return result;

        // Called when the moon map image finishes loading.
        // Sets up the on-screen elements (moon image with fisheye filter and its mask);
        // starts the Timer that creates the animation effect.
        private function imageLoadComplete(event:Event):void
            textureMap = event.target.content.bitmapData;
            radius = textureMap.height / 2;

            sphere = new Bitmap();
            sphere.bitmapData = new BitmapData(textureMap.width / 2, textureMap.height);
                                                  new Rectangle(0, 0, sphere.width, sphere.height),
                                                  new Point(0, 0));

            // Create the BitmapData instance that's used as the displacement map image
            // to create the fisheye lens effect.
            var fisheyeLens:BitmapData = createFisheyeMap(radius);

            // Create the fisheye filter
            var displaceFilter:DisplacementMapFilter;
            displaceFilter = new DisplacementMapFilter(fisheyeLens,
                                                                     new Point(radius, 0), 
                                                                     radius, 0);

            // Apply the filter
            sphere.filters = [displaceFilter];


            // Create and apply the image mask
            var moonMask:Shape = new Shape();
            moonMask.graphics.drawCircle(radius * 2, radius, radius);
            this.mask = moonMask;

            // Set up the timer to start the animation that 'spins' the moon
            var rotationTimer:Timer = new Timer(15);
            rotationTimer.addEventListener(TimerEvent.TIMER, rotateMoon);

            // add a slight atmospheric glow effect
            this.filters = [new GlowFilter(0xC2C2C2, .75, 20, 20, 2, BitmapFilterQuality.HIGH, true)];


Can't find my bidimensional array on a movie clip AS3

i'm new on AS3 and I'm having troubles to read a bidimensional array created after reading a xml. Here is the code:

var countdowns:Array = new Array;
var xmlLoader:URLLoader = new URLLoader();
var url:URLRequest = new URLRequest("products.xml");
xmlLoader.addEventListener(Event.COMPLETE, onXmlLoad);
function onXmlLoad(e:Event):void
  var xml = new XML(xmlLoader.data);
  var productElements:XMLList = xml.product;
  var len:int = productElements.length();

    for (var i:int = 0; i < len; i++)
        var productElement:XML = productElements[i];

        countdowns[productElements[i].name] = new Array;
        countdowns[productElements[i].name]["name"] = productElements[i].name;
        countdowns[productElements[i].name]["user"] = productElements[i].user;
        countdowns[productElements[i].name]["image"] = productElements[i].image;
        countdowns[productElements[i].name]["fondo"] = productElements[i].fondo;
    trace("Productos: "+countdowns["ambar"]["image"])}

This works like a charm. But when I want to trace it in the next frame it gives me an error. Years ago I used to do _level0 vars so I can trace them with "trace(_level0.countdowns["ambar"]["image"])" but it seems that "trace(MovieClip(root).countdowns["ambar"]["image"])" doesn't do the same. Where is my bidimensional array? How can I access to it from other movieclips?

AS3: Loading different, externa text values on MouseOver

I'm stuck with this thing for a while now. I'm working on a map that displays popup with dynamically loaded text when you hover over specific objects (mc's). mc_box is my popup clip with text fields (aTxt, bTxt) and 1, 2 are objects I'm hovering over. This is part of the code I'm using, I figured I have to get the target name and data loaded from the text file, but I'm really not sure how can I go from here:


var targetName:String;
this.addEventListener(MouseEvent.MOUSE_OVER, getName);
function getName(e:MouseEvent):void {
    targetName = e.target.name;

var lv:URLLoader = new URLLoader();
lv.addEventListener(Event.COMPLETE, onLoaded);
function onLoaded(e:Event):void {
    txtData = e.target.data
lv.load(new URLRequest("text.txt"));

this.addEventListener(MouseEvent.MOUSE_OVER, mouseover, true);
function mouseover(e:MouseEvent) {

this.addEventListener(MouseEvent.MOUSE_OUT, mouseout, true);
function mouseout(e:MouseEvent) {

The text file looks like this:

&a_1=some text 1
&b_1=some text 2

&a_2=some other text 1
&b_2=some other text 2

And my question is how the hell can I get it to display text fields according to the object name I mouseOver on? I've been trying to do something like this:


but obviously it won't work. Please help...

AS3/AIR desktop application: I can not type vietnamese on s:Textarea

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ift.tt/rYUnH9"
        <!-- Place non-visual elements (e.g., services, value objects) here -->
            private function resetPrompts():void { 
                myTextInput.text = ""; 
                myTextArea.text = ""; 
        <s:TextInput id="myTextInput" prompt="Enter name..." fontFamily="Marker Felt Thin" /> 
        <s:TextArea id="myTextArea" prompt="Triệu hổ..." fontFamily="A"/> 
        <s:Button label="Reset" click="resetPrompts()"/> 


As my code: I use use this tool to write vietnamse character: http://ift.tt/29XDYLP but any special char: ê, ô, í, ì... has been removed..

mardi 19 juillet 2016

Non tween Animation in as3(actionscript 3)

I wanna be able to change to frames for a walking animation. I have 3 frames. The second and third one are 2 walking frames the first is a normal still on

package  {

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

public class main extends MovieClip {
    var player:Player = new Player();

    var px = 0;
    var py = 0;

    public function main() {
        stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyPressed);
        addEventListener(Event.ENTER_FRAME, update);
    public function KeyPressed(e:KeyboardEvent):void {
        if(e.keyCode == 38 || e.keyCode == 87) {
            py -= 5;
        if(e.keyCode == 39 || e.keyCode == 68) {
            px += 5;
        if(e.keyCode == 37 || e.keyCode == 65) {
            px -= 5;
        if(e.keyCode == 40 || e.keyCode == 83) {
            py += 5;
    public function moveAnimation():void {
    public function update(e:Event):void {
        player.x = px;
        player.y = py;


So also in my other file (For the player class) I added a stop(); if that helps. But it moves. The calling function moves it to like the 2nd or 3rd frame, but only 1. It doesnt animate it. Just one frame gets called and its stuck

Looking for a way to make three sliders affect an image (as a teaching tool)

I tried looking for this in search, but it is a lot of individual things packed together. What I am looking to make for my students is an interactive display of the triangle of exposure on a camera. It has three sliders that show what happens with different settings. One is ISO (controls dark and lightness), another is shutter speed (which controls background blur/depth of field), and aperture, which controls motion blur. I was able to make a slider that effectively changes the test image in darkness. I am currently working on the slider for shutter speed. I am wondering if the interaction between the sliders would be better accomplished through switching between PRE-PHOTOSHOPPED images by substitution, or using AS3 to accomplish changes on the fly. For instance, if they move the sliders for shutter speed and ISO at the same time, it gets dark AND has background blur. do I need to pre-photoshop every possible option, and switch symbols, or can I do it interactively with AS3?

Here is my code: import flash.utils.getDefinitionByName; import fl.motion.Color;

import fl.events.SliderEvent;
var myImageName1 = "blurback.jpg";
var classRef:Class = getDefinitionByName(myImageName1) as Class;
var instance:MovieClip = new classRef();

var c:Color=new Color();
var color = "#000000";

ISO.addEventListener(SliderEvent.CHANGE, sliderChanged);
aperture.addEventListener(SliderEvent.CHANGE, apertureChanged);

function sliderChanged(evt:SliderEvent):void {



The 'setTint' method of of the Color class takes two parameters: tint 

(a number between 0 and 1), and a tint color.

The tint multiplier, is determined by the positon of the slider, 'val'      
and equals val/100.
The tint color, 'color', is determined by the color selected
in the picker. 

function tintClip():void {

var val:Number=ISO.value;



function apertureChanged(evt:SliderEvent):void {




I am still experimenting with the second slider, so the gotoand play is a work in progress on substituting a pre-background-blurred image when the slider is slid.

Here is a pic of the final image, with the sliders named appropriately. Final

Something wrong with my collision detection in AS3

This is a problem with a little platformer test game I've made. It should be trivial, and I don't want to use a prebuilt physics engine since this is a learning moment. My dude runs around fine and lands on the platforms etc. but every so often, he just passes right through one or two. But then if I come back to that platform at a different speed (by jumping from a different height), he lands on it. So the velocity effects whether or not the collision detection works. oops. Can't seem to figure out why.

Why might my collision test not be working? It works at some velocities on all objects, but at certain velocities, it doesn't seem to. I can't find a pattern to it. Here is my code.

// detection between allMassObj and allBlocks (both vectors populated with custom Classes)
    private function checkCollision(): void {
        var objArrLen: int = allMassObj.length;
        var blockArrLen: int = allBlocks.length;
        for (var j: int = 0; j < objArrLen; j++) {
            for (var i: int = 0; i < blockArrLen; i++)
                // using + GRAV here is supposed to allow me to ascertain 
                // what the future velocity will be.  I've also tried it
                // without the GRAV here, but I get similar results.
                var yV:Number = allMassObj[j]._yVel + GRAV;
                if (allMassObj[j].y <= allBlocks[i].y && // if obj is above block and
                    allMassObj[j].y + yV >= allBlocks[i].y && // will be on or below block
                    allMassObj[j].x >= allBlocks[i].x && // and x coords intersect
                    allMassObj[j].x <= allBlocks[i].x + allBlocks[i].width)
                    allMassObj[j].y = allBlocks[i].y;
                    allMassObj[j]._onGround = true;
                } else {
                    allMassObj[j]._onGround = false;

I find this method preferable to using a hitTest because this method allows me to detect if the object is going to pass through the other object on the next frame, and short circuit that event before it happens. If there is a better way, I'm all ears.

Check if SWF is being loaded by being embedded to an HTML page or not (direct accessed)?

I want an idea to check if my SWF is being loaded from my HTML page by embedding or if it's being directly accessed.

I've tried many things but they are being kinda ruined with caching issues.


Return 1 instead of infinite in division by 0

As the math principles says, when some number is divided by 0 it will be infinite, but, in my case, when it becomes infinite I need it to be 1, how can I achieve this?

if(obj.x > -180){
    left_fade.alpha = -(1/obj.x);
} else{
    left_fade.alpha = 0;

How can I get the Hit point on hit test between two dynamically added objects in AS3?

I want to know the actual hit point when the dash line is hitting to the triangle object.

I am using the following codes for hit between two object :


where target is the triangle object and border is a group where I placed a rectangle with stroke SolidColorDash.

And I am using the following codes for getting the hit coordinate :

var x:Number = target.x;
var y:Number = target.y;

And it is giving the x and y coordinate when the dash line is touching to the boundary of the triangle object but I want the coordinate when dash line will touch the bitmapdata of the triangle object.

enter image description here

So Anybody have an idea how to resolve this issue or how to get the hit coordinate.

Unresolved Function or Method push() FLEX ActionScript

After a recent reinstallation of my computer I have encoutered a very frustrating and strange issue with JetBrains IntelliJ.

I have this line of code

this.path_.data.push(r.left, r.top, r.right, r.top, r.right, r.bottom, r.left, r.bottom);

And similar ones around my project.

path_ = new GraphicsPath(GraphicsUtil.QUAD_COMMANDS, new Vector.<Number>());

data inside of path_ is a Vector.<Number> but for some reason I am unable to use the function native AS3 function push(... rest):uint; on it. It just shows me this error

I have tried to find a solution to this issue for the past 6 hours and haven't found anything so far... Hoping anyone here might be able to give some assistance with this issue.

Note: This has never happened to me in the past.

I have looked into the declaration of push() and it points to my library.swf for everything except the code that uses GraphicsPath.data... That file seem to point to ECMAScript.js2 which doesn't contain anything for Vector Objects at all.

Difference between date.getHours() and date.hours in AS3 ?

var date:Date = new Date();
date.setTime(date.getTime() + date.getTimezoneOffset() * 60000); // converts to GMT

I need hours in GMT. Should I use date.hours ? or should I use date.getHours() ?

ActionScript 3: Enter frame with movieclip and play a sound just once

I'm a beginner in as3 and now I'm working on a little game where you can explore different rooms with different events. Every single room is in a movieclip and now I want to play a single sound in a few rooms, but this sound should just played once in the whole game.

I've tryed to insert the sound in the main-timeline, where the certain room is in it, with a "synchronization" as "start" and no repeats, but this didn't work. So the sound is playing everytime you go in this room and that's annoying.

What can I do?

Delete or Remove SFSArray in AS3

var list : SFSArray = sfsRankObject.getSFSArray("rank_list")as SFSArray;
var currentPlayerArray : SFSArray = new SFSArray;
if (list.size() <= 3)
  topPlayerArray = list;
  currentPlayerArray = list;
 //take only top three entries
//delete list

I have the above situation where i need to delete an SFSArray properly to remove it from memory. As it doesnt work like a normal array, I cant really use:

list.lenght = 0;
list = null;

lundi 18 juillet 2016

Getting data from Flash that playing online

It somehow should be possible to get all data from Flash File that running currently in browser.

Get all data from rendered objects like values, positions and ect. The more inforamation the better

So what I think is if my computer my adobe flash render all this locally so I'm receiving already it to my computer so I need to read as adobe flash render this.

Beginner: Text doesn't change on frame 1

Hi I'm new to flash programming so please bear with me if this sounds like a bit too junior a question to someone in the Flash area.

I've dragged a Text Tool from the panel to Stage and named the instance "status". Then I typed in "ABC" into the Text Tool. In frame 1 on the timeline I typed in the following code:

status.text = "Hello"; status.color = 0x0000FF;

The problem is that text in the status doesn't seem to change and remain "ABC". The color also doesn't change to the specified one, although if I delete the second line of code, I wouldn't be able to see the text at all (it seems the color gets to white which is the same as the background?)

Could someone please give me some guidance?

Thanks, Jack

How to edit a text field directly from as3?

I am designing an app and basically I want the user to fill in text field directly from the app and then I want this textfield to be saved in a text file inside a server ? How can I do it ? Right now I can Only view the text file but I can't really edit it . Thanks for answers.

How to tab vertically instead of horizontally.

I am working in Flex and trying to get a sparks datagrid to tab vertically instead of horizontally.

var hBox:HBox = new HBox();
var templateDataGrid:spark.components.DataGrid = new spark.components.DataGrid();
templateDataGrid.dataProvider = dataGridList;
templateDataGrid.columns = columnHeaders;
templateDataGrid.sortableColumns = false;
templateDataGrid.editable = true;

Have a pretty simple as3 implementation that I am rendering inside a HBox.

While adding record in AdvanceDataGrid: TypeError: Error #1010: A term is undefined and has no properties

TypeError: Error #1010: A term is undefined and has no properties.

I have editable AdvancedDataGrid in flex, when i click on any column to add new row i face above error.

dimanche 17 juillet 2016

drag & drop function actionscript 3

I'm quite new to ActionScript 3 and I'm currently creating a game that there are colours cube that can drag & drop and snap together. Also there are unlimited (clone) drag and drop of the cubes. I managed to snap different colour cubes together but not the cube with same colour. I've tried to set different name for the same colour cube when drop but it does not make a difference. Can anyone help me where is my mistake and how to fix it? Below is my code for the white cube. I'd be grateful for your help:-)

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

var myWhiteCubes = new MovieClip();
white.addEventListener (MouseEvent.MOUSE_DOWN, whitePressed);
function whitePressed (event:MouseEvent):void
myWhiteCubes = new White(); 
myWhiteCubes.x = event.stageX;
myWhiteCubes.y = event.stageY;
myWhiteCubes.addEventListener(MouseEvent.MOUSE_DOWN, cloneWhitePressed);

function cloneWhitePressed (event:MouseEvent):void
myWhiteCubes = MovieClip(event.currentTarget);
var topPos:uint = this.numChildren - 1;
myWhiteCubes.buttonMode = true;

stage.addEventListener (MouseEvent.MOUSE_UP, cloneWhiteReleased);
function cloneWhiteReleased (event:MouseEvent) : void

if (myWhiteCubes.hitTestPoint(myWhiteCubes.x+50,myWhiteCubes.y+10,true))
var whiteCubes : MovieClip = new myWhiteCubes();
    whiteCubes.x = myWhiteCubes.x + 46;
    whiteCubes.y = myWhiteCubes.y;

if (myWhiteCubes.hitTestPoint(latestTaro.x+50,latestTaro.y+10,true))
    myWhiteCubes.x = latestTaro.x + 46;
    myWhiteCubes.y = latestTaro.y;

if (myWhiteCubes.hitTestPoint(latestPurple.x+50,latestPurple.y+10,true))
    myWhiteCubes.x = latestPurple.x + 46;
    myWhiteCubes.y = latestPurple.y;

if (myWhiteCubes.hitTestPoint(latestBlue.x+50,latestBlue.y+10,true))
    myWhiteCubes.x = latestBlue.x + 46;
    myWhiteCubes.y = latestBlue.y;

if (myWhiteCubes.hitTestPoint(latestPurple.x+50,latestPurple.y+10,true))
    myWhiteCubes.x = latestPurple.x + 46;
    myWhiteCubes.y = latestPurple.y;

if (myWhiteCubes.hitTestPoint(latestBlue.x+50,latestBlue.y+10,true))
    myWhiteCubes.x = latestBlue.x + 46;
    myWhiteCubes.y = latestBlue.y;

if (myWhiteCubes.hitTestPoint(latestTurquois.x+50,latestTurquois.y+10,true))
    myWhiteCubes.x = latestTurquois.x + 46;
    myWhiteCubes.y = latestTurquois.y;

if (myWhiteCubes.hitTestPoint(latestLime.x+50,latestLime.y+10,true))
    myWhiteCubes.x = latestLime.x + 46;
    myWhiteCubes.y = latestLime.y;

if (myWhiteCubes.hitTestPoint(latestYellow.x+50,latestYellow.y+10,true))
    myWhiteCubes.x = latestYellow.x + 46;
    myWhiteCubes.y = latestYellow.y;

if (myWhiteCubes.hitTestPoint(latestOrange.x+50,latestOrange.y+10,true))
    myWhiteCubes.x = latestOrange.x + 46;
    myWhiteCubes.y = latestOrange.y;

if (myWhiteCubes.hitTestPoint(latestRed.x+50,latestRed.y+10,true))
    myWhiteCubes.x = latestRed.x + 46;
    myWhiteCubes.y = latestRed.y;


white.buttonMode = true;