samedi 30 avril 2016

Looking to make an Accordion menu in Flash

So i would like to make an Accordion Menu in flash. I need tabs to be transparent, so i need to make the content collapse. Does anyone have any ideas? Here is kind of what I am looking for. http://ift.tt/1eRVBE8

FluorineFx request as Externalized Object c#

currently I am developing C# application that sends amf packet to server using FluorineFx.

It works fine, but I found out strange datatype called Externalized Object.

I found out that FluorineFX Contains a class named ArrayCollection but i dont now how i need to use it and the bigger problem, how i can send it as externalized object

This is the capture file from Charles and I have re-produce those Externalized Objects.

pic

cheers, Niklas

How to request an Externalized Object in FluorineFx for C#?

currently I am developing C# application that sends amf packet to server using FluorineFx.

It works fine, but I found out strange datatype called Externalized Object.

I found out that FluorineFX Contains a class named ArrayCollection but i dont now how i need to use it and the bigger problem, how i can send it as externalized object

This is the capture file from Charles and I have re-produce those Externalized Objects.

Pic

cheers, Niklas

Flash Builder 4.6 - ComboBox set to visible on underlying component MouseOver, but flickers when MouseOver of ComboBox

I have a ComboBox that is set to be visible when a component that lies beneath it is hovered, my problem is that when I hover over the ComboBox it starts flickering because I am leaving the underlying component.

My code is:

<fx:Script>
    <![CDATA[
        private function videoRollOut():void
        {
            controls.visible=false;
        }
        private function videoRollOver():void
        {
            controls.visible=true;
        }   
    ]]>
</fx:Script>

<mx:Canvas width="100%" height="46%">
    <mx:VideoDisplay id="localVideoDisplay" top="0" right="0" bottom="0" left="0" height="100%" width="100%" rollOver="videoRollOver()" rollOut="videoRollOut()"/>  
    <s:VGroup id="controls" bottom="10" right="0" left="0" horizontalAlign="center" visible="false" mouseOver="videoRollOver()" mouseOut="videoRollOut()">
        <s:HGroup verticalAlign="middle">
            <s:Label color="0xFFFFFF" text="Audio: "/>
            <s:ComboBox id="micSelection" change="micChanged(event)"
            dataProvider="{micNames}"/>
        </s:HGroup>
        <s:HGroup verticalAlign="middle">
            <s:Label color="0xFFFFFF" text="Video: "/>
            <s:ComboBox id="cameraSelection" change="cameraChanged(event)"
            dataProvider="{cameraNames}"/>
        </s:HGroup>
    </s:VGroup>
</mx:Canvas>

I attempted to add the same mouseOver and mouseOut functions to the ComboBox, and while I could now hover over the ComboBox without it flickering, when I tried to hover over some of the options it would leave both the ComboBox and the VideoDisplay, making the ComboBox once again invisible however keeping the options of the ComboBox visible.

I attempted to add a mouseEnabled="false" mouseChildren="false" to the ComboBox, however the ComboBox was then unusable.

If anyone has any advice that would be great!

vendredi 29 avril 2016

AS3 preloader shoing 0% until complete

I've seen similar questions with preloaders stuck at 90% or showing blank altogether, however mine, as usual, works inside flash - trace statement shows % progression, and when loading is slow the preloader displays the % progression as meant to.

Then once uploaded online, the preloader shows 0% statically for seconds, all the way until the content is loaded, rendering the preloader half meaningless.

The preloader weighs 2-4 kb.

Why doesn't the percentage increase from 0% on the server?

Custom Header colors on Datagrid?

Is this possible? Ive seen many examples of it done with Flex components... What im trying to do is a have a custom color for each column header item in a datagrid component. I have found ways to set the all the header colors to a specific color, but not individuals...

AS3 Super Class Issue

I have a problem and I'm not too sure the best way to resolve it.

Scenario:

I have a Super Class called 'food' and I have 20 different foods and extends 'food' like Pizza, Curry, Fish and Chip etc.

When I remove a 'food' I keep a record of it so I can reuse (for performance purposes). Can I make a new Pizza class that uses an old 'food'?

E.g.

public class Pizza extends food
{
      public function Pizza()
      {
           super = FOOD.returnUsedClass();
      }
}

Is this possible or would I need to save the extending Class as well?

Hope this all make sense.

Scroll-able list in flash works but not as an apk on phone?

I'm developing a list in in Flash/Animate CC. The list extended over the mobile screen. Therefore, the script below allows the user to scroll down the list. When I test this in the mobile simulator in flash it works. However, when I publish it as an apk and then test it on an android device, the screen is blank.

Does anyone know why?

The Script

    import flash.events.Event;
import fl.transitions.Tween;

import fl.motion.easing.*;
import flash.events.TouchEvent;

var flingMotionX:Twaeen;
var flingMotionY:Tween;

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
var counter:uint = 1;
var origX:Number = menu.x;
var origY:Number = menu.y;

var finalX:Number = 0;
var finalY:Number = 0;

function updateCounter(evt:Event):void
{
    counter++;
}

menu.addEventListener(TouchEvent.TOUCH_BEGIN, fl_TouchBeginHandler);
menu.addEventListener(TouchEvent.TOUCH_END, fl_TouchEndHandler);

var fl_DragBounds:Rectangle = new Rectangle(0, -800, 0, 6000);

function fl_TouchBeginHandler(event:TouchEvent):void
{
    try
    {
        flingMotionX.stop();
        flingMotionY.stop();
    }
    catch (e:*)
    {

    }
    counter = 1;
    origX = menu.x;
    origY = menu.y;

    stage.addEventListener(Event.ENTER_FRAME, updateCounter);
    event.target.startTouchDrag(event.touchPointID, false, fl_DragBounds);
}

function fl_TouchEndHandler(event:TouchEvent):void
{
    stage.removeEventListener(Event.ENTER_FRAME, updateCounter);
    finalX = menu.x;
    finalY = menu.y;
    event.target.stopTouchDrag(event.touchPointID);
    calculateFling();
}

function calculateFling():void
{
    var flingX:Number = (finalX - origX) / counter;
    var flingY:Number = (finalY - origY) / counter;
    var flingDuration:Number = counter/10;
    var flingXFinal:Number = 0;
    var flingYFinal:Number = 0;

    if(flingDuration < 0.5)
    {
        flingXFinal = (flingX < 0) ? Math.max(0, menu.x + flingX*50) : Math.min(stage.stageWidth, menu.x + flingX*50);

        flingYFinal = (flingY < 0) ? Math.max(0, menu.y + flingY*50) : Math.min(2000, menu.y + flingY*50);

    }
    else
    {
        flingXFinal = (flingX < 0) ? Math.max(0, menu.x + flingX*10) : Math.min(stage.stageWidth, menu.x + flingX*10);

        flingYFinal = (flingY < 0) ? Math.max(0, menu.y + flingY*10) : Math.min(2000, menu.y + flingY*10);

        flingDuration = 1;

    }
    flingMotionX = new Tween(menu, "x", Quadratic.easeOut, menu.x, flingXFinal, flingDuration, true);
    flingMotionY = new Tween(menu, "y", Quadratic.easeOut, menu.y, flingYFinal, flingDuration, true);
}

function removeAllEventListeners()
{
    removeEventListener(TouchEvent.TOUCH_BEGIN, fl_TouchBeginHandler);
    removeEventListener(TouchEvent.TOUCH_END, fl_TouchEndHandler);
    stage.removeEventListener(Event.ENTER_FRAME, updateCounter);
}


stop();

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

I need help with something with Actionscript for school. It's a simple catching game. It keeps saying that my displayed object must be a caller of the child which it should be and it kinda works but I'm not sure how to fix the problem where my bunny object falls through my point character and gives me an error when it collides with the point character and when it hits the floor when it's not caught. The child should exist but I guess it doesn't. I don't know what to do. The commented stuff was stuff I tested on another file and transferred it over to see what it would do.

//Block = Asuka
//Ball = Bunny
//Ballz = Bunz
//Bunny is linked in library
import flash.events.Event;

var intervalBunny = setInterval(addBunny, 1000);

var bunz: Array = [];

function addBunny() {
    var bunny: Bunny = new Bunny();
    bunny.x = Math.ceil(Math.random() * 500);
    bunny.y = -50;
    addChild(bunny);
    bunz.push(bunny);
    bunny.addEventListener(Event.ENTER_FRAME, dropBunny);
}

function dropBunny(e: Event) {
    var b: Bunny = Bunny(e.target);
    b.y += 10;
    if (b.y > 400) {
        eliminatebunz(b);
    }
}

stage.addEventListener(Event.ENTER_FRAME, moveAsuka);

function moveAsuka(e: Event) {
    Asuka.x = mouseX;
    for (var i: int = 0; i < bunz.length; i++) {
        trace(i);
        if (Asuka.hitTestObject(bunz[i])) {
            eliminatebunz(bunz[i]);
            //points
        }
    }
}

function eliminatebunz(p) {

    p.removeEventListener(Event.ENTER_FRAME, dropBunny);
    removeChild(p);
}

Here's the code Any help on how to fix it would be GREATLY appreciated, especially since I am not a big coder and I'm more of an artist/illustrator

AS3 new URLRequest results in 404 despite file being there

I have a flash preloader in the same folder as the swf file it's supposed to load, located on the webhost server. Within Flash, the preloader loads the swf without problem, but online it can't find the file/it won't load (404 seen under developer tools -> network), but the file is patently there, in the same folder, and the file name is correct (copy/pasted). The preloader loads, only the requested file doesn't.

using (relevant snippet, there are no errors with the rest of the code):

var myloader:Loader =  new Loader();

myloader.load(new URLRequest("movie.swf"));

I've set 'Access network only' under Publish Settings (didn't work with or without).

Anyone being able to tell what other thing could cause a 404 error other than file not existing at said location?

As an aside, the preloader text (bytes loaded) doesn't show either, (no 'movie not loaded' under right click), is it because it can't find the file?

jeudi 28 avril 2016

AS3: Need to removeChild before addChild?

I notice that you don't have to removeChild a DisplayObject from it's parent before addChilding it to another container. If you just addChild it to the second container, it will automatically be removed from its current parent first. Is there any point to doing removeChild first if you're just going to addChild it someplace else right after?

AS3: Call Child SWF from Main SWF

I'm a beginner in AS3. I'm currently doing a project where I will call a child swf from main swf. So my problem is, the child swf not fitting in my main swf. I already added Exact_FIT but still not working. Child SWF came from my friend. I tried a basic child swf and its working but when I used the SWF Child of my friend its not working anymore. Its only in the left side then the height cutted.

Here's my code:

import flash.display.StageScaleMode;

loadSWF("index.swf");

var _swfLoader:Loader;
var _swfContent:MovieClip;

function loadSWF(path:String):void {
   var _req:URLRequest = new URLRequest();
   _req.url = path;

   _swfLoader = new Loader();
   setupListeners(_swfLoader.contentLoaderInfo);
   _swfLoader.load(_req);

}
function setupListeners(dispatcher:IEventDispatcher):void {

   dispatcher.addEventListener(Event.COMPLETE, loaded);
   dispatcher.addEventListener(Event.COMPLETE, addSWF);

   dispatcher.addEventListener(ProgressEvent.PROGRESS, preloadSWF);

}
function preloadSWF(event:ProgressEvent):void {
   var _perc:int = (event.bytesLoaded / event.bytesTotal) * 100;
   // swfPreloader.percentTF.text = _perc + "%";
}
function addSWF(event:Event):void {
   event.target.removeEventListener(Event.COMPLETE, addSWF);
   event.target.removeEventListener(ProgressEvent.PROGRESS, preloadSWF);    
   _swfContent = event.target.content;
   _swfContent.addEventListener("close", unloadSWF);   
   addChild(_swfContent);  
}
function unloadSWF(event:Event):void {
   _swfLoader.unloadAndStop();
removeChild(_swfContent);
   _swfContent = null;
}
//==================================

function loaded(event:Event):void 
{ 
    var content:Sprite = event.target.content; 
    stage.scaleMode = StageScaleMode.EXACT_FIT;

}

I tried to put also the width and height of the main swf but the output of child swf is small (not fitted)

Thank you.

How are Apache Flex Workers constructed when using a single SWF?

In AIR, if I extend Sprite I can add code which launches a worker by using loaderInfo.

If I use Flex, when the second worker is launched, I get a context error because the mxml Application is trying to be built for the second time.

Is there a different method of starting to build a Flex application than using Application that would be compatible with single SWF workers?

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ift.tt/rYUnH9" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" applicationComplete="init()">
    <fx:Script>
        <![CDATA[

            protected function init():void{
                if(Worker.current.isPrimordial) {
                    trace("isPrimordial");
                    var m_worker : Worker = WorkerDomain.current.createWorker(this.loaderInfo.bytes);
                    m_worker.start();
                }
                else {
                    trace("is NOT Primordial");
                }

                return;
            }

        ]]>
    </fx:Script>
</s:Application>

Error: Error #3731: This feature is not available within this context. at spark.components::Application/initContextMenu()[/Users/justinmclean/Documents/ApacheFlex4.15/frameworks/projects/spark/src/spark/components/Application.as:1832]

Movieclip names

I'm having troubles with AS3 and addChild methods.

First, I create an object called "container". Inside container I create an empty object with an empty MovieClip from library called "holder". Then I create the Movieclips inside the container.holder But I cannot access to the MovieClips! Anyone knows why? Here is the code:

// Creating object
var container:Object {
   x: 30,
   y: 30
}

// Empty object
var eObject: MovieClip = new MovieClip();
container.holder = eObject;

// Creating Movieclips
var mc : MovieClip;
   for (var i : int = 0; i < 5; i++) {
      var mc: _myClip = new _myClip(); // _myClip is a MC from my library.
      mc.name = "myMc"+ i;
      mc.x = 10;
      container.holder.addChild(mc);
}

// Calling MovieClips
container.holder["myMc"+3].x = 40; // Nothing happens

Flash cc As3 instance checking for direction

My main question here if there is a way that as3 can check for which side or direction of an instance is true? For example, lets say there's a block. I want flash to be able to detect which direction of the block the player is on. Like check if the player is standing in the direction the right side of the block is facing.

CreateJS JavasScript Frame Scripting in Animate CC

I used to be a Flash Developer, and I'm trying to understand the differences between ActionScript and the new CreateJS platform. I'm finding it difficult to find answers on Google so I figured I would ask here in hopes an expert can give me a solid explanation to build off of. Any help is very much appreciated.

Basically, I'm having difficulty understanding the complexities of timeline scope and how movie clips on the stage interact with each other in CreateJS. I'm also having trouble understanding how scope works between frames on the timeline.

In AS3 you could basically just drop a symbol on the stage and reference it on the main timeline like this:

if(ball_mc.aVariable == true) ball_mc.gotoAndPlay(2);

It seems, however, that in the new HTML5 Canvas Animate CC this no longer works. I get a lot of 'undefined'. I'm also finding that each frame is locked in scope. If I create a variable on frame 1 of ball_mc and then try to reference it on frame 2 I get an error unless I do something like this:

var aMovieClip = this.aMovieClip;

In ActionScript each nested timeline had it's own scope. If you created a variable on the first frame, that variable persisted across the entire timeline. I find it hard to believe that there is no easy way to extend the scope of a variable or function across a timeline. This is what made Flash a breeze when it came to adding interactivity on a timeline.

I tried to do the same thing with a function and I got an error like this:

createjs-2015.11.26.min.js:12 Uncaught TypeError: Cannot read property 'handleEvent' of undefined

I would like to understand how to have two movieclips on a timeline and have them interact with each other in a similar fashion as was possible in AS3:

MovieClip(parent).ball_mc.colour = 'red';

or..

this.addEventListener(MOUSE_EVENT.CLICK, callParentTimeline);
function callParentTimeline():void{
MovieClip(parent).gotoAndPlay(5);
}

etc. etc. etc.

this.parent isn't working for me.. and referencing a movieclip from the main timeline doesn't allow me to access it's frame variables along it's timeline.

I'm finding this confusing and frustrating because when I Google these issues, I find numerous articles that say such things as "Just say this.variable and it will work" or "just use parent.ball_mc to call the root", and I'm finding none of these suggestions seem to work.

Can any of you explain this to me?

Thank you!

passing instance name as string in a function

Hello guys
I am creating adobe air desktop project which has many movieclips in the main timeline (RadioSel, CarMC1, CarMC2, CarMC3....etc)
when you click on any of CarMC it shows the RadioSel

function showRadio(event: MouseEvent) {
RadioSel.visible = true;
RadioSel.instance = event.currentTarget.name;
trace (RadioSel.instance);

}

the CarMC are movieclips that has many frames each one show a different shape which depends on radioSel choice
the radioSel is a movie clip that has multiple radiobuttons each one make carMC in a different shape and a var called instance which carry the clicked CarMC instance as string.
And i created a function inside the RadioSel which is called when radiobuttongroup change so it change the clicked CarMC to a specific frame and hide the RadioSel

function chooseCar(CarInstance: String, frame: Number) {
this["Object(root)."+CarInstance].gotoAndStop(frame);
this.visible = false;
//trace(event.target)

}

when I change radiosel choice i call this

chooseCar(instance, frameNo)

where instance is the instance name of CarMC and frameNo is a number selected by which radiobutton clicked
but i get error everytime i call the function i think the error in this part

this["Object(root)."+CarInstance].gotoAndStop(frame);

how to fix it??

Flash Hit Test Object as3

Ok I need help to figure out how to make it when the stuntman collides with the hoop it adds one point but instead it detects the collision multiple times and adds 5 points.Thanks for the help. This is my code:

stop();

// Variables to increase money

var totalmoney = 0;

var moneygain:int = 1;

var moneylimit:int = 100000;


//on collision with hoop add 1 point to money

addEventListener(Event.ENTER_FRAME, HoopCollision);

function HoopCollision(event:Event):void
{
  if(startstuntman.hitTestObject(starthoop))
  {
    totalmoney += moneygain;
  }
  Total.text = totalmoney;
  trace("HIT");
}

upload offline video to livebroadcast event using youtube api

I have created livebroadcast event using api(http://ift.tt/1SSh5Kq).

Is there any way to upload video to specific event (created using above api) via Youtube api ?.

Got the error 1046 when changing the property of a component from a RSL

I got a problem about the RSL. I created a RSL named a.fla, and I created a component which basic class is XXButton.as(written by myself.), I reflected some property for designers to change the button's label, besides, this component's Nenter image description hereame and Class are both "ShareLib_Button". Then I put the button in B.fla as a import component(checked the "Import for runtime sharing."). And I ignored the "Automatically declare stage instance" in the flash publish setting.

When I just put this component on B's stage, exporting the fla is ok. But when I changed the property which I reflected of the component, I got the error 1046 "1046: Type was not found or was not a compile-time constant: ShareLib_Button".

Does anyone have any ideas about it?

Thanks in advance!

Echo

mercredi 27 avril 2016

Flash as3 platform game Error 1009

Im making a platform game with patrolling enemies with an enemy class and a bumper class which changes the direction of the enemies when they collide. Once you open the door and call on the nextLevel function I need the enemies and bumpers to be removed. This is the code for the nextLevel function:

function nextLevel():void {
    currentLevel++;
    trace("Next Level: " + currentLevel);
    if (enemyList.length>0) {
        for (var i:int = 0; i < enemyList.length; i++) {
            trace("enemyRemoved");
            enemyList[i].removeSelf();
        }
    }
    if (bumperList.length>0) {
        for (var b:int = 0; b < bumperList.length; b++) {
            trace("bumperRemoved");
            bumperList[b].removeSelf();
        }
    }
    if (currentLevel==2) {
        gotoLevel2();
        addEnemiesToLevel2();
        addBumpersToLevel2();
    }
}
if (currentLevel==3) {
    gotoLevel3();
    addEnemiesToLevel3();
    addBumpersToLevel3();
    trace("gotoLevel3");
}

which works fine for going to level 2. But somehow when I go to level 3, I get error 1009 cannot access a property of a null object reference when removing the bumpers. I don't understand why it would work for level 2 but not 3 and also the enemies get removed just fine which is almost identical to the remove bumper code. Here is my removeSelf function in the bumper class

public function removeSelf():void {
            trace("remove bumper");
            removeEventListener(Event.ENTER_FRAME, bumperloop);
            this.parent.removeChild(this);

Also my function for pressing the down arrow key while on the open door to call the nextLevel function

} else if (e.keyCode == Keyboard.DOWN) {
        downPressed=true;
        if (doorOpen&&player.hitTestObject(back.other.lockedDoor)) {
            nextLevel();
        }

Anyone know what could be the problem here? I would be very grateful to anyone who could answer Iv'e been working at this for days

Flash/AS3 Animating an object in an application

So I have an application which the user enters data and then the stuff the person enters are used in calculations which are shown to the user. To the application I am adding an animation of a rotating circle. All the objects that are used in the application are in frame 1. The rotation animation is displayed from frame 1 to lets say frame 10.

The problem is then that the objects other than the rotating circle are only visible on frame 1. I want the objects on frame 1 to be visible at all times while the circle rotates. At the same time the objects must not be altered in between frames. Is this possible?

Tips for following php calls in code base

I am working with action script 3 and often I see server calls using php here is an example

var serverCall:ServerCall = new ServerCall("getDeviceFirmwareLog", getDeviceFirmwareLogResponse, getDeviceFirmwareLogResponse, false);

This line calls some php functions that cannot be searched in my IDE, so I usually go from here and I would try to grep for that string "getDeviceFirmwareLog" and then I run into some php that makes other weird calls that somehow calls some stuff on the embedded hardware we run. In general when I grep for that string I don't even get any results and I'm so confused as to how it might be connected.

I am much more used to regular code calls and includes that are easier to follow. I've asked some people at work but it seems to get glossed over and I don't want to ask the same question a third time until I've exhausted my other options. I am wondering if there are any general debugging / code following tips for this kind of a setup that could help me understand what is going on in my codebase.

Thanks in advance.

Doing math with elements of a 2d-array?

So I am making a 2d-array like this:

var kcalVerdier:Array = new Array(92,80,103,36,53);
var alleNumSteppers:Array = new    Array(alleNumSteps.numStepMelk.value,alleNumSteps.numStepEgg.value,alleNumSteps.numStepBrød.value,alleNumSteps.numStepSmør.value,alleNumSteps.numStepOst.value);
var c:Array = new Array(kcalVerdier,alleNumSteppers);
function endreAntall(evt:Event)
{


        txtTotalKcal.text = String(c[0] * [0]);




}

Is it not possible to do multiply 2 values of a 2-d Array? I get this error:

Scene 1, Layer 'script', Frame 1, Line 17, Column 38 1067: Implicit coercion of a value of type Array to an unrelated type Number.

I don't understand why, c[0][0] should both be integer values or am I misunderstanding?

Actionscript CameraRoll delete Images

I am currently using Actionscript 3.0 with Animate CC. I have CameraRoll working in Actionscript perfectly. I can browse and add photos from the Gallery. I have a need to delete photos from the Gallery using either the CameraRoll class or the File class.

After a thorough search on the net and Adobe API pages it doesn't appear that CameraRoll allows either deletion of photos once it browses or allows the native delete gallery function to be executed.

Is there a method in the CameraRoll class that I missed or should I look at using the File class to browse the image directories? If the latter then does anyone have a good example on how to do this were the images are displayed in the gallery format? Keep in mind that all images and connections should remain local to the phone. There can be no internet access where a web interface could be used of any kind. Also the local native image store is the source of all images.

Thanks

Implicit Coercion of a value of a type of text.flash:TextField to an unrelated Int

Okay, so I'm trying to create a mobile flash game (I'm mostly an animator, a storyteller) and I'm having trouble with the input text for the player name. I've often read helpful tips on this site so I signed up to get some help. The code I use to load and save data is saveDataObject, But as far as I know input text has to be used with package code. I tried to convert it to function var, but then these errors occur. I am unsure how to use the Package class code, and everything I've read on it has been confusing. I am pretty much self taught for everything I know about code though tutorials and forums, so if it isn't explained in a way I can understand I wont be able to do it...

Here's the section of code if I wasn't clear:

       var playerName:int;

init(); // this line goes directly beneath the variables

function f_1(init):void{ // call once to set everything up

 saveDataObject = SharedObject.getLocal("DataBattle/character/name"); // give the save data a location
 playerName = txtPlayer; 

function addName(e:TouchEvent):void{

 var myTextBox1:TextField = new TextField(); 
    var txtPlayer:TextField = new TextField(); 
    var myText:String = "Cyan"; 

    function CaptureUserInput() 
    { 
        captureText(); 
    } 

    function captureText():void 
    { 
        myTextBox1.type = TextFieldType.INPUT; 
        myTextBox1.background = true; 
        addChild(myTextBox1); 
        myTextBox1.text = myText; 
        myTextBox1.addEventListener(TextEvent.TEXT_INPUT, textInputCapture); 
    } 

    function textInputCapture(event:TextEvent):void 
    { 
        var str:String = myTextBox1.text; 
        createOutputBox(str); 
    } 

    function createOutputBox(str:String):void 
    { 
        txtPlayer.background = false; 
        txtPlayer.x = 200; 
        addChild(txtPlayer); 
        txtPlayer.text = str; 
    } 

     if(saveDataObject.data.characterName = playerName == null){ // checks if there is save data
      trace("No Player data yet."); // if there isn't any data on the computer...
      saveDataObject.data.characterName = playerName; // ...set the savedScore to 0
 } else {
      trace("Player data found."); // if we did find data...
      loadData1(); // ...load the data
 }

function loadData1():void{
 playerName = saveDataObject.data.characterName; // set the current score to the saved score
 trace("Data Loaded!");
}


} 


}

function saveData(e:TouchEvent):void{
     saveDataObject.data.characterName = playerName; // set the saved score to the current score
 trace("Data Saved!");
 saveDataObject.flush(); // immediately save to the local drive
 trace(saveDataObject.size); // this will show the size of the save file, in bytes
}

SWF Flash File behaves differently outside root folder - Friday Deadline

Friday is the deadline for my flash project, im supposed to export my flash project into a swf file and then hand it over to the moderators. However, i noticed when i move the swf file outside the main folder for example email to teacher for them to mark, it behaves differently and starts bugging out. For example, there are some videos not displaying, some pictures are suppossed to not be visible when i click on a certain button but they still are. This should not happen in my knowledge as the swf file should contain all the data require and is completely standalone from all the files in the main folder. MY as3 files are all inside the main project

EDIT: i noticed the file "MinimaFlatCustomColorPlayBackSeekMute" which is part of the videos, however i tried moving this file also to where the moved files is but no change... same goes for the "textLayout_1.0.0.595" file... please help

AS3 URLLoader unable to find local file

Using AS3 Loader object's load(new URLRequest('file.swf'), and the file is in the same directory as the FLA file. Just read that flash looks for files based on the application directory, but even when using the absolute file path flash can't find it such as "C:\Users\acerbook\Desktop\swf2\file.swf".

i keep getting "Error #2044: Unhandled IOErrorEvent:." and "Error #2035: URL Not Found.", seemingly regardless

Why does EaselJS and AS3 Matrix methods have different results

Maybe I am doing something wrong but given this code from EaselJS on rotating and translating with a matrix:

var m = new createjs.Matrix2D();
m.identity();
m.translate(150,65);
m.rotate(45)
m.translate(319, 79.07611844574882);

console.log(m.tx + " " + m.ty);

http://ift.tt/1WSuRwq

The result I get for this is:

319.651803615609 346.48232278140824

If I take the same example code and run it through Actionscript 3:

package {
    import flash.text.TextField;
    import flash.geom.Matrix;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            var m:Matrix = new Matrix();
            m.identity();
            m.translate(150,65);
            m.rotate(0.785398) // in radians
            m.translate(319, 79.07611844574882);
            var t:TextField = new TextField();
            t.text = m.tx + " " + m.ty;
            t.width = 2000;
            addChild(t)
        }
    }
}

It is giving me tx=379.4178764008566, ty=231.5402764008565

http://ift.tt/1qT3lCt

I used that site wonderfl which can be buggy but I tested on another person's computer who has flashbuilder installed.

I would think they should have the right results.

I did notice that the latest version of EaselJS the matrix method is missing tx and ty. I fixed that by changing the rotate method to be:

p.rotate = function(angle) {
    angle = angle*Matrix2D.DEG_TO_RAD;
    var cos = Math.cos(angle);
    var sin = Math.sin(angle);

    var a1 = this.a;
    var c1 = this.c;
    var tx1 = this.tx;

    this.a = a1*cos-this.b*sin;
    this.b = a1*sin+this.b*cos;
    this.c = c1*cos-this.d*sin;
    this.d = c1*sin+this.d*cos;
    this.tx = tx1*cos-this.ty*sin;
    this.ty = tx1*sin+this.ty*cos;
    return this;
};

The existing translate method does look right. It does not make sense to me that the results from AS3 and EaselJS should be different.

One more note is that I noticed that if I trace the first translate and the first rotate I get the same results. I only get different results at the last translate. This confuses me even more.

Make movieclips appear randomly in AS3

Right now I have six mice places in spesific places on the stage. These mice move based on adjustments made on the timeline inside the movieclip itself. What I aim to do is to start these six movieclips randomly based on a timer. This task im currently struggeling with..

Here is my code;

var clipArray:Array = new Array();

clipArray[0] = musx0_mc;
clipArray[1] = musx1_mc;
clipArray[2] = musx2_mc;
clipArray[3] = musx3_mc;
clipArray[4] = musx4_mc;
clipArray[5] = musx5_mc;



var i:int = 0;

var musTimer:Timer = new Timer(100);

musTimer.addEventListener(TimerEvent.TIMER, playMus);

function playMus(event:TimerEvent):void
{
    for(i=0; i<clipArray.length; i++)
    {
        var randomMus:Number = Math.floor(Math.random()*100);        
        clipArray[randomMus].play();
    }
}

musTimer.start();

finding point inside bezier curve

I am drawing a bezier curve , but i need to find whether mouse is inside the curve , how to check that?

var bs:BezierSegment = new BezierSegment(p1, p2, p3, p4);
        for( var t:Number=0.01 ; t<1.01 ; t+=0.01 ) 
        {
            var val:Point = bs.getValue(t);
            trace("segmentis"+val)
            _graphics.lineTo(val.x, val.y);
        }

How to find whether the point lies between these points

I have been trying to create a curve and i've already created it . but the thing is if i add a point it will be added to the array[last point -1] , but if i add a point between the first and second point the curve takes it as the last point -1 which is my coding anyway, I need to find where i shoulkd add , the index of the curveenter image description here

The above imnage is an example , here i have a curve with three points , the point's are numbered so that you can see how the points are stored in the array , I am going to add the purple point to th array but i need to know which index i should paste , please help

mardi 26 avril 2016

compare two arrays in as3

I have two arrays. Array one has predefined elements. Array two collect elements at run-time.I need to get true or false after comparing these two arrays.Also these two arrays can be..

var ArrayOne:Array = new Array("b1","b2","b3","b4");
var ArrayTwo:Array = ["b1","b2","b3","b4"];
//output must be true 

var ArrayOne:Array = new Array("b1","b2","b3","b4");
var ArrayTwo:Array = ["b2","b1","b4","b3"];
//output must be true 

var ArrayOne:Array = new Array("b1","b2","b3","b4");
var ArrayTwo:Array = ["b1","b2","b3","b4","b1","b2"];
//output must be true 

var ArrayOne:Array = new Array("b1","b2","b3","b4");
var ArrayTwo:Array = ["b1","b2","b3","b4","b5"];
//output must be false

Any way to tell Nape to not check collision against certain bodies?

Situation: I got a player that shoots bullet, lots of them, and I consider that Nape checking collision against my own body (player's body) is a waste of resources, my own bullets should only check collision against enemy entities.

Is it possible to set Nape in a way only certain type of collisions are even processed?.

(I know about the CBType listeners, I'm only using them when I need them but still Nape is checking/acting on collisions that it shouldn't).

related to upload video to specific event in youtube channel

I created livebroadcast event in YouTube. I need to upload video to those created event using youtube api. Is there any way to do this?.

Haxe Map Memory Cleanup Issue

So I have been using Haxe for a while and it has occurred to me recently that I don't really get what happens on some other the non-flash targets as far as memory cleanup. I mean 'new'ing everything and dumping it by setting references to null gives me this feeling that there are memory leakages, but I can't seem to find the documentation I'm looking for.

Specifically I use dictionaries/maps a decent amount. Like this:

var items:Map<String, MyObject> = new Map();

items.set("someKey", new MyObject(args...));

// Later
items["someKey"].doSomething();
items["someKey"].setVal(2);
...

// When Finished
items.remove("someKey");

The last line there just dumps my object somewhere into oblivion and hopefully gets garbage collected (at least on the Flash target).

I put together a little program just to see the cleanup in action on Flash and then change it for other targets, but I am failing to even see the cleanup on the Flash target. Here is the project code:

    package;

import openfl.display.Sprite;
import openfl.events.Event;
import haxe.ds.StringMap;

import openfl.events.KeyboardEvent;
import openfl.ui.Keyboard;

class Main extends Sprite 
{
    private var keypressID:Int;
    private var itemID:Int;
    private var dict:StringMap<Sprite>; // Using this since I read Map<String, T> just compiles to StringMap<T>.

    public function new() 
    {
        super();

        addEventListener(Event.ENTER_FRAME, init);
    }

    private function init(event:Dynamic):Void
    {
        removeEventListener(Event.ENTER_FRAME, init);
        // Entry point.

        keypressID = 0;
        itemID = 0;
        dict = new StringMap();

        stage.addEventListener(KeyboardEvent.KEY_UP, keyPress);
    }

    private function keyPress(event:Dynamic):Void
    {
        if (Std.is(event, KeyboardEvent) && cast(event, KeyboardEvent).keyCode == Keyboard.A)
        {
            trace('ID: $keypressID - Adding Item');
            keypressID += 1;

            for (i in 0...10000)
            {
                itemID += 1;
                dict.set('$itemID', new Sprite());
            }
        }
        else if (Std.is(event, KeyboardEvent) && cast(event, KeyboardEvent).keyCode == Keyboard.R)
        {
            trace('ID: $keypressID - Removing Items');
            keypressID += 1;

            removeItems();
        }

        // Force garbage collector to run.
        else if (Std.is(event, KeyboardEvent) && cast(event, KeyboardEvent).keyCode == Keyboard.C)
        {
            trace('ID: $keypressID > Starting GC');
            keypressID += 1;

            forceGarbageCollection();
        }
    }

    private function removeItems()
    {
        trace('ID: $keypressID > Remove All Item');

        for (val in dict.keys())
        {
            dict.remove(val);
        }

        dict = new StringMap();
    }

    private function forceGarbageCollection():Void
    {
        neko.vm.Gc.run(true);   // I have tried flash and neko and both get the same results.
    }
}

I run this on Windows and under task manager, my neko process only grows and never shrinks. Its gets up to 500MB quick when hitting 'A'. I then 'R' to remove all references to the items, but they never get collected it seems even when I force the GC.

I also tried storing openfl.util.Timer objects with event listeners attached to them to do traces and they never seem to get collected either. They just keep tracing. Now I suspect that may be because of the event listener reference, but am sure I have seen that trick in other AS3 memory leak tracking code.

Am I missing something or doing something wrong?

Horizontal collision issue with actionscript 3 flash

In my platformcollision function, when the player is checking for collision on his left side everything is fine. My player doesnt go through, he can move the opposite way. However, when I put the warMage on the left and its checking if theres collision with the platform on his right side, the player immediately teleports next to the platform. I dont understand why as all I did was flip the arithmetic signs in that if statement from the other for the player to check its right side.

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

var Key:KeyObject = new KeyObject(stage);//Help the stage checks for   keypressed objects           //Initialized variable integers
var hsp:Number = 0;// horizontal speed
var vsp:Number = 0;// vertical speed
var grav:Number = 2;//Gravity
var fric:Number  = .5;//Friction
var floor:int = 800;//Bottom of the stage
//All Booleans
var lDown:Boolean = false;
var rDown:Boolean = false;
var jumped:Boolean = false;
var attacking:Boolean = false;


warMage.gotoAndStop("idleWarmage");//Initially starts at idle state
stage.addEventListener(Event.ENTER_FRAME, keyPressed);//Listens for buttons    pressed
stage.addEventListener(Event.ENTER_FRAME, gameloop);// The physics applied  to character
stage.addEventListener(Event.ENTER_FRAME, platformCollision);

function keyPressed(e:Event):void
{
if(Key.isDown(Key.LEFT))//If we pressed the left arrow button
{

    lDown = true;//Condition to check if player is in running state
    if(lDown = true)//If we are running left
      {
         hsp -= 15;//Move left
         warMage.gotoAndStop("RunWarmage");//Play the running animation
         warMage.scaleX = -1;//Flip the image scale
      }
}else if(Key.isDown(Key.RIGHT))//If we pressed the right arrow button
{

    rDown = true;//Condition to check if player is in running state
    if(rDown = true)//If we are moving right
      {
        hsp += 15;//Move the position right
        warMage.gotoAndStop("RunWarmage");//Play the animation
        warMage.scaleX = 1//Face right
      }
}else if(Key.isDown(Key.SPACE))//If we press the spacebar
     {
         warMage.gotoAndStop("AttackWarmage");//Play teh attack animation
         warMage.x += 5; //Lunge right
         if(warMage.scaleX == -1)//If we are initially facing left
             {
                 warMage.x -= 10;//Lunge left
             }

     }else if(Key.isDown(Key.DOWN))
      {
        warMage.gotoAndStop("CrouchWarmage"); 

      }else if(Key.isDown(Key.UP) || jumped == true)//If we press the up arrow or we've jumped
      {

          warMage.y -= 60;//vertical speed goes up to 20
          jumped = true;//We know that player has jumped
          warMage.gotoAndStop("JumpWarmage");//Play teh jump animation

      }else if(jumped == false)//If we're not jumping
        {
            warMage.gotoAndStop("idleWarmage");//Return to idle position
        }
}


function gameloop(e:Event):void
{  
  warMage.y += grav;//Apply gravity to the player
  hsp *= fric;//Friction is applied to hsp to prevent infinite acceleration

  warMage.x += hsp;//The plater moves horizontal position
  if(warMage.x - warMage.width/2 < 0)//If the player goes past the left side
      {
          warMage.x = warMage.width/2;
      }
  if(warMage.x + warMage.width/2 > 1400)//If the player goes past right
      {
          warMage.x = 1400 - warMage.width/2;//Player cant go past
      } 
  if(warMage.y  < floor)//If we are above the floor
        {
         // warMage.y += grav;//Apply gravity to the player
          grav++;//Accelerate gravity in the process
          warMage.gotoAndStop("JumpWarmage");//Play the jump animation  

        } else //if(warMage.y - warMage.height/2 > floor)
          {

            jumped = false;//If we are on the floor then we're not jumping
            grav = 0;//Gravity can no longer be applied
            warMage.y = floor;//Player sits on top of the floor
          }
}

function platformCollision(e:Event):void
{
//If the player.x is less then the left side and the player can go into the box and if the warMage.y is equal to the  height
if(warMage.x - warMage.width/2 < platform.x + platform.width/2 + 2 && warMage.y - platform.y == platform.height/2) 
    {
        warMage.x = platform.x + platform.width/2 + warMage.width/2;
        //Player.x is equal to the left side of the platform

    }
if(warMage.x + warMage.width/2 > platform.x - platform.width/2 - 2 && warMage.y - platform.y == platform.height/2)
    {
        rDown = false;
        warMage.x = platform.x - platform.width/2 - warMage.width/2;
        //Player.x is equal to the left side of the platform

    }
}

How are Apache Flex Workers constructed when using a single SWF?

In AIR, if I extend Sprite I can add code which launches a worker by using loaderInfo.

If I use Flex, when the second worker is launched, I get a context error because the mxml Application is trying to be built for the second time.

Is there a different method of starting to build a Flex application than using Application that would be compatible with single SWF workers?

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ift.tt/rYUnH9" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" applicationComplete="init()">
    <fx:Script>
        <![CDATA[

            protected function init():void{
                if(Worker.current.isPrimordial) {
                    trace("isPrimordial");
                    var m_worker : Worker = WorkerDomain.current.createWorker(this.loaderInfo.bytes);
                    m_worker.start();
                }
                else {
                    trace("is NOT Primordial");
                }

                return;
            }

        ]]>
    </fx:Script>
</s:Application>

Error: Error #3731: This feature is not available within this context. at spark.components::Application/initContextMenu()[/Users/justinmclean/Documents/ApacheFlex4.15/frameworks/projects/spark/src/spark/components/Application.as:1832]

Delete a data of my database from AS3

I'm trying to delete a data from my database with ActionScript 3.

I've created a php on my server :

<?php
include ("shared/connect.php");
$idToDelete   = $_POST['idToDelete'];

$result = mysqli_query($conn,"
DELETE  FROM `annoncesNew` WHERE id=$idToDelete");
?> 

Then I have to send the variable idToDelete to this php in order to delete the entry.

So I did :

deleteBtn.addEventListener(MouseEvent.CLICK, deleteThisAnnonce);

function deleteThisAnnonce(event:MouseEvent):void { 
    trace("deleteThisAnnonce");
var variablesDelete:URLVariables = new URLVariables();
var varDelete:URLRequest = new URLRequest("http://ift.tt/1UfCwnS");
varDelete.method=URLRequestMethod.POST;
varDelete.data=variablesDelete;

var varLoaderDelete:URLLoader = new URLLoader;
varLoaderDelete.dataFormat=URLLoaderDataFormat.VARIABLES;
varLoaderDelete.addEventListener(Event.COMPLETE,completeHandlerDelete);
ValidateAndSendDelete();
function completeHandlerDelete(event:Event):void{
            trace("Data Sent");

}
function ValidateAndSendDelete():void{
        trace("deleting"+item.id);  //item.id is my the ID. When I trace the output is 144 so it's good.    
        variablesDelete.idToDelete = item.id;
        varLoaderDelete.load(varDelete);
    }
}   

So, with this code, it's supposed to delete the data where id = 144. But I've got this error when click on the deleteBtn : Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs..

(all the traces are working correctly but my data isn't delete).

I've tried my php by changing DELETE FROMannoncesNew WHERE id=$idToDelete");withDELETE FROM annoncesNew WHERE id=144"); and execute it on my webbrowser and it worked (the line with the id 144 was deleted).

Weirdly, the line is delete with my AS3 code (so the code is working) but it throws this error 2101 anyway. Any idea why ?

Thx

As3 animation issue with the movieclip for my player

Ok so Ive established boundaries for all the sides of the rooms so the player wouldnt go past the stage. However for some reason, when my player hits the floor, the animation keeps flashing at the animation stages when the player is on the ground. It just goes blank and back to the image again over and over and over. It also duplicates the animation under it and that duplicate flashes. This includes flashing running and attacking states as well. The collision is fine but the animation is weirded out for some reason.

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

var Key:KeyObject = new KeyObject(stage);//Help the stage checks for keypressed objects           //Initialized variable integers
var hsp:Number = 0;// horizontal speed
var vsp:Number = 0;// vertical speed
var grav:Number = 2;//Gravity
var fric:Number  = .5;//Friction
var floor:int = 650;//Bottom of the stage
//All Booleans
var lDown:Boolean = false;
var rDown:Boolean = false;
var jumped:Boolean = false;
var attacking:Boolean = false;


warMage.gotoAndStop("idleWarmage");//Initially starts at idle state
stage.addEventListener(Event.ENTER_FRAME, keyPressed);//Listens for buttons   pressed
stage.addEventListener(Event.ENTER_FRAME, gameloop);// The physics applied  to character
//.addEventListener(Event.ENTER_FRAME, platformCollision);

function keyPressed(e:Event):void
{
if(Key.isDown(Key.LEFT))//If we pressed the left arrow button
{

    lDown = true;//Condition to check if player is in running state
    if(lDown = true)//If we are running left
      {
         hsp -= 15;//Move left
         warMage.gotoAndStop("RunWarmage");//Play the running animation
         warMage.scaleX = -1;//Flip the image scale
      }
}else if(Key.isDown(Key.RIGHT))//If we pressed the right arrow button
{

    rDown = true;//Condition to check if player is in running state
    if(rDown = true)//If we are moving right
      {
        hsp += 15;//Move the position right
        warMage.gotoAndStop("RunWarmage");//Play the animation
        warMage.scaleX = 1//Face right
      }
}else if(Key.isDown(Key.SPACE))//If we press the spacebar
     {
         warMage.gotoAndStop("AttackWarmage");//Play teh attack animation
         warMage.x += 5; //Lunge right
         if(warMage.scaleX == -1)//If we are initially facing left
             {
                 warMage.x -= 10;//Lunge left
             }

     }else if(Key.isDown(Key.UP) || jumped == true)//If we press the up arrow or we've jumped
      {

          vsp = -25;//vertical speed goes up to 20
          jumped = true;//We know that player has jumped
          warMage.gotoAndStop("JumpWarmage");//Play teh jump animation

      }else if(jumped == false)//If we're not jumping
        {
            warMage.gotoAndStop("idleWarmage");//Return to idle position
        }
}


   function gameloop(e:Event):void
{  

  hsp *= fric;//Friction is applied to hsp to prevent infinite acceleration
  warMage.x += hsp;//The plater moves horizontal position
  if(warMage.x - warMage.width/2 < 0)//If the player goes past the left side
      {
          warMage.x = warMage.width/2;
          /*lDown = false;//We are not moving left anymore
          if(lDown == false)
              {
                hsp = 0;  
              }*/
      }
  if(warMage.x + warMage.width/2 > 1000)//If the player goes past right
      {
          warMage.x = 1000 - warMage.width/2;//Player cant go past
         /* rDown = false;
          if(rDown == false)
              {
                hsp = 0;  
              }*/
      } 
  if(warMage.y - warMage.height/2 > platform.y - platform.height/2)
      {
          jumped = false;
          grav = 0;
          warMage.y = platform.y - warMage.height/2 ;
      }else if(warMage.y - warMage.height/2 < platform.y - platform.height/2)
      {
           vsp += grav;
           grav++;
           warMage.y += vsp;
      }




  /*if(warMage.x + warMage.width/2 < 0 )//Checking for collision with the left side
      {
        warMage.x = 0;
      }else if(warMage.x + warMage.width/2 > 1000)
         {
             warMage.x = 1000;

         }

  if(lDown == true || rDown == true)
      {
          //hsp *= fric;
          warMage.x += hsp;
      }*/
  }

Related to upload video using Youtube API in AS3

I created live broadcast event using youtube livebroadcast api. Is there any way to upload video to my live broadcast event in channel?. I have tried a lot but didn't find the solution.

how to reduce button click event code in AS3

I have 1 to 64 buttons called(instance name) b1 - b64. I need to add mouse click event to every buttons.My current code like this....

b1.addEventListener(MouseEvent.CLICK, btn1click);
function btn1click(event:MouseEvent)
{
 var e = b1;
}
b2.addEventListener(MouseEvent.CLICK, btn2click);
function btn2click(event:MouseEvent)
{
 var e = b2;
}
b3.addEventListener(MouseEvent.CLICK, btn3click);
function btn3click(event:MouseEvent)
{
 var e = b3;
}
.......

I need to reduce that repetition.

lundi 25 avril 2016

AS3 Scrolling Drop-Down Menu

I'm trying to create a Drop-Down Menu that can be scrolled (so I can display some of the drop down list items, instead of looking at the entire list of items at all times). I found tutorials for making a scrolling block of text and another tutorial for making a drop down list, but I haven't been able to get them to combine. It seems like I can't have the menu array (menu_arr) generated inside of a container movie clip, which is what is scrolling. Instead of posting all of the failed combination attempts, below is the code for the two separate entities while they still work individually.

package 
{
    // import packages
    import flash.display.MovieClip;
    import flash.events.*;
    import flash.utils.Timer;
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import fl.transitions.TweenEvent;

    public class DropDown2 extends MovieClip
    {
        // variables
        var menu_arr:Array = new Array ("Item 1", "Item 2", "Item 3", "Item 4", "Item 5","Item 6", "Item 7");
        var item:submenu;
        var target:String;

        public function DropDown2()
        {
            // constructor code

            for (var i:int = 0; i < menu_arr.length; i++)
            {
                item = new submenu();
                item.x = fullMenu.x;
                item.y = fullMenu.y + 36 + (i * 36);
                item.name = menu_arr[i];
                item.submenu_output.text = menu_arr[i];
                item.addEventListener(MouseEvent.MOUSE_OVER, rollover);
                item.addEventListener(MouseEvent.MOUSE_OUT, rollout);
                item.addEventListener(MouseEvent.MOUSE_DOWN, selectItem);
                item.visible = false;
                addChild(item);
            }

            container.mask = myMask; // mask

            // listeners
            fullMenu.addEventListener(MouseEvent.MOUSE_OVER, rollover);
            fullMenu.addEventListener(MouseEvent.MOUSE_OUT, rollout);
            fullMenu.addEventListener(MouseEvent.MOUSE_DOWN, showMenu);

            addEventListener(Event.ENTER_FRAME, scrollManage); // scroll manager
            up_btn.addEventListener(MouseEvent.MOUSE_DOWN, scroll_up);
            down_btn.addEventListener(MouseEvent.MOUSE_DOWN, scroll_down);
        }

        function rollover(e:MouseEvent):void
        {
            e.target.parent.gotoAndStop(2);
        }

        function rollout(e:MouseEvent):void 
        {
            e.target.parent.gotoAndStop(1);
        }

        function showMenu(e:MouseEvent):void
        {
            for (var i:int = 0; i < menu_arr.length; i++) 
            {
                var thisMenuItem = getChildByName(menu_arr[i]);

                if (thisMenuItem.visible == false)
                {
                    thisMenuItem.visible = true;
                }
                else if (thisMenuItem.visible != false)
                {
                    thisMenuItem.visible = false;
                }
            }
        }

        // Currently selected
        private function selectItem(e:MouseEvent):void
        {
            target = e.target.parent.name;
            fullMenu.menu_output.text = target;
        }

        // Scroll Manager
        private function scrollManage(e:Event):void
        {
            if (container.y < myMask.y)
            {
                up_btn.mouseEnabled = true;
            }
            if (container.y > myMask.y + myMask.height - container.height)
            {
                down_btn.mouseEnabled = true;
            }
        }

        private function scroll_up(e:MouseEvent):void
        {
            /*trace(container.y); // 54
            trace(myMask.y); // 54
            trace(myMask.y + myMask.height - container.height); // -126*/
            if (container.y < myMask.y)
            {
                /*container. y = container.y + 18;*/
                var scroll_up:Tween = new Tween(container, "y", Regular.easeInOut, container.y, myMask.y, 2, true);
            }
            if (container.y >= myMask.y)
            {
                trace("top");
                up_btn.mouseEnabled = false;
            }
        }

        private function scroll_down(e:MouseEvent):void
        {
            var scroll_bottom = myMask.y + myMask.height - container.height;
            if (container.y > scroll_bottom)
            {
                /*container. y = container.y - 18;*/
                var scroll_down:Tween = new Tween(container, "y", Regular.easeInOut, container.y, scroll_bottom, 2, true);
            }
            else if (container.y <= scroll_bottom)
            {
                trace("bottom");
                down_btn.mouseEnabled = false;
            }
        }
    }
}

How to use a single script for multiple frames

I've build a topotrainer in Flash consisting of 50 states. For every state I made a frame. The code of these 50 frames should be the same for all, while the graphics defer. If I put the code on the first of the 50 frames it is only working there. If I put the code at every frame I get a lot of errors, because all the functions are doublated.

Is there a way for all the 50 frames to run the same code?

Thanks for your time,

Justin

List of third party libraries to embed for flex development

What are all the third party libraries available to use in flex application.

AS3 video loop doesn't work on Mac OS

For reasons too complicated to explain here, I've suddenly had to start making Flash ads with AS3.

I'm a designer, I know little enough about coding languages and have to tinker with found code to make things work. So I've tried to make a simple flash ad with a looping video, which works fine on windows machines, but not on Mac ones (the video plays once, doesn't loop). Any idea what is wrong with my very simple code ?

var fl_NC:NetConnection = new NetConnection();
fl_NC.connect(null);    

var fl_NS:NetStream = new NetStream(fl_NC);
fl_NS.client = {};

var fl_Vid:Video = new Video( 300, 600 );
fl_Vid.attachNetStream(fl_NS);
addChild(fl_Vid);

var theVid = "http://ift.tt/1NLdJBA angle_VE4.mp4";

fl_NS.play(theVid);

fl_NS.addEventListener(NetStatusEvent.NET_STATUS, NCListener); 
function NCListener(e:NetStatusEvent){ 
  if (e.info.code == "NetStream.Buffer.Empty") { 
    fl_NS.play(theVid); 
  } 
}
;

How to create a globe chart in adobe flex?

I'm new to flex technology. I need to develop a globe like chart in adobe flex. Is it possible ? Can someone help me on this? Any Suggestions. An example for my scenario will be something like this :

Example : http://ift.tt/1q6Sr4p

Thanks in Advance!!

Stage.RESIZE : Is it possible to run this example in a browser?

Is it possible to run this simple code in a browser? In the .swf all seems to work fine, but I'm unable to resize the .swf in a browser... The stage is not resizing in an HTML page. Through the .swf flile it works like a charm. Do somebody have an idea about this issue?

package com{
    import flash.display.Graphics;
    import flash.display.MovieClip;
    import flash.display.Stage;
    import flash.display.StageAlign;
    import flash.display.StageQuality;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.text.TextField;

public class Main extends MovieClip{
    private static const ORANGE:int = 0xff9900;
    var bg:MovieClip;
    var bg_mask:MovieClip;
    var marginx:int = 10;
    var marginy:int = 10;
    var display:MovieClip;
    var displayTextField:TextField;
    var ellipseWidth:int = 90;
    var ellipseHeight:int = 90;
    public function Main(){
        super();
        bg = new MovieClip();
        bg_mask = new MovieClip();
        display = new MovieClip();
        displayTextField = new TextField();
        this.addChild(bg);
        this.addChild(bg_mask);
        this.addChild(display);
        this.display.addChild(displayTextField);
        displayTextField.text = "";
        displayTextField.x = ellipseWidth/Math.PI;
        displayTextField.y = ellipseHeight/Math.PI;
        stage.align = StageAlign.TOP_LEFT;  // or StageAlign.TOP
        stage.scaleMode = StageScaleMode.NO_SCALE;
        drawBackground();
        display.mask = bg_mask;
        addListeners();
    }
    private function drawBackground(thickness:int=1,lineColor:int=0x000000,lineAlpha:Number=0.5,fillColor:int=ORANGE,fillAlpha:Number=0.5):void{
        var g:Graphics = bg.graphics;
        g.clear();
        g.lineStyle(thickness,lineColor,lineAlpha);
        g.beginFill(fillColor,fillAlpha);
        g.drawRoundRect(marginx,marginy,this.stage.stageWidth-marginx*2,this.stage.stageHeight-marginy*2,ellipseWidth,ellipseHeight);
        g.endFill();
    }
    private function drawMask():void{
        var g:Graphics = bg_mask.graphics;
        g.clear();
        g.lineStyle(1,0x000000,0.3);
        g.beginFill(0xcccccc,0.1);
        g.drawRoundRect(marginx,marginy,this.stage.stageWidth-marginx*2,this.stage.stageHeight-marginy*2,90,90);
        g.endFill();
    }
    private function addListeners():void{
        stage.addEventListener(Event.ADDED,updateLabel);
        stage.addEventListener(Event.RESIZE,updateLabel);
    }
    private function updateLabel(e:Event):void{
        updateDisplay();
        drawBackground();
        drawMask();
    }
    private function updateDisplay():void{
        var tf:TextField = displayTextField;
        tf.text = ("{" + this.stage.stageWidth + ";" + this.stage.stageHeight + "}");
    }
}

}

Lose data in draggable List with nested ItemRenderers

I am suffering from this problem for a few days. There is a List in which you can drag items.

[Bindable] public static var posts:ArrayCollection = new ArrayCollection();
[Bindable] private var dragit:Boolean = false;
protected function lst_itemClickHandler(evt:ItemClickEvent):void {
                if (evt.label == 'mousedown') {
                    dragit = false;
                    return;
                }
                if (evt.label == 'mouseup') {
                    dragit = true;
                    return;
                }
            }
<s:List id="list" width="100%" height="100%" dataProvider="{posts}" itemRenderer="postIR" selectedIndex="0" dragEnabled="{dragit}" dragMoveEnabled="true" dropEnabled="true" useVirtualLayout="false"/>

This list have an item renderer (postIR) as part of which buttons, images, TextArea and another Tile List with his item renderer - socIR. Here is postIR:

<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ift.tt/rYUnH9" 
                xmlns:s="library://ns.adobe.com/flex/spark" 
                xmlns:mx="library://ns.adobe.com/flex/mx" 
                xmlns:c="*"
                autoDrawBackground="true" creationComplete="itemrenderer1_creationCompleteHandler(event)" maxHeight="120">
    <fx:Script>
        <![CDATA[
            [Bindable] private var index:int;
            [Bindable] private var socDP:ArrayCollection;
protected function itemrenderer1_creationCompleteHandler(event:FlexEvent):void
            {
                index = ((this.owner as List).dataProvider as ArrayCollection).getItemIndex(data);

                socDP = Copypaste.socialVector[index] as ArrayCollection;
                soc.addEventListener(ItemClickEvent.ITEM_CLICK, soc_itemClickHandler);
            }
//Deleted some code
]]>
    </fx:Script>
    <c:CheckList id="soc" width="100%" height="100%" itemRenderer="socIR" mouseDown="txt_mouseDownHandler(event)" mouseUp="soc_mouseUpHandler(event)"
            dataProvider="{socDP}" allowMultipleSelection="true" useVirtualLayout="false" click="soc_clickHandler(event)">
        <c:layout>
            <s:TileLayout requestedColumnCount="3" verticalAlign="top" padding="5"/>
        </c:layout>
    </c:CheckList>
    //Deleted some code
</s:ItemRenderer>

Here is socIR:

<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ift.tt/rYUnH9" 
                xmlns:s="library://ns.adobe.com/flex/spark" 
                xmlns:mx="library://ns.adobe.com/flex/mx" 
                autoDrawBackground="true" click="itemrenderer1_clickHandler(event)" creationComplete="itemrenderer1_creationCompleteHandler(event)">
    <s:layout>
        <s:HorizontalLayout verticalAlign="middle" padding="5"/>
    </s:layout>
    <s:states>
        <s:State name="normal"/>
        <s:State name="selected"/>
    </s:states>
    <fx:Script>
        <![CDATA[

            protected function itemrenderer1_clickHandler(event:MouseEvent):void
            {
                if (this.selected) {
                    data.selected = true;
                } else {
                    data.selected = false;
                }   

                var parentList:List = owner as List;
                var e:ItemClickEvent = new ItemClickEvent(ItemClickEvent.ITEM_CLICK, true);
                e.item = data;
                e.index = parentList.dataProvider.getItemIndex(data);
                e.label = "selected";
                dispatchEvent(e); 
            } 

             override public function set data(value:Object):void
            {
                super.data = value;
                 if (value.selected) {
                    data.selected = true;
                } else {
                    data.selected = false;
                }  
            }  

            protected function itemrenderer1_creationCompleteHandler(event:FlexEvent):void
            {
                if (data.selected == 1) {
                    this.selected = true;
                } else {
                    this.selected = false;
                }
            }
        ]]>
    </fx:Script>
    <s:CheckBox id="socCheck" selected.selected="true" selected.normal="false" mouseEnabled="false"/>
    <s:Image source="{'images/socialicons/' + data.icon}"/>
    <s:Label text="{data.label}"/>
</s:ItemRenderer>

Everything works fine until I need to drag an items in main List. Selected items in socIR or disappear or randomly shuffled. I used a variety of methods - to store data when changing items in the main class in the vector for each itemrenderers - public static var socialVector:Vector. = new Vector.(); , but it only adds to the confusion. I experimented with useVirtualLayout, but it did not help. Please any advice how to avoid issue with data loss when drag an item. Thanks.

PS so looks my list enter image description here

Flash-position of small circle keep changing when i click "Resume"

I am trying to make small circles moving inside a big circle and also having buttons to pause,resume and reverse it. But when i pause and resume it, it will change the small circle's position but i want it to stay at the original position. Is there anyway to do it? and also is there a way to make reverse the direction when i click?(eg. starting is cw when i click "reverse" it will turn anti-cw and when i click "reverse" again it will go cw)

This is my code for action layer:

var Rec:Number=1;

stage.addEventListener(Event.ENTER_FRAME,EntFrame);
function EntFrame(e:Event):void
{
if (Rec >= 1)
{
    CircleL.rotation-= 2;
}
else if(Rec <= -1)
{
    CircleL.rotation+=2;
}
}

var twoPI = 2 * Math.PI;
var circleSNum1:Number = Math.random();
var circleSNum2:Number = Math.random();
var circleSNum3:Number = Math.random();
var circleSNum4:Number = Math.random();
var circleSNum5:Number = Math.random();
function randomRange(minNum:Number, maxNum:Number):Number 
{
return (Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum);
}


var radius = randomRange(10, 90);

function move(event:Event):void{


CircleL.CircleS1.x = Math.cos(circleSNum1 * twoPI) * radius;
CircleL.CircleS1.y = Math.sin(circleSNum1 * twoPI) * radius;

CircleL.CircleS2.x = Math.cos(circleSNum2 * twoPI) * radius;
CircleL.CircleS2.y = Math.sin(circleSNum2 * twoPI) * radius;

CircleL.CircleS3.x = Math.cos(circleSNum3 * twoPI) * radius;
CircleL.CircleS3.y = Math.sin(circleSNum3 * twoPI) * radius;

CircleL.CircleS4.x = Math.cos(circleSNum4 * twoPI) * radius;
CircleL.CircleS4.y = Math.sin(circleSNum4 * twoPI) * radius;

CircleL.CircleS5.x = Math.cos(circleSNum5 * twoPI) * radius;
CircleL.CircleS5.y = Math.sin(circleSNum5 * twoPI) * radius;
}
addEventListener(Event.ENTER_FRAME,move);

Pause.addEventListener(MouseEvent.CLICK, clickPause);
function clickPause(Event:MouseEvent):void{
gotoAndStop("Pause");
Rec=0
}

Resume.addEventListener(MouseEvent.CLICK, clickResume);
function clickResume(Event:MouseEvent):void{
gotoAndStop("Resume");
Rec=1
}

Reverse.addEventListener(MouseEvent.CLICK, clickReverse);
function clickReverse(Event:MouseEvent):void{
gotoAndStop("Reverse");
Rec=-1
}

When i test it is this position

After i click "pause" and "resume" the position of small circle changed

dimanche 24 avril 2016

As3 jumping collision issue

I have successfully made my character jump and but have only perfect collision on the top of the platform but when it hits the bottom of the floating platforms, it goes through the platforms and the player doesn't fall off the edge of these platforms. Instead he runs on the y axis of the instances. Also, when the game initially starts, the player is running in mid air on a specific y coordinate. Is there anyway i can reverse the issues?

 import flash.events.KeyboardEvent;
 import flash.events.Event;
 import flash.text.engine.EastAsianJustifier;   
 import flash.sensors.Accelerometer;

 var Key:KeyObject = new KeyObject(stage);//Help the stage checks for keypressed objects          
 //Initialized variable integers
 var hsp:Number = 0;// horizontal speed
 var vsp:Number = 0;// vertical speed
 var grav:Number = 2;//Gravity
 var fric:Number  = 4//Friction

 //Arrays list for platforms


//All Booleans
var lDown:Boolean = false;
var rDown:Boolean = false;
var jumped:Boolean = false;
var attacking:Boolean = false;

warMage.gotoAndStop("idleWarmage");//Initially starts at idle state
stage.addEventListener(Event.ENTER_FRAME, keyPressed);//Listens for buttons   pressed
stage.addEventListener(Event.ENTER_FRAME, gameloop);// The physics applied  to character
stage.addEventListener(Event.ENTER_FRAME, platformCollision);

function keyPressed(e:Event):void
{
if(Key.isDown(Key.LEFT))//If we pressed the left arrow button
    {
        lDown = true;//Condition to check if player is in running state
        if(lDown = true)//If we are running left
          {
             warMage.x -= 15;//Move left
             warMage.gotoAndStop("RunWarmage");//Play the running animation
             warMage.scaleX = -1;//Flip the image scale
          }
    }else if(Key.isDown(Key.RIGHT))//If we pressed the right arrow button
    {
        rDown = true;//Condition to check if player is in running state
        if(rDown = true)//If we are moving right
          {
            warMage.x += 15;//Move the position right
            warMage.gotoAndStop("RunWarmage");//Play the animation
            warMage.scaleX = 1//Face right
          }
    }else if(Key.isDown(Key.SPACE))//If we press the spacebar
         {
             warMage.gotoAndStop("AttackWarmage");//Play teh attack animation
             warMage.x += 5; //Lunge right
             if(warMage.scaleX == -1)//If we are initially facing left
                 {
                     warMage.x -= 10;//Lunge left
                 }

         }else if(Key.isDown(Key.UP) || jumped == true)//If we press the up arrow or we've jumped
          {

              vsp = -25;;//vertical speed goes up to 20
              jumped = true;//We know that player has jumped
              warMage.gotoAndStop("JumpWarmage");//Play teh jump animation

          }else if(jumped == false)//If we're not jumping
            {
                warMage.gotoAndStop("idleWarmage");//Return to idle position
            }
  }

 function gameloop(e:Event)//This checks the laws per frame
 {

     if(warMage.x < 0)//Sets room boundaries for left
    {
        warMage.x = 0;
    }
if(warMage.x > 1000)//Sets room boundaries for right
    {
        warMage.x = 1000;   
    }

 }

 function platformCollision(e:Event):void//Collision for the platforms
 {
          vsp += grav;
          if(!multiplePlatforms.hitTestPoint(warMage.x,warMage.y , true) && jumped == true)
              {

                  grav++;
                  warMage.y += vsp;
                  warMage.gotoAndStop("JumpWarmage");//Play teh jump animation
              }
          for(var i:Number = 0;i < 34; i++)
          {
          if(multiplePlatforms.hitTestPoint(warMage.x,warMage.y , true))//Check if the player hits any platforms in the array
              {
                  warMage.y --;//Place the character a pixel above the platforms
                  grav = 0;//Gravity isnt applied
                  vsp = 0;
                  jumped = false;

              }
          }       
          }

Using a list component and a MouseEventlistener

btn.addEventListener(MouseEvent.CLICK, leggTilListe)

function leggTilListe(evt:MouseEvent)
{


var gulost:Object = new Object;
gulost.navn = "Gulost";
gulost.kcal = Number(53) * numStepOst.value;
gulost.protein = Number(4) * numStepOst.value;
gulost.fett = Number(4.2) * numStepOst.value;
gulost.karbohydrater = Number(0) * numStepOst.value;
gulost.label = String(numStepOst.value) + " " + "skiver ost";

liste.addItem(gulost);

If the numeric stepper value is 2 then this will add " 2 skiver ost" to the list component. If i click the button again it will add another row of "2 skiver ost" beneath the previous one. How do I get these to stack instead of creating a seperate label?

In app purchase in IOS with Milkman Plugin

First time that I'm trying to put an in-app function in my AIR app.

Here's what I did. I don't really know if the "buy" fonction should be called like that pledgeBtn.addEventListener(MouseEvent.CLICK,giveAPledge, false, 0, true); ?

I'd like the user to click on the pledgeBtn and it would open the IOS purchase window.

Like that :

    function giveAPledge(event:MouseEvent):void{
var productIdList:Vector.<String>=new Vector.<String>();
productIdList.push("***.*****.****.help1");

StoreKit.storeKit.loadProductDetails(productIdList);

// listen for a response from loadProductDetails():
StoreKit.storeKit.addEventListener(StoreKitEvent.PRODUCT_DETAILS_LOADED,onProducts);

function onProducts(e:StoreKitEvent):void{

for each(var product:StoreKitProduct in e.validProducts){
trace("ID: "+product.productId);
trace("Title: "+product.title);
trace("Description: "+product.description);
trace("String Price: "+product.localizedPrice);
trace("Price: "+product.price);
}
trace("Loaded "+e.validProducts.length+" Products.");
if (e.invalidProductIds.length>0)
{
trace("[ERR]: invalid product ids:"+e.invalidProductIds.join(","));
}
}

StoreKit.storeKit.addEventListener(StoreKitErrorEvent.PRODUCT_DETAILS_FAILED,
onProductsFailed);
function onProductsFailed(e:StoreKitErrorEvent):void
{
trace("error loading products: "+e.text);
}

// this call purchases a product. The second parameter is an
// optional quantity- if you want to purchase more than one item at a time.

StoreKit.storeKit.purchaseProduct("nc.cocogeek.mareesNC.help1",1);



// this event is fired when a purchase goes through ok
StoreKit.storeKit.addEventListener(StoreKitEvent.PURCHASE_SUCCEEDED,onPurchaseSuccess);

function onPurchaseSuccess(e:StoreKitEvent):void {
// your app is now responsible for 'giving' the user whatever they bought!
thxWindow.visible=true;
pledgeBtn.visible=false;
allPuzzles.meteo.pledgeGiven = true;
thxWindow.closePledge.addEventListener(MouseEvent.CLICK, closePledge, false, 0, true);
}

// this event is fired when a purchase gets cancelled
StoreKit.storeKit.addEventListener(StoreKitEvent.PURCHASE_CANCELLED,onPurchaseCancel);
function onPurchaseCancel(e:StoreKitEvent):void
{
trace("the user decided not to buy: "+e.productId);
}

// listen for ERROR response from purchaseProduct():
StoreKit.storeKit.addEventListener(StoreKitErrorEvent.PURCHASE_FAILED,
onPurchaseFailed);
function onPurchaseFailed(e:StoreKitErrorEvent):void
{
trace("error purchasing product: "+e.text);
}




} 

Is there something wrong in this code ?

autosizing movieclips to match text size (AS3)

I'm looking to add a specialized border around some dynamic text. A special type of border that filters just can not produce

So I need this border to match the length of the dynamic text. Unfortunately this code is not working

thistext.autoSize = TextFieldAutoSize.LEFT;
border.width = thistext.width;

What happens is, the border width is set to the initial starting width of the text and is not changed as the width of the text changes

Any ideas on how I can make this work?

Flash Builder Creative Cloud Error Messages When Testing Simple Program

I am using Flash Builder Creative Cloud (4.7) with Actionscript Project. The project uses AIR SDK 3.4. I am using Starling framework to complete a tutorial for learning. I set up Starling correctly per tutorial. However, when I use this test code from

http://ift.tt/1XPPQhR

I get 53 error messages. The 53 error messages do not appear until I create the Game class. I have changed html file as stated by tutorial to "params.wmode = "direct". I also changed my web browser in the IDE settings to work from Firefox. I do not get any error messages directed from Firefox due to flash errors. So I do not believe it is an issue from not installing the debugger from adobe.

This site (http://ift.tt/1XPPQhR) also states that I should do this:

"If we're talking about an AIR project, you will need to edit the AIR application descriptor, which is probably called “Project-app.xml” or similar, depending on your project name. Find and update the “renderMode” XML tag (which might be commented out) to the value “direct”."

Find this: </renderMode> -->

Replace with this: direct

I am also unsure where to find “Project-app.xml” and replace as the above directions state. This is the only other step I have not tried in my troubleshooting.

I am unsure what is causing the 53 error messages when I run the simple test program.

Some of the 53 errors state this: Access of possibly undefined property backBufferHeight through a reference with static type Context3D. Painter.as /Spacer/code/starling/rendering line 126 Flex Problem

Others state this:

Call to a possibly undefined method insertAt through a reference with static type Vector.. DisplayObjectContainer.as /Spacer/code/starling/display line 238 Flex Problem

.

best way to convert ActionScript1,2 to AS3 fast and easy

need to convert the AS1 to AS3

> Scene 1, Layer 'Action Layer', Frame 1, Line 1, Column 1    1120: Access of undefined property url.
> Scene 1, Layer 'Action Layer', Frame 1, Line 2, Column 1    1180: Call to a possibly undefined method loadVariablesNum.
> Scene 1, Layer 'Action Layer', Frame 1, Line 2, Column 18   1120: Access of undefined property url.
> Scene 1, Layer 'Action Layer', Frame 1, Line 3, Column 1    1120: Access of undefined property _root.
> Scene 1, Layer 'Action Layer', Frame 243, Line 1, Column 19 1120: Access of undefined property _root.

frame 1

> url = "xxx";
> loadVariablesNum(url + "_main.html", 0);
> _root.link = 1;
> stop ();

frame 243

> pages.gotoAndStop(_root.link);

my best regards.

Need help to make a RegExp filter to replace redundant Parentheses

For the past few days (weeks, months, years maybe if you count my on-again off-again search and attempts) I've been trying to make or find a RegEx filter to help me remove all redundant parentheses found in my code.

A worst case scenario of what the regex filter will have to deal with is attached. As is a best case scenario

return ((((((((((((((((((((((((((getHumanReadableLine("avHardwareDisable") + getHumanReadableLine("hasAccessibility")) + getHumanReadableLine("hasAudio")) + getHumanReadableLine("hasAudioEncoder")) + getHumanReadableLine("hasEmbeddedVideo")) + getHumanReadableLine("hasIME")) + getHumanReadableLine("hasMP3")) + getHumanReadableLine("hasPrinting")) + getHumanReadableLine("hasScreenBroadcast")) + getHumanReadableLine("hasScreenPlayback")) + getHumanReadableLine("hasStreamingAudio")) + getHumanReadableLine("hasStreamingVideo")) + getHumanReadableLine("hasTLS")) + getHumanReadableLine("hasVideoEncoder")) + getHumanReadableLine("isDebugger")) + getHumanReadableLine("language")) + getHumanReadableLine("localFileReadDisable")) + getHumanReadableLine("manufacturer")) + getHumanReadableLine("os")) + getHumanReadableLine("pixelAspectRatio")) + getHumanReadableLine("playerType")) + getHumanReadableLine("screenColor")) + getHumanReadableLine("screenDPI")) + getHumanReadableLine("screenResolutionX")) + getHumanReadableLine("screenResolutionY")) + getHumanReadableLine("version")));

return ((((name + ": ") + Capabilities[name]) + "\n"));

As you can see there's... a few... redundant parentheses in my code. Been working actively with these for a very long time but have always tried to clean up what I come across and been trying to find a faster way to do it.

So one example of how the "clean" code would look, I'm hoping at least!

return (name + ": " + Capabilities[name] + "\n");

return name + ": " + Capabilities[name] + "\n";

Either one is acceptable to be completely honest as long as the code itself doesn't mock up and change how it works.

I greatly appreciate any answers anyone can give me. Please don't Mock what I do or am trying to achieve. I haven't worked much with regex or similar things before...

And just to humour you... Here's my "RegExp" for my "clean" example

(return) ({1,}((.[^)]{1,}))(.{1,}))(.{1,})){1,}

$1 $2 $3 $4 // output

oh... Forgot to mention

(!(testCrossZ()))

Might appear at times as well but those aren't as big of an issue to clean up manually if needed.

P.S... There is a "LOT" of occurances of the redundant parentheses... Like... Maybe thousands... Most likely thousands.

how to move object in the direction it is bring hit in(as3)?

I have a ball and a player.What should I do to move ball in the direction in which the player hits it?I tried comparing x and y of player and ball. But it didn't work.

Flash- circle not rotating inside another circle

I am trying to make the small circles to be able to rotate inside the large circle. But what i got is that the small circles are rotating outside the large circle. Here is my code:

import flash.events.Event;
import flash.events.MouseEvent;

var Rec:Number=-1;

stage.addEventListener(Event.ENTER_FRAME,EntFrame);
function EntFrame(e:Event):void
{
if (Rec == -1)
{
    CircleL.rotation-= 2;
}
}

var cenX = CircleL.x;
var cenY = CircleL.y;

var ccStep = .01;
var twoPI = 2 * Math.PI;
var circleSNum1:Number = Math.random();
var circleSNum2:Number = Math.random();
var circleSNum3:Number = Math.random();
var circleSNum4:Number = Math.random();
var circleSNum5:Number = Math.random();
function randomRange(minNum:Number, maxNum:Number):Number 
{
return (Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum);
}

var radius1 = randomRange(10, 90);
var radius2 = randomRange(10, 90);
var radius3 = randomRange(10, 90);
var radius4 = randomRange(10, 90);
var radius = randomRange(10, 90);

function move(event:Event):void{


CircleL.CircleS1.x = cenX + Math.cos(circleSNum1 * twoPI) * radius;
CircleL.CircleS1.y = cenY + Math.sin(circleSNum1 * twoPI) * radius;

CircleL.CircleS2.x = cenX + Math.cos(circleSNum2 * twoPI) * radius2;
CircleL.CircleS2.y = cenY + Math.sin(circleSNum2 * twoPI) * radius2;

CircleL.CircleS3.x = cenX + Math.cos(circleSNum3 * twoPI) * radius3;
CircleL.CircleS3.y = cenY + Math.sin(circleSNum3 * twoPI) * radius3;

CircleL.CircleS4.x = cenX + Math.cos(circleSNum4 * twoPI) * radius4;
CircleL.CircleS4.y = cenY + Math.sin(circleSNum4 * twoPI) * radius4;

CircleL.CircleS5.x = cenX + Math.cos(circleSNum5 * twoPI) * radius1;
CircleL.CircleS5.y = cenY + Math.sin(circleSNum5 * twoPI) * radius1;
}
addEventListener(Event.ENTER_FRAME,move);

Here is how it looks like when i run it

How to request an Externalized Object in FluorineFx for C#?

currently I am developing C# application that sends amf packet to server using FluorineFx.

It works fine, but I found out strange datatype called Externalized Object.

I found out that FluorineFX Contains a class named ArrayCollection but i dont now how i need to use it and the bigger problem, how i can send it as externalized object

This is the capture file from Charles and I have re-produce those Externalized Objects.

Pic

i home someone can help me!

cheers, Niklas

samedi 23 avril 2016

Is it possible to use the Milkman iOS In-App Purchase Extension for Adobe AIR for pledge?

I've got an AIR app (AS3) and I'd like to add a button that allows the user to give money to our company.

I saw the Milkman Plugin "http://ift.tt/1r95CtQ" for putting a in app feature in an AIR app.

Can I use it for this purpose (pledge) ? Do you think I should use it or something else ?

Thx for your help

I have copied a synthesizer filter into code, it works perfectly at wrong frequencies

I have copied a filter from a digital synth. Using the same frequency and input variables, it zeroes sound at the intended heard frequency and lets it through when frequency control is high.

All the B0 B1 B2... parameters were easy and 100% fine, the rest of the filter code seems okay, from in this diagram:

Z-1 is a sample delay, -->A value is just cosmetic

I wrote this code: //reaktor core static 2 pole biquad band pass

    static var in2 = 0.0; // input delayed once
    static var in3 = 0.0; // input delayed 2 samples

    static var out2 = 0.0; // output delayed once
    static var out3 = 0.0; // output ut delayed 2 samples

    static function BP( in1: float, f: float, res:float , srr : float) :float{

        if (f > srr/2.125  )f = srr/2.125   ;
        if (f < srr/24576.0 )f = srr/24576.0 ;

        var omega = f * ( 6.28319 / srr ) ; 
        var mysin   = Rsine(omega);
        var mycos  = Rcos(omega);


        var alpha = (1.0-res)  * mysin;

        var s1 = mysin * 0.5 ;
        var s2 = 1 + alpha ;
        var s3 = 1 - alpha  ;

        var b0 = s1  ;//not optimized
        var b1 = 0.0 ;
        var b2 = -s1 ;
        var a0 = s2  ;
        var a1 = -mycos * 2.0 ;
        var a2 = s3  ;

        //have tested the previous coefficients and sine/cos function 100% OK
        //the next 12 lines are the only place where an error could be.    
        //Otherwise i simply dont understand what the difference is.
        var za0 = 1.0 / a0 ;  

        var zb0  = za0 * b0 * in1 ;
        var zb1  = za0 * b1 * in2 ;
        var zb2  = za0 * b2 * in3 ;
        var za1  = -za0 * a1 * out2 ;
        var za2  = -za0 * a2 * out3 ;

        var out = zb0 + zb1 + zb2 + za1 + za2 ;

        in2   = in1     ; //delay
        in3   = in2     ;
        out2 = out     ;
        out3 = out2   ;

        return out      ;
    }

    // ' Default   = 7.4436643444641959e-006
    // ' Formatted = 0.0000074436643444641959

    static function Rsine(  input:float ):float
    {
        var s1 = input*input;
        var s2 = s1 * -0.0000000239; //e008
        var s3 = s2 + 0.0000027526; // 2.7526E-006
        var s4 = s3 * s1; 
        var s5 = s4  -0.000198409; 
        var s6 = s5 * s1;   
        var s7 = s6 + 0.00833333;       
        var s8 = s7 * s1; 
        var s9 = s8  -0.166667; 
        var s10 = s9 * s1+1; 
        return s10 * input;
    }

    static function Rcos(  input:float ):float
    {
        var s1 = input*input;
        var s2 = s1 * -0.0000002605; //e007
        var s3 = s2 + 0.0000247609; // 2.7526E-006
        var s4 = s3 * s1; 
        var s5 = s4 - 0.00138884; 
        var s6 = s5 * s1;   
        var s7 = s6 + 0.0416666;        
        var s8 = s7 * s1; 
        var s9 = s8 - 0.499923; 
        var s10 = s9 * s1+1; 
        return s10 ;
    }

full diagram is here, however i have debug/checked all except above picture. enter image description here

The code seems to be ok, i have read it over 12 times. i am trying to figure how else i can print where the difference happens because i cannot see audio rate values happening in the schematic version.

i even made a pic of the error filter response as a graph of time(y) and freq(x) it lets through the 310hz sound when the frequency is set to 1000.

enter image description here Any suggestions would be greatly appreciated.

Puzzle Game as3

I have a problem with my puzzle game as there is an image which appears when a button is pressed. The continue button should go to the next puzzle but it only works when the image is on the screen and when its not on screen the button does not work

this is the code for the continue button

continuelvl3.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_23);

function fl_ClickToGoToAndStopAtFrame_24(event:MouseEvent):void { removeChild(Elsa);
gotoAndStop(15); }

Any help would be appreciated thank you

Actionscript 3 jumping animation issue

Im having this issue where when I press the up key for my player to jump, the player goes to the jump animation but immediately returns to the idle animation while in mid air. My question is how can i get the player to hold the jump animation and then return to idle once he reaches the ground.

enter code hereimport KeyObject;
      import flash.events.Event;

      var hsp = 15; 
      var vy:Number = 0;//Vertical speed variable
      var grav:Number = 20;//gravity variable
      var jumped:Boolean = false;//Checking if we jumped, false means 
                       //not jumping

      warMage.gotoAndStop("idleWarmage");
     //Player initially starts with idle animation

    var Key:KeyObject = new KeyObject(stage);//Adds the new method for keyboard check

   //The stage always checks for these events and functions
   stage.addEventListener(Event.ENTER_FRAME, onEnter);
   stage.addEventListener(Event.ENTER_FRAME, gameloop);

   function onEnter(e:Event):void
   {   

       if(Key.isDown(Key.RIGHT))//Check if right arrow is pressed
       {
         warMage.x += 15;//Move at this speed
         warMage.gotoAndStop("RunWarmage");//Play this animation
         warMage.scaleX = 1;//Keep the image svale to right
       } else if(Key.isDown(Key.LEFT))//Check if left arrow is pressed
         {
           warMage.x -= 15;//Move left
           warMage.scaleX = -1;//Flip the image
           warMage.gotoAndStop("RunWarmage");//Play this animation
         }else if(Key.isDown(Key.UP))//Check if spacebar is pressed
            {
                if(!jumped)//the boolean is true
                {
                   vy -= 70;//Player jumps 50 pixels upward
                   jumped = true;
                   warMage.gotoAndStop("JumpWarmage");//Play the jump animation


            }

        }else
        {
            warMage.gotoAndStop("idleWarmage");//Return to idle state
        }

       }


     function gameloop(e:Event):void
     {
        if(warMage.x + 36.55 < 0)//Setting room boundaries
    {
       warMage.x = 0;//Setting boundary on right
    }
if(warMage.x + 55.22 > 999)//Setting boundary on left
    {
       warMage.x = 999;
    }

vy += grav;
if(!ground.hitTestPoint(warMage.x + 36.55, warMage.y + 55.22, true))//If we're not on a surface
    {
         warMage.y += vy;//apply gravity to the player  
    }
for(var i = 0;i < 109; i++)
    {   //If the warmage is on the ground
        if(ground.hitTestPoint(warMage.x + 36.55, warMage.y + 55.22, true))
        {
            warMage.y--;//A pixel above the platform
            vy = 0;//Gravity isn't applied on the player
            jumped = false;//We're not jumping

        }
    }
}

Actionscript 3 Code Keeps Giving Error 1009

I managed to apply this code, which fetches a text file and places it into a dynamic text box. Here's the code:

<code>
// reference code from permadi

import flash.events.MouseEvent;
import flash.net.FileReference;
import flash.net.FileFilter;
import flash.utils.ByteArray;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.display.MovieClip;
import fl.controls.ProgressBarMode;
import fl.controls.TextArea;
var mFileReference:FileReference;
stop();
// Setup button to handle browsing
browseButton.buttonMode = true;
browseButton.mouseChildren = false;
browseButton.addEventListener(MouseEvent.CLICK, onBrowseButtonClicked);
// Hide progress bar;
progressBar.visible = false;
// This function is called when the BROWSE button is clicked.
function onBrowseButtonClicked(event:MouseEvent):void
{
    trace("onBrowse");
    mFileReference=new FileReference();
    mFileReference.addEventListener(Event.SELECT, onFileSelected);
    var swfTypeFilter:FileFilter = new FileFilter("Text Files","*.txt; *.html;*.htm;*.php");
    var allTypeFilter:FileFilter = new FileFilter("All Files (*.*)","*.*");
    mFileReference.browse([swfTypeFilter, allTypeFilter]);
}
// This function is called after user selected a file in the file browser dialog.;
function onFileSelected(event:Event):void
{
    trace("onFileSelected");
    // This callback will be called when the file is uploaded and ready to use
    mFileReference.addEventListener(Event.COMPLETE, onFileLoaded);

    // This callback will be called if there's error during uploading;
    mFileReference.addEventListener(IOErrorEvent.IO_ERROR, onFileLoadError);

    // Optional callback to track progress of uploading;
    mFileReference.addEventListener(ProgressEvent.PROGRESS, onProgress);

    // Tells the FileReference to load the file;
    mFileReference.load();

    // Show progress bar;
    progressBar.visible = true;
    progressBar.mode = ProgressBarMode.MANUAL;
    progressBar.minimum = 0;
    progressBar.maximum = 100;

    browseButton.visible = false;
}

// This function is called to notify us of the uploading progress
function onProgress(event:ProgressEvent):void
{
    var percentLoaded:Number = event.bytesLoaded / event.bytesTotal * 100;
    trace("loaded: "+percentLoaded+"%");
    progressBar.setProgress(percentLoaded, 100);
}

// This function is called after the file has been uploaded.;
function onFileLoaded(event:Event):void
{
    var fileReference:FileReference = event.target as FileReference;

    // These steps below are to pass the data as DisplayObject 
    // These steps below are specific to this example.
    var data:ByteArray = fileReference["data"];
    codeText.text = data.toString();
    browseButton.visible = true;
    progressBar.visible = false;
    mFileReference.removeEventListener(Event.COMPLETE, onFileLoaded);
    mFileReference.removeEventListener(IOErrorEvent.IO_ERROR, onFileLoadError);
    mFileReference.removeEventListener(ProgressEvent.PROGRESS, onProgress);
}

function onFileLoadError(event:Event):void
{
    // Hide progress bar
    progressBar.visible = false;
    browseButton.visible = true;
    mFileReference.removeEventListener(Event.COMPLETE, onFileLoaded);
    mFileReference.removeEventListener(IOErrorEvent.IO_ERROR, onFileLoadError);
    mFileReference.removeEventListener(ProgressEvent.PROGRESS, onProgress);

    trace("File load error");
}
</code>

It works fine, I added the loaded file to a string, but now I want Flash to read the string and send it to the related frames corresponding to it. Here's the code:

<code>stage.addEventListener(Event.ENTER_FRAME, updateFunction);
function updateFunction(e:Event)
{
    if (codeText.text == "Preference 01")
    {
        gotoAndStop(50);
    }
    else if (codeText.text == "Preference 02")
    {
        gotoAndStop(51);
    }
    else if (codeText.text == "Preference 03")
    {
        gotoAndStop(52);
    }
    else if (codeText.text == "Preference 04")
    {
        gotoAndStop(53);
    }
    else
    {
        gotoAndStop(54);
    }
}
</code>

I Keep Getting Error 1009 About A Null Object, I Tried For Hours But I Think I Need Some Help.

AS3 bytearray in C#

im trying to port a as3 code to c#.

I want to send an amf request which contains an bytearray which i want to port from as3 to c#.

this function creates the array:

public static function serialize(param1:Object) : ByteArray
  {
     var _loc2_:ByteArray = new ByteArray();
     _loc2_.writeObject(param1);
     return _loc2_;
  }

i recorded this array in an amf request using charles web debugger and i got this:

pic

(0a0b011d4d6f7669654163746f7252656c730a0743666c65782e6d6573736167696e672e696f2e4172726179436f6c6c656374696f6e090d010a531b4d6f7669654163746f7252656c0f4d6f76696549640b5374617465194669677572654e756d6265721f4d6f7669654163746f7252656c49640f4163746f724964040004000400040004889dfa2d0a0904000400040104000487fa99010a090400040004020400048791f9a20a0904000400040304000487bcd2630a0904000400040404000487edc7580a0904000400040504000487b0a7c317436c6f7468657344617461090d010a0113457965536861646f77011f457965536861646f77436f6c6f72730115436c6f746865734d696e0909010a0123436c6f7468657343617465676f72794964040217436f6c6f72536368656d6501234163746f72436c6f7468657352656c49640541bf3556890000000d536b696e4964040213436c6f74686573496404c8761146696c656e616d6506010b436f6c6f72061f3078333333332c307839393939393913697357656172696e67040107535746063b4d6f766b696e67626972645f323031345f626f797353756974315f64670b5363616c65053fd3333333333333010a011804031a011c0541bf35568a0000001e04022004a73b22060124061130783433366239632804012a0649486970737465725f323031325f4d616c6542617369634a65616e735f6d735f66697865642e053fd3333333333333010a0118040a1a011c0541bf3556870000001e04002004c32122060124065930783030303030302c30783538464630302c30783030423146462c30784646393930302c30784633303046462804012a0633776174657253706c6173685f323031345f73686f65735f6d662e053fd3333333333333010a011804011a011c0541bf3556880000001e04022004c75322060124062330784246383733332c30783845353430452804012a063963616665436f75747572655f323031345f6d616c65486169725f6d662e053fd3333333333333010b4d6f7574680a81733c0f4d6f75746849641b4469616d6f6e647350726963651e1b44656661756c74436f6c6f7273094e616d650d68696464656e1d6c6173744e6577546167446174652a0b50726963650756697015447261676f6e426f6e650b69734e657713736f72746f7264657211446973636f756e74155265674e6577557365720404040004000101020106196d616c655f6d6f7574685f310400040002040004000400040013457965436f6c6f7273062330783333363630302c307830303030303013536b696e436f6c6f7206113135373038383038094e6f73650a8173620d4e6f73654964401e424446482a4a4c4e5052545604050400040001010201060d6e6f73655f3404000400020400040004000400174d6f757468436f6c6f72730625736b696e636f6c6f722c30786363393939390f6163746f72496404889dfa2d074579650a81736e0b4579654964401e424446482a4a4c4e50525456042504000400010102010621457965735f5468654d616e5f3230313304000400030400040004000400010a0112011401160909010a0118040a1a011c0541bdd4aac40000001e04002004c43022060124062330783030303030302c30783333333333332804012a0639526f6164547269705f323031345f626f6f7473556e697365785f464a2e053fd3333333333333010a011804021a011c0541bdd4aac20000001e04012004c82322060124063d3078302c30783636323630612c30786666666666662c30783333333333332804012a062d4d6f7669654e696768745f323031345f7465655f464a2e053fd3333333333333010a011804031a011c0541bdd4aac30000001e04012004c8192206012406073078302804012a063b43616665436f75747572655f323031345f4849676857616973745f464a2e053fd3333333333333010a011804011a011c0541bdd4aac10000001e04012004c47c22060124061130786463626335652804012a06255465656e5f323031345f48616972315f464a2e053fd3333333333333013c0a0d04010400040001010201061d66656d616c655f6d6f7574685f31040004000204000400040004005a062330783636393963632c30783030303030305e06113133333337313636620a11040b04000400010102010619686f6e65795f6e6f73655f3704000400020400040004000400680681086c0487fa99016e0a15042c04000400010102010627457965735f4d6f766965537461725f3230313304000400030400040004000400010a0112011401160907010a011804011a011c0541b9cef9460000001e04002004955e2206012406012804012a0629646563656d6265725f6d616c655f686169725f342e053fd3333333333333010a0118040d1a011c0541bb8ce8cf0000001e04002004d63a2206012406012804012a0635586d617343616c656e6461725f4561726d756666735f323031352e053fd3333333333333010a011804021a011c0541b8d4c8760000001e04012004d5132206012406012804012a06474e69636b656c6f64656f6e5f3130305468696e67735f6769726c7364726573735f464a2e053fd3333333333333013c0a0d04070400040001010201061d66656d616c655f6d6f7574685f33040004000204000400040004005a062330783333363633332c30783030303030305e06113135393731393635620a1104010400040001010201060d6e6f73655f3504000400020400040004000400680625736b696e636f6c6f722c31363736343035376c048791f9a26e0a15042a0400040001010201062d457965735f4769726c4e657874446f6f725f3230313304000400030400040004000400010a011201140116090b010a011804011a011c0541babf61840000001e04022004c7532206012406382804012a063a2e053fd3333333333333010a011804031a011c0541babf61860000001e04022004a73b22060124067c2804012a06322e053fd3333333333333010a0118040a1a011c0541babf61870000001e04022004c64122060124064f30786363303033332c3078302c30786666666666662c30786666666666662c30786666666666662804012a06314d696e69536b38727a5f323031345f536e65616b735f464a2e053fd3333333333333010a011804021a011c0541be8df5220000001e04022004cf7b2206012406012804012a063d6e69636b656c6f64656f6e5f323031355f6d616c65546f705265645f6d662e053fd3333333333333010a0118042d1a011c0541be9619820000001e04002004967c2206012406012804012a062b6a616e5f323031315f6163635f6769726c735f32382e053fd3333333333333013c0a0d040404000400010102010658040004000204000400040004005a065c5e06113136373634303537620a1104040400040001010201060d6e6f73655f3304000400020400040004000400680681286c0487bcd2636e0a1504250400040001010201067204000400030400040004000400010a0112011401160909010a011804021a011c0541bd6c015e0000001e04012004cb3122060124061130786666636366662804012a0639436f756e7472794d616e6f725f323031345f72656463726f705f64672e053fd3333333333333010a011804031a011c0541bd6c015f0000001e04012004c81922060124061130784343454146372804012a067e2e053fd3333333333333010a011804011a011c0541bd6c015d0000001e04012004c47e22060124061130784344423037382804012a062b5465656e5f323031345f506f6e795461696c5f464a2e053fd3333333333333010a0118040a1a011c0541bd6c01600000001e04002004c51522060124063530783135304330362c30784646464646462c30783036303731352804012a063563616d7075735f323031345f756e6973657853686f65735f64672e053fd3333333333333013c0a0d04070400040001010201068114040004000204000400040004005a061130783030303066665e060f39353237313035620a110401040004000101020106811a04000400020400040004000400680625736b696e636f6c6f722c30786161303030306c0487edc7586e0a15042a040004000101020106811e04000400030400040004000400010a0112011401160909010a011804031a011c0541ba352a130000001e04012004ab5222060124063530783030303030302c30786666666666662c30784343434343432804012a06454361726e6976616c4c6f76655f323031325f66656d616c65626f74746f6d735f64672e053fd3333333333333010a011804011a011c0541ba352a110000001e04002004947c22060124061130783333333333332804012a0629646563656d6265725f6d616c655f686169725f312e053fd3333333333333010a0118040a1a011c0541bd75d2a90000001e04012004c64d22060124065930786666666666662c30786666666666662c30786666666666662c30784646464646462c30784646464646462804012a0681222e053fd3333333333333010a011804021a011c0541bd9cf3f40000001e04012004de0d22060124062d3078636366662c3078323936362c30783030303033332804012a06217369645f323031365f746565325f64672e053fd3333333333333013c0a0d04010400040001010201068104040004000204000400040004005a061f3078636366662c30783030303030305e068118620a11040b040004000101020106810a0400040002040004000400040068061130786666303030306c0487b0a7c36e0a15042a040004000101020106811e040004000304000400040004000101)

and i want to get this same byte array in c# so i can send it as an amf request with c#

cheers, niklas