mercredi 30 novembre 2016

as3 - Use of arrays to give letters a value of another array

I am trying to make a chemistry calculator where I can put in the elements letters, like "H", "He", "O", etc, so I have made an array called elements. Then I have made an array with the values. I want for the letters.

Is there any way to make it that if I write element[x] it would use the value[x]?

if (input.text == element[x]) {
     n = value[x];
}

So, I don't have to write one if statement for each and every possible element.

Is there a way to get the DefaultProperty metadata at runtime?

I'm trying to get the DefaultProperty metadata for a class in ActionScript but I can't find any mention of the DefaultProperty in the metadata XML.

I'm using the following code:

var describedTypeRecord:DescribeTypeCacheRecord = mx.utils.DescribeTypeCache.describeType(BorderContainer);
var typeDescription:* = describedTypeRecord.typeDescription;

The XML is long but here the first node it returns:

<type name="spark.components::BorderContainer" base="spark.components::SkinnableContainer" isDynamic="false" isFinal="false" isStatic="false">

The default property for BorderContainer or SkinnableContainer is mxmlContentFactory:

[DefaultProperty("mxmlContentFactory")]

I've also tried RichText. The default property for this is "content":

[DefaultProperty("content")]

It doesn't seem to show anything about it in the metadata.

In the compiler options I have included the compiler arguments:

-keep-as3-metadata+=DefaultProperty

Sonar blocker for managed "ame" + flex project

I'm trying to fix bocker given by sonar for a Flex+ actionScript3 web application.

I was faced to this unresolvable blocker:

The managed event "ame" is either misspelled or is missing a companion Event metadata tag

My code is as follows:

    [Bindable]  
    [ManagedEvents(names="message")]
    public class ClassName extends EventDispatcher
    {
      .........
     }

I tried to fix this issue as follows:

    [Bindable]
    [Event(name="message",type="package.ClassEvent")]
    [ManagedEvents(names="message")]
    public class ClassName extends EventDispatcher
    {
      ....    
     }

Where in package.ClassEvent is the declared event "message"

[Command(selector="message")]
public function message(evt:NameEvent):AsyncToken
{           
    .....
}

PS: Sonar suggest as solution :

The "ManagedEvents" metadata tag allows you to flag an event as being managed. By definition this "ManageEvents" metadata tag should be used in pair with an "Event" metadata tag.

Noncompliant Code Example

[Event(name="message", type="my.package.MyEvemt")] [ManagedEvents("mes")] //This "mes" event is not defined with the "Event" metadata tag public class MyClass {...} Compliant Solution [Event(name="message", type="my.package.MyEvemt")] [ManagedEvents("message")] public class MyClass {...}

mardi 29 novembre 2016

How to get line number when an exception occurs for release version of flash application?

I am trying to get line number of exceptions for an released version of flash application(Flex based). I have followed below instructions, but could not get the line number information. http://ift.tt/2fJHfg8 http://ift.tt/1IamfKl

My Flash Builder compiler setting:
flash builder setting

The exception stack trace information of release version:
exception stack trace without line number

The application could not be installed because the installer file is damaged. Try obtaining a new installer file from the application author

We have an old version of our application that was successfully code signed using a Thawte SHA 256 certificate. This certificate expired and we are now using a new one.

enter image description here

When the user upgrades from the old version of the application to the latest, they encounter this error: Reinstalling the application gets around the issue but we want a more professional solution.

I used the following shell script to sign it, which seems to run successfully, but am still getting the error

if (($# < 1))
then
echo "Usage: $0 version"
exit -1
fi
echo "Fixing file permissions..."
chmod a+x bin-debug/bin/SWC

echo "packaging Air file for mac..."
cd bin-debug

/Volumes/Macintosh\ HD/Users/Shared/flex_sdk_4.6/bin/adt -package -storetype pkcs12  -keystore ../../../thawte\ certificates/airSigningBackup2018.p12 -storepass myPassword -target air ../SW_Desktop_mac.air DieBook-app.xml DieBook.swf bin/SWCM bin/SWCMLE builddate icons
cd ..

/Volumes/Macintosh\ HD/Users/Shared/flex_sdk_4.6/bin/adt -migrate -storetype pkcs12 -keystore ../../thawte\ certificates/airSigningBackup2016.p12 -storepass myPassword SW_Desktop_mac.air SW_Desktop_mac_migrated.air

/Volumes/Macintosh\ HD/Users/Shared/flex_sdk_4.6/bin/adt -package -target native SWD_$1.dmg SW_Desktop_mac_migrated.air

echo "SWD_$1.dmg should be ready now."

why 2nd external swf file not unloaded?

after unloading the first swf file then load 2nd. debugger output show unload message. but when 2nd file unload that time debugger output not showing unload message. why ? but i watch that file has been unloaded in my view

stop();
SoundMixer.stopAll();
var myLoader: Loader = new Loader();
loadThis();
function loadThis(): void {
    SoundMixer.stopAll();
    myLoader.load(new URLRequest("intro page.swf"));
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
    myLoader.addEventListener("AllBooks", killLoadedClip1);

}
function onCompleteHandler(loadEvent: Event): void {
    addChild(myLoader);
}
function killLoadedClip1(e: Event): void {
    myLoader.removeEventListener("AllBooks", killLoadedClip1);
    myLoader.unloadAndStop(true);
    loadThis2();
}
function loadThis2(): void {
    SoundMixer.stopAll();
    myLoader.load(new URLRequest("class 3 home page 2016.swf"));
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
    myLoader.addEventListener("AllBooks2", killLoadedClip2);
}
function killLoadedClip2(e: Event): void {
    myLoader.removeEventListener("AllBooks2", killLoadedClip2);
    myLoader.unloadAndStop(true);
    loadThis3();
}
function loadThis3(): void {
    SoundMixer.stopAll();
    myLoader.load(new URLRequest("sub home page.swf"));
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
    myLoader.addEventListener("AllBooks2", killLoadedClip3);
}
function killLoadedClip3(e: Event): void {
    myLoader.removeEventListener("AllBooks3", killLoadedClip3);
    myLoader.unloadAndStop(true);
}

The OUTPUT Messages are :

Attempting to launch and connect to Player using URL         C:\Users\Bijoy\Desktop\new ins\Class3.swf
[SWF] C:\Users\Bijoy\Desktop\new ins\Class3.swf - 1975 bytes after decompression
[SWF] C:\Users\Bijoy\Desktop\new ins\intro page.swf - 273304 bytes after decompression
[SWF] C:\Users\Bijoy\Desktop\new ins\class 3 home page 2016.swf - 5746128 bytes after decompression
[UnloadSWF] C:\Users\Bijoy\Desktop\new ins\intro page.swf
[SWF] C:\Users\Bijoy\Desktop\new ins\sub home page.swf - 954649 bytes after decompression
Debug session terminated.

How can I use Event class from Starling and Flash both in the same class

While working with Starling, I am encountering this problem. It's important to use the flash Event sometimes.

    import starling.events.Event;
    import flash.events.Event ;

function someEventHandler(event:Event ):void
{
  .....
}

I tried to use the full specification

function someEventHandler(event:flash.events.Event ):void
{
  ....
}

But the above doesnot work, and shows compile time error. Then what's the way out ?

Avatar Layering and Animating in Flash

So for my latest Flash project, I'm designing a game. The dimetric character can move in 8 directions. I've been given the spritesheets for the hats, hair styles, etc., that the player can wear.

The spritesheets contain the images for each direction, AND they contain four frames of animation (four per direction) for when the player is walking. This is basically the layout of the Spritesheet (and all of the files and "frames" are the same size, which makes things easier):

[IDLE]              [WALKING]                 
[S][SE][E][N][NW][W][S1][S2][S3][S4][SE1][SE2]...

My goal is to embed all of the items in a single file other than the main one. But I need to implement walking animation.

One thought I had is to set the main SWF's framerate to 7 FPS, then use an Event.ENTER_FRAME handler to alternate between the walking ones. Programmatically animating.

Another thought is to create SWFs for each item of clothing, then use motion tweening to move the spritesheet symbol over the stage.

What I'd really like it so avoid using Adobe Animate entirely. Even if there's an approach that requires the use of Flex, I'd take it if it meant saying goodbye to graphically-designing.

ArgumentError: Error #1063: Argument count mismatch on PlayerGril(). Expected 3, got 0. in Adobe Animate CC

When I debug my program, an error appears. Here it is:

ArgumentError: Error #1063: Argument count mismatch on PlayerGril(). Expected 3, got 0.
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()
    at MainGame()[E:\folder ni cj\DMTHESIS\dmgame\MainGame.as:52]
    at Main/game()[E:\folder ni cj\DMTHESIS\dmgame\Main.as:188]
    at Main/skip()[E:\folder ni cj\DMTHESIS\dmgame\Main.as:185]

Here are my codes:

Main.as:

package {

    import flash.display.*;
    import flash.text.*;
    import flash.events.Event;
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.desktop.NativeApplication;
    import flash.events.TouchEvent;
    import flash.display.Sprite;
    import flash.display.Stage;
    import flash.display.SimpleButton;

    public class Main extends MovieClip {

        public var playergril: PlayerGril;
        private var stageRef:Stage;
        private var thisThing:Object;
        public var mainmenu: MainMenu = new MainMenu();
        public var maingame: MainGame;
        public var startopt: StartOpt = new StartOpt();
        public var learnopt: LearnOpt = new LearnOpt();
        public var newload: NewLoad = new NewLoad();
        public var propocon: PropoCon = new PropoCon();
        public var setcon: SetCon = new SetCon();
        public var relationcon: RelationCon = new RelationCon();
        public var scrollinstructwin: ScrollInstructWin = new ScrollInstructWin();
        public var scrollstorywin: ScrollStoryWin = new ScrollStoryWin();

        public function Main() {
            addChild(mainmenu);

            mainmenu.x = 350;
            mainmenu.y = 290;

            mainmenu.btnStart.addEventListener(MouseEvent.CLICK, start);
            mainmenu.btnInstruct.addEventListener(MouseEvent.CLICK, instruct);
            mainmenu.btnBye.addEventListener(MouseEvent.CLICK, bye);
        }
        public function start(event: MouseEvent): void {
            removeChild(mainmenu);
            addChild(startopt);

            startopt.x = 350;
            startopt.y = 290;

            startopt.btnLearn.addEventListener(MouseEvent.CLICK, learn);
            startopt.btnPlay.addEventListener(MouseEvent.CLICK, laro);
            startopt.btnBack.addEventListener(MouseEvent.CLICK, back);
        }
        public function instruct(event: MouseEvent): void {
            removeChild(mainmenu);
            addChild(scrollinstructwin);

            scrollinstructwin.x = 36.20;
            scrollinstructwin.y = 21.50;
            var max_Y: Number = 0;
            var min_Y: Number = Math.min(0, stage.stageHeight - scrollinstructwin.scrollinstruct.height);
            var startY: Number;
            var startMouseY: Number;

            addChild(scrollinstructwin.scrollinstruct);

            addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);

            function mouseDownHandler(event: MouseEvent): void {
                startY = scrollinstructwin.scrollinstruct.y;
                startMouseY = mouseY;

                stage.addEventListener(MouseEvent.MOUSE_MOVE, stagemouseMoveHandler, false, 0, true);
                stage.addEventListener(MouseEvent.MOUSE_UP, stagemouseUpHandler, false, 0, true);
            }

            function stagemouseMoveHandler(event: MouseEvent): void {
                var offset_Y: Number = mouseY - startMouseY;
                scrollinstructwin.scrollinstruct.y = Math.max(Math.min(max_Y, startY + offset_Y), min_Y);
            }

            function stagemouseUpHandler(event: MouseEvent): void {
                stage.removeEventListener(MouseEvent.MOUSE_MOVE, stagemouseMoveHandler);
                stage.removeEventListener(MouseEvent.MOUSE_UP, stagemouseUpHandler);
            }

            scrollinstructwin.btnGi.addEventListener(MouseEvent.CLICK, gi);
        }
        public function bye(event: MouseEvent): void {
            NativeApplication.nativeApplication.exit(0);
        }
        public function gi(event: MouseEvent): void {
            removeChild(scrollinstructwin);
            addChild(mainmenu);

            mainmenu.x = 350;
            mainmenu.y = 290;
        }
        public function back(event: MouseEvent): void {
            removeChild(startopt);
            addChild(mainmenu);

            mainmenu.x = 350;
            mainmenu.y = 290;
        }
        public function learn(event: MouseEvent): void {
            removeChild(startopt);
            addChild(learnopt);

            learnopt.x = 350;
            learnopt.y = 290;

            learnopt.btnPropo.addEventListener(MouseEvent.CLICK, propo);
            learnopt.btnSets.addEventListener(MouseEvent.CLICK, sets);
            learnopt.btnRelations.addEventListener(MouseEvent.CLICK, relations);
            learnopt.btnBack3.addEventListener(MouseEvent.CLICK, backo);
        }
        public function laro(event: MouseEvent): void {
            removeChild(startopt);
            addChild(newload);

            newload.x = 350;
            newload.y = 290;

            newload.btnNew.addEventListener(MouseEvent.CLICK, neww);
            newload.btnBack2.addEventListener(MouseEvent.CLICK, backu);
        }
        public function backo(event: MouseEvent): void {
            removeChild(learnopt);
            addChild(startopt);

            startopt.x = 350;
            startopt.y = 290;
        }
        public function neww(event: MouseEvent): void {
            removeChild(newload);
            addChild(scrollstorywin);

            scrollstorywin.x = 51.15;
            scrollstorywin.y = 30.05;
            var maxY: Number = 0;
            var minY: Number = Math.min(0, stage.stageHeight - scrollstorywin.scrollcontent.height); 
            //var minY_: Number = Math.min(0, stage.stageHeight - scrollstorywin.scrollcontent2.height);
            var _startY: Number;
            var _startMouseY: Number;

            addChild(scrollstorywin.scrollcontent);

            addEventListener(MouseEvent.MOUSE_DOWN, mouseoDownHandler);

            function mouseoDownHandler(event: MouseEvent): void {
                _startY = scrollstorywin.scrollcontent.y;
                _startMouseY = mouseY;

                /*_startY = scrollstorywin.scrollContent2.y;
                _startMouseY = mouseY;*/

                stage.addEventListener(MouseEvent.MOUSE_MOVE, stage_mouseMoveHandler, false, 0, true);
                stage.addEventListener(MouseEvent.MOUSE_UP, stage_mouseUpHandler, false, 0, true);
            }

            function stage_mouseMoveHandler(event: MouseEvent): void {
                var offsetY: Number = mouseY - _startMouseY;
                scrollstorywin.scrollcontent.y = Math.max(Math.min(maxY, _startY + offsetY), minY);
                //scrollstorywin.scrollContent2.y = Math.max(Math.min(maxY, _startY + offsetY), minY_);
            }

            function stage_mouseUpHandler(event: MouseEvent): void {
                stage.removeEventListener(MouseEvent.MOUSE_MOVE, stage_mouseMoveHandler);
                stage.removeEventListener(MouseEvent.MOUSE_UP, stage_mouseUpHandler);
            }

            scrollstorywin.btnCho.addEventListener(MouseEvent.CLICK, nw);
            scrollstorywin.btnSkip.addEventListener(MouseEvent.CLICK, skip);
            scrollstorywin.scrollcontent.btnCC.addEventListener(MouseEvent.CLICK, cc);
            scrollstorywin.scrollcontent.btnAA.addEventListener(MouseEvent.CLICK, aa);
            //scrollstorywin.scrollcontent2.btnSaa.addEventListener(MouseEvent.CLICK, saa);
        }
        public function nw(event: MouseEvent): void {
            removeChild(scrollstorywin);
            addChild(newload);

            mainmenu.x = 350;
            mainmenu.y = 290;
        }
        private function skip(event: MouseEvent): void {
            removeChild(scrollstorywin);
            game();
        }
        private function game(){
            maingame = new MainGame(stageRef, thisThing);
            thisThing.visible = true;
            //addChild(maingame);

            maingame.x = 415.00;
            maingame.y = 228.00;
            maingame.gotoAndStop(1);
        }
        public function cc(event: MouseEvent): void {
            removeChild(scrollstorywin.scrollcontent);
            scrollstorywin.scrollcontent.gotoAndStop(2);
        }
        public function aa(event: MouseEvent): void {
            removeChild(scrollstorywin);
            addChild(newload);

            newload.x = 350;
            newload.y = 290;
        }
        /*public function saa(event: MouseEvent): void {
            removeChild(scrollstorywin.scrollcontent2);
            addChild(maingame);
        }*/
        public function backu(event: MouseEvent): void {
            removeChild(newload);
            addChild(startopt);

            startopt.x = 350;
            startopt.y = 290;
        }
        public function propo(event: MouseEvent): void {
            removeChild(learnopt);
            propocon.gotoAndStop(1);
            addChild(propocon);

            propocon.x = 414.80;
            propocon.y = 218.60;

            //propocon.btnBtm.addEventListener(MouseEvent.CLICK, popo);
            propocon.btnExit.addEventListener(MouseEvent.CLICK, byeol);
            //propocon.btnQt.addEventListener(MouseEvent.CLICK, qtu);
        }
        /*public function popo(event: MouseEvent): void {
            removeChild(propocon);
            addChild(learnopt);

            learnopt.x = 350;
            learnopt.y = 290;
        }*/
        public function byeol(event: MouseEvent): void {
            removeChild(propocon);
            addChild(learnopt);

            learnopt.x = 350;
            learnopt.y = 290;
        }
        /*public function qtu(event: MouseEvent): void {
            removeChild(propocon);
            addChild(mainmenu);

            mainmenu.x = 350;
            mainmenu.y = 290;
        }*/
        public function sets(event: MouseEvent): void {
            removeChild(learnopt);
            setcon.gotoAndStop(1);
            addChild(setcon);

            setcon.x = 412.45;
            setcon.y = 225.00;

            setcon.btnBai2.addEventListener(MouseEvent.CLICK, byeo);
            //setcon.btnBtm2.addEventListener(MouseEvent.CLICK, pop);
            //setcon.btnQt2.addEventListener(MouseEvent.CLICK, qti);
        }
        public function byeo(event: MouseEvent): void {
            removeChild(setcon);
            addChild(learnopt);

            learnopt.x = 350;
            learnopt.y = 290;
        }
        /*public function pop(event: MouseEvent): void {
            removeChild(setcon);
            addChild(learnopt);

            learnopt.x = 350;
            learnopt.y = 290;
        }
        public function qti(event: MouseEvent): void {
            removeChild(setcon);
            addChild(mainmenu);

            mainmenu.x = 350;
            mainmenu.y = 290;
        }*/
        public function relations(event: MouseEvent): void {
            removeChild(learnopt);
            relationcon.gotoAndStop(1);
            addChild(relationcon);

            relationcon.x = 400.00;
            relationcon.y = 225.00;

            relationcon.btnBai3.addEventListener(MouseEvent.CLICK, byel);
            //relationcon.btnBtm3.addEventListener(MouseEvent.CLICK, poup);
            //relationcon.btnQt3.addEventListener(MouseEvent.CLICK, qtui);
        }
        public function byel(event: MouseEvent): void {
            removeChild(relationcon);
            addChild(learnopt);

            learnopt.x = 350;
            learnopt.y = 290;
        }
        /*public function poup(event: MouseEvent): void {
            removeChild(relationcon);
            addChild(learnopt);

            learnopt.x = 350;
            learnopt.y = 290;
        }
        public function qtui(event: MouseEvent): void {
            removeChild(relationcon);
            addChild(mainmenu);

            mainmenu.x = 350;
            mainmenu.y = 290;
        }*/
    }
}

Based on the error, here are the affected codes in this AS file:

Line 185: game();

Line 188: maingame = new MainGame(stageRef, thisThing);

MainGame.as (from movieclip symbol):

package {

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

    public class MainGame extends MovieClip {

        private var main: Main;
        public var playergril: PlayerGril;
        public var key: Key = new Key();
        public var door: Door = new Door();
        public var pausewin: PauseWin = new PauseWin();
        public var corekwin: CorekWin = new CorekWin();
        public var maliwin: MaliWin = new MaliWin();
        public var gameoverwin: GameOverWin = new GameOverWin();
        public var scorerr: Scorer = new Scorer();
        public var timerr: Timerr = new Timerr();
        public var lives: Lives = new Lives();
        public var room: Room = new Room();
        public var room2: Room2 = new Room2();
        public var room3: Room3 = new Room3();
        public var room4: Room4 = new Room4();
        public var room5: Room5 = new Room5();
        public var quizquest: QuizQuest = new QuizQuest();
        public var quizquest2: QuizQuest2 = new QuizQuest2();
        public var quizquest3: QuizQuest3 = new QuizQuest3();
        public var quizquest4: QuizQuest4 = new QuizQuest4();
        public var quizquest5: QuizQuest5 = new QuizQuest5();
        public var gamestage: int = 0;
        public var buhay: int = 0;
        public var iskoru: int = 0;
        private var stageRef:Stage;
        private var thisThing:Object;
        private var walkRate:Number;
        private var targetBuffer:Number;
        /*public var v: Number = 5;
        public var dir: int = 0;
        public var clickPoint: Point = new Point();
        public var angle: Number;
        public var goX: Number;
        public var goY: Number;*/

        public function MainGame(stageRef:Stage, thisThing:Object) {
            this.stageRef = stageRef;
            this.thisThing = thisThing;
            this.scorerr.visible = false;
            this.timerr.visible = false;
            this.pausewin.visible = false;
            this.quizquest.visible = false;
            this.quizquest2.visible = false;
            this.quizquest3.visible = false;
            this.quizquest4.visible = false;
            this.quizquest5.visible = false;
            startgame();
        }
        private function startgame() {
            playergril = new PlayerGril(stageRef, walkRate, targetBuffer);
            for (var i = 0; i > 5; i++) {
                buhay = 3;
                this.lives.txtLives.text = buhay.toString();
                if (gamestage == 1) {
                    this.room.x = -15.00;
                    this.room.y = -1.00;
                    this.room.visible = true;
                    //walk();
                    addChild(key);
                    if (key.hitTestObject(playergril)) {
                        this.gotoAndStop(2);
                        i++;
                        quiztime();
                    }
                } else if (gamestage == 2) {
                    this.room2.x = -15.85;
                    this.room2.y = -0.90;
                    this.room2.visible = true;
                    //walk();
                    addChild(key);
                    if (key.hitTestObject(playergril)) {
                        this.gotoAndStop(4);
                        i++;
                        quiztime2();
                    }
                } else if (gamestage == 3) {
                    this.room3.x = -15.80;
                    this.room3.y = -1.00;
                    this.room3.visible = true;
                    //walk();
                    addChild(key);
                    if (key.hitTestObject(playergril)) {
                        this.gotoAndStop(6);
                        i++;
                        quiztime3();
                    }
                } else if (gamestage == 4) {
                    this.room4.x = -15.40;
                    this.room4.y = -2.05;
                    this.room4.visible = true;
                    //walk();
                    addChild(key);
                    if (key.hitTestObject(playergril)) {
                        this.gotoAndStop(8);
                        i++;
                        quiztime4();
                    }
                } else if (gamestage == 5) {
                    this.room5.x = -15.80;
                    this.room5.y = -0.95;
                    this.room5.visible = true;
                    //walk();
                    addChild(key);
                    if (key.hitTestObject(playergril)) {
                        this.gotoAndStop(10);
                        i++;
                        quiztime5();
                    }
                }

                this.btnPause.addEventListener(MouseEvent.CLICK, oop);
            }
            function oop(event: MouseEvent): void {
                stage.frameRate = 0;
                this.gotoAndStop(11);

                this.pausewin.btnResume.addEventListener(MouseEvent.CLICK, op);
            }
            function op(event: MouseEvent): void {
                stage.frameRate = 24;
            }
        }
        /*public function walk() {
            this.btnForward.addEventListener(MouseEvent.CLICK, myClickReaction);
            function myClickReaction(e: MouseEvent): void {
                var target = e.target;

                if (target == this.btnForward) {

                    goX = mouseX;
                    goY = mouseY;
                }
                addEventListener(Event.ENTER_FRAME, onEnterFrame);
            }
        }
        function onEnterFrame(event: Event): void {
            var xDistance: Number = clickPoint.x - playergril.x;
            var yDistance: Number = clickPoint.y - playergril.y;
            var angle: Number = Math.atan2(yDistance, xDistance);
            playergril.x += v * Math.cos(angle);
            playergril.y += v * Math.sin(angle);
            playergril.gotoAndPlay(1);
            if (xDistance <= 0) {
                trace("works");
                playergril.gotoAndPlay(8);
                removeEventListener(Event.ENTER_FRAME, onEnterFrame);
            }
        }*/
        public function quiztime() {
            this.quizquest.visible = true;
            this.scorerr.visible = true;
            this.timerr.visible = true;
            this.quizquest.ans11.buttonMode = true;
            this.quizquest.ans12.buttonMode = true;
            this.quizquest.ans13.buttonMode = true;

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

            function buttones1(eventObject: MouseEvent): void {
                this.gotoAndStop(12);
                iskoru += 1;
                this.scorerr.txtSkor.text = iskoru.toString();
            }
            function buttones2(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }

            function buttones3(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }
        }

        public function quiztime2() {
            this.quizquest2.visible = true;
            this.scorerr.visible = true;
            this.timerr.visible = true;
            this.quizquest2.ans21.buttonMode = true;
            this.quizquest2.ans22.buttonMode = true;
            this.quizquest2.ans23.buttonMode = true;

            this.quizquest2.ans21.addEventListener(MouseEvent.CLICK, buttones4);
            this.quizquest2.ans22.addEventListener(MouseEvent.CLICK, buttones5);
            this.quizquest2.ans23.addEventListener(MouseEvent.CLICK, buttones6);
            function buttones4(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }
            function buttones5(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }
            function buttones6(eventObject: MouseEvent): void {
                this.gotoAndStop(12);
                iskoru += 1;
                this.scorerr.txtSkor.text = iskoru.toString();
            }
        }

        public function quiztime3() {
            this.quizquest3.visible = true;
            this.scorerr.visible = true;
            this.timerr.visible = true;
            this.quizquest3.ans31.buttonMode = true;
            this.quizquest3.ans32.buttonMode = true;
            this.quizquest3.ans33.buttonMode = true;

            this.quizquest3.ans31.addEventListener(MouseEvent.CLICK, buttones7);
            this.quizquest3.ans32.addEventListener(MouseEvent.CLICK, buttones8);
            this.quizquest3.ans33.addEventListener(MouseEvent.CLICK, buttones9);
            function buttones7(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }
            function buttones8(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }
            function buttones9(eventObject: MouseEvent): void {
                this.gotoAndStop(12);
                iskoru += 1;
                this.scorerr.txtSkor.text = iskoru.toString();
            }
        }

        public function quiztime4() {
            this.quizquest4.visible = true;
            this.scorerr.visible = true;
            this.timerr.visible = true;
            this.quizquest4.ans41.buttonMode = true;
            this.quizquest4.ans42.buttonMode = true;
            this.quizquest4.ans43.buttonMode = true;

            this.quizquest4.ans41.addEventListener(MouseEvent.CLICK, buttones10);
            this.quizquest4.ans42.addEventListener(MouseEvent.CLICK, buttones11);
            this.quizquest4.ans43.addEventListener(MouseEvent.CLICK, buttones12);
            function buttones10(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                lives.txtLives.text = buhay.toString();
            }
            function buttones11(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }
            function buttones12(eventObject: MouseEvent): void {
                this.gotoAndStop(12);
                iskoru += 1;
                this.scorerr.txtSkor.text = iskoru.toString();
            }
        }

        public function quiztime5() {
            this.quizquest5.visible = true;
            this.scorerr.visible = true;
            this.timerr.visible = true;
            this.quizquest5.ans51.buttonMode = true;
            this.quizquest5.ans52.buttonMode = true;
            this.quizquest5.ans53.buttonMode = true;

            this.quizquest5.ans51.addEventListener(MouseEvent.CLICK, buttones13);
            this.quizquest5.ans52.addEventListener(MouseEvent.CLICK, buttones14);
            this.quizquest5.ans53.addEventListener(MouseEvent.CLICK, buttones15);
            function buttones13(eventObject: MouseEvent): void {
                this.gotoAndStop(12);
                iskoru += 1;
                this.scorerr.txtSkor.text = iskoru.toString();
            }
            function buttones14(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }
            function buttones15(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }
            if (buhay == 0) {
                this.gotoAndStop(14);
                this.gameoverwin.btnTry.addEventListener(MouseEvent.CLICK, dasi);
            }
            function dasi(event: MouseEvent): void {
                this.gameoverwin.visible = false;
                startgame();
                this.btnPause.addEventListener(MouseEvent.CLICK, tgil);
            }
            function tgil(event: MouseEvent): void {
                this.gotoAndStop(11);
            }
        }
    }
}

And its affected code from line 52: public function MainGame(stageRef:Stage, thisThing:Object) {

I can't find the wrong code line from it. I'm trying to fix the errors but still, that error appears. Is there any problem on my code? How can I fix those errors? Any help would be appreciated. Thanks.

Break out from If statement in ActionScript3?

I try to write a small Android program, which tells me the distance from a fix point. When the distance of the device and the fix point is below 100meters, a phone plays a sound.

if (distance<100){mySound.Play()};

It's OK, the sound starts, but when the GPS send the new coordinates, and the distance is below 100meters again, the mySound starts again and again in each second. The Sound should be played only one, when the the distance decrase below 100metes at First time. Any advice? Thx!

Porting processing to actionscript 3 - understanding color data type

Im trying to port a script from processing to as3. I dont know processing at all and I am having trouble understanding a specific line of code (processing):

color[] unsorted = new color[sortLength];

color seems to be a data type in processing but here the implementation looks more like an array. Is there some kind of color array data type that Im missing?

Update app to play store every day?

I have an app that provide football predictions every day and i was wondering if i have to publish the new apk to play store every day. I have study other predictions apps and i see that the last update was before 1 or 2 months but they predictions are uptodate. I use animate cc and every day i have to write my new predictions , publish my app with a new version bigger than the old and upload my apk to playstore. is this ok? The problem that i have is that the clients must go to play store and update the app every day to see the daily predictions.

lundi 28 novembre 2016

Add navigation when flash is in fullscreen mode [chrome]

I want to add an advertisment on my website when playing a live video.

when receiving a message(including the image source& navigation url), I load the image and add such mouse handler in my as3 code:

function navigateUrl(event:MouseEvent):void{ navigateToURL(new URLRequest(targetUrl),"_blank"); }

It works on normal mode and full-screen mode in other browsers. However, this navigation was blocked by Google Chrome if the ad is added in full-screen mode. Without switching into normal mode, the image cannot be clicked.

I've searched for two days and cannot find a solution.

solution I've tried:

1.use js to navigate;(window.open)

2.add 'a' tag in html and bind the url, try ExternalInterface.call to navigate;(a.click)

3.add sprite to stage (size 1X1) and reload image at full-screen.

navigation was blocked

Using arrays and hitTest - AS3

from what my friend has told me this SHOULD work but doesn't im getting an error on publishing

var P2hb:Array = new Array(P2char1, P2char2, P2char3);
var P2life:Number = 0;  

addEventListener(Event.ENTER_FRAME, framecheck)
function framecheck(event:Event):void
{
if (P2hb.hitTestObject(P1attack)) { P2life-=2; }
}

This is a generic code but it is the same as what I have basically all elements in the P2hb are movieclips on the stage My friend who recommended I use the array function said this should work but I cant seem to get it to work. Can anyone tell me what I am doing wrong? Thank you in advance.

Flash CS6, Making Enemies Move

I want to know how to make an enemy move in random directions on flash. It can be up/down or left/right. The following is my code for creating the enemy.

function createEnemy():Void  
{  
    var tempNewEnemy:MovieClip = _root.attachMovie("enemy_mc", "enemy"+_root.getNextHighestDepth(), _root.getNextHighestDepth());

    //set a random x&y
    tempNewEnemy._x = random(Stage.width)
    tempNewEnemy._y = random(Stage.height)

    //add it to the enemyArray
    enemyArray.push(tempNewEnemy);

    trace("Enemy created: "+tempNewEnemy)
}

AS3 gotoAndStop events trigger enterFrame but only after loading external files

OK, we've found a solution to this problem but we're not happy that we understand it and so I wondered if anyone can explain it for me - maybe it'll lead us to a slightly less hacky answer.

So. We've got a complex AS3 project that loads in various external files. What we've discovered is that once this has happened, gotoAndStop commands (not necessarily on the externally loaded files) trigger the EnterFrame event we have attached to the main timeline. This leads to some really weird results and occasionally complete crashes.

The example we found that showed us we had a problem looked something like this:

(Bit of code in one place)

trace("goto 1")
tClip.gotoAndStop("on")
trace("goto 1 done")

(bit of code somewhere else)

trace("goto 2")
tClip2.gotoAndStop("off")
trace(goto 2 done")

output:

goto 1
goto 2
goto 2 done
goto 1 done

Note that this behaviour only seems to happen if we've previously downloaded some external files. Otherwise we get

goto 1
goto 1 done
goto 2
goto 2 done

as we'd expect.

The workround we've come up with is to put all our gotoAndStop commands into a new function:

public function fGoToFrame(tClip:MovieClip, tFrame:*):void {
    pIgnoreFrameEventFromGoToAndStop = true
    tClip.gotoAndStop(tFrame)
    pIgnoreFrameEventFromGoToAndStop = false
}
// frame event:
public function fAction(e:Event):void {
    if (!pIgnoreFrameEventFromGoToAndStop) {
...

}
}

That seems to prevent any of the bugs, but it's not exactly satisfying. I'd like to know why gotoAndStop on a child movieClip would trigger a frame event on the root sprite at all! And is there any way of stopping it without using this hack?

Thanks for any thoughts

Is it possible to change the size of a bitmap data instance after it has been created?

I see that there are methods to merge, draw, and copy pixels but no matter what I try it doesn't seem to change the size of the bitmap instance. Here is what I have so far:

var initialWidth:int = 100;
var initialHeight:int = 100;
bitmapData = new BitmapData(initialWidth,initialHeight,true,0xFFFFFFFF);
rectangle = new Rectangle(0, 0, newBitmapData.width, newBitmapData.height);
bitmapData.merge(newBitmapData, rectangle, new Point(), 0, 0, 0, 0);
bitmapData.drawWithQuality(newBitmapData, null, null, null, null, false, quality);
bitmapData.drawWithQuality(LoaderInfo(event.currentTarget).loader, null, null, null, null, false, quality);
bitmapData.copyPixels(newBitmapData, newBitmapData.rect, new Point());
bitmapData.merge(newBitmapData, null, new Point(), 0, 0, 0, 0);

AlivePdf embeded .otf

I need some specifics symbols from my pdf. If I use ttf+afm embeded fonts I need specify CodePage like 1251. And after convert some symbols (√, ²) displays like "?".

[Embed(source="/Klassy_obshchikh_komponentov/CreatePDF/alivepdf/fonts/embeded/ArialI.ttf", mimeType="application/octet-stream")]
    private var _fontTtf:Class;

    [Embed(source="/Klassy_obshchikh_komponentov/CreatePDF/alivepdf/fonts/embeded/ArialCyrMT-Italic.afm", mimeType="application/octet-stream")]
    private var _fontAfm:Class;

    pdfItem.setFont(new EmbeddedFont(new _fontTtf(), new _fontAfm(), CodePage.CP1251), textHeight*5);

pdfItem.addText (Convert(text), x, y);

    private function Convert(data:String):String 
    {
       var byteDataArray:ByteArray = new ByteArray();
       byteDataArray.writeMultiByte(data,"windows-1251"); 
       return byteDataArray.toString();
    }

I want use .otf font file and unicode. But I can not find how to do it. Anybody nows how to embed .otf font and use it without converting.

Is there a syncronous load bytes method yet for Flash or AIR?

Is there a synchronous loadBytes() method yet in Flash Player or AIR?

More Info:
I'm trying to load a byte array and convert it into bitmap data synchronously (NOT ASYNCHRONOUSLY). It cannot be asynchronous. It is PNG that was encoded into base64 data.

Now I'm decoding from base64 into a byte array and then trying to decode that byte array into bitmap data. There is no way to go from byte array to bitmap data without a loader and loader.loadBytes() is asynchronous.

I suppose I could pass the byte array to JavaScript if there is a class for that but that's a last resort.

FYI I'm running AIR 23.

Android AIR application developed in Flash CS6 did not run smoothly on mobile phone

I have developed AIR application for Android in Flash CS6. But the problem is, the application doesn't run smoothly on mobile phone. I can't find the solution to my problem. Is it because of too many scenes or too many key frames in a scene?

Thank you so much for the explanation.

ActionScript 2 to ActionScript 3 convertting

Can anyone convert this code --> http://ift.tt/2frAp3x to ActionScript 3 format I don't know how to do it

dimanche 27 novembre 2016

Can't get a list of elements from an XML object when using the elements operator?

I have been working with this XML and I'm not able to get a list of the nodes with the elements operator:

<s:LinearGradient rotation="90" xmlns:s="library://ns.adobe.com/flex/spark">
  <s:GradientEntry color="0x000000" alpha="0.8"/>
  <s:GradientEntry color="0xFFFFFF" alpha="0.8"/>
</s:LinearGradient>

Here is my AS3:

var fillXML:XML = <s:LinearGradient rotation="90" xmlns:s="library://ns.adobe.com/flex/spark">
      <s:GradientEntry color="0x000000" alpha="0.8"/>
      <s:GradientEntry color="0xFFFFFF" alpha="0.8"/>
    </s:LinearGradient>;

var entriesXML:XMLList;
var GRADIENT_ENTRY:String = "GradientEntry";
entriesXML = fillXML..entries;

if (entriesXML.length()==0) {
    entriesXML = fillXML.descendants(GRADIENT_ENTRY);

    if (entriesXML.length()==0) {
        entriesXML = fillXML.elements(GRADIENT_ENTRY);
    }
}

Can't get list of descendants in XML node?

I have this XML and no matter what I use I'm not able to get a list of the nodes:

<s:LinearGradient rotation="90" xmlns:xlink="http://ift.tt/PGV9lw" xmlns:fx="http://ift.tt/rYUnH9" xmlns:flow="http://ift.tt/1MMzxNZ" xmlns:fc="library://ns.flexcapacitor.com/flex" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex" xmlns:html="http://ift.tt/lH0Osb" xmlns:svg="http://ift.tt/nvqhV5">
  <s:GradientEntry color="0x000000" alpha="0.8"/>
  <s:GradientEntry color="0xFFFFFF" alpha="0.8"/>
</s:LinearGradient>

Here is what I've tried so far:

var fillXML:XML = <s:LinearGradient rotation="90" xmlns:xlink="http://ift.tt/PGV9lw" xmlns:fx="http://ift.tt/rYUnH9" xmlns:flow="http://ift.tt/1MMzxNZ" xmlns:fc="library://ns.flexcapacitor.com/flex" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex" xmlns:html="http://ift.tt/lH0Osb" xmlns:svg="http://ift.tt/nvqhV5">
      <s:GradientEntry color="0x000000" alpha="0.8"/>
      <s:GradientEntry color="0xFFFFFF" alpha="0.8"/>
    </s:LinearGradient>;

var entriesXML:XMLList;
var GRADIENT_ENTRY:String = "GradientEntry";
entriesXML = fillXML..entries;

if (entriesXML.length()==0) {
    entriesXML = fillXML.descendants(GRADIENT_ENTRY);

    if (entriesXML.length()==0) {
        entriesXML = fillXML.elements(GRADIENT_ENTRY);
    }
}

equivalent to: my_obj.height += 10; in adobe animate HTML5 canvas?

I have this in my old AS3 project:

button_1.addEventListener(MouseEvent.CLICK, onReset);
function onReset(e:MouseEvent):void{
        my_obj.height += 10;
}

What's it's equivalent in adobe animate HTML5 canvas?

How to get an array of attributes when there is whitespace characters between the name and value?

I'm trying to get an array of attributes and I'm splitting on the whitespace character. What I have works fine except when namespaces are involved. Here is my sample code:

XML:

<?xml version="1.0" encoding="utf-8"?>
<s:node something xmlns:s = "library://ns.adobe.com/flex/spark" 
xmlns:b='testnamespace.com' xmlns="noprefix.com"></something>

Exmascript:

var attributes:Array = tag.split(/\s+/g);

That results in this array of items:

 - something
 - xmlns:s
 - =
 - "library://ns.adobe.com/flex/spark"
 - xmlns:b='testnamespace.com'
 - xmlns="noprefix.com"

How would I split the attributes up when there are spaces between the name and value?

my button keep displaying the same frame in adobe flash action script 3.0

I have been doing this for a week and i cannot get it right. Im still new with adobe flash and currently doing assignment on BMI calculator. but my button keep directing me to the 'obese' frame eventho the result should be underweight. there's no error reported by the compiler.

this is my coding. enter image description here

please help me.

Making a DragDrop class on as3

I'm making a DragDrop class on as3. I'm trying to make movable movie clips "stick" to a target movieclip. I've got the basic drag drop and positioning/sticking to work but when I try to create an "easing" effect using Enter Frame, somehow the movie clips move to 0 x and y position.

Here's the code that's working (without Enter Frame Event).

public class DragDrop{
public var clip:MovieClip;
public var targ:MovieClip;
public var myHomeX:Number;
public var myHomeY:Number;
public var myFinalX:Number;
public var myFinalY:Number;

public function selectClip(clipV:MovieClip, targV:MovieClip):void{
clip = clipV;
targ = targV;
var myHomeX = clip.x;
var myHomeY = clip.y;
var myFinalX = targ.x;
var myFinalY = targ.y;

clip.addEventListener(MouseEvent.MOUSE_DOWN,startDragging);
clip.addEventListener(MouseEvent.MOUSE_UP,stopDragging);
clip.addEventListener(MouseEvent.ROLL_OVER, rollOver);
clip.addEventListener(MouseEvent.ROLL_OUT, rollOut);

function startDragging(e:MouseEvent):void{
clip.startDrag();
clip.beingDragged = true;
clip.parent.setChildIndex(clip, clip.parent.numChildren-1);
}

function stopDragging(e:MouseEvent):void{
clip.stopDrag();
clip.beingDragged = false; 
var onTarget:MovieClip
if (clip.dropTarget!=null) {
onTarget = e.target.dropTarget.parent;
}else{
onTarget = null;
}

if (onTarget == targ) {
clip.onTarget = true;
targ.gotoAndStop(2);
clip.x = myFinalX;
clip.y = myFinalY;
} else {
clip.onTarget = false;
targ.gotoAndStop(1);
clip.x = myHomeX;
clip.y = myHomeY;
}
}

function rollOver(e:MouseEvent){
clipGlow.restart();
}

function rollOut(e:MouseEvent){
clipGlow.reverse();
}

}
}

Here's the code that's not working (with Eneter Frame Event).

public class DragDrop{
public var clip:MovieClip;
public var targ:MovieClip;
public var clip:MovieClip;
public var targ:MovieClip;
public var myHomeX:Number;
public var myHomeY:Number;
public var myFinalX:Number;
public var myFinalY:Number;

public function selectClip(clipV:MovieClip, targV:MovieClip):void{
clip = clipV;
targ = targV;
var myHomeX = clip.x;
var myHomeY = clip.y;
var myFinalX = targ.x;
var myFinalY = targ.y;

clip.addEventListener(MouseEvent.MOUSE_DOWN,startDragging);
clip.addEventListener(MouseEvent.MOUSE_UP,stopDragging);
clip.addEventListener(MouseEvent.ROLL_OVER, rollOver);
clip.addEventListener(MouseEvent.ROLL_OUT, rollOut);
clip.addEventListener(Event.ENTER_FRAME,slide);

function startDragging(e:MouseEvent):void{
clip.startDrag();
clip.beingDragged = true;
clip.parent.setChildIndex(clip, clip.parent.numChildren-1);
}

function stopDragging(e:MouseEvent):void{
clip.stopDrag();
clip.beingDragged = false; 
var onTarget:MovieClip
if (clip.dropTarget!=null) {
onTarget = e.target.dropTarget.parent;
}else{
onTarget = null;
}

if (onTarget == targ) {
clip.onTarget = true;
targ.gotoAndStop(2);

} else {
clip.onTarget = false;
targ.gotoAndStop(1);
}
}

function rollOver(e:MouseEvent){
clipGlow.restart();
}

function rollOut(e:MouseEvent){
clipGlow.reverse();
}

function slide(e:Event):void{
    if (!clip.beingDragged && !clip.onTarget) {
        clip.x -= (clip.x-clip.myHomeX)/5;
        clip.y -= (clip.y-clip.myHomeY)/5;
        clip.scaleX += (1-clip.scaleX)/5;
        clip.scaleY += (1-clip.scaleY)/5;
    } else if (!clip.beingDragged && clip.onTarget) {
        clip.x -= (clip.x-clip.myFinalX)/5;
        clip.y -= (clip.y-clip.myFinalY)/5;
        clip.scaleX += (1.5-clip.scaleX)/5;
        clip.scaleY += (1.5-clip.scaleY)/5;
    }
    }

}

}
}

Thanks in advance for any help. :)

samedi 26 novembre 2016

How can I make removeChild() work like unloadAndStop()?

Hooboy. I'm building an "interactive book" using Flash and Air for iOS, and have VERY little AS3 experience...

I had planned to load "pages" in as external SWFs then banish them with unloadAndStop - so that each time a user "turned the page" the SWF loaded in and the nested mini-games in those pages would play "fresh" for the first time. Well - apparently reloaded SWFs are a no-go for AIR and iOS.

I suppose I'm left with replacing those external SWFS with Internal MCs and using AddChild / RemoveChild - but that doesn't reset the variables so that the mini-games play fresh and I'm a little too green to know a better solution.

Is there any way to beef up RemoveChild so the MC loads "fresh" every time I put it on stage?

8-direction Figure Animation with Arrow Keys

I've been charged with designing a demo for an isometric video game in ActionScript 3. I have the bitmap spritesheets that show the avatar I'm using standing and walking in each direction. The walking animation is made up of three frames.

My problem, though, is that I need to figure out how to make use of them. I'm not familiar with animation in Flash, and I need input on how to gotoAndPlay() the walking frames for the right direction. I don't think isolating the necessary DIRECTION is going to be a challenge, so much as starting it and keeping it going while the arrow keys are down.

My current code is basically comprised of keyboard handlers for KEY_UP and KEY_DOWN, each containing a switch-case statement that changes the Avatar.currentDirection property. The handler continues to fire while the keys are down, but I need to add animation to the game.

I've seen some examples where they simply embed the animations into an SWF, propagate an array of the various walking stages, and alternate between them using an EnterFrame event handler, but this seems really clunky. I guess in the end I'm trying to make use of Adobe Animate, but I don't know how you're supposed to do that.

Flex Popup not setting child CSS from global style sheet

I have a CustomListItemRenderer class. It's styling, and contained components' styling, are set via an external CSS stylesheet.

When this renderer is used in a list in the main application, everything is set and styled correctly. When this renderer is being used in a list inside of a popup opened through the PopupManager class, the styling is not being set correctly.

This is a Flex Web Application: SDK 4.1

Help is greatly appreciated.

how to make Increasing Instagram Follower Count program which runs with id:pass

I just want to make Increasing Instagram Follower Count Program which runs with id:pass but İ could not find any script. Can you help me?

Adobe Air 23 + IOS 10.1.1 full screen

I am using Air Latest version with Starling and feathers latest version

My problem is some how my application is not getting full height on iphone6 latest ios 10.1.1 version, I am also using launch images and they are working correctly on the device

enter image description here

Any idea to fix this issue ??

vendredi 25 novembre 2016

How do I get Adobe Flash CS3 to respond?

Okay, I had a code in Adobe Flash CS3 that was working very well. However, even though I did not change the code, Flash stopped responding. Whenever I tried running the swf, it keeps on moving too slowly and saying "(Not Responding)". I tried restarting the computer a few times but that did not change anything. Is there anyway I can get the file to speed up?

If I give you a reference to the function can you get the name of the function?

I'm writing debugging tools and I want to make it clear where I'm at. My ideal output would write the class name and function name to the console like so:

Vehicle.addWheels()
  Wheels were added by the user

and in code it would be a function like:

trace(addWheels, "Wheels were added by the user");

I'm thinking of writing a custom function that gets the details like so (pseudo code):

public static myTrace(function:Function, message:String):void {
   var className:String = function.parent;
   var functionName:String = getQualifiedName(function.prototype);
   trace(className + "." + functionName + ": " + message);
}

This is an AS3 example but AS3 is based on JavaScript so if it works in Javascript it may work in ActionScript.

If that doesn't work I can pass in the class reference easily using a third parameter but still need to know how to get the name of the function.

public static myTrace(object:Object, function:Function, message:String):void {
   var className:String = getQualifiedName(object);
   var functionName:String = getQualifiedName(function.prototype);
   trace(className + "." + functionName + ": " + message);
}

Read the ouput text from swf with javascript/jquery

Im a beginner in actionscript 3 so I need help from you! Im doing a small application where I look if the user has a microphone or a camera installed:

import flash.media.Microphone;
import flash.media.Camera;
import flash.display.Sprite; 
import flash.text.*; 
import flash.external.ExternalInterface;
var myText:TextField = new TextField();

function getDataX():void {
    setInterval(function (){
        if (Microphone.names.length == 0 && Camera.names.length == 0){
            myText.htmlText="<p>none</p>";
        }else if (Microphone.names.length !== 0 && Camera.names.length !== 0){
            myText.htmlText="<p>both</p>";
        }else if (Microphone.names.length !== 0 && Camera.names.length == 0){
            myText.htmlText="<p>mic</p>";
        }else if (Microphone.names.length == 0 && Camera.names.length !== 0){
            myText.htmlText="<p>cam</p>";
        }
    addChild(myText);
    },2);
}
return getDataX();

And this is how I embeded it with jquery:

 var flashvars = {};

    var params                  =   {};
    params.menu                 =   "false";
    params.salign               =   "t";
    params.scale                =   "noscale";
    params.wmode                =   "fff";
    params.allowScriptAccess    =   "always";

    var attributes              =   {};
    attributes.id = "webcam_check";
    swfobject.embedSWF("swf/scriptcam.swf", "webcam", "1000px", "2000px", "11.2", "", flashvars, params, attributes);

My question is how do I read the text with javascript/jquery that addChild(myText); has outputed? Is it even possible? If not: Is it possible to do in other ways?

Thanks in regards

calling actionscript 3 function from javascript with addCallback not working

I have a requirement in a project which has to call an actionscript 3 function from javascript. I read many answers from stackoverflow and adobe and have created a simple test application. In that, I have used ExternalInterface.addCallback to register both the functions and I've also included the security permissions in both actionscript and in html.

Action Script 3 Embedded code

I did not use an external .as file instead i used the action panel to create the code.

import fl.controls.Button
import flash.events.MouseEvent;

flash.system.Security.allowDomain("*")

var butt:Button = new Button();
addChild(butt);

butt.label = "hello";
butt.toggle = true;
butt.move(50, 50);
butt.height = 100;
butt.addEventListener(MouseEvent.CLICK, clickhandle);

function clickhandle(e:MouseEvent)
{

        if(butt.height == 100)
            butt.height = 200;
        else butt.height = 100;

}

ExternalInterface.addCallback("callas", clickhandle);

The test app will display a ac3 button. Upon clicking that button it will toggle the expanding and collapsing of its height through a click handler 'clickhandle'. This is the function i am intended to call from javascript.

HTML Code

<html>
<head>
<script>
function callas() {
    var hehe = document.getElementById('cvpanel');
    console.log(hehe);
    hehe.clickhandle();
}
</script>
</head>

<body>
<p>Test</p>
<object id='cvpanel' name='cvpanel' width="425" height="350" type="application/x-shockwave-flash" data="one.swf">
    <param value="one.swf" name="movie">
    <param name="allowscriptaccess" value="always"/>
    <p>You need Flash to see it.</p>
</object>
</body>
</html>

The application runs under http://localhost through apache and all the files needed are in the same folder. I could run the application and could see the buttons appearing. By clicking it they toggle in height as expected.

When i call the function callas from browser console i get the error in console as

"TypeError: hehe.clickhandle is not a function"

in firefox and similar in Internet Explorer.

Is there anything missing?

Executing MXML page inside Action Script Project

We want to check the unused classes of FLEX SDK to remove them in order to have a light project. To do this, we get the source code of Flex , and we added it in an ActionScript project (on Flash Builder). The problem now is that we want to test an MXML page inside this project but the MXML page is ignored during the execution. The Action Script project only executes the AS file. Do you have some solution for this problem ? Is there another way to do this (testing Flex SDK source code with MXML page) ?

adobe flex - how to get mobile total internal storage size

In flex 4.6 (flash builder)

How to get total internal storage size?

I tried Capabilities, System, etc. but failed.

help me please.

jeudi 24 novembre 2016

Replace an item in an array?

Trying to figure some logic and wondering if the following code will work, or if there's another way of doing this. (Just trying to find out if my logic works, might missform a bit of the code)

Thanks in advance!

Var some1:MovieClip = mc_1;
" "
" "
Var other1:MovieClip = mc_a;
" "
" "

Var myArray = [some1, some2, some3];

Var i:uint;
Var iLength:uint = myArray.length;

For(i=0;i<iLength;i++){
If(myArray[i] == some2){
myArray[i] = other1;
}
}

Question: will this replace 'some2' with 'other1'?

mercredi 23 novembre 2016

why 2nd external swf file not unloaded?

after unloading the first swf file then load 2nd. debugger output show unload message. but when 2nd file unload that time debugger output not showing unload message. why ? but i watch that file has been unloaded in my view

        stop();
    SoundMixer.stopAll();
    var myLoader: Loader = new Loader();
    loadThis();
    function loadThis(): void {
        SoundMixer.stopAll();
        myLoader.load(new URLRequest("intro page.swf"));
        myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
        myLoader.addEventListener("AllBooks", killLoadedClip1);

    }
    function onCompleteHandler(loadEvent: Event): void {
        addChild(myLoader);
    }
    function killLoadedClip1(e: Event): void {
        myLoader.removeEventListener("AllBooks", killLoadedClip1);
        myLoader.unloadAndStop(true);
        loadThis2();
    }
    function loadThis2(): void {
        SoundMixer.stopAll();
        myLoader.load(new URLRequest("class 3 home page 2016.swf"));
        myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
        myLoader.addEventListener("AllBooks2", killLoadedClip2);
    }
    function killLoadedClip2(e: Event): void {
        myLoader.removeEventListener("AllBooks2", killLoadedClip2);
        myLoader.unloadAndStop(true);
        loadThis3();
    }
    function loadThis3(): void {
        SoundMixer.stopAll();
        myLoader.load(new URLRequest("sub home page.swf"));
        myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
        myLoader.addEventListener("AllBooks2", killLoadedClip3);
    }
    function killLoadedClip3(e: Event): void {
        myLoader.removeEventListener("AllBooks3", killLoadedClip3);
        myLoader.unloadAndStop(true);
    }

The OUTPUT Messages are :

   Attempting to launch and connect to Player using URL         C:\Users\Bijoy\Desktop\new ins\Class3.swf
   [SWF] C:\Users\Bijoy\Desktop\new ins\Class3.swf - 1975 bytes after decompression
   [SWF] C:\Users\Bijoy\Desktop\new ins\intro page.swf - 273304 bytes after decompression
   [SWF] C:\Users\Bijoy\Desktop\new ins\class 3 home page 2016.swf - 5746128 bytes after decompression
   [UnloadSWF] C:\Users\Bijoy\Desktop\new ins\intro page.swf
   [SWF] C:\Users\Bijoy\Desktop\new ins\sub home page.swf - 954649 bytes       after decompression
  Debug session terminated.

Adobe Animate - Controlling outside movie clip on MouseOver

I created HTML5-canvas with movie clip on it using Adobe Animate CC 2017. This clip has buttons that rotate in a circle.

Example: http://ift.tt/2gmDr6D

I'd like the the buttons to highlight when you roll over and for the clip to stop rotating. But I can't get it work on just MouseOver (eiffel tower, example)

var frequency = 3;
stage.enableMouseOver(frequency);
this.eiffel_tower.addEventListener("mouseover", fl_MouseOverHandler_4);

function fl_MouseOverHandler_4()
{
        
        this.parent.stop();

}

It works just fine on MouseClick (big ben, example).

this.big_ben.addEventListener("click", fl_MouseClickHandler_4.bind(this));

function fl_MouseClickHandler_4()
{
        this.parent.stop();
}

It works on MouseOver if I add code to trigger an alert box (state of liberty, example). But it breaks again if I delete the alert box code.

var frequency = 3;
stage.enableMouseOver(frequency);
this.stat_of_lib.addEventListener("mouseover", fl_MouseOverHandler_5);

function fl_MouseOverHandler_5()
{
        
        alert("Moused over");
        this.parent.stop();
}

I haven't worked in actionscript in a long time. What am I doing wrong? How can I get the buttons to stop the clips rotation when you rollover?

Thanks in advance for your help! I'm pulling out my hair over here.

Convert AS2 Script to AS3 Script

I have a problem to convert as2 script to as3 script I dont know how to begin.. I just learning this 1 month and my lecturer give me this task.. please help me

jumlah = 0;
waktu_muncul = 0;
function buat_tikus() {
 nomor = random(6)+1;
 tikus = attachMovie("tikus", "tikus", 2, {_x:_root["lingkaran"+nomor]._x, _y:_root["lingkaran"+nomor]._y});
 tikus.onEnterFrame = function() {
  waktu_muncul++;
  if (waktu_muncul == 12) {
   this.gotoAndStop(7);
  }
  if (waktu_muncul == 25) {
   removeMovieClip(this);
   buat_tikus();
   waktu_muncul = 0;
  }
  tikus.onPress = function() {
   if (this._currentframe == 1) {
    jumlah += 1;
    this.gotoAndPlay(2);
   }
  };
 };
}
onEnterFrame = function () {
 palu.swapDepths(_root.getNextHighestDepth());
 palu._x = _xmouse;
 palu._y = _ymouse;
};
onMouseDown = function () {
 if (palu._currentframe == 1) {
  palu.gotoAndPlay(2);
 }
};
buat_tikus();

Matching parameters of a function with Regex

What I have so far: \w+\(((".+")|(\d+))+\)
I'm not sure how to go about matching more than one paramter separated by a comma. How can I capture the parameters (and function names) of the following test cases?

scroll("foo")
scroll("foo",55)
scroll("foo","bar")
scroll("foo","bar",55)
scroll(55)
scroll(55,"foo")
scroll(55, 13,"foo","bar")

For example, in the last one the groups must be scroll, 55, 13, "foo", and "bar".

Edit: Language is AS3

ArgumentError: Error #1063: Argument count mismatch on PlayerGril(). Expected 3, got 0. in Adobe Animate CC

When I debug my program, an error appears. Here it is:

ArgumentError: Error #1063: Argument count mismatch on PlayerGril(). Expected 3, got 0.
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()
    at MainGame()[E:\folder ni cj\DMTHESIS\dmgame\MainGame.as:52]
    at Main/game()[E:\folder ni cj\DMTHESIS\dmgame\Main.as:188]
    at Main/skip()[E:\folder ni cj\DMTHESIS\dmgame\Main.as:185]

Here are my codes:

Main.as:

package {

    import flash.display.*;
    import flash.text.*;
    import flash.events.Event;
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.desktop.NativeApplication;
    import flash.events.TouchEvent;
    import flash.display.Sprite;
    import flash.display.Stage;
    import flash.display.SimpleButton;

    public class Main extends MovieClip {

        public var playergril: PlayerGril;
        private var stageRef:Stage;
        private var thisThing:Object;
        public var mainmenu: MainMenu = new MainMenu();
        public var maingame: MainGame;
        public var startopt: StartOpt = new StartOpt();
        public var learnopt: LearnOpt = new LearnOpt();
        public var newload: NewLoad = new NewLoad();
        public var propocon: PropoCon = new PropoCon();
        public var setcon: SetCon = new SetCon();
        public var relationcon: RelationCon = new RelationCon();
        public var scrollinstructwin: ScrollInstructWin = new ScrollInstructWin();
        public var scrollstorywin: ScrollStoryWin = new ScrollStoryWin();

        public function Main() {
            addChild(mainmenu);

            mainmenu.x = 350;
            mainmenu.y = 290;

            mainmenu.btnStart.addEventListener(MouseEvent.CLICK, start);
            mainmenu.btnInstruct.addEventListener(MouseEvent.CLICK, instruct);
            mainmenu.btnBye.addEventListener(MouseEvent.CLICK, bye);
        }
        public function start(event: MouseEvent): void {
            removeChild(mainmenu);
            addChild(startopt);

            startopt.x = 350;
            startopt.y = 290;

            startopt.btnLearn.addEventListener(MouseEvent.CLICK, learn);
            startopt.btnPlay.addEventListener(MouseEvent.CLICK, laro);
            startopt.btnBack.addEventListener(MouseEvent.CLICK, back);
        }
        public function instruct(event: MouseEvent): void {
            removeChild(mainmenu);
            addChild(scrollinstructwin);

            scrollinstructwin.x = 36.20;
            scrollinstructwin.y = 21.50;
            var max_Y: Number = 0;
            var min_Y: Number = Math.min(0, stage.stageHeight - scrollinstructwin.scrollinstruct.height);
            var startY: Number;
            var startMouseY: Number;

            addChild(scrollinstructwin.scrollinstruct);

            addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);

            function mouseDownHandler(event: MouseEvent): void {
                startY = scrollinstructwin.scrollinstruct.y;
                startMouseY = mouseY;

                stage.addEventListener(MouseEvent.MOUSE_MOVE, stagemouseMoveHandler, false, 0, true);
                stage.addEventListener(MouseEvent.MOUSE_UP, stagemouseUpHandler, false, 0, true);
            }

            function stagemouseMoveHandler(event: MouseEvent): void {
                var offset_Y: Number = mouseY - startMouseY;
                scrollinstructwin.scrollinstruct.y = Math.max(Math.min(max_Y, startY + offset_Y), min_Y);
            }

            function stagemouseUpHandler(event: MouseEvent): void {
                stage.removeEventListener(MouseEvent.MOUSE_MOVE, stagemouseMoveHandler);
                stage.removeEventListener(MouseEvent.MOUSE_UP, stagemouseUpHandler);
            }

            scrollinstructwin.btnGi.addEventListener(MouseEvent.CLICK, gi);
        }
        public function bye(event: MouseEvent): void {
            NativeApplication.nativeApplication.exit(0);
        }
        public function gi(event: MouseEvent): void {
            removeChild(scrollinstructwin);
            addChild(mainmenu);

            mainmenu.x = 350;
            mainmenu.y = 290;
        }
        public function back(event: MouseEvent): void {
            removeChild(startopt);
            addChild(mainmenu);

            mainmenu.x = 350;
            mainmenu.y = 290;
        }
        public function learn(event: MouseEvent): void {
            removeChild(startopt);
            addChild(learnopt);

            learnopt.x = 350;
            learnopt.y = 290;

            learnopt.btnPropo.addEventListener(MouseEvent.CLICK, propo);
            learnopt.btnSets.addEventListener(MouseEvent.CLICK, sets);
            learnopt.btnRelations.addEventListener(MouseEvent.CLICK, relations);
            learnopt.btnBack3.addEventListener(MouseEvent.CLICK, backo);
        }
        public function laro(event: MouseEvent): void {
            removeChild(startopt);
            addChild(newload);

            newload.x = 350;
            newload.y = 290;

            newload.btnNew.addEventListener(MouseEvent.CLICK, neww);
            newload.btnBack2.addEventListener(MouseEvent.CLICK, backu);
        }
        public function backo(event: MouseEvent): void {
            removeChild(learnopt);
            addChild(startopt);

            startopt.x = 350;
            startopt.y = 290;
        }
        public function neww(event: MouseEvent): void {
            removeChild(newload);
            addChild(scrollstorywin);

            scrollstorywin.x = 51.15;
            scrollstorywin.y = 30.05;
            var maxY: Number = 0;
            var minY: Number = Math.min(0, stage.stageHeight - scrollstorywin.scrollcontent.height); 
            //var minY_: Number = Math.min(0, stage.stageHeight - scrollstorywin.scrollcontent2.height);
            var _startY: Number;
            var _startMouseY: Number;

            addChild(scrollstorywin.scrollcontent);

            addEventListener(MouseEvent.MOUSE_DOWN, mouseoDownHandler);

            function mouseoDownHandler(event: MouseEvent): void {
                _startY = scrollstorywin.scrollcontent.y;
                _startMouseY = mouseY;

                /*_startY = scrollstorywin.scrollContent2.y;
                _startMouseY = mouseY;*/

                stage.addEventListener(MouseEvent.MOUSE_MOVE, stage_mouseMoveHandler, false, 0, true);
                stage.addEventListener(MouseEvent.MOUSE_UP, stage_mouseUpHandler, false, 0, true);
            }

            function stage_mouseMoveHandler(event: MouseEvent): void {
                var offsetY: Number = mouseY - _startMouseY;
                scrollstorywin.scrollcontent.y = Math.max(Math.min(maxY, _startY + offsetY), minY);
                //scrollstorywin.scrollContent2.y = Math.max(Math.min(maxY, _startY + offsetY), minY_);
            }

            function stage_mouseUpHandler(event: MouseEvent): void {
                stage.removeEventListener(MouseEvent.MOUSE_MOVE, stage_mouseMoveHandler);
                stage.removeEventListener(MouseEvent.MOUSE_UP, stage_mouseUpHandler);
            }

            scrollstorywin.btnCho.addEventListener(MouseEvent.CLICK, nw);
            scrollstorywin.btnSkip.addEventListener(MouseEvent.CLICK, skip);
            scrollstorywin.scrollcontent.btnCC.addEventListener(MouseEvent.CLICK, cc);
            scrollstorywin.scrollcontent.btnAA.addEventListener(MouseEvent.CLICK, aa);
            //scrollstorywin.scrollcontent2.btnSaa.addEventListener(MouseEvent.CLICK, saa);
        }
        public function nw(event: MouseEvent): void {
            removeChild(scrollstorywin);
            addChild(newload);

            mainmenu.x = 350;
            mainmenu.y = 290;
        }
        private function skip(event: MouseEvent): void {
            removeChild(scrollstorywin);
            game();
        }
        private function game(){
            maingame = new MainGame(stageRef, thisThing);
            thisThing.visible = true;
            //addChild(maingame);

            maingame.x = 415.00;
            maingame.y = 228.00;
            maingame.gotoAndStop(1);
        }
        public function cc(event: MouseEvent): void {
            removeChild(scrollstorywin.scrollcontent);
            scrollstorywin.scrollcontent.gotoAndStop(2);
        }
        public function aa(event: MouseEvent): void {
            removeChild(scrollstorywin);
            addChild(newload);

            newload.x = 350;
            newload.y = 290;
        }
        /*public function saa(event: MouseEvent): void {
            removeChild(scrollstorywin.scrollcontent2);
            addChild(maingame);
        }*/
        public function backu(event: MouseEvent): void {
            removeChild(newload);
            addChild(startopt);

            startopt.x = 350;
            startopt.y = 290;
        }
        public function propo(event: MouseEvent): void {
            removeChild(learnopt);
            propocon.gotoAndStop(1);
            addChild(propocon);

            propocon.x = 414.80;
            propocon.y = 218.60;

            //propocon.btnBtm.addEventListener(MouseEvent.CLICK, popo);
            propocon.btnExit.addEventListener(MouseEvent.CLICK, byeol);
            //propocon.btnQt.addEventListener(MouseEvent.CLICK, qtu);
        }
        /*public function popo(event: MouseEvent): void {
            removeChild(propocon);
            addChild(learnopt);

            learnopt.x = 350;
            learnopt.y = 290;
        }*/
        public function byeol(event: MouseEvent): void {
            removeChild(propocon);
            addChild(learnopt);

            learnopt.x = 350;
            learnopt.y = 290;
        }
        /*public function qtu(event: MouseEvent): void {
            removeChild(propocon);
            addChild(mainmenu);

            mainmenu.x = 350;
            mainmenu.y = 290;
        }*/
        public function sets(event: MouseEvent): void {
            removeChild(learnopt);
            setcon.gotoAndStop(1);
            addChild(setcon);

            setcon.x = 412.45;
            setcon.y = 225.00;

            setcon.btnBai2.addEventListener(MouseEvent.CLICK, byeo);
            //setcon.btnBtm2.addEventListener(MouseEvent.CLICK, pop);
            //setcon.btnQt2.addEventListener(MouseEvent.CLICK, qti);
        }
        public function byeo(event: MouseEvent): void {
            removeChild(setcon);
            addChild(learnopt);

            learnopt.x = 350;
            learnopt.y = 290;
        }
        /*public function pop(event: MouseEvent): void {
            removeChild(setcon);
            addChild(learnopt);

            learnopt.x = 350;
            learnopt.y = 290;
        }
        public function qti(event: MouseEvent): void {
            removeChild(setcon);
            addChild(mainmenu);

            mainmenu.x = 350;
            mainmenu.y = 290;
        }*/
        public function relations(event: MouseEvent): void {
            removeChild(learnopt);
            relationcon.gotoAndStop(1);
            addChild(relationcon);

            relationcon.x = 400.00;
            relationcon.y = 225.00;

            relationcon.btnBai3.addEventListener(MouseEvent.CLICK, byel);
            //relationcon.btnBtm3.addEventListener(MouseEvent.CLICK, poup);
            //relationcon.btnQt3.addEventListener(MouseEvent.CLICK, qtui);
        }
        public function byel(event: MouseEvent): void {
            removeChild(relationcon);
            addChild(learnopt);

            learnopt.x = 350;
            learnopt.y = 290;
        }
        /*public function poup(event: MouseEvent): void {
            removeChild(relationcon);
            addChild(learnopt);

            learnopt.x = 350;
            learnopt.y = 290;
        }
        public function qtui(event: MouseEvent): void {
            removeChild(relationcon);
            addChild(mainmenu);

            mainmenu.x = 350;
            mainmenu.y = 290;
        }*/
    }
}

Based on the error, here are the affected codes in this AS file:

Line 185: game();

Line 188: maingame = new MainGame(stageRef, thisThing);

MainGame.as (from movieclip symbol):

package {

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

    public class MainGame extends MovieClip {

        private var main: Main;
        public var playergril: PlayerGril;
        public var key: Key = new Key();
        public var door: Door = new Door();
        public var pausewin: PauseWin = new PauseWin();
        public var corekwin: CorekWin = new CorekWin();
        public var maliwin: MaliWin = new MaliWin();
        public var gameoverwin: GameOverWin = new GameOverWin();
        public var scorerr: Scorer = new Scorer();
        public var timerr: Timerr = new Timerr();
        public var lives: Lives = new Lives();
        public var room: Room = new Room();
        public var room2: Room2 = new Room2();
        public var room3: Room3 = new Room3();
        public var room4: Room4 = new Room4();
        public var room5: Room5 = new Room5();
        public var quizquest: QuizQuest = new QuizQuest();
        public var quizquest2: QuizQuest2 = new QuizQuest2();
        public var quizquest3: QuizQuest3 = new QuizQuest3();
        public var quizquest4: QuizQuest4 = new QuizQuest4();
        public var quizquest5: QuizQuest5 = new QuizQuest5();
        public var gamestage: int = 0;
        public var buhay: int = 0;
        public var iskoru: int = 0;
        private var stageRef:Stage;
        private var thisThing:Object;
        private var walkRate:Number;
        private var targetBuffer:Number;
        /*public var v: Number = 5;
        public var dir: int = 0;
        public var clickPoint: Point = new Point();
        public var angle: Number;
        public var goX: Number;
        public var goY: Number;*/

        public function MainGame(stageRef:Stage, thisThing:Object) {
            this.stageRef = stageRef;
            this.thisThing = thisThing;
            this.scorerr.visible = false;
            this.timerr.visible = false;
            this.pausewin.visible = false;
            this.quizquest.visible = false;
            this.quizquest2.visible = false;
            this.quizquest3.visible = false;
            this.quizquest4.visible = false;
            this.quizquest5.visible = false;
            startgame();
        }
        private function startgame() {
            playergril = new PlayerGril(stageRef, walkRate, targetBuffer);
            for (var i = 0; i > 5; i++) {
                buhay = 3;
                this.lives.txtLives.text = buhay.toString();
                if (gamestage == 1) {
                    this.room.x = -15.00;
                    this.room.y = -1.00;
                    this.room.visible = true;
                    //walk();
                    addChild(key);
                    if (key.hitTestObject(playergril)) {
                        this.gotoAndStop(2);
                        i++;
                        quiztime();
                    }
                } else if (gamestage == 2) {
                    this.room2.x = -15.85;
                    this.room2.y = -0.90;
                    this.room2.visible = true;
                    //walk();
                    addChild(key);
                    if (key.hitTestObject(playergril)) {
                        this.gotoAndStop(4);
                        i++;
                        quiztime2();
                    }
                } else if (gamestage == 3) {
                    this.room3.x = -15.80;
                    this.room3.y = -1.00;
                    this.room3.visible = true;
                    //walk();
                    addChild(key);
                    if (key.hitTestObject(playergril)) {
                        this.gotoAndStop(6);
                        i++;
                        quiztime3();
                    }
                } else if (gamestage == 4) {
                    this.room4.x = -15.40;
                    this.room4.y = -2.05;
                    this.room4.visible = true;
                    //walk();
                    addChild(key);
                    if (key.hitTestObject(playergril)) {
                        this.gotoAndStop(8);
                        i++;
                        quiztime4();
                    }
                } else if (gamestage == 5) {
                    this.room5.x = -15.80;
                    this.room5.y = -0.95;
                    this.room5.visible = true;
                    //walk();
                    addChild(key);
                    if (key.hitTestObject(playergril)) {
                        this.gotoAndStop(10);
                        i++;
                        quiztime5();
                    }
                }

                this.btnPause.addEventListener(MouseEvent.CLICK, oop);
            }
            function oop(event: MouseEvent): void {
                stage.frameRate = 0;
                this.gotoAndStop(11);

                this.pausewin.btnResume.addEventListener(MouseEvent.CLICK, op);
            }
            function op(event: MouseEvent): void {
                stage.frameRate = 24;
            }
        }
        /*public function walk() {
            this.btnForward.addEventListener(MouseEvent.CLICK, myClickReaction);
            function myClickReaction(e: MouseEvent): void {
                var target = e.target;

                if (target == this.btnForward) {

                    goX = mouseX;
                    goY = mouseY;
                }
                addEventListener(Event.ENTER_FRAME, onEnterFrame);
            }
        }
        function onEnterFrame(event: Event): void {
            var xDistance: Number = clickPoint.x - playergril.x;
            var yDistance: Number = clickPoint.y - playergril.y;
            var angle: Number = Math.atan2(yDistance, xDistance);
            playergril.x += v * Math.cos(angle);
            playergril.y += v * Math.sin(angle);
            playergril.gotoAndPlay(1);
            if (xDistance <= 0) {
                trace("works");
                playergril.gotoAndPlay(8);
                removeEventListener(Event.ENTER_FRAME, onEnterFrame);
            }
        }*/
        public function quiztime() {
            this.quizquest.visible = true;
            this.scorerr.visible = true;
            this.timerr.visible = true;
            this.quizquest.ans11.buttonMode = true;
            this.quizquest.ans12.buttonMode = true;
            this.quizquest.ans13.buttonMode = true;

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

            function buttones1(eventObject: MouseEvent): void {
                this.gotoAndStop(12);
                iskoru += 1;
                this.scorerr.txtSkor.text = iskoru.toString();
            }
            function buttones2(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }

            function buttones3(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }
        }

        public function quiztime2() {
            this.quizquest2.visible = true;
            this.scorerr.visible = true;
            this.timerr.visible = true;
            this.quizquest2.ans21.buttonMode = true;
            this.quizquest2.ans22.buttonMode = true;
            this.quizquest2.ans23.buttonMode = true;

            this.quizquest2.ans21.addEventListener(MouseEvent.CLICK, buttones4);
            this.quizquest2.ans22.addEventListener(MouseEvent.CLICK, buttones5);
            this.quizquest2.ans23.addEventListener(MouseEvent.CLICK, buttones6);
            function buttones4(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }
            function buttones5(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }
            function buttones6(eventObject: MouseEvent): void {
                this.gotoAndStop(12);
                iskoru += 1;
                this.scorerr.txtSkor.text = iskoru.toString();
            }
        }

        public function quiztime3() {
            this.quizquest3.visible = true;
            this.scorerr.visible = true;
            this.timerr.visible = true;
            this.quizquest3.ans31.buttonMode = true;
            this.quizquest3.ans32.buttonMode = true;
            this.quizquest3.ans33.buttonMode = true;

            this.quizquest3.ans31.addEventListener(MouseEvent.CLICK, buttones7);
            this.quizquest3.ans32.addEventListener(MouseEvent.CLICK, buttones8);
            this.quizquest3.ans33.addEventListener(MouseEvent.CLICK, buttones9);
            function buttones7(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }
            function buttones8(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }
            function buttones9(eventObject: MouseEvent): void {
                this.gotoAndStop(12);
                iskoru += 1;
                this.scorerr.txtSkor.text = iskoru.toString();
            }
        }

        public function quiztime4() {
            this.quizquest4.visible = true;
            this.scorerr.visible = true;
            this.timerr.visible = true;
            this.quizquest4.ans41.buttonMode = true;
            this.quizquest4.ans42.buttonMode = true;
            this.quizquest4.ans43.buttonMode = true;

            this.quizquest4.ans41.addEventListener(MouseEvent.CLICK, buttones10);
            this.quizquest4.ans42.addEventListener(MouseEvent.CLICK, buttones11);
            this.quizquest4.ans43.addEventListener(MouseEvent.CLICK, buttones12);
            function buttones10(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                lives.txtLives.text = buhay.toString();
            }
            function buttones11(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }
            function buttones12(eventObject: MouseEvent): void {
                this.gotoAndStop(12);
                iskoru += 1;
                this.scorerr.txtSkor.text = iskoru.toString();
            }
        }

        public function quiztime5() {
            this.quizquest5.visible = true;
            this.scorerr.visible = true;
            this.timerr.visible = true;
            this.quizquest5.ans51.buttonMode = true;
            this.quizquest5.ans52.buttonMode = true;
            this.quizquest5.ans53.buttonMode = true;

            this.quizquest5.ans51.addEventListener(MouseEvent.CLICK, buttones13);
            this.quizquest5.ans52.addEventListener(MouseEvent.CLICK, buttones14);
            this.quizquest5.ans53.addEventListener(MouseEvent.CLICK, buttones15);
            function buttones13(eventObject: MouseEvent): void {
                this.gotoAndStop(12);
                iskoru += 1;
                this.scorerr.txtSkor.text = iskoru.toString();
            }
            function buttones14(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }
            function buttones15(eventObject: MouseEvent): void {
                this.gotoAndStop(13);
                buhay -= 1;
                this.lives.txtLives.text = buhay.toString();
            }
            if (buhay == 0) {
                this.gotoAndStop(14);
                this.gameoverwin.btnTry.addEventListener(MouseEvent.CLICK, dasi);
            }
            function dasi(event: MouseEvent): void {
                this.gameoverwin.visible = false;
                startgame();
                this.btnPause.addEventListener(MouseEvent.CLICK, tgil);
            }
            function tgil(event: MouseEvent): void {
                this.gotoAndStop(11);
            }
        }
    }
}

And its affected code from line 52: public function MainGame(stageRef:Stage, thisThing:Object) {

I can't find the wrong code line from it. I'm trying to fix the errors but still, that error appears. Is there any problem on my code? How can I fix those errors? Any help would be appreciated. Thanks.

ArgumentError: Removing Child from Stage

I am trying to develop a basic Snake game that involves some inverse kinematics and state machines. I'm trying to get it so when the first segment of the snake interacts with a certain "mouse", it disappears. However, when I do, it doesn't work and I end up getting ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.

Here's my code:

package 
{
        import agent.Agent;
        import flash.display.Sprite;
        import flash.display.StageAlign;
        import flash.display.StageScaleMode;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.events.KeyboardEvent;
        import flash.geom.Point;
        public class Main extends Sprite 
        {
                private var Agents:Vector.<Agent>;
                                private var segments:Array;
                private var numSegments:uint = 150;
                private var player:Point = new Point (15, 15)
                public function Main():void 
                {
                        if (stage) init();
                        else addEventListener(Event.ADDED_TO_STAGE, init);
                }
                
                private function init(e:Event = null):void 
                {
                        stage.align = StageAlign.TOP_LEFT;
                        stage.scaleMode = StageScaleMode.NO_SCALE;
                        segments = new Array();
                        for(var i:uint = 0; i < numSegments; i++)
                        {
                                var segment:Segment = new Segment (5, 10);
                                addChild(segment);
                                segments.push(segment);
                        }
                        //updatePoint();
                        addEventListener(Event.ENTER_FRAME, onEnterFrame);

                        removeEventListener(Event.ADDED_TO_STAGE, init);
                        stage.scaleMode = StageScaleMode.NO_SCALE;
                        stage.align = StageAlign.TOP_LEFT;
                        // entry point
                        graphics.beginFill(0xeeeeee);
                        graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
                        
                        Agents = new Vector.<Agent>();
                        addEventListener(Event.ENTER_FRAME, gameloop);
                        for (var x:int = 0; x < 10; x++) 
                        {
                                var a:Agent = new Agent();
                                addChild(a);
                                Agents.push(a);
                                a.x = Math.random() * 10;
                                a.y = Math.random() * 10;
                        }
                        stage.addEventListener(MouseEvent.CLICK, createAgent);
                }
                
                private function createAgent(e:MouseEvent):void 
                {
                        var a:Agent = new Agent();
                        stage.addChild(a);
                        Agents.push(a);
                        a.x = mouseX;
                        a.y = mouseY;
                }
                
                private function gameloop(e:Event):void 
                {
                        for each (var a: Agent in Agents) {
                                a.update();
                                trace ("Follow me on Twitter.");
                                for each(var target: Segment in segments)
                                {
                                        if (target.hitTestPtarget.x, a.y + target.y, true))
                                        {
                                                stage.removeChild(a);
                                        }
                                }
                                
                        }
                }
                private function onEnterFrame(event:Event):void
                {
                        drag(segments[0], player.x, player.y);
                        stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);

                        for(var i:uint = 1; i < numSegments; i++)
                        {
                                var segmentA:Segment = segments[i];
                                var segmentB:Segment = segments[i - 1];
                                drag(segmentA, segmentB.x, segmentB.y);
                        }
                }
                private function keyDown (evt: KeyboardEvent): void {
                        //87=w 68=d 83=s 65=a
                        if (evt.keyCode == 87) 
                        {
                                player.y-=50;
                        } 
                        else if (evt.keyCode == 83) 
                        {
                                player.y+=50;
                        } 
                        else if (evt.keyCode == 68) 
                        {
                                player.x+=50;
                        } 
                        else if (evt.keyCode == 65) 
                        {
                                player.x-=50;
                        }
                        trace (player.x + " " + player.y);
                }
                private function drag(segment:Segment, xpos:Number, ypos:Number):void
                {
                        
                        var dx:Number = xpos - segment.x;
                        var dy:Number = ypos - segment.y;
                        var angle:Number = Math.atan2(dy, dx);
                        segment.rotation = angle * 180 / Math.PI;
                        
                        var w:Number = segment.getPin().x - segment.x;
                        var h:Number = segment.getPin().y - segment.y;
                        segment.x = xpos - w;
                        segment.y = ypos - h;
                }

                
        }
}

I have tried looking at other posts with the same topic, but I just don't understand what I'm doing wrong. Any help would be greatly appreciated!

Appropriate data structure for Event class

I was coding class that will give users multiple choices and based on that do some action and continue with event."Something similar in RPG-s when you have option what to talk with npc and what you said will affect later options"

Example: Structure

I was trying to use tree structure here but i had problems making branches connect.

So what kind of data structure should i choose or make some myself? I dont have options for pointers in this language.

Any tips are welcome!

Actionscript/Animate - Fill in next array spot if this one is already filled

so I am working on a graphical calculator (bit more of a challenge than the basic windows one), and I want to be able to do the entire "math" in one textfield, just like typing in "5+3-5*11/3" and it gives you the solution when you press '='

I decided to make it with arrays of numbers and symbols, but I have no idea how to make it to fill the next array if this one already is used:

var numbers:Array = new Array("","","","","","","","","","","","","","","","");
var actions:Array = new Array("","","","","","","","","","","","","","","","");

I am using split to split the numbers I input with symbols, and I want the numbers to be placed in the arrays. Example: I type in 555+666 and then I need to have something like

if (numbers[0] = "") {numbers[0] = 555}
else if (numbers[1] = "") {numbers[1] = 555}
else if.....

Know what I mean? Pretty hard to describe... something like... When I type in a number, if the numbers[0] is already filled, go fill in numbers[1], if numbers[1] is filled, go to numbers[2] etc