mardi 28 février 2017

Adobe Animate Errors - Building a website with buttons, need assistance please! :)

I'm very new to coding/script and am working on building a website for a class I am enrolled in. I have read manuals, books and even google answers but can't seem to figure out some of the questions I have with Animate CC.

First question is: When building a website on Animate, I have created separate keyframes to represent the pages. Each page gets 1 keyframe. Buttons connect all the pages. If I want to add a motion or shape tween, how do I do so in only one frame?

Second Question: I am unable to connect all the pages with the following code I was given from class....

     stop();

     function button1_clicked(e:MouseEvent):void{gotoAndStop("home"); }   

     function button2_clicked(e:MouseEvent):void{gotoAndStop("about"); }  

     function button3_clicked(e:MouseEvent):void{gotoAndStop("shop"); } 

     function button4_clicked(e:MouseEvent):void{gotoAndStop("cart"); }   

     function button5_clicked(e:MouseEvent):void{gotoAndStop("blog"); } 

     function button6_clicked(e:MouseEvent):void{gotoAndStop("contact"); } 

     button1.addEventListener(MouseEvent.CLICK, button1_clicked);
     button2.addEventListener(MouseEvent.CLICK, button2_clicked);
     button3.addEventListener(MouseEvent.CLICK, button3_clicked);
     button4.addEventListener(MouseEvent.CLICK, button4_clicked);
     button5.addEventListener(MouseEvent.CLICK, button5_clicked);
     button6.addEventListener(MouseEvent.CLICK, button6_clicked);

    function handleClick(pEvent:MouseEvent):void {
     var myFirstVariable=boxOne.text;
         boxTwo.text = " Thank you! We will respond to you within 48 hours." 
     }
     myButton.addEventListener(MouseEvent.MOUSE_UP, handleClick);

Animate keeps giving me the error message of

"TypeError: Error #1009: Cannot access a property or method of a null object reference. at MyWebsite_fla::MainTimeline/frame1()"

and I'm unsure how to fix it.

Lastly, with that code all my buttons aren't seeming to work to connect the pages to one another.

Please, if anyone can help it would be GREATLY appreciated!!!! Thank you all so much.

Oba

swf try to load crossdomain.xml from the other site when is embed directly in that site

i have a basic .swf movie and is hosted in one subdomain example: http://sub.myexample.com/blog/players/movie.swf

and when i try to embed directly in another website just using the direct url, in firebug inspector i see my movie is searching the crosdomain.xml in the external server and return me 404

the other server only need the full path to my swf movie to generate the html output, no need to make html on my side for my movie

i have this in the top of the code of my movie

Security.allowDomain('*');
Security.loadPolicyFile("http://ift.tt/2lQR8Pr");
Security.loadPolicyFile("http://ift.tt/2lU2lNy");
Security.loadPolicyFile("http://ift.tt/2lQUzpc");

this is the content of my crossdomain.xml and i sthe same in the root of my domain, subdomain and folder of my swf

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://ift.tt/1d1B8yI">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" secure="false"/>
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
</cross-domain-policy>

any ideas why is happening this? thanks in advance

Can't move variables outside of a function

function playvideo(path:String, wid:Number=1280, heigt:Number=720):void
{
    var nc:NetConnection = new NetConnection();
    nc.connect(null);
    var ns:NetStream = new NetStream(nc);
    ns.client = this;
    ns.addEventListener(NetStatusEvent.NET_STATUS, statusChanged);
    ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
    SoundMixer.stopAll();
    var vid:Video = new Video(); 
    ns.play(path);
    vid.width = wid;
    vid.height = heigt;
    vid.attachNetStream(ns);
    mc_bg.removeChildAt(0);
    mc_bg.addChild(vid);
}

Greetings, here's my "playvideo" function. whenever I try to move variables outside of function to control the video from elsewhere(for example "vid"), specific movieclips and buttons dissapear(are not shown on the stage). Is that some kind of a bug or am I doing something wrong? Thanks!

How to use the replaceItemAt method for a datagrid in Actionscript 3 Flash to update dataproviders in an array?

In a Flash CS6 project, I have an array with 5 separate dataproviders that supplies the data for an editable datagrid called priceGrid.

 var priceGrid:DataGrid = new DataGrid();
 var enterPriceDataProviderArray:Array = new Array(new DataProvider(), new DataProvider(), new DataProvider(), new DataProvider(), new DataProvider());

 priceGrid.dataProvider = enterPriceDataProviderArray[arrayIndex];

I have an event listener for when the user edits a specific cell in the datagrid with one of the dataproviders supplying data, the global variable credit is updated.

 credit = priceGrid.columns[5].itemToLabel(priceGrid.getItemAt(0));

I would like to be able to update the other dataproviders in the array with the new value of credit that the user changed. In this way, I'm hoping that the datagrid will update with the new value of credit irrespective of whichever dataprovider supplies the data. The address in the datagrid is the same for all the other data providers.

Can I use the replaceItemAt method to be able to do this? Can someone please give me an example code of what this would look like?

how to make a native menu in a AS3 class which extends the WindowedApplication class

We all know how to define a native menu using XML in MXML. It looks like this:

<s:WindowedApplication xmlns:fx="http://ift.tt/rYUnH9"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx">

<fx:Declarations>
    <!-- The xml data provider for menu -->
    <fx:XML format="e4x" id="menuData">
        <root>
            <menuitem label="File">
                <menuitem label="Open"/>
                <menuitem label="Save"/>
            </menuitem>
            <menuitem label="Help"/>
        </root>
    </fx:XML>
</fx:Declarations>
<s:menu>
    <mx:FlexNativeMenu dataProvider="{menuData}" labelField="@label" showRoot="false"/>
</s:menu>   

But I need to make a native menu(application menu) using a loaded XML in a class which extends the WindowedApplication class and is extended by the main MXML. How can I do this? Thanks for any help in advance!

storing and retrieving multiple shared object

I am doing sign up and sign in using sharedobject in AS3. I am storing username and password in different shared object variables. It stores successfully. But while retrieving and checking the username and password during sign-in, i don't know about how to relate particular username with the password assigned to that username as both are stored in the different shared object variables. Here is my code.

//sign up code

var signup:SharedObject = SharedObject.getLocal("newSignUp");
var signupPassword:SharedObject = SharedObject.getLocal("newSignUpPassword");
var kvalue:SharedObject = SharedObject.getLocal("kvalue1");
var k:Number;

signup_mc.signup_btn.addEventListener(MouseEvent.CLICK, signupcheck);

function signupcheck(event:MouseEvent):void {
    if(kvalue.data.updatedValue!=undefined) {
        k = kvalue.data.updatedValue;
        k_txt.text = k_txt.text + k + "\n";
        }
        else {
            k=1;
        }   
    newusername = signup_mc.username_txt.text;
    newpassword = signup_mc.password_txt.text;
    signup.data["nwusername" + k] = newusername;
    signupPassword.data["nwpassword" + k] = newpassword;      
    signup.flush();
    signupPassword.flush();
    k++;
    kvalue.data.updatedValue = k;   

}

//sign in code

login_mc.signin_btn.addEventListener(MouseEvent.CLICK, signin1);

function signin1(event:MouseEvent):void {
    for(var l:String in signup.data) {
    usersnameArr.push(signup.data[l]);      
    }
    for(var r:String in signupPassword.data) {
    passArr.push(signupPassword.data[r]);
    }

    for(var t:Number=0; t<usersnameArr.length; t++) {
        users_txt.text = users_txt.text+usersnameArr[t]+"\n";
        pass_txt.text = pass_txt.text+passArr[t]+"\n";
    }   
    getusername = login_mc.username1_txt.text;
    getpassword = login_mc.password1_txt.text;  

    for(var u:Number=0; u<usersnameArr.length; u++) {
    if(getusername==usersnameArr[u] && getpassword==passArr[u]) {           
     logged_txt.text = "signed in as "+getusername;
     myMC8= new MCVisibilityOff(login_mc);  
     break;
    }
    else {      
        logged_txt.text = "Username doesn't exist";
    }
    }
}

ERROR in loading texture to 3d object ".3ds" in flash actionscript3.0 programming with Alternativa3D 8

I want get http://ift.tt/2lug6Bn (used only 3d model and 1 texture), but I have http://ift.tt/2l7BsZu, why?

Moving a separate glyph in TextField/TextBlock/TextLine

I want to make an RPG-like animation with text, like waving, shaking, etc. So I need to move separate glyphs in in text container. I looked up in Adobe documentation, but didn't find myself any information about accessing separate glyph graphics, to change it's position/scale/whatever.

Is it possible? Or the only way to do it is to draw glyphs separately from text field to BitmapData and do the whole thing by myself?

Remote Debugging wont connect

I sort of make shift followed this guide on how to setup remote debugging. Since I am using Adobe Animate to compile my app I assume it has done the majority of the build steps already as I get a similar screen described.

I don't understand though. Here I have port forwarding up on my router so that it goes to my PC. I have TCP port 7935 up and open. Windows firewall on or off doesn't seem to make difference. Windows firewall even prompted me to allow or deny fdb after I ran it. I can't get my phone to connect via remote debugging. I want to be able to send this to my client who is having issue with the app so I can see what's going on under the hood instead of relying on a giant sum of try/catch statements and screenshots. Any help?

I tried a dummy domain and it seems to know that it can't connect to it. When I try mine or my IPv4 it doesn't let me connect. It just freezes up the app.

enter image description here enter image description here

lundi 27 février 2017

Actionscripts 3 Function doesn't work

I write some code for getting current date and compare it with a future date for application limitation. I don't know why this function doesn't work.

getYYMMDD();

function getYYMMDD(): String {
    var dateObj: Date = new Date();
    var year: String = String(dateObj.getFullYear());
    var month: String = String(dateObj.getMonth() + 1);
    if (month.length == 1) {
        month = "0" + month;
    }
    var date: String = String(dateObj.getDate());
    if (date.length == 1) {
        date = "0" + date;
    }
    return year.substring(0, 4) + month + date;

    trace(year + ":" + month + ":" + date);
    if (int(year) > 2017 && int(month) > 5 && int(date) > 31) {
        trace("SYSTEM TIME IS OFF.");
    } else {
        trace("SYSTEM TIME IS ON.");
    }
}

Actionscript quiz game using adobe animate

Hi im new to actionscript and I and my classmates are making a quiz game using adobe animate. What i want to happen is when a user tap the checkbutton the checkbutton will check if the the answer that the user inputted in the textbox is correct or wrong. When the Answer matched the correct answer it will go to the next page which is frame3 and when it is wrong it will only stay in its currentframe. the problem is even when the answer that is inputted is correct and it matched with the right answer it wont proceed to the other frame it will always stay in its currentframe, as if like the if(textbox.text == "correctanswer") is ignored. I hope you can help me :) Thanks in Advance

checkbutton_2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopFromFrame_2);

function fl_ClickToGoToAndStopFromFrame_2(event:MouseEvent)
{
    if(textbox.text == "correctanswer"){
        gotoAndStop(3);
      }else{
        gotoAndStop(2);
    }
}

dimanche 26 février 2017

Save multiple images with one function - AS3 ADOBE AIR

I've got an Array with 17 web links of images

        var products:Array;
        trace(products) 

 // Ouput : 
"http://ift.tt/2l0UErI"
"http://ift.tt/2ldVWLf"
"http://ift.tt/2l0QP5O"
    ..etc

If I do products[10].movieimage; the output will be the 9th link (something like : "http://ift.tt/2le3M7A")

I'm looking for downloading every images without a dialog box.

I manage to do so for 1 image with the specific link, like that :

function saveImage (event:Event):void {

 var stream:URLStream = new URLStream(); 
 var image1:File = File.documentsDirectory.resolvePath("test.jpg"); 
 var fileStream:FileStream = new FileStream(); 

stream.load(new URLRequest("http://ift.tt/2le3M7A")); 
stream.addEventListener(Event.COMPLETE, writeComplete); 
        

 function writeComplete(evt:Event):void  { 
                var fileData:ByteArray = new ByteArray(); 
                stream.readBytes(fileData,0,stream.bytesAvailable); 
                fileStream.openAsync(image1, FileMode.UPDATE); 
                fileStream.writeBytes(fileData,0,fileData.length); 
                fileStream.close(); 
                 trace("writeComplete");
                 trace(image1.url); 
        } 
}

Question : Is there a way to download all the images with the web links of my products array ?

If you could show me how, with a bit of code, I could that.

Also, note that I'd like to load the images then in Uiloader, like that :

    function loadImages():void {
uiloader1.source = image1.url;
uiloader2.source = image2.url;
etc...
    }

Youtube embedded player video size issue

We have implemented embedded youtube player in our flash application which is written in action script 3. We are facing a issue with the display of video. After clicking on play button the video size is displaying 1/4 of the display and shifting to the top left corner of the player display leaving the remaining space as blank.

Reference used for implementing embedded youtube player. http://ift.tt/1ha31aO

Kindly suggest.

Thanks

ActionScript 2 and Sockets using mtasc on Linux

How can I correctly implement in ActionScript 2 connecting to a socket and sending some data? I tried many variants of code, but still there is the same error:

file.as:13: characters 0-9 : parse error Unexpected theSocket.

I'm trying to compile a file using mtasc -swf some.swf -main -header 800:600:20 file.as.

class Tuto {

static var app : Tuto;

function sendData() {
var myXML:XML = new XML();
var mySend = myXML.createElement("thenode");
mySend.attributes.myData = "some data";
myXML.appendChild(mySend);
theSocket.send(myXML);
}

theSocket.onConnect = function(myStatus) {
if (myStatus) {
    conn_txt.text = "connection successful";
} else {
    conn_txt.text = "no connection made";
}

function Tuto() {
var theSocket:XMLSocket = new XMLSocket();
theSocket.connect("localhost", 5555);
_root.createTextField("tf",0,0,0,800,600);
_root.tf.text = "Hello world !";

sendData();

}
};

static function main(mc) {
    app = new Tuto();
}
}

samedi 25 février 2017

how to check a font can support bulleted text

I am developing a flex application, where user can upload there own fonts.I just want check the uploaded font can support bullets text. While calling Font.registerfont(); These gives fontfamily,fontstyle and embedd.

Does JavaScript in the browser have a reflection mechanism?

I would like to get a list of all the properties, styles, events and methods of an HTML element. Is there a reflection API in the browsers?

I'm looking for something like this:

var button = new HTMLButtonElement();
var className = document.getQualifiedClassName(button); // "HTMLButtonElement"
var definition = document.getDefinition(className); // HTMLButtonElement reference
var instance = document.getInstance(definition); // instance of HTMLButtonElement
var properties = document.getProperties(button); // properties of HTMLButtonElement
var methods = document.getMethods(button); // methods of HTMLButtonElement
var styles = document.getStyles(button); // styles applicable to HTMLButtonElement
var events = document.getEvents(button); // events on HTMLButtonElement
var inheritance = document.getInheritance(button); // HTMLButtonElement > HTMLElement

EDIT:
This is the call in ActionScript3 that gets what I'm looking for:

var objectInformation = document.describeType(button) // metadata

This may make it more clear what I'm trying to do in JavaScript.

Save image loaded to my UILoader in AS3 in order to load it without internet connection

I've got some UIloader in my AS3 code that displays images via web link.

uiloader1.source = "http://ift.tt/2lSiSU6";
uiloader2.source = "http://ift.tt/2mqsjIj";

Once the user have open the app with an internet connection, I'd like him to be able to open it again without any internet connection but still have the possibility to display the images.

I thought about something like :

var savedImage:SharedObject;
savedImage= SharedObject.getLocal("ImagesFolder");

if (monitor.available || savedImage.data.images == "null") {

    uiloader1.source = "http://ift.tt/2lSiSU6";
    uiloader2.source = "http://ift.tt/2mqsjIj";

    savedImage.data.loader1 = uiloader1.source;
    savedImage.data.loader2 = uiloader2.source;

}

else {

    uiloader1.source = savedImage.data.loader1;
    uiloader2.source = savedImage.data.loader2;

}

But it doesn't work as it saves the link of the image and not the actual image.

Any idea how can I save the images into a file and told uiloader1.source and uiloader2.source to load them ?

What to do with the error " Cannot access a property or method of a null object reference."?

I've been getting this error since I added the code for my timer. It looks like I can't switch frames or something. Or maybe I have to clear something before moving to another frame. This is from a game I created and now I've decided to make speed as the basis of scoring. The higher the score the sooner you finish a level. Please help.

stop();
stage.addEventListener(KeyboardEvent.KEY_DOWN,Directions);
stage.addEventListener(Event.ENTER_FRAME,Kikoy);
NextOne_btn.addEventListener(MouseEvent.CLICK,NextLevelOne);
Ok_btn.addEventListener(MouseEvent.CLICK,DoneHow);
var hasBlueKeyOne:Boolean = false;
levelCompleteOne_mc.visible =false;
NextOne_btn.visible =false;
back.addEventListener(MouseEvent.CLICK, PlayMen1);

function PlayMen1(event:MouseEvent):void
{
    gotoAndPlay("StartMenu");
}

pawup.addEventListener(MouseEvent.CLICK,pawUp);
pawdown.addEventListener(MouseEvent.CLICK,pawDown);
pawleft.addEventListener(MouseEvent.CLICK,pawLeft);
pawright.addEventListener(MouseEvent.CLICK,pawRight);

function pawLeft(event:MouseEvent):void
{
    if(BlueKeyOne_mc.hitTestPoint(Avatar_mc.x, Avatar_mc.y, true))
    {BlueKeyOne_mc.x=850;BlueKeyOne_mc.y=45;BlueKeyOne_mc.scaleX+=0.1; BlueKeyOne_mc.scaleY+=0.1;
    hasBlueKeyOne=true;}
    if(!Blocks_mc.hitTestPoint(Avatar_mc.x-35, Avatar_mc.y, true)){Avatar_mc.x-=40;}
}
function pawUp(event:MouseEvent):void
{
    if(BlueKeyOne_mc.hitTestPoint(Avatar_mc.x, Avatar_mc.y, true))
    {BlueKeyOne_mc.x=850;BlueKeyOne_mc.y=45;BlueKeyOne_mc.scaleX+=0.1; BlueKeyOne_mc.scaleY+=0.1;
    hasBlueKeyOne=true;}
    if(!Blocks_mc.hitTestPoint(Avatar_mc.x, Avatar_mc.y-35, true))Avatar_mc.y-=40;
}

function pawRight(event:MouseEvent):void
{
    if(BlueKeyOne_mc.hitTestPoint(Avatar_mc.x, Avatar_mc.y, true))
    {BlueKeyOne_mc.x=850;BlueKeyOne_mc.y=45;BlueKeyOne_mc.scaleX+=0.1; BlueKeyOne_mc.scaleY+=0.1;
    hasBlueKeyOne=true;}
    if(!Blocks_mc.hitTestPoint(Avatar_mc.x+35, Avatar_mc.y, true))Avatar_mc.x+=40;
}

function pawDown(event:MouseEvent):void
{
    if(BlueKeyOne_mc.hitTestPoint(Avatar_mc.x, Avatar_mc.y, true))
    {BlueKeyOne_mc.x=850;BlueKeyOne_mc.y=45;BlueKeyOne_mc.scaleX+=0.1; BlueKeyOne_mc.scaleY+=0.1;
    hasBlueKeyOne=true;}
    if(!Blocks_mc.hitTestPoint(Avatar_mc.x, Avatar_mc.y+35, true))Avatar_mc.y+=40;
}



function Directions(event:KeyboardEvent):void
{
    if(BlueKeyOne_mc.hitTestPoint(Avatar_mc.x, Avatar_mc.y, true))
    {BlueKeyOne_mc.x=850;BlueKeyOne_mc.y=45;BlueKeyOne_mc.scaleX+=0.1; BlueKeyOne_mc.scaleY+=0.1;
    hasBlueKeyOne=true;}

    if(event.keyCode==37){
        if(!Blocks_mc.hitTestPoint(Avatar_mc.x-35, Avatar_mc.y, true)){Avatar_mc.x-=40;}
    }
    if(event.keyCode==38){
        if(!Blocks_mc.hitTestPoint(Avatar_mc.x, Avatar_mc.y-35, true))Avatar_mc.y-=40;
    }

    if(event.keyCode==39){
        if(!Blocks_mc.hitTestPoint(Avatar_mc.x+35, Avatar_mc.y, true))Avatar_mc.x+=40;
    }

    if(event.keyCode==40){
        if(!Blocks_mc.hitTestPoint(Avatar_mc.x, Avatar_mc.y+35, true))Avatar_mc.y+=40;
    }

}


function Kikoy(event:Event):void
    {

        if(Door_mc.hitTestPoint(Avatar_mc.x, Avatar_mc.y, true) && hasBlueKeyOne){
            levelCompleteOne_mc.visible =true;
            BlueKeyOne_mc.visible=false;
            NextOne_btn.visible =true;
            stage.removeEventListener(Event.ENTER_FRAME, Kikoy);
            stage.removeEventListener(KeyboardEvent.KEY_DOWN, Directions);
        }
    }


function NextLevelOne(Event:MouseEvent):void
{
    WhatLevel=2;
    gotoAndStop("ToIrosin");
}

function DoneHow(Event:MouseEvent):void
{
    Ok_btn.visible=false;
    Instruction_mc.visible=false;
}



GameOverOne_mc.visible = false;
tryAgainOne_btn.visible=false;
timerFunction(1,30);

function timerFunction(minutes, seconds)
{
    var seconds = seconds;
    var minutes = minutes;
    var clock;
    var tmr = setInterval(timer,100);

    function timer()
    {
        seconds--;
        if (seconds<0)
        {
            minutes--;
            seconds = 59;
        }
        if (minutes == 0 && seconds == 0)
        {
            clearInterval(tmr);
            GameOverOne_mc.visible = true;
            tryAgainOne_btn.visible=true;
        }
        clock = minutes + "0" + seconds;
        if (seconds<10)
        {
            if (minutes<10)
            {
                clock = "0" + minutes + ":0" + seconds;
            }
        }
        else
        {
            if (minutes<10)
            {
                clock = "0" + minutes + ":" + seconds;
            }
            else
            {
                clock = minutes + ":" + seconds;
            }
        }
        txt.embedFonts = false;
        txt.text = clock;

    }

}

ActionSctipt 3.0 Error:

I'm having real trouble trying to access the symbol dynamically, I have 9 buttons that all call this method, and they pass in their location (tl, t, tr, etc.) I've tried this method before on another program and it works without a problem, but in this program it fails.

I am attempting to access a symbol call s_tl (example location), but all I'm getting is undefined (see results).

function turn(btn : String):Function {
return function(e:MouseEvent) {
    var players_turn : int;
    var chosen : String = "s_" + btn;

    trace(this);
    trace(this[chosen]);
    trace(chosen);
    trace(this[chosen]);
    // if crosses turn 0 else 1
    if (s_c.currentFrame == 1) {
        players_turn = 0;
    } else {
        players_turn = 1;
    }       

    // check who's turn it is if it's been pressed before
    if (players_turn == 0 && this[chosen].visible == false) {
        this[chosen].gotoAndStop(1);
        this[chosen].visible = true;
    } else {
        this[chosen].gotoAndStop(2);
        this[chosen].visible = true;
    }
};
}

Results:

[object global]
undefined
s_br
undefined
TypeError: Error #1010: A term is undefined and has no properties.
    at MethodInfo-6()

vendredi 24 février 2017

Get wrong timezoneOffset in AIR/Flex/AS3

in Germany I get on my PC:

new Date().getTimezoneOffset(); //-60

new Date().timezoneOffset //-60

but as my PC shows me correctly I am in UTC+01:00 as normal for Berlin, Amsterdam, ...

Can I fix this?

Kind regards

Christian

Understanding Actionscript 3 Code

I was given this piece of code and am trying to understand it as best as I can. I have ran the code and understand what it does, but there are a few lines which I do not know how to explain.

Code here

Here is what I have come up with so far:

In line 1 of the code shown, we have created a new Array called “theElements”. It contains 5 different elements named “Earth, Wind, Fire, Water & Ether.”

In line 2 of the code, we are creating a variable with a String function, however this line of code seems to be an error that was left in to the code as “element” does not feature within our code again. This line of code was used in a previous example and had been forgotten to be removed. We can successfully run the piece of code without any errors if we remove this line.

In line 3 of the code, we create a variable called “numberOfRoles” and give this a 10 value.

In line 5 of the code, we pull the Array “theElements” and variable “numberOfRoles” and use them as attributes, while naming them both as “roleThem”

In line 7 of the code, we create a function and use roleThem

In line 9 we use the while loop, which will repeat as long as the statement “numberOfRoles > 0” is true.

In line 12 we check that our variable “numberOfRoles” is always equal.

I am stuck on explaining Line 10/11 and 16-19. I know that lines 16-19 pick 10 of the elements at random and display then which you can see, however I do not know how to explain it in the correct manner. I am still learning the basics of Actionscript so any help would be much appreciated.

jeudi 23 février 2017

Applying .as document to as3 swf main file

Okay so I finally have no errors on my .as file! BUT I do have errors on my main file, It says that the 'type was not found or was not compile-time constant' referring to my code used to connect the .as file. Here it is:

import BetterScrolling;

var BetterScrolling:BetterScrolling = new BetterScrolling();
addChild(BetterScrolling);

and here is a link to to the current .as code BetterScrolling: http://ift.tt/2luGhdL

Show error when value of numeric stepper out of range

When I set maximum and minimum for a numeric stepper, I still can enter a number out of that range. But it is automatically receive the maximum value if I enter a number greater than that. How can I show error for this case, but still keep set maximum and minimum value?

Flash Differences Between Adobe AIR And Internet Explorer

We have developed an application front end in Flash. Now we are allowing access either from a browser or an Adobe AIR application. We point to the URL of our web server and download swf components and data via a NetConnection. We are seeing differences in the communication behavior of our web application with the Adobe AIR container verses Internet Explorer. There are some communication drops between the Adobe AIR container in our requests back to the web server for requests that take a longer time. Internet Explorer seems to be much more tolerant and handles much better.

It is not an issue simply with the connection reliability because the same behaviors can be observed by setting and holding a breakpoint on the requests for data from the web server.

So, same code but different behaviors when flash runs in Adobe Air. We have made sure both are using the same version of the flash dll.

As I missing some configuration of the Adobe AIR container that changes default behaviors?

How do I graphic of score

I trying to make a score graphic.I have last seven score of the game.I could use to line object as code but it's take so long.
Is there an easy way to do this ?

Example graphic.

enter image description here

AC3 display data attextfiled from array of numbers

I'm new at actionScript and I've a problem with my code, will I'm trying to build a simple app which allow the users to enter a data number and these data will be stored in array , after that the data could be display on a bar chat but for now my problem is that I want to display these data on specific positions in textinput filed on stage I tried several methods but I failed. please here is the code and any advice will be appreciated.

    package
{
    import feathers.controls.Button;
    import feathers.controls.Header;
    import feathers.controls.Screen;
    import feathers.controls.TextInput;

    import starling.display.Image;
    import starling.events.Event;
    import starling.textures.Texture;
    import starling.utils.Color;


   public class MainScreen extends Screen
   {

       [Embed(source="assets/axis1.png")]
       private static var BG:Class;
       public static var BGTexture:Texture;

       [Embed(source="assets/Line.png")]
       private static var BG1:Class;
       public static var BG1Texture:Texture;


      private var EnterButton:Button;
      private var TextF:TextInput;

      private var DataArray:Array
      private var num:Number;
      private var ChartButton:Button;
      private var Ax:Image;

      private var l1:TextInput;
      private var l2:TextInput;
      private var l3:TextInput;
      private var l4:TextInput;
      private var l5:TextInput;

      private var Jheader:Header;
      private var Fheader:Header;
      private var Mheader:Header;
      private var Aheader:Header;
      private var Maheader:Header;

    private var max:Number;
    private var min:Number;
    private var len:Number;
    private var check:Number;

    public function MainScreen()
    {

    }

    override protected function draw():void
    {

        TextF.width =  100;
        TextF.height = 50;
        TextF.y = 500;
        TextF.x = 5;


        EnterButton.width = 60;
        EnterButton.height = 50;
        EnterButton.y = TextF.y ;
        EnterButton.x =120;


        ChartButton.width = 60;
        ChartButton.height = 50;
        ChartButton.y = EnterButton.y;
        ChartButton.x =200;

        l1.width = 30;
        l1.height = 20;
        l1.y=340;
        l1.x=15;

        l2.width = 30;
        l2.height = 20;
        l2.y=280;
        l2.x=15;

        l3.width = 30;
        l3.height = 20;
        l3.y=215;
        l3.x = 15;

        l4.width = 30;
        l4.height = 20;
        l4.y=155;
        l4.x = 15;


        l5.width = 30;
        l5.height = 20;
        l5.y=90;
        l5.x=15;


        Jheader.x = 90;
        Jheader.y=400;

        Fheader.x = 155;
        Fheader.y=400;

        Mheader.x = 215;
        Mheader.y=400;

        Aheader.x = 275;
        Aheader.y=400;

        Maheader.x = 335;
        Maheader.y=400;



    }

    override protected function initialize():void
    {
        DataArray = new Array();

        TextF = new TextInput();
        TextF.prompt = "Enter Data"


        EnterButton = new Button ();
        EnterButton.label = "Add";

        ChartButton = new Button();
        ChartButton.label = "Chart";


        l1 = new TextInput();

        l2 = new TextInput();
        l3 = new TextInput();
        l4 = new TextInput();
        l5 = new TextInput();



    //l1.isEditable = false;


        Jheader = new Header();
        Fheader = new Header();
        Mheader = new Header();
        Aheader = new Header();
        Maheader = new Header();


        Jheader.title = "Jan";
        Fheader.title = "Feb";
        Mheader.title = "Mar";
        Aheader.title = "Apr";
        Maheader.title = "May";


        addChild(TextF);
        addChild(EnterButton);
        addChild(ChartButton);





        EnterButton.addEventListener(Event.TRIGGERED,OnClick);
        ChartButton.addEventListener(Event.TRIGGERED,OnChart);

    }

    private function OnChart():void
    {
        BGTexture = Texture.fromBitmap(new BG());
        Ax = new Image(BGTexture);
        Ax.color = Color.TEAL;
        Ax.x=40;
        Ax.y = 40;
        addChild(Ax);

        addChild(l1);
        addChild(l2);
        addChild(l3);
        addChild(l4);
        addChild(l5);



        addChild(Jheader);
        addChild(Fheader);
        addChild(Mheader);
        addChild(Aheader);
        addChild(Maheader);



        trace("chart");

    }

    private function OnClick():void
    {
        num = new Number(TextF.text);
        DataArray.push(num);
        trace(DataArray);

        len = DataArray.length;
        min = Number.MAX_VALUE;
        max = Number.MIN_VALUE;

        for (var i:int = 0;i<len;i++)
        {
            check = DataArray[i];

            if (check < min)
            {
                min = check;
            }
            if(check > max)
            {
                max = check;
            }

        }

        trace("minimum value= ",  min);
        trace("maximum value=" , max);


      } 


  }

}

I keep getting a 404 from the youTube API V3 in AS3

We are actively working on moving our product from AS3 to HTML5, but until we complete the process we still have many clients using the Flash version of the Youtube API V3. We have gotten our project Key and are making the request with https://www.youtube.com/apiplayer?version=3&key=[key], it returns a 404 when the AS3 goes to get it, but returns the flash API when pasted into the browser directly.

We have Security.allowDomain("www.youtube.com"); in the code. Here is how we are loading the API, which has worked for years.

_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
var url:String = "https://www.youtube.com/apiplayer?version=3&key=*[key]*";
_loader.load(new URLRequest(url));

Trying to figure out what i'm missing.

Object Undefined but it seems to be Defined actionscript

First I am still new to coding so take it easy on me. Bit of back tracking before I show the code. I got a book on how to make games with ActionScript 3, only thing is it mainly works under the assumption your working with Photoshop & Flash Builder together rather than adobe animate/flash. So it has you do things like embed images, and I'm not sure how to change the code to define the images, which is exactly the problem. However at the same time, the stage is coming up as undefined access! I really, I mean how can the stage be undefined... Well any way, Heres an example of one of the Undefined Properties:

///
class BetterScrolling extends Sprite 
    var ForegroundImage: Class;
    var foregroundImage: DisplayObject = ForegroundImage();
    var foreground = ForegroundImage;
///

Theres some code in-between.

///
function BetterScrolling(){
     foreground.x = -((foreground.width - stage.width) / 2);
    foreground.y = -((foreground.height - stage.height) / 2);
    }

///

The point of this code is to create a scrolling Background. However I'm kinda complicating it because I have an X and an Y variable, yet I also have a slowed background in addition to my foreground. I will now link to the complete code as is currently, http://ift.tt/2luGhdL Every change in that code I made with a reason in mind, even if it is a stupid one... so please don't be distracted by the other errors that I'm sure are in there... for now just the defining of my images.

Hi, can anyone explain this whole code to me? I need a better understanding of it. Thanks

import flash.display.MovieClip;

import flash.events.Event;

import fl.transitions.Tween;

import fl.transitions.easing.*;

var rat1:Rat = new Rat();

var rat2:Rat = new Rat();

addChild(rat1);

addChild(rat2);

rat1.rotationX += 180;

rat1.rotationZ += 270;

rat1.x =0;

rat1.y =400;

rat2.rotationX += 180;

rat2.rotationZ += 100;

rat2.x = 2;

rat2.y = 90;

rat2.alpha -= 0.6

enterStage(rat1);

function enterStage(mc:MovieClip)

{

var speed = 50;

mc.addEventListener(Event.ENTER_FRAME, comeIn);

function comeIn (e:Event)

{

    mc.x += speed;

    speed -= 3;

    if (speed <=0)

    {

        mc.removeEventListener(Event.ENTER_FRAME, comeIn);

    }
}

}

var ratTween:Tween = new Tween(rat2,"x", Strong.easeOut,stage.stageWidth, 200, 1, true);

ratTween.start();

creating multiple sharedobject dynamically

I would like to dynamically create multiple sharedobject to create multi-login and I used the below code for that. But it throws error.Please post if there is any way to do it.

var k:Number=0;
var signup:SharedObject = SharedObject.getLocal("newSignUp");

signup_mc.signup_btn.addEventListener(MouseEvent.CLICK, signupcheck);

function signupcheck(event:MouseEvent):void {
newusername = signup_mc.username_txt.text;
    newpassword = signup_mc.password_txt.text;
    signup.data.nwusername+k = newusername;
    signup.data.nwpassword+k = newpassword; 
    signup.flush();
k++;
}

AS3 novice struggles. Can anyone help? thanks

var animal:String ="Cat";


var isFish:Boolean;

isFish = isItAFish(animal);
trace(isFish);

function isItAFish (animal:String):Boolean {

var fishArray:Array = new Array("haddock", "Trout", "Salmon", "Cod");

for(var i:int = 0; i < fishArray.length; i++){

    if (fishArray[i] == animal){

        return true;


        break;
    }
    }
    return false; 
}

I just need help explaining this code guys and girls. The "isFish = isItAFish (animal); trace(isFish); is where I'm confused from. Thank you

Hovering off DPAD sometimes makes character move infinitely in one direction

I have a DPAD in my game when the player holds down let's say the Left DPAD, if he moves his touch to the Up DPAD and let's go, the player continues going in the left direction.

It also works if you hold the a direction, lets say Up continue holding but move off the Up DPAD, sometimes you may continue going in that direction.

What I've tried to prevent this:

  • On direction clicks, trigger checks on whether your in motion, or already going a different direction
  • Setting collisions to force these variables to become false; aka, you hit something, inMotion = false, etc

That's about all I can think of on how to fix this.

Also, I use a lot of variables for my checks, is it better to change my functions to return booleans, or is this way fine? Just curious.

Game Class

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

    public class Game extends MovieClip
    {
        public var area1:Boolean = true;
        public var area2:Boolean = false;
        public var area3:Boolean = false;

        public var player1:Boolean = true;
        public var player2:Boolean = false;

        public var upWalkspeed:Number = -5;
        public var downWalkspeed:Number = 5;
        public var leftWalkspeed:Number = -5;
        public var rightWalkspeed:Number = 5;

        public var inMotion:Boolean = false;
        public var goingUp:Boolean = false;
        public var goingDown:Boolean = false;
        public var goingLeft:Boolean = false;
        public var goingRight:Boolean = false;

        public var playerPosKeeper_mc:MovieClip = new mc_PlayerPosKeeper();

        public var up_dpad:MovieClip = new dpad_Up();
        public var down_dpad:MovieClip = new dpad_Down();
        public var left_dpad:MovieClip = new dpad_Left();
        public var right_dpad:MovieClip = new dpad_Right();
        public var menu_dpad:MovieClip = new dpad_Menu();
        public var run_dpad:MovieClip = new dpad_Menu();

        public var barrierRoof1_game:MovieClip = new game_BarrierRoof();
        public var barrierRoof2_game:MovieClip = new game_BarrierRoof();
        public var barrierSide1_game:MovieClip = new game_BarrierSide();
        public var barrierSide2_game:MovieClip = new game_BarrierSide();

        public var StageCollisions:Array = new Array(barrierRoof1_game, barrierRoof2_game, barrierSide1_game, barrierSide2_game);
        // fix MC goes after not before ||| public var player1States:Array = new Array(mc_P1D1,mc_P1D2,"mc_P1L1","mc_P1L2","mc_P1R1","mc_P1R2","mc_P1U1","mc_P1U2");

        public function Game()
        {
            trace("SUCCESS | Constructed Game Class");

            var aMove:Movement = new Movement(this);
            addChild(aMove);

        }
    }
}

Movement Class

package 
{
    import flash.display.Stage;
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.TouchEvent;
    import flash.net.dns.AAAARecord;
    import flash.ui.Multitouch;
    import flash.ui.MultitouchInputMode;


    public class Movement extends MovieClip
    {
        public function Movement(main:Game)
        {
            trace("SUCCESS | Constructed Movement Class");

            addChild(main.playerPosKeeper_mc);
            main.playerPosKeeper_mc.x = 384;
            main.playerPosKeeper_mc.y = 46;

            addChild(main.up_dpad);
            main.up_dpad.x = 55;
            main.up_dpad.y = 336;

            addChild(main.down_dpad);
            main.down_dpad.x = 57;
            main.down_dpad.y = 432;

            addChild(main.left_dpad);
            main.left_dpad.x = 19;
            main.left_dpad.y = 372;

            addChild(main.right_dpad);
            main.right_dpad.x = 118;
            main.right_dpad.y = 372;

            addChild(main.menu_dpad);
            main.menu_dpad.x = 61;
            main.menu_dpad.y = 377;

            addChild(main.run_dpad);
            main.run_dpad.x = 684;
            main.run_dpad.y = 369;

            addChild(main.barrierRoof1_game);
            main.barrierRoof1_game.x = 0;
            main.barrierRoof1_game.y = 0;

            addChild(main.barrierRoof2_game);
            main.barrierRoof2_game.x = 0;
            main.barrierRoof2_game.y = 470;

            addChild(main.barrierSide1_game);
            main.barrierSide1_game.x = 0;
            main.barrierSide1_game.y = 0;

            addChild(main.barrierSide2_game);
            main.barrierSide2_game.x = 790;
            main.barrierSide2_game.y = 0;

            Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

            main.up_dpad.addEventListener(TouchEvent.TOUCH_BEGIN, upBeginInput);
            main.down_dpad.addEventListener(TouchEvent.TOUCH_BEGIN, downBeginInput);
            main.left_dpad.addEventListener(TouchEvent.TOUCH_BEGIN, leftBeginInput);
            main.right_dpad.addEventListener(TouchEvent.TOUCH_BEGIN, rightBeginInput);

            // Maybe add diagnol direction buttons in the future?;


            //  !!  NOTE  !!
            //  Use some sort of value, maybe a return or a variable to sync up animations
            // to if the player is moving, in the future

            // Movement Directions

            // Start of UP Movement
            function upBeginInput(e:TouchEvent):void
            {
                main.inMotion = true;
                main.goingUp = true;
                main.goingDown = false;
                main.goingLeft = false;
                main.goingRight = false;
                main.up_dpad.addEventListener(TouchEvent.TOUCH_END, upEndInput);
                addEventListener(Event.ENTER_FRAME,sendUpMovement);
            }
            function upEndInput(e:TouchEvent):void
            {
                main.inMotion = false;
                main.goingUp = false;
                main.up_dpad.removeEventListener(TouchEvent.TOUCH_END, upEndInput);
                removeEventListener(Event.ENTER_FRAME,sendUpMovement);
            }
            function sendUpMovement():void
            {
                if (main.inMotion == true && main.goingUp == true && main.goingDown == false && main.goingLeft == false && main.goingRight == false)
                {
                    movePlayer(0, main.upWalkspeed);
                }
                else
                {
                }
            }
            // End of UP Movement



            // Start of DOWN Movement
            function downBeginInput(e:TouchEvent):void
            {
                main.inMotion = true;
                main.goingUp = false;
                main.goingDown = true;
                main.goingLeft = false;
                main.goingRight = false;
                main.down_dpad.addEventListener(TouchEvent.TOUCH_END, downEndInput);
                addEventListener(Event.ENTER_FRAME,sendDownMovement);
            }
            function downEndInput(e:TouchEvent):void
            {
                main.inMotion = false;
                main.goingDown = false;
                main.down_dpad.removeEventListener(TouchEvent.TOUCH_END, downEndInput);
                removeEventListener(Event.ENTER_FRAME,sendDownMovement);
            }
            function sendDownMovement():void
            {
                if (main.inMotion == true && main.goingUp == false && main.goingDown == true && main.goingLeft == false && main.goingRight == false)
                {
                    movePlayer(0, main.downWalkspeed);
                }
                else
                {
                }
            }
            // End of DOWN Movement



            // Start of LEFT Movement
            function leftBeginInput(e:TouchEvent):void
            {
                main.inMotion = true;
                main.goingUp = false;
                main.goingDown = false;
                main.goingLeft = true;
                main.goingRight = false;
                main.left_dpad.addEventListener(TouchEvent.TOUCH_END, leftEndInput);
                addEventListener(Event.ENTER_FRAME,sendLeftMovement);
            }
            function leftEndInput(e:TouchEvent):void
            {
                main.inMotion = false;
                main.goingLeft = false;
                main.left_dpad.removeEventListener(TouchEvent.TOUCH_END, leftEndInput);
                removeEventListener(Event.ENTER_FRAME,sendLeftMovement);
            }
            function sendLeftMovement():void
            {
                if (main.inMotion == true && main.goingUp == false && main.goingDown == false && main.goingLeft == true && main.goingRight == false)
                {
                    movePlayer(main.leftWalkspeed, 0);
                }
                else
                {
                }
            }
            // End of LEFT Movement



            // Start of RIGHT Movement
            function rightBeginInput(e:TouchEvent):void
            {
                main.inMotion = true;
                main.goingUp = false;
                main.goingDown = false;
                main.goingLeft = false;
                main.goingRight = true;
                main.right_dpad.addEventListener(TouchEvent.TOUCH_END, rightEndInput);
                addEventListener(Event.ENTER_FRAME,sendRightMovement);
            }
            function rightEndInput(e:TouchEvent):void
            {
                main.inMotion = false;
                main.goingRight = false;
                main.right_dpad.removeEventListener(TouchEvent.TOUCH_END, rightEndInput);
                removeEventListener(Event.ENTER_FRAME,sendRightMovement);
            }
            function sendRightMovement():void
            {
                if (main.inMotion == true && main.goingUp == false && main.goingDown == false && main.goingLeft == false && main.goingRight == true)
                {
                    movePlayer(main.rightWalkspeed, 0);
                }
                else
                {
                }
            }
            // End of RIGHT Movement


            function movePlayer(movementX:Number, movementY:Number):void
            {
                var originalX:Number = main.playerPosKeeper_mc.x;
                var originalY:Number = main.playerPosKeeper_mc.y;
                main.playerPosKeeper_mc.x +=  movementX;
                if (checkCollision())
                {
                    main.playerPosKeeper_mc.x = originalX;
                }
                main.playerPosKeeper_mc.y +=  movementY;
                if (checkCollision())
                {
                    main.playerPosKeeper_mc.y = originalY;
                }
            }

            function checkCollision():Boolean
            {
                for each (var StageCollisions:MovieClip in main.StageCollisions)
                {
                    if (main.playerPosKeeper_mc.hitTestObject(StageCollisions))
                    {
                        return true;
                        main.inMotion = false;
                        main.goingUp = false;
                        main.goingDown = false;
                        main.goingLeft = false;
                        main.goingRight = false;
                    }
                }
                return false;
            }
        }
    }
}

mercredi 22 février 2017

SharedObject Not saving data safely?

I try to have an object with some immutable properties which initiate at the constructor and won't be able to change after initiation. Those properties then only have getter method. Since I want this object can be shared with other classes, I save it to the SharedObject class called saveIt().

All work fine when running the app on iOS (I do not test it on Android yet) except that if I completely shutdown the app from memory and reopen it, those properties' without setter are lost. The code is as below:

          var rooms:ArrayCollection = saveData.read("rooms") as ArrayCollection;
          if (!roomExists) {
                var room:Room;
                room = new Room(myID, myName, maxRoomSize);

                room.name = rm.name;
                room.timestamp = new Date();
                room.joinUrl = rm.joinUrl;
                room.attendeeUrl = rm.attendeeUrl;
                room.attendees = conferenceParameters.metadata.hasOwnProperty("attendees") ? conferenceParameters.metadata["attendees"] : null;

                rooms.addItem(room);
            }
            saveIt.save("rooms", rooms);

Air native extension: pass bitmapdata from thread (winapi) to as3

In my native extension for air I want to create a screenshot. I managed to do this in synchronous way. Now I want to do it asynchronous in a thread (using WINAPI CreateThread).

In the thread I create new bitmapdata and set the color for each pixel. But now my question is:

How do I pass the bitmapdata created in the thread back to actionscript?

Here I create the thread:

FREObject getScreenShotAsynchronous(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[])
{
    FREGetObjectAsInt32(argv[1], &_iSsWidth);
    FREGetObjectAsInt32(argv[2], &_iSsHeight);
    FREGetObjectAsInt32(argv[3], &_iSsOffsetX);
    FREGetObjectAsInt32(argv[4], &_iSsOffsetY);

    //Context ref for thread:
    oCtxThreadScreenshot = ctx;

    //Create thread:
    bRunThreadScreenshot = true;
    hThreadScreenshot = CreateThread(NULL, 0, threadScreenshot, 0, 0, &dwThreadScreenshotID);
    CloseHandle(hThreadScreenshot);

    return NULL;
}

And here is the thread itself:

DWORD WINAPI threadScreenshot(LPVOID data)
{
    int32_t iWidth, iHeight, iOffsetX, iOffsetY;
    iWidth = _iSsWidth;
    iHeight = _iSsHeight;
    iOffsetX = _iSsOffsetX;
    iOffsetY = _iSsOffsetY;

    FREObject freWidth;
    FRENewObjectFromUint32(uint32_t(iWidth), &freWidth);

    FREObject freHeight;
    FRENewObjectFromUint32(uint32_t(iHeight), &freHeight);

    FREObject freTransparent;
    FRENewObjectFromBool(uint32_t(0), &freTransparent);

    FREObject freFillColor;
    FRENewObjectFromUint32(uint32_t(0xFF0000), &freFillColor);


    // first get those values from imaage
    FREObject freArguments[4] = { freWidth, freHeight, freTransparent, freFillColor };

    // create an instance of BitmapData
    FREObject freoBitmapData;
    FRENewObject((uint8_t *)"flash.display.BitmapData", 4, freArguments, &freoBitmapData, NULL);

    // now acquire the bitmap data in order to manipulate it
    FREBitmapData freBitmapData;
    FREAcquireBitmapData(freoBitmapData, &freBitmapData);

    //***
    //Grab screenshot data and fill bitmapdata...
    //**.

    // Tell Flash which region of the bitmapData changes (all of it here)
    FREInvalidateBitmapDataRect(freoBitmapData, 0, 0, freBitmapData.width, freBitmapData.height);
    // Release our control over the bitmapData
    FREReleaseBitmapData(freoBitmapData);

    //Dispatch event:
    FREDispatchStatusEventAsync(oCtxThreadScreenshot, (const uint8_t *)"onMsg", (const uint8_t *)"screenshot_done");

    return 0;
}

Thanks for help!

FileStream openAsync throws Error #1009

hi I have a problem regarding FileStream openAsync read file, I have a listener and waiting on complete

    var file:File = File.applicationStorageDirectory.resolvePath(fName+'.'+EXT);
    var fileStream:FileStream = new FileStream();  


     if (!file.exists) {
              this.dispatchEvent(new AppEvent(AppEvent.DATA, null, false));                                         

     }else {

         fileStream.addEventListener(Event.COMPLETE, fileReadCompleteHandler);
         fileStream.openAsync(file, FileMode.READ);
         fileStream.addEventListener(Event.CLOSE, fileClosedHandler);
         fileStream.addEventListener(IOErrorEvent.IO_ERROR, IOErrorHandler);
     }


     private function fileReadCompleteHandler(event:Event):void {
        var ob:Object;
        var fileStream:FileStream = FileStream(event.currentTarget);

        try {
            ob.source = fileStream.readObject();
        }catch (e:Error) {
            trace('error:' + e.message) 
        }

        fileStream.removeEventListener(Event.COMPLETE, fileReadCompleteHandler);
        fileStream.close(); 

      }

on fileReadCompleteHandler I get error: "Error #1009: Cannot access a property or method of a null object reference." what I am missing, how can I read object from openAsync?

thanks

Issues with TextField

Anyone notice this? In my mobile air application, when I have text in a field and I tap on the text field, the pointer will sometimes shift a few words behind if I hit backspace or try to type in words. It shows itself at the end but then it shifts off and assumes I'm injecting characters in between chars instead of at the end.

Normal stage, normal situations. Adobe air 23 with a target android sdk of 22. Haven't tested on iOS

flex - How can I set the font of Label by setting android os?

  1. I changed the device font in android device : setting - display - font

  2. I want to change the font of Lables my flex application automatically. In android studio, It proceeds naturally. but, in flex application it's not so.

How can I do this?

Function for setting Bit rate and encoder in flash adobe builder (Flex)

I am working on a loop back video in Adobe Flash Builder(Flex). I want to specify bit rates and encoder. What functions will be used to do this.

mardi 21 février 2017

Accessing Items in an Array - AS3

I've got item.movieimage = one, three, sixteen, fourteen; (where item is an object (item:Object) )

The words changes as the code is taking them from my database. The database changes the words every week.

Now, I want my AS3 code to display the third element of item.movieimage.

I've tried to do this :

var my_str:String = item.movieimage+",";
var ary:Array = my_str.split(",");
    trace(ary[2]);

But it's not working. The output is "undefined".

Do you know how can I access a specific item in the Array that I've created ? Or how can I access the third item of item.movieimage ?

If I do trace(ary);, the output is :

one, 
three, 
sixteen, 
fourteen,

YouTube AS3 API (onReady doesn't work more ?)

YouTube AS3 API . This simple code was writed long time ago . and all was ok . But some days ago some problems. Early (up to 18th this month) all working OK. Flash player using AS3 API.

    public function Main()
          {
                 super();
                 Security.allowInsecureDomain("*");
                 Security.allowDomain("*");
                 stage.align = StageAlign.TOP_LEFT;
                 stage.scaleMode = StageScaleMode.SHOW_ALL;
                 this._loader = new Loader();
                 this._loader.contentLoaderInfo.addEventListener(Event.INIT,this._onLoaderInit);
                 this._loader.addEventListener(IOErrorEvent.IO_ERROR,this.errorHandlerIOErrorEvent);
                 this._loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,this.errorHandlerIOErrorEvent);
                 this._loader.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR,this.onUncaughtError);
                 this.loadTime = new Date();
                 this._loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3");
    }

    private function _onLoaderInit(param1:Event) : void
          {
             this.player = this._loader.content;
             this.player.addEventListener("onReady",this.onPlayerReady);
             this.player.x = 0;
             this.player.y = 0;
             addChild(DisplayObject(this.player));
             this._loader.contentLoaderInfo.removeEventListener(Event.INIT,this._onLoaderInit);
             this._loader = null;
    }

function onPlayerReady(param1:Event) : void // start from 18th this month , onReady dont fired
{

}

is somebody know this issue , or how fix it ? Thx .

I have to write a very basic SFTP client

My hosting company provides FTP, SFTP and shell access. I need to connect to it and upload our database. We've switched from unsecured FTP to SFTP. I've worked with an FTP library we've been able to upload via FTP but I can't find an SFTP library and it looks like I might have to write one myself. I have the source for the FTP library. Is there any change I need to make to connect via SFTP?

My project is build in Flash and ActionScript3 and it may run in the browser so it may be possible to use a JavaScript library if available.

Flash SWF, reading the file contents from inside the browser, possible?

I have an actionscript project which I deploy as both a Air desktop application and in the browser using the Flash plugin.

My desktop deployment reads the SWF file itself, creates a hash of the file and send it to my server. If the hash does not match whats expected the SWF then uploads itself to my server for further examination. This all uses the flash.filesystem libraries.

Can the same be done when deployed as Flash file in the browser. I do not have access to flash.filesystem for browser deployment.

Does a way other than using filesystem exist to read the SWF itself.

Accessing an existing property of a "null" reference

enter image description here

Here I have an object made with JSON.parse. I am trying to go through my object and fetch the media of it. It's likes, comments ext.

This however makes no sense.

In the vars I can clearly see my mediaObject. Yet in the trace defines it as 0. I can clearly see the number of likes. Yet it declares mediaObj.likes = null.

Why is this?

lundi 20 février 2017

What's a more efficient way to do collisions?

Here's my dilemma

I have 4 walls around the stage of my game, when a player hits these walls I do not want to make an if statement for each and every one of the walls checking if the player is hitting it, so I have created an array to hold the walls, then check if the player is hitting that. Now, because I am doing this I will not know what the player is actually hitting if he hits something, and I cannot do a check in my array if he's hitting like [0], [1], [2] etc because then I'm back to doing the checks if he's hitting specific walls. The reason I don't want to do that is for the future, when I add more barriers, buildings, and so on.

So my question is, how can I do collision checks, without hard coding checks on specific objects, and giving some sort of value that can be used for the player to respond to, for example if your hitting the top wall and you can figure that out somehow without doing the above, then make it so you can't walk through or something,

if (main.playerPosKeeper_mc.hitTestObject(this[main.StageCollisions]))
{
    trace("hit");
}

StageCollisions is an array which contains all of my barriers in it.

When the player hits anything in StageCollisions, I cannot just simply subtract from his y value, or x value, because I do not know which object he hit, but I also do not want to hard code it so that I check if I'm hitting lets say the top barrier, because then why do an array in the first place if I'm just going back to making static if else statements.

^^ Refrencing this topic

AS3 - How to Cycle States of Character Animations (moving & stopped)

This has been stumping me for a little while, so help would be greatly appreciated. It is a hard question to form so I can clarify points if necessary.

How to call on a variable from parent? AS3

Let's say I have a variable in the actionscript panel on a movieclip parent_mc: var ispaused:Boolean = false;

inside this movieclip is another movieclip with its own actionscript child_mc: if (!ispaused) { gotoAndPlay(1); }

How do I call for a variable inside the parent when dealing the actionscript inside a child movieclip?

What is causing this card to change dimensions? [Video & Code]

I am programming a board game in Starling (Action Script 3). The Starling version that I am using has a class called Sprite3D, which allows me to conveniently and easily code the flipping of the cards used in this game. I am troubled by the fact that my card changes dimension when flipped, and I cannot find the source of the change.

All help is appreciated.

The problem can be viewed on this youtube video.

The code can be seen in full on github at this github page.

I will continue here with more detail... All the following information is covered in the video.

The Card class contains no visual information. It is a controller class. It does hold two sprites. One sprite fills the front face, and the other sprite fills the back face. The Card class also has a mask applied and dimension attributes so that the faces will be of equal size and shape.

The Card class also holds the animation code. The code to animate the card is very similar to the code used in a video found on the starling blog that shows how Stage3D can be used implemented in a 2D game of Memory very quickly and easily. The Card class animates the rotation by using a tween to change the card's rotationY property from 0 to PI and from PI to 0 on touch events. The error occurs during the flipping process, so I will include the flipping code here:

public function flip() : void {
    _state = !(this._state);
    if( this.animations ){
        var tween : starling.animation.Tween = new Tween( this, 2, starling.animation.Transitions.EASE_OUT_BOUNCE );
        var card : Card = this;
        var didFlip : Boolean = false;
        tween.animate("rotationY", this._state == Card.FACE_UP ? Math.PI : 0 );
        tween.onUpdate = updateVisibility;
        Starling.juggler.add( tween );
    }
}
private function updateVisibility():void
{
    var sHelper:Vector3D = new Vector3D();
    var card : Card = this;
    stage.getCameraPosition( card, sHelper );
    if( sHelper ){
        this._front_face.visible = sHelper.z < 0;
        this._back_face.visible = sHelper.z >= 0;
    }
}

The FrontFace and BackFace classes both derive from the class CardFace. The CardFace class takes a card as a reference and sets a mask equal to the size and shape of the card's mask. This is likely redundant, as the card's mask should mask all children DisplayObjects, but we do it anyway.

The BackFace has text, a logo, a texture and a color.

The FrontFace does nothing. It is subclassed with specific behaviors and will convert a data object into a display layout.

In this case, we are subclassing FrontFace with ProfileFrontFace. ProfileFrontFace takes the card object and a profile data object as constructor arguments. The card object is passed to CardFace via super() calls, and the profile object is saved for later use.

When the ProfileFrontFace is added to the stage, the class extracts the title, income, and expenses from the profile data object. It creates text fields for each of these items. It also calculates a cash flow and creates a text field for this value. A background is created using a PNG texture, which is a simple white square, that is stretched over the whole face of the card's dimensions. Over this white square, we apply a color texture. After it is created, the background image is not altered. The code appears as follows:

//we remove the event listener so this function code is only executed once
this.removeEventListener( Event.ADDED_TO_STAGE, onAddedToStage );
var width : int = this.cardWidth; /* 400 */
var height : int = this.cardHeight; /* 300 */
var bg : Image = new Image( Game.assets.getTexture("blank") );
/* start the background in the top left */
bg.x = 0;
bg.y = 0;
/* have the background fill the card dimension space */
bg.width = width;
bg.height = height;
/* apply a color so that the background is not pure white */
bg.color = ColorScheme.OPAL;
/* add the background to the stage */
this.addChild( bg );

In the rest of the function, we create the text and display it. I am not including that code here for simplicity. In testing, I have removed that code and seen that it has no impact on the peculiar behavior that changes the dimensions of the card when flipped to the front face.

Has anyone seen a case where masks on a Sprite3D fail to perform as a mask?

Has anyone seen cases where a mask fails to perform on a regular Sprite object?

What about the Tween.animate() method might cause strange behavior when Tween is used to change the value of "rotationY" on an object?

Any and all answers will help. Thank you!

ActionScript synax-error

as 2.0 was like java, now in 3.0, I cannot find my error in this code:

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.Socket;
public class Main {
public static void main(String[] args){
String hostName = "localhost";
Int portNumber = 16834;
String str = "starttimer\r\n"; 
try {
    @SuppressWarnings("resource")
    Socket socket = new Socket(hostName, portNumber);
    OutputStreamWriter osw = new <br>OutputStreamWriter(socket.getOutputStream(), "UTF-8");$
    send(str, osw);
} catch (Exception e) {
        System.err.println(e.getMessage());
    }
}
static void send(String str, OutputStreamWriter o) throws IOException {
    o.write(str, 0, str.length());
    o.flush();
}

}
By the way dont worry about where is the data going

dimanche 19 février 2017

Send flash video stream to JavaScript

I want to make a script that will help user to center his face in the capture preview. Some <div> that would keep his outline green if the face is kept in a defined area and red if the face goes out.

For capture, I use Webcam.js a library with Flash fail-back.
For tracking, I'm using Tracking.JS that can handle object detection from a video element.

The goal is to make a real time face positioning plugin.

Different preview modes of Webcam.js :

  • The HTML5 preview :

A video element created by WEBCAM.JS that has for src attribute the video stream of getUserMedia function. (The video is nice handled by TRACKING.JS)

  • The Flash preview (IE Fail-back):

A .swf object (webcam.swf) whos prompts access of camera, displays the preview -IN THE FLASH MOTOR- and when the user snaps, it send back the picture to Javascript.

HERE IS MY PROBLEM:

Is there a way to build/edit swf file to make it send the video stream to javascript ? (Instead of only the picture when the snap is fired) The goal is to TRACKING.JS as well the Flash's stream than HTML5's one.

Webcam.swf > Here is Github directory of Actionscript files.

Thank you.

Why can't I access public variables from other classes?

I want to define my variables in my game document class, then use some of those variables in my Movement class. However, when I use these variables in my movement class I get tons of Compiling Errors saying that they're all undefined.

Thus my question is, why are my public variables not passed over to my other class? I have imported the class by doing import game; so this leaves me confussed. I'm probably just doing it wrong, but help is much appreciated.

Timeline

addChild((new Movement));

Game Document Class

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

    public class game extends MovieClip
    {
        public var area1:Boolean = true;
        public var area2:Boolean = false;
        public var area3:Boolean = false;

        public var player1:Boolean = true;

        public var playerPosKeeper_mc:MovieClip = new mc_PlayerPosKeeper();

        public var up_dpad:MovieClip = new dpad_Up();
        public var down_dpad:MovieClip = new dpad_Down();
        public var left_dpad:MovieClip = new dpad_Left();
        public var right_dpad:MovieClip = new dpad_Right();
        public var menu_dpad:MovieClip = new dpad_Menu();
        public var run_dpad:MovieClip = new dpad_Menu();

        public var barrierRoof1_game:MovieClip = new game_BarrierRoof();
        public var barrierRoof2_game:MovieClip = new game_BarrierRoof();
        public var barrierSide1_game:MovieClip = new game_BarrierSide();
        public var barrierSide2_game:MovieClip = new game_BarrierSide();

        public function game()
        {
            trace("SUCCESS | Constructed Game Class");

        }
    }
}

Movement Class

package 
{
    import game;
    import flash.display.Stage;
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.TouchEvent;
    import flash.net.dns.AAAARecord;
    import flash.ui.Multitouch;
    import flash.ui.MultitouchInputMode;


    public class Movement extends MovieClip
    {
        var inMotion:Boolean = false;

        public function Movement()
        {
            trace("SUCCESS | Constructed Movement Class");

            addChild(playerPosKeeper_mc);
            playerPosKeeper_mc.x = 384;
            playerPosKeeper_mc.y = 46;

            addChild(up_dpad);
            up_dpad.x = 55;
            up_dpad.y = 336;

            addChild(down_dpad);
            down_dpad.x = 57;
            down_dpad.y = 432;

            addChild(left_dpad);
            left_dpad.x = 19;
            left_dpad.y = 372;

            addChild(right_dpad);
            right_dpad.x = 118;
            right_dpad.y = 372;

            addChild(menu_dpad);
            menu_dpad.x = 61;
            menu_dpad.y = 377;

            addChild(run_dpad);
            run_dpad.x = 684;
            run_dpad.y = 369;

            addChild(barrierRoof1_game);
            barrierRoof1_game.x = 0;
            barrierRoof1_game.y = 0;

            addChild(barrierRoof2_game);
            barrierRoof2_game.x = 0;
            barrierRoof2_game.y = 470;

            addChild(barrierSide1_game);
            barrierSide1_game.x = 0;
            barrierSide1_game.y = 0;

            addChild(barrierSide2_game);
            barrierSide2_game.x = 790;
            barrierSide2_game.y = 0;

            Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

            up_dpad.addEventListener(TouchEvent.TOUCH_BEGIN, moveUpTouchBEGIN);
            up_dpad.addEventListener(TouchEvent.TOUCH_END, moveUpTouchEND);

        }
        public function moveUpTouchBEGIN(e:TouchEvent):void
        {
            trace("Touch Began")
        }

        public function moveUpTouchEND(e:TouchEvent):void
        {
            trace("Touch Ended")
        }
    }

}

Actionscript, does a faster hashing method exist than MD5?

I am using as3corelib's MD5 has function from adobe.

I am hashing a 3mb file, this is taking around 6 seconds on decent hardware.

I must find a much faster way of creating a hash.

Am I correct in assuming that its slow because its running inside the actionscript virtual machine?

Do any ways exist to speed it up?

I am really looking for minimum possible security and so if some more simple hash method exists and was faster this may be a solution.

How Do You Add MovieClips to Stage From Classes?

Actionscript 3 classes are so confusing to me.

I have defined a variable up_dpad to dpad_up, where then I have attempted to add it to the stage by putting addChild(up_dpad) in the compiler function.

This is supposed to be simple code, but I cannot understand why it doesn't work, had it been on the timeline it would've worked just fine, and this is why I don't understand why people say to put code in classes rather than on the timeline, because from what I can tell it's so annoying. Sorry for the rant, I'm just frustrated.

Timeline

new Test();

Test.as Class

    package 
{
    import flash.display.MovieClip;

    public class Test extends MovieClip
    {
        var up_dpad:MovieClip = new dpad_Up();


        public function Test()
        {
            addChild(up_dpad);
        }

    }

}

.width is the same...but they're obviously different

I have a numerous amount of displayobjects that I made using Adobe Illustrator. I am trying to get them to be exactly the same width and height as my mobile device's stage.

Should be simple....but I have some that are off, and some that are about a pixel less...

I don't mind that they are a bit stretched internally. What matters is getting them to cover the screen when I want.

Take this scene for instance... enter image description here

Just to be sure my resize script was working, I added a before and after trace statement to my script and resized it as soon as I called the function to display it.

```

trace("!!! Profile scene width = " + profileScene_mc.width);
trace("!!! stage stageWidth = " + stage.stageWidth);
trace("!!! stage width = " + stage.width);
profileScene_mc.width = stage.stageWidth;
trace("!!! Profile scene width = " + profileScene_mc.width);
trace("!!! stage stageWidth = " + stage.stageWidth);
trace("!!! stage width = " + stage.width);

```

Traces...

```

!!! Profile scene width = 480.05
!!! stage stageWidth = 480
!!! stage width = 2681.65
!!! Profile scene width = 480.05
!!! stage stageWidth = 480
!!! stage width = 2681.65

```

Clearly this profile scene is not filling up my entire stage. Nothing inside the movie clip is outside it's original bounds. The MovieClip is originally 450 by 800...I don't know what else to do or how to debug this. It's been a sore in my project for the past few weeks. I was going to just break it all in a bitmap and then recreate it if I couldn't figure it out but I'd rather not fall back on that.

Getting error #1069 when trying to call a function from actionScript?

I've a following function as:

 public function rawFlexClickDataGridItem(datagridId:String, colIndex:String, itemText:String):String
    {
        var child:Object = appTreeParser.getElement(datagridId);
        if(child == null)
        {
            return ErrorMessages.getError(ErrorMessages.ERROR_ELEMENT_NOT_FOUND, [datagridId]);
        }

        // Assumes the DataGrid has only one ListBaseContentHolder
        var dgContentList:Object = Tools.getChildrenOfTypeFromContainer(child, 
            ReferenceData.LISTBASECONTENTHOLDER_DESCRIPTION)[0];

        for each (var array:Array in dgContentList.listItems)
        {
            var item:Object = array[int(colIndex)]; 
            if(item.hasOwnProperty("numChildren"))
            {
                for(var i:int = 0;i < item.numChildren;i++)
                { 
                    if((item.getChildAt(i).hasOwnProperty("text") && (item.getChildAt(i).text == itemText)) || 
                        (item.getChildAt(i).hasOwnProperty("label") && (item.getChildAt(i).label == itemText)))
                    {
                        return String(item.getChildAt(i).dispatchEvent(new MouseEvent(MouseEvent.CLICK)));
                    }
                }
            }
            if((item.hasOwnProperty("text") && (item.text == itemText)) || 
                (item.hasOwnProperty("label") && (item.label == itemText)))
            {
                return String(item.getChildAt(i).dispatchEvent(new MouseEvent(MouseEvent.CLICK)));
            }
        }
        return ErrorMessages.getError(ErrorMessages.ERROR_TEXT_NOT_FOUND, [itemText,colIndex]);
    }
}

}

when I'm calling it from the javascript with providing (dataGrid,1,yellow) as arguments, I'm getting error #1069

My datGrid is as below:

enter image description here

samedi 18 février 2017

Print and hide dialogue with Flex/ActionScript/Air - PrintUIOptions not found

I want to print with flex/air - the normal print dialogue works.. But when I start to use start2, I get following error:

/Users/myuser/Test2.as:9
Warning: Definition flash.printing.PrintUIOptions could not be found.
      import flash.printing.PrintUIOptions;
             ^

/Users/myuser/Test2.as:12
Error: Type was not found or was not a compile-time constant: PrintUIOptions.
      var uiOpt:PrintUIOptions = new PrintUIOptions();
                ^

/Users/myuser/Test2.as:12
Error: Call to a possibly undefined method PrintUIOptions.
      var uiOpt:PrintUIOptions = new PrintUIOptions();
                                     ^

/Users/myuser/Test2.as:15
Error: Call to a possibly undefined method start2 through a reference with static type PrintJob.
      var accepted:Boolean = myPrintJob.start2(uiOpt);
                                        ^

And this is my class:

package {

  import flash.display.Sprite;

  public class Test2 extends Sprite {

    public function Test2 () {
      import flash.printing.PrintJob;
      import flash.printing.PrintUIOptions;

      var myPrintJob:PrintJob = new PrintJob();
      var uiOpt:PrintUIOptions = new PrintUIOptions();
      uiOpt.minPage = 1;
      uiOpt.maxPage = 3;
      var accepted:Boolean = myPrintJob.start2(uiOpt);
    }
  }
}

When I look at this SO answer, it should be easily possible: How to hide print dialog box in Flex?

I cannot find anymore infos in the web, maybe someone has a hint for me?

Is there anyway to use multi-lingual text fields in adobe animate cc?

Animate CC 2017 by default doesn't support right to left languages for text inputs and labels, what is a right way for this issue? how to possible create new component for use in adobe animate for this?

Anyway I can publish...faster?

enter image description here

Any time I want to test out my app (and it's fairly large) I have to debug it on my smart phone. I cant use the mobile simulator built into animate because it has a bunch of ANEs that are dependent on Google Play Services. Is there a faster way to do this vs converting everything to ARM code every time?

SWF only works in bin-debug/-release-directory

if I run Flash Builder RUN an Actionscript-Project, it works. Also if I go directly into the directory bin-debug and start the html or swf it works fine! If I build the project, I can also run it from the bin-release directory, but i I copy/move the directory to another place (local or webspace) it does not work!

Can somebody help me to build the project this way, I can upload it?

I am a newb, so plz be kind :-D

vendredi 17 février 2017

Actionscript 3 scaling

I've recently started coding in Actionscript 3, and I've run into a problem when trying to scale a MovieClip.

{
    private var valGrandX:Number;
    private var valGrandY:Number;
    public function Bonhomme_Fil()
    {
        valGrandX = this.scaleX;
        valGrandY = this.scaleY;

        this.addEventListener(MouseEvent.ROLL_OVER, big);
        this.addEventListener(MouseEvent.ROLL_OUT, small);
    }
    private function big(event:MouseEvent):void
    {
        this.scaleX *=  1.5;
        this.scaleY *=  1.5;
    }
    private function small(event:MouseEvent):void
    {
        this.scaleX = valGrandX;
        this.scaleY = valGrandY;
    }
}

My goal is to have the Clip become larger when the user's mouse hovers over it, and return to its normal size when he hovers outside of it. What ends up happening is that when it scales to a bigger size it moves towards the bottom and right, and ends up flickering back and forth.

Stop and Resume issue with stage.frameRate

I use stage.frameRate for stop and resume the game.The game menu down on stage to when click the pause button.But when I click stop button it not work until when I moving the mouse.

stopa.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void
{

fa.y+=asagi;
ban.y+=banasagi;
playa.y+=asagi;

if (fa.y>=fa.height/0.0) {
    asagi*=-2;
}   

if (ban.y>=ban.height/0.0) {
    banasagi*=-2;
}   

if (playa.y>=playa.height/0.0) {
    asagi*=-2;
}   
stage.frameRate = 0.01;
}
 
//Resume Button
playa.addEventListener(MouseEvent.CLICK, onaClick);
function onaClick(e:MouseEvent):void
{
timercheck.stop();

  fa.y+=yukari;
  ban.y+=banyukari;
  playa.y+=yukari;

if (fa.y>=fa.height/0.0) {
    yukari*=-2;
}

    if (ban.y>=ban.height/0.0) {
    banyukari*=-2;
}

        if (playa.y>=playa.height/0.0) {
    yukari*=-2;
}
stage.frameRate = 24;
}

Importing *.dae file with texture to papervision 3D

I downloaded the exmaples from http://3dvrm.com/flar/, set up a new Flash Builder Project, made some changes and finally I got my cow on top of the marker BUT just the wireframe, not the texture :-(

The Actionscript-Code looks like

                private function setupDAE():void
                {
                        //Load collada model
                        collada_model = new DAE();
                        collada_model.load("model/cow.dae");
                        //And setup it's initial parameters
                        collada_model.scale = 40;                       
                        collada_model.rotationX = 90;           
                }

The DAE shows

<library_images>
        <image id="texture0" name="texture0">
                <init_from>./Cow.png</init_from>
        </image>
</library_images>
<library_materials>
        <material id="material0" name="material0">
                <instance_effect url="#material0-fx" />
        </material>
</library_materials>

Any help?

how to enable blink cursor in TLFTextFeild in as3

mc.textFlow.interactionManager.setFocus();//mc is a TLFTextField It successfully gives focus to mc, however the familiar blinking text cursor/beam does not appear in the TLFTextField. This makes you think it does not have focus, so how to set cursor.

[How to set focus on TLFTextField - Here i refered about focus set

jeudi 16 février 2017

Object name from variable in Actionscript

I am trying to use the string in a variable to create an item in an object.

Example non functioning code:

    private var myName:String = 'group1';

    private var _ins:Object = {
        myName : { 
            data1: arr[0],
            data2: arr[1]               
        }
    }

I can not understand what syntax to use to make myName be 'group1' text. Currently I am using:

    private var _ins:Object = {
        'group1' : { 
            data1: arr[0],
            data2: arr[1]               
        }
    }

What am I missing in this Embed & Texture create code?

I am trying to follow the Starling video tutorials by Hemanth Sharma. I have typed the code as he has done on his 2nd video (linked here), but I am having difficulty getting the same results.

At first, when my code matched Mr. Sharma's and appeared as:

var bitmap:Bitmap = new Assets[name]();
gameTextures[name] = Texture.fromBitmap( bitmap );

I received the error using this code. The error stated that I was trying to instantiate a class from a non-object.

I traced the code process by breaking this into steps. Now my code appears as:

trace( "Building for", name );
var classObj : Class = Assets[name];
trace( "Class", classObj );
var bitmap : Bitmap = new classObj() as Bitmap;
trace( "Bitmap", bitmap );
trace( "Assign value" );
Assets["gameTextures"][name] = Texture.fromBitmap( bitmap );
trace("Value assigned" );

Using this code, I am able to see that the reason I get the error with Mr. Sharma's code is that the classObj, which Mr. Sharma accesses using Assets[name], initializes to null.

Mr. Sharma has no constructor to set the value of the static variables, so I assume that the Embed meta tag has something to do with the assignment of value to this field.

I will copy my code from that file and paste it below.

  1. Does anyone see where I am making my error?

  2. Can anyone explain how Embed metatags work so that I can find the error with more skill than I have now?

Assets.as:

package
{
    import flash.display.Bitmap;
    import flash.utils.Dictionary;

    import starling.textures.Texture;

    public class Assets
    {
        [Embed(source="../media/graphics/bgWelcome.jpg")]
        public static const BgWelcome:Class;

        [Embed(source="../media/graphics/welcome_hero.png")]
        public static const WelcomeHero:Class;

        [Embed(source="../media/graphics/welcome_title.png")]
        public static const WelcomeTitle:Class;

        [Embed(source="../media/graphics/welcome_playButton.png")]
        public static const WelcomePlayButton:Class;

        [Embed(source="../media/graphics/welcome_aboutButton.png")]
        public static const WelcomeAboutButton:Class;

        private static var gameTextures:Dictionary = new Dictionary();

        public static function getTexture( name: String ): Texture
        {
            if( Assets.gameTextures[name] == undefined ){
                trace( "Building for", name );
                var classObj : Class = Assets[name];
                trace( "Class", classObj );
                var bitmap : Bitmap = new classObj() as Bitmap;
                trace( "Bitmap", bitmap );
                trace( "Assign value" );
                Assets["gameTextures"][name] = Texture.fromBitmap( bitmap );
                trace("Value assigned" );
            }
            return Assets.gameTextures[name];
        }
    }
}

How to set the space between image and text in the AS3 TextFlow

my code is:

htmlMarkup:XML =
            <TextFlow whiteSpaceCollapse="preserve" version="3.0.0" xmlns="http://ift.tt/1MMzxNZ">
                <p><font face="Arial" size="18"><span>TLF 2.0 will <span class="word">include</span> support for Floats. This feature is currently under development,</span>
                    <span> so the final form may change, but what follows is a description of how it works now. We are </span>
                    <img height="auto" width="auto" src="http://ift.tt/2iNhfFp" align="left"/>
                    <span>so the final form may change, but what follows is a description of how it works now. We are </span>
                    <span>very interested in feedback on this feature, so please let us know how it works for you, </span>
                    <span>very interested in feedback on this feature, so please let us know how it works for you, </span>
                    <span>and if you have any suggestions for improvements.</span></font>
                </p>
            </TextFlow>;
var textFlow:TextFlow = TextConverter.importToFlow(htmlMarkup, TextConverter.TEXT_FIELD_HTML_FORMAT);

Run this code, the image and text is closed, no space. But I want separate them with some white pixels. I try to use css label "padding", but no effect.

mercredi 15 février 2017

Defining Variables in Class File Causing Crashes

Currently, I'm still very new to classes in flash. I've been watching tons of videos about them and I am trying to learn more about Object Oriented Programming.

With that being said, I started defining variables and assigning them to symbols in my library, all in my class file. When I use these variables in my code, I get an error message popup which says the following

Error Message:

TypeError: Error #1009: Cannot access a property or method of a null object reference. at Movement()[C:\Users\Kevin\Main Directory\Flash\Clients\org\tcdsb\ZenithsReach\Movement.as:12] at game/frame1()[game::frame1:4] at runtime::ContentPlayer/loadInitialContent() at runtime::ContentPlayer/playRawContent() at runtime::ContentPlayer/playContent() at runtime::AppRunner/run() at ADLAppEntry/run() at global/runtime::ADLEntry()

My Movement.as class file:

package 
{
    import flash.display.MovieClip;
    import flash.events.TouchEvent;

    public class Movement extends MovieClip
    {
        function Movement()
        {
            trace("SUCCESS | Constructed Movement Class");
            down_dpad.addEventListener(TouchEvent.TOUCH_BEGIN, moveDownTouchBEGIN);
            down_dpad.addEventListener(TouchEvent.TOUCH_END, moveDownTouchEND);
            var inMotion:Boolean = false;

            var area1:Boolean = true;
            var area2:Boolean = false;
            var area3:Boolean = false;

            var player1:Boolean = true;
            var playerPosKeeper_mc:MovieClip = new mc_PlayerPosKeeper  ;
            addChild(playerPosKeeper_mc);
            playerPosKeeper_mc.x = 384;
            playerPosKeeper_mc.y = 46;

            var up_dpad:MovieClip = new dpad_Up  ;
            addChild(up_dpad);
            up_dpad.x = 55;
            up_dpad.y = 346;

            var down_dpad:MovieClip = new dpad_Down  ;
            addChild(down_dpad);
            down_dpad.x = 57;
            down_dpad.y = 442;

            var left_dpad:MovieClip = new dpad_Left  ;
            addChild(left_dpad);
            left_dpad.x = 19;
            left_dpad.y = 382;

            var right_dpad:MovieClip = new dpad_Right  ;
            addChild(right_dpad);
            right_dpad.x = 118;
            right_dpad.y = 382;

            var menu_dpad:MovieClip = new dpad_Menu  ;
            addChild(menu_dpad);
            menu_dpad.x = 61;
            menu_dpad.y = 386;

            var run_dpad:MovieClip = new dpad_Menu  ;
            addChild(run_dpad);
            run_dpad.x = 684;
            run_dpad.y = 386;

            var barrierRoof1_game:MovieClip = new game_BarrierRoof  ;
            addChild(barrierRoof1_game);
            barrierRoof1_game.x = 0;
            barrierRoof1_game.y = 0;

            var barrierRoof2_game:MovieClip = new game_BarrierRoof  ;
            addChild(barrierRoof2_game);
            barrierRoof2_game.x = 0;
            barrierRoof2_game.y = 470;

            var barrierSide1_game:MovieClip = new game_BarrierSide  ;
            addChild(barrierSide1_game);
            barrierSide1_game.x = 790;
            barrierSide1_game.y = 0;
            function moveDownTouchBEGIN(e:TouchEvent):void
            {
                if (player1 == true)
                {
                    if (area1 == true)
                    {
                        if (playerPosKeeper_mc.hitTestObject(barrierRoof1_game))
                        {

                        }
                    }
                    else
                    {
                        // add other areas in the future
                    }
                }
                else
                {
                    // if your not player1, then we need to find out what you are,
                    // and give you the proper walking animations
                }
            }

            function moveDownTouchEND(e:TouchEvent):void
            {

            }

        }

    }

}

dynamic txtField issue in different frames in Actionscript 3

I have one input name txt field and log in button in PAGE 1(Frame 1), next button PAGE 2(Frame 2) and lastly, another dynamic txt box PAGE 3(Frame 3). I wanted the name of the user to appear in dynamic txt box in Frame 3 only.

The user must proceed first in frame 2 (page without dynamic txtbox) before going to frame 3 which have a the dynamic txtbox. I have tried inserting a dynamic txtbox in PAGE TWO/FRAME 2 and hide it (using .visible=false;) but when I turn on its visibility in FRAME 3, the name is not appearing anymore. This is my code so far:

FRAME 1/PAGE 1:

var myName:String = "";

function handleClick(Event:MouseEvent):void
{
    myName = boxOne.text;
    gotoAndStop("logIn")
    else 
}
btn_LogIn.addEventListener(MouseEvent.MOUSE_UP, handleClick);

FRAME 3/PAGE 3:

boxTwo.text = myName;

error #1009 can't access property of null object

i'm newbie here i got an eror where i can't load external swf from my main fla the ouput said like this

`TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at com.senocular.utils::KeyObject/construct()
    at com.senocular.utils::KeyObject()
    at com.asgamer.basics1::Ship()
    at com.asgamer.basics1::Engine()`

I create a button and tried to load swf file called basics1 which content all those classes above, and i using action code snippet to load swf file please help i'm not a programmer sorry if my question in easy

THANKS IN ADVANCE.

Missing Rightbrace Syntax Error, I don't see any issues

I must be blind or something, as I cannot see what's wrong with my code. I'm just playing around with flash, but I stumbled on this error that I cannot see how to fix.

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

    public class game extends MovieClip{
        public function game() 
        {
            trace("SUCCESS | Constructed Game Class");
            var playerPosKeeper_mc:MovieClip = new mc_PlayerPosKeeper;

            private var timer:Timer = new Timer(3000);

            private var timerFn:Function = new Function(e.TimerEvent){

            }
            timer.addEventListener(TimerEvent.TIMER, timerFn);
            timer.start();
        }
    }
}

I get the error

Line 17 1084: Syntax error: expecting rightbrace before timer.

URLRequest works in Chrome, but not in Safari

The same URLRequest inside of a .swf works on Chrome, but not Safari

Chrome environment: Windows 10 + Chrome (56.0.2924.87) + Flash debugger 24,0,0,221

Mac environment (OS 10.11.06) + Safari (9.1.2) + Flash debugger 24.0

private function getAsset(url:String,callback:Function):void{
            var urlLoader:URLLoader = new URLLoader();
            var urlRequest:URLRequest = new URLRequest(url);

            urlLoader.addEventListener(Event.COMPLETE,callback);

            urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,function(e:SecurityErrorEvent):void{
                Debug.log( "Security error event", e );
            });
            urlLoader.addEventListener(IOErrorEvent.IO_ERROR,function(e:IOErrorEvent):void{
                Debug.log( "IO error event", e );
            });
            urlLoader.addEventListener(ErrorEvent.ERROR,function(e:ErrorEvent):void{
                Debug.log( "error event", e);
            });
            urlLoader.load(urlRequest);
        }

When this AS3 code is compiled into a .swf and run inside of Chrome, it works.
When this same code is run inside of Safari, it fails with an IOError:

Error #2032: Stream Error. URL: [url]

Why do I get an error in Safari, and not in Chrome?

The url (a .m3u8 file) is sensitive information, so I can't paste it here, but it is absolute (contains http://...) as opposed to a relative link

When the link is navigated to in Safari, you'd get a 403, but when the link is opened in Chrome, you'd download the file, which makes me think that it's a problem with the browser, and not with the code.

The project is compiled with Flash Builder 4.6, using Flex 4.6.0

Flash AS3 - Remove Multiple addChild

I am using the following to add a repeating animation.

var recC01: cube01;
function attachC1() {
    recC01 = new cube01();
    recC01.x = -158;
    recC01.y = 159;
    addChild(recC01);
    trace("cube1");
}
var myIntervalC1: uint = setInterval(attachC1, 500);

The repeating animations are added at various keyframes with unique names. ie. recC01, recC02, etc. as well as attachC1, attachC2, etc.

During playback the user is able to click a "Back" button to rewind to the previous section. I am struggling because the button appears on the timeline before the instances so I cannot use clearInterval and Removechild for an instance that does not yet exist. I'd like to avoid creating unique var everytime a new child is added. Keeping track of that would be crazy.

The user could click the back button before any of these are loaded or in between say recC01 and recC02...

What is the best way to remove all of the child instances? Is there a method to listen for the Interval and Child and then

mardi 14 février 2017

String with multiple lines of weblink images. How to display them ?

I've got a String full of weblink image (23 links) :

listItem.text = String(item.movieimage);

How can I displays these 23 images in my AS3 code (AIR app) ?

Thanks