vendredi 31 juillet 2015

Convert a symbol to bitmap in Flash using Action Script

I am developing a small game using Flash CC. The question may seem very absurd since I am a novice to coding and Action Script.

Here it goes: Can we write a code to convert a symbol to bitmap?

Actually, the game has multiple objects and I have defined them as buttons. When the user clicks on one of the object, it moves to a new position. I dont want two objects simultaneously to move to a new position.

My logic: If I can make every other object as a bitmap, the user wont be able to click on any other object when one object is moving. Any thoughts???

How can i convert a monophonic netstream to stereo in AS3?

I have one client that broadcasts monophonic audio, and a client that recieves this audio via netstream. What i want to do, is convert this monophonic stream into stereo AFTER i received it. I know how to convert to stereo in AS3, but only using sample data.But i'm broadcasting into the netstream with netstream.publish, so how am i going to catch the samples on the receiver? Maybe i should just send samples and dispatch a class to receive them on the other side? Please help me, i'm a very confused student...

Actionscript: Check Throttle Status?

Is there a way to check the throttle status without using ThrottleEvent?

E.g., someone else's Flash container swf loads, gets throttled and receives the ThrottleEvent, then loads my swf. Can my swf tell that it's throttled?

(Assume I do not know the owner of the container swf and cannot change it in any way.)

Actionscript 2.0 Apply sound on keydown

I have problem, i am coding flash app in AS2 and i need help. I want to when my character jump sound can be heard. Here is what i've tried.

if (Key.isDown(Key.UP) {
jump.wav.start();
}

This code is applied on character. There are another code that is applied on my character, here it is. Instance name of character is char, I was exploring on internet about 20 minutes and nothing works. Name of sound is jump and it is .wav file. I think that i wrote all that i need. Every answer is very helpful! :)

Flex Spark PNG Image with Transparency acting as button

I have a PNG image that has some transparency it is a 20px x 20px png image of an X. Given the shape of the X the hit state is odd since it gets interpreted as transparent. How do you make the whole area 20px x 20px clickable?

<s:Image id="closeOut" y="10" source="@Embed('/assets/png/X.png')" click="this.visible=false"/>

If you hover over where ever there isn't the X, left and right mostly it isn't clickable. Thoughts?

A conflict exists with definition event in namespace internal

I am new in as3. please help me. i got error "A conflict exists with definition event in namespace internal". i 'm using same coding but different scene.second scene i change

var mysound:bila =new bila()

this is coding in my 1st scene and success only in 1st scene

var isItPlaying:Boolean = true;

var lastposition:Number = 0;

var mysound:izhar = new izhar();

var soundchannel:SoundChannel = new SoundChannel();

soundchannel = mysound.play(0,0);// playing sound in the channel

soundchannel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete1);

    function onPlaybackComplete1(event:Event):void
    {

        lastposition = 0;
        soundchannel.stop();
        btn.btn_pause.visible = false;
        trace("finished");
        isItPlaying=false;

    }

    /************end of part 1********/

btn.addEventListener(MouseEvent.CLICK, playsound);

function playsound(event:MouseEvent):void {

if (! isItPlaying)
{
    soundchannel = mysound.play(lastposition,0);
    btn.btn_pause.visible = true;
    isItPlaying = true;


}
else
{
    lastposition = soundchannel.position;
    soundchannel.stop();
    btn.btn_pause.visible = false;
    /*trace(lastposition.toFixed(0), mysound.length.toFixed(0));*/
    isItPlaying = false;
}

soundchannel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);

    function onPlaybackComplete(event:Event):void
    {

        lastposition = 0;
        soundchannel.stop();
        btn.btn_pause.visible = false;
        trace("finished");
        isItPlaying=false;

    }

}

flash ,black screen after movie end on full screen mode

i have a flash file in local , it have a flv movie on first frame . in the moviecomplete event it go to another frame . the problem is that when i play it in full screen after end of movie only a black screen remain that i could pass by pressing esc . how can i remove this? its my code

stage.displayState = StageDisplayState.FULL_SCREEN;
   stage.scaleMode = "showAll";

load1.addEventListener(Event.COMPLETE, loadvideoComplete);
load1.fullScreenTakeOver = false;

load1.play();
function loadvideoComplete(event: Event): void //event:Event not event:VideoEvent
{
    //load1.visible=false;
    trace("loadvideoComplete");
    gotoAndPlay("index");
}

hiding video didnt worked either

Away3D HoverCamera Pan Angle - relative angle out of 360

I'm trying to work out the percentage of rotation of the HoverCamera but .panAngle() returns any number from -infinity to + inifinity, is there a way to work out the current angle out of 360 instead, no matter how times you rotate the camera?

Published SWF file not displaying required content

I have an existing SWF file that was given by someone else which looks & works just fine.Working SWF file

When I tried to open the source FLA file and just publish it without making any changes whatsoever, the published SWF does not display some of the required content. Broken areas have been highlighted in red Broken SWF file

The problem I had initially was due to missing fonts but even when I installed the missing fonts and embedded them in the FLA before publishing, I still see the same problem. Any clues as to what I could be missing?

XML Data missing when project gets published

I completed my first Flash/Actionscript project and I feel ready to publish it. Here is the problem:

In my program I refer to several values which are defined in one XML file and are loaded in via code. When I test my program in Flash everything works fine. But after I publish my project all parameters which should be defined by the XML are setted to zero. It seems like the published fla file doens't find the XML it should refer to. I want the program to run on computers which don't have the original XML file on their hard drive.

Which settings do I have to apply to fix this? What should I do?

Thanks ;)

How can i use the gotoAndStop function and frame label in subclass in actionscript3?

Actually in my timeline totally 5 frames are present. Having two movieclips in first frame, If I pressed an any of the one I need to go to third frame in the timeline. I am getting error when I am using this code in Sub class

public function Game(num:uint):void
        {
            if (num == 1)
            {
                gotoAndStop("Gameplay");
            }
        }

Kindly help me how to do this in subclass.

Thanks in advance!

jeudi 30 juillet 2015

URLLoader Flash to grab PHP Info

I am trying to send a variable from Flash to PHP, and then echo it back to flash (ignore function names etc. for now; just trying to troubleshoot the basics first).

Flash file (call it test.as):

  var myLoader:URLLoader = new URLLoader();
  var file_path:String = "get_this.php";
  var myRequest:URLRequest = new URLRequest(file_path);
  myRequest.method = URLRequestMethod.POST;
  var memberInfo:URLVariables = new URLVariables();
  myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
  memberInfo.member_id = 10;
  myRequest.data = memberInfo;
  myLoader.addEventListener(Event.COMPLETE, onXMLLoad);
  myLoader.load(myRequest);

  function onXMLLoad(event:Event)
  {
    trace(myLoader.data);
  }

PHP file (get_this.php):

<?php
header('Content-Type: text/xml');
echo "<?xml version='1.0' encoding='UTF-8'?>";

$member_id = $_POST['member_id'];   

echo "member_id=$member_id";
?>

However, when I do this, the trace on "myLoader.data" returns a massive string consisting of every single word in the entire PHP file, including comments, which are omitted on this post (C++/Flash style comments (//) ), with some random numbers separated by % signs. This surely is an easy fix, but I am rather new to PHP (and not too experienced with Flash yet), so if someone could help me out I would be very appreciative.

actionscript 3 calling function from another movieclip

i have 2 movieclip on different frames of main timeline . im trying to move in different frame of timeline(from index to page c11) and call a function in the second movieclip . when i use code in main timeline using a bottom it work good

gotoAndPlay("c11");
aks1.aks2.c1Load();

but when i use it in another movieclip like this

MovieClip(parent).gotoAndPlay("c11");
MovieClip(parent).aks1.aks2.c1Load();

the function c1Load() dosent start . i dont get any error but this is displayed TypeError: Error #1009: Cannot access a property or method of a null object reference. at fan_fla::hand_3/frame184()

p.s i need to run it after the last frame of first movieclip

AS3 - How do you wait for a tween inside a for loop to complete?

I'm drawing a large shape using an array of points in a for loop and tweenlite as found at http://ift.tt/1I5Wnyc

for(var i:uint = 0; i < pointsArray.length; i++){
TweenLite.to(dot2, .05, {x:pointsArray[i].x,
  y:pointsArray[i].y,
  delay:i*.05,
  overwrite:false,
 onUpdate:updateHandler});
}
function updateHandler():void{
lineAnim.graphics.lineTo(dot2.x, dot2.y);
lineAnim.graphics.moveTo(dot2.x, dot2.y);
}

I would like the animation to complete before continuing, but I'm unable to find a way to be notified when the full animation is complete. onComplete does not work as it triggers on the first set of coords. I also tried triggering when

i == pointsArray.length

but the loop finishes multiple seconds before the animation completes. I would like to avoid using a timer.

How to check TabNavigator Page efficiently

I am using flex TabNavigator to display few datagrids. Each datagrid have same structure but populated with different dataProvider. Currently I am using following method to check which datagrid or an element from a tab was clicked.

if(TabNavigator.selectedIndex == 0){

}else if(TabNavigator.selectedIndex == 1){

} ... else if(TabNavigator.selectedIndex == 4){

}

My question is is there an efficient way to check this? Is there anyway I can organize similar structure in to one property? Thank you.

Passing data/variable from a Visual Basic form to a Flash Object

I'm pretty sure that this can be answered somewhere here on stackOverflow but I'm out of options with this.

I have a VisualBasic form with an button object on it. I would like that button to have an onClick procedure so that clicking it passes a variable or other command to another window which has a Shockwave Flash "movie" running. (For example, there is a function on the ActionScript of the Flash file to display some text in the Flash Video running when invoked.)

What am I missing to make this possible? I know it's something about the fscommand but not sure how to pass a variable from VB with it.

Trouble compiling AIR for iOS using ADT

I'm fairly new to AIR. I'm developing an app for Android and iOS that uses some ANEs (Milkman's GoViral, AdMob, GoogleServices). They're all supposedly compatible across platforms. My app works perfectly on Android, but completely crashes when I install it on an iPad. It shows a black screen and crashes two seconds after. Anyone got any ideas?

This is the command line I'm using: -package -target ipa-test -storetype pkcs12 -keystore blablabla.p12 -provisioning-profile blablabla.mobileprovision bla.ipa bla-app.xml bla.swf languajes.xml resources -extdir exDir

Any help on this matter would be GREATLY appreciated. I have zero knowledge about iOS or any Apple product. Thank you!

Monitor load of crossdomain.xml file?

Is there any way to monitor the loading of the crossdomain.xml file?

I'd like report the load times of this file, since it seems to be intermittently taking longer than expected. There doesn't seem to be an event from URLLoader and Security.loadPolicyFile() doesn't allow any event listeners.

How can get the load time for a crossdomain.xml file without requiring additional loads of the file?

Working with large number of Labels

(Probably a noobish question but...) I am trying to write a custom component which essentially contains a rather large table (at the largest, it should be 800 x 35 fields, of which only up to 20 x 10 is visible at a time). I was wondering if anyone could give me some pointers/advices how to do that in optimal way.

What am I using now: component extends UIComponent, I have a custom scroll-bar and use a new spark.components.Label as a text container for each field in the table. I put the labels inside another UIComponent, so I can mask label edges outside the display area. I have tried:

  1. Draw only data that is contained in display area. When the user moves the scroll-bar, data is re-drawn, however, since there is still a lot of Labels, the component becomes a bit laggy.
  2. Draw the entire table and use mask/container position to show only the part of a table represented by the position of sliders. However, it takes a long time to draw and might use a lot of memory I suppose.
  3. (Current idea) Multithreading. This is completely new for me, so I have set up a background Worker and want it to return an UIComponent with the table drawn, while the user can continue interacting with other parts of the component. So here come my questions:
    • So far I am having trouble transferring UIComponent using MessageChannel. Is such a transfer using MessageChannel possible in the first place or should I use alternative approach?
    • Is there an alternative approach for similar cases? Maybe I should use different containers for the text/table itself?
    • Maybe I should use the background worker to draw BMP and use it instead of a UIComponent. If so, maybe someone could refer me to a nice tutorial or guide how to do this?

Thanks for the help and let me know if you need any additional info.

-Vil

Rearrange children of Scroll Container

I am trying to rearrange the children in a Scroll Container. I have a list collection with the same children and it is in the right order, all I need to do is take the scroll container and make the order of the children the same as the list collections order.

If any more details are needed, just ask and I can provide.

Thanks.

A script to start webcam live streaming on website

I have a live webcam streaming app that has been using Red5 server and rtmp protocol. When I test oflaDemo (www.mydomain:5080/demos/publisher.html) I can see my streaming, so rtmp is ok.

But, what is the best approach and is there any script that can be placed on .php page that will connect to Red5 and start streaming on my Red5 server.

This should work: User login to his account, and has the option to start broadcasting. Then this will connect to Red5 and start the streaming under his name. So when anyone else enter his profile, they can see the user.

Any script? Tutorial? Hint?

swf customize order of symbol class

In a flash project, I'm embedding images into SWF using actionscript code. To generate SWF from action script, I'm using "mxmlc" for compilation. But now the problem with the symbol class. When viewed swf with swfdump, the order in which the resources are embedded into the code are different each time when the class/constructor name changes.
Is there any way to customize the order of symbol class name.

Order should be as follows when views in swfdump:

[04c]       174 SYMBOLCLASS
                exports 0001 as "swffile_img0"
                exports 0003 as "swffile_img2"
                exports 0002 as "swffile_img6"
                exports 0006 as "swffile_img5"
                exports 0005 as "swffile_img1"
                exports 0004 as "swffile_embeddedXML"
                exports 0007 as "swffile_img4"
                exports 0009 as "swffile_img3"
                exports 0008 as "swffile_img7"

AWS Flask no longer accepting POST method from Flash actionscript

I have a Flask project deployed on AWS / Elastic Beanstalk

I have an embedded Adobe Flash SWF which attempts a POST request method to my published URL. It was previously working, but now it no longer accepts it -- instead, it does nothing.

The POST request does work on localhost, but not when deployed. I believe this may be a permissions issue involving crossdomain / CORS support, but I am not sure. How can I ensure that cross-domain requests are accepted in AWS EB?

Adobe Air - put image inside a circle

I am making a contact manager and I have the images of the contacts. I would like to display these images inside a circle like Android's "Material Design" does.

How?

Thanks!

Avi

Adobe Air - How to style a textbox so it only has the bottom border line

I have a form that the user needs to fill out. The form contains TextBoxes. The default Adobe Air textboxes are old school styled. I want to modify them so they look more modern. How can I style a textbox so it only has the bottom border line and its fill color is white?

Thanks!

Avi

AS3 shuffling movieclips

I've added the basic targets and applying drag and drop for my puzzle pieces, now Im having trouble making the shuffling aspect. As in, after the player completes or opens up the fla, each time will start the puzzle pieces in random places of the stage. I understand using arrays for shuffling somehow but Im not sure exactly how to achieve this. I've stored the instance of my 19 puzzle pieces inside the array but now I have no idea what to do with this array. Other tutorials were abit out of my league and leaves my head scratching.

Just started doing coding for flash professional so yeah, any help with the shuffling movie clips ie the puzzles pieces would be greatly appreciated.

Heres's my code, Im not posting the whole thing since from P1 to P19 is basically copy pasting:

import flash.events.Event; stage.addEventListener(Event.ENTER_FRAME, EntFrame) function EntFrame(e: Event) : void {

P1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
function fl_ClickToDrag(event:MouseEvent):void
{
    P1.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
function fl_ReleaseToDrop(event:MouseEvent):void
{
    P1.stopDrag();
}
if (T1.hitTestObject(P1.Tar1))
{
    P1.x = 313.15;
    P1.y = 242.75;
}

P19.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_19);
function fl_ClickToDrag_19(event:MouseEvent):void
{
    P19.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_19);
function fl_ReleaseToDrop_19(event:MouseEvent):void
{
    P19.stopDrag();
}
if (T19.hitTestObject(P19.Tar19))
{
    P19.x = 624.35;
    P19.y = 455.60;
}

}

How to display a notification in adobe air for android

I want to display notifications in my Adobe Air App for Android using Adobe Flash and Action Script 3.0 .

I want to use notifications for reminding people to update my app when a new version gets released, so how do I do this?

Thank you.

mercredi 29 juillet 2015

How do I get this actionscript Flash program to display an image?

I'm building inside Flash Builder and just started learning actionscript about 1 hour ago; I can't seem to find a good resource to learn this subject quickly. Prime objective, what should be a simple task: Get this thing to display an image. It appears to load the image correctly (It apparently figured out the encoding), and it compiles fine, but all I get is a blank white screen when it loads in firefox(Flash is enabled and working fine.). Could anyone help? Complete n00b here. I'm well experienced with java, c#, c, html, php and the like, but complete actionscript/flash n00b.

package
{
    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.display.Bitmap;

    public class images extends Sprite
    {
        public function images()
        {
            drawIcon();
        }
        private var sp:Shape;

        [Embed(source="E:/Documents/Shapemakr/ebayPics/July29_TreeImagesForFBbuilding/IMG_3294.JPG")]
        private var contentIconClass:Class;
        private var contentIcon:Bitmap = new contentIconClass ();

        // ...

        private function drawIcon():void{
            sp.graphics.beginBitmapFill(contentIcon.bitmapData);
            sp.graphics.drawRect(20, 35, 13, 13);
            sp.graphics.endFill();
        }
    }
}

AS3 addChild with multiple buttons top layer fails

this seems like an odd one as it seems pretty straight forward, I have a movieclip that contains a back and forward button to invoke a tween for 2 groups of buttons to slide accross the screenI addChild then make the tween and then removeChild for the old group of buttons to leave the new one on the screen.

My question is when the second group comes in with all the buttons the button that is on the top layer of the movieclip fails to work (rollOver Tween and all) if I change which button is on the top layer then that one fails.

any ideas as to why this may occur so I can make a fix?

code for process is below.

import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.Strong;
import flash.events.*;
import flash.display.MovieClip;

fOverlay.addEventListener(MouseEvent.ROLL_OVER, mOver);
fOverlay.addEventListener(MouseEvent.ROLL_OUT, mOut);
fOverlay.addEventListener(MouseEvent.CLICK, mDown);
bOverlay.addEventListener(MouseEvent.ROLL_OVER, mOverB);
bOverlay.addEventListener(MouseEvent.ROLL_OUT, mOutB);
bOverlay.addEventListener(MouseEvent.CLICK, mDownB);
var butts1:MovieClip = new sButtons1;
var butts2:MovieClip = new sButtons2;

addChild(butts1);
butts1.x = -10;
butts1.y = 0;

function mOver(e:MouseEvent)
{
    var mouseOTween:Tween = new Tween(fBack, "alpha", Strong.easeOut,0.2,0.8,1,true);
}

function mOut(e:MouseEvent)
{
    var mouseOTween:Tween = new Tween(fBack, "alpha", Strong.easeOut,0.8,0.2,1,true);
}

function mOverB(e:MouseEvent)
{
    var mouseOTween:Tween = new Tween(bBack, "alpha", Strong.easeOut,0.2,0.8,1,true);
}

function mOutB(e:MouseEvent)
{
    var mouseOTween:Tween = new Tween(bBack, "alpha", Strong.easeOut,0.8,0.2,1,true);
}

function mDown(e:MouseEvent)
{
    if (butts1.stage)
{
    addChild(butts2)
    butts2.x = 1832;
    butts2.y = 0;

    var nTweenout1:Tween = new Tween(butts1,"x", Strong.easeInOut, -10, -1860, 1, true);
    var nTweenin1:Tween = new Tween(butts2,"x", Strong.easeInOut, 1832, -10, 1, true);
    nTweenout1.addEventListener(TweenEvent.MOTION_FINISH, moFinish1);

    function moFinish1(e:TweenEvent)
    {
        removeChild(butts1);
    }
}

else if (butts2.stage)
{
    addChild(butts1)
    butts1.x = 1832;
    butts1.y = 0;

    var nTweenout2:Tween = new Tween(butts2,"x", Strong.easeInOut, -10, -1860, 1, true);
    var nTweenin2:Tween = new Tween(butts1,"x", Strong.easeInOut, 1832, -10, 1, true);
    nTweenout2.addEventListener(TweenEvent.MOTION_FINISH, moFinish2);

    function moFinish2(e:TweenEvent)
    {
        removeChild(butts2);
    }
}

else
{
    MovieClip(root).addChild(butts1)
    butts1.x = -10;
    butts1.y = 0;
}
}

function mDownB(e:MouseEvent)
{
    if (butts1.stage)
    {
        addChild(butts2)
        butts2.x = -1860;
    butts2.y = 0;

    var nTweenoutB1:Tween = new Tween(butts2,"x", Strong.easeInOut, -1860, -10, 1, true);
    var nTweeninB1:Tween = new Tween(butts1,"x", Strong.easeInOut, -10, 1832, 1, true);
    nTweenoutB1.addEventListener(TweenEvent.MOTION_FINISH, moFinish3);

    function moFinish3(e:TweenEvent)
    {
        removeChild(butts1);
    }
}

else if (butts2.stage)
{
    addChild(butts1)
    butts1.x = -1860;
    butts1.y = 0;

    var nTweenoutB2:Tween = new Tween(butts1,"x", Strong.easeInOut, -1860, -10, 1, true);
    var nTweeninB2:Tween = new Tween(butts2,"x", Strong.easeInOut, -10, 1832, 1, true);
    nTweenoutB2.addEventListener(TweenEvent.MOTION_FINISH, moFinish4);

    function moFinish4(e:TweenEvent)
    {
        removeChild(butts2);
    }
}

else
{
    addChild(butts1)
    butts1.x = -10;
    butts1.y = 0;
}
}

Adobe Air - How to dim background when displaying a dialog (title window)

Lets say I have the following mxml:

<view...>

  <s:VGroup width="100%" height="100%">
      <s:Button label="some label"/>
      <s:Button label="some other label"/>
      <s:Button label="yet another label"/>
      <s:Button label="one last label"/>
  </s:VGroup>

  <s:TitleWindow includeIn="abandon" id="dlgAbandon" title="Question">
        <s:VGroup horizontalAlign="center" paddingTop="8" paddingBottom="8" paddingLeft="20" paddingRight="20" gap="10" width="100%" height="100%">
            <s:Label text="Why?" color="{Constants.ChromeColor}" fontWeight="bold"/>
            <s:VGroup width="100%" gap="10">
                <s:Button label="reason 1" width="100%" id="btnR1"  click="onDlgWhyNotClose('reason 1')"/>
                <s:Button label="reason 2" width="100%" id="btnR1"  click="onDlgWhyNotClose('reason 2')"/>
                <s:Button label="reason 3" width="100%" id="btnR1"  click="onDlgWhyNotClose('reason 3')"/>
            </s:VGroup>
        </s:VGroup>
    </s:TitleWindow>

</view>

Now in my code I change the currentState to "abandon" so the dialog is displayed on top of the VGroup.

How can I dim the background behind the dialog (everything in the VGroup or even its parent - the view)? how can I undim it when dialog is closed?

Thanks :-)

Avi

Find the target Flash Player version of a parent swf?

Is it possible to find out which Flash Player version was targeted to compile a swf that has loaded my swf into it?

I.e., if my game swf is targeted to version 11.2 and gets loaded into a swf that was compiled to target 10.1, how I can get access to that 10.1 target version?

Distriqt ANE key cannot be verified in Android

I am developing an App for iOS and Android, for this app I am using ANEs from distriqt, and they say they work for both platforms. In iOS these ANEs work but when I develop in Android I get the error: Your key was not able to be verified for the com.distriqt.Notifications native extension, but the key works for NetworkInfo ANE.

If you have had a similar situation with these ANEs, could you please help me to attack this problem?

Thank you very much.

PD: My descriptor for android where i declare the extensions is below.

   <extensions>
        <extensionID>com.milkmangames.extensions.GoViral</extensionID>
        <extensionID>com.distriqt.NetworkInfo</extensionID>
        <extensionID>com.distriqt.InAppBilling</extensionID>
        <extensionID>com.distriqt.Application</extensionID>
        <extensionID>com.distriqt.Notifications</extensionID>
        <extensionID>com.distriqt.PushNotifications</extensionID>
        <extensionID>com.distriqt.Core</extensionID>
    </extensions>

  <android>
    <manifestAdditions><![CDATA[
        <manifest android:installLocation="auto" >
            <!--<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16"/>-->
            <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" />

            <uses-permission android:name="android.permission.INTERNET"/>
            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
            <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
            <uses-permission android:name="android.permission.GET_ACCOUNTS" />
            <uses-permission android:name="android.permission.VIBRATE"/>
            <uses-permission android:name="android.permission.WAKE_LOCK" />
            <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
            <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

            <!-- Only this application can receive the messages and registration result -->
            <permission android:name="com.4starscasino.4StarsCasino.C2D_MESSAGE" android:protectionLevel="signature" />
            <uses-permission android:name="com.4starscasino.4StarsCasino.permission.C2D_MESSAGE" />

            <uses-permission android:name="com.android.vending.BILLING" />

            <application>
                <receiver android:name="com.distriqt.extension.notifications.NotificationsReceiver">
                    <intent-filter>
                        <action android:name="com.4starscasino.4StarsCasino.NOTIFICATION" />
                        <action android:name="com.4starscasino.4StarsCasino.DELAYED_NOTIFICATION" />
                    </intent-filter>
                </receiver>
                <receiver android:enabled="true" android:exported="true" android:name="com.distriqt.extension.pushnotifications.PushNotificationsBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
                    <intent-filter>
                        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                        <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                        <category android:name="com.4starscasino.4StarsCasino" />
                    </intent-filter>
                </receiver>
                <service android:enabled="true" android:exported="true" android:name="com.distriqt.extension.pushnotifications.gcm.GCMIntentService" />
                <receiver android:name="com.distriqt.extension.pushnotifications.PushNotificationsReceiver">
                    <intent-filter>
                        <action android:name="com.4starscasino.4StarsCasino.PUSHNOTIFICATION_SELECTED" />
                        <data android:scheme="dtpn" />
                    </intent-filter>
                </receiver>
                <receiver android:enabled="true" android:name="com.distriqt.extension.application.receivers.ApplicationStartupReceiver" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
                    <intent-filter>
                        <action android:name="android.intent.action.BOOT_COMPLETED" />
                        <category android:name="android.intent.category.DEFAULT" />
                    </intent-filter>
                </receiver>
                <activity android:launchMode="standard">
                    <intent-filter>
                     <action android:name="android.intent.action.MAIN"/>
                     <category android:name="android.intent.category.LAUNCHER"/>
                    </intent-filter>
                </activity>
                <activity android:name="com.facebook.LoginActivity"
                      android:theme="@android:style/Theme.Translucent.NoTitleBar"
                      android:label="Login" />

                       <!-- replace 000000000000000 with your numeric Facebook Application ID -->
                      <provider android:authorities="com.facebook.app.NativeAppCallContentProvider634656129942853" android:name="com.facebook.NativeAppCallContentProvider" />

                      <!-- replace 000000000000000 with your numeric Facebook Application ID, and com.yourcompany.example with your apks application ID -->
                      <meta-data android:name="com.4starscasino.4StarsCasino" android:value="634656129942853"/>
                <activity android:name="com.distriqt.extension.inappbilling.activities.PurchaseActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"></activity>
            </application>

        </manifest>

      ]]></manifestAdditions>

    <!-- Color depth for the app (either "32bit" or "16bit"). Optional. Default 16bit before namespace 3.0, 32bit after -->
    <!--<colorDepth></colorDepth>-->
    <!-- Indicates if the app contains video or not. Necessary for ordering of video planes with graphics plane, especially in Jellybean - if you app does video this must be set to true - valid values are true or false -->
    <!-- <containsVideo></containsVideo> -->
</android>

mardi 28 juillet 2015

FLVPlayback Event.Complete not detecting video ending

I'm using Flash CC 2015 and Action Script 3.0. The general idea is a menu (that's on frame 1), with buttons that lead to frames with different FLVPlayback components that play videos. Upon completion of the video I want to return to the menu on frame 1.

Here's what I have an frame 2 (where the component is) so far:

import fl.video.*;

stop();

var hole1:FLVPlayback = new FLVPlayback();
hole1.source = "Hole 1.mp4"

hole1.width = 1920;
hole1.height= 1200;
hole1.scaleMode = VideoScaleMode.MAINTAIN_ASPECT_RATIO;


addChild(hole1);

hole1Vid.addEventListener(Event.COMPLETE, playbackComplete);

function playbackComplete(event:Event):void
{
    trace("Video End");
    gotoAndPlay(1);
}

The main menu links to this frame and plays without any issue, however nothing happens when the video ends.

Thanks in advance for the help!

I would like to use bitmap fill for an array

I would like to use the beginBitmapFill property to fill with a sprite from an array. Is this possible, and if so, how would I go about it? Thanks!

SOAP Web Service Auth Headers issue

I am currently trying to use a web service from a Flex client, and hitting a small issue. The service reads a SOAP header called 'AuthHeader' for credentials, and it works from a test client (using Storm from CodePlex) using this request:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://ift.tt/ra1lAU" xmlns:xsd="http://ift.tt/tphNwY" xmlns:soap="http://ift.tt/sVJIaE">
  <soap:Header>
    <AuthHeader xmlns="http://ift.tt/1U4svrm">
      <Username />
      <Password />
    </AuthHeader>
  </soap:Header>
  <soap:Body>
    <Authenticate xmlns="http://ift.tt/1U4svrm" />
  </soap:Body>
</soap:Envelope>

The service returns true (Boolean) if the credentials are ok, false if not. Now when I call the service from Flex it sends this:

<?xml version="1.0" encoding="utf-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://ift.tt/sVJIaE" xmlns:s="http://ift.tt/tphNwY" xmlns:xsi="http://ift.tt/ra1lAU">
    <SOAP-ENV:Header>
        <ns0:AuthHeader xmlns:ns0="https://stickykiwi01">
            <ns0:Password/>  
            <ns0:Username/>
        </ns0:AuthHeader>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <tns:Authenticate xmlns:tns="http://ift.tt/1U4svrm"/>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

This returns,

'System.NullReferenceException: Object reference not set to an instance of an object'

because for some reason, probably best known to someone with better eyesight than me, there is a serious difference between these 2 requests, I am just not seeing it.

So, how do I create the headers in Flex? I have this code in the web service definition file:

    var qname:QName = new QName("https://stickykiwi01","AuthHeader");
    var header:SOAPHeader = new SOAPHeader(qname,{Username:"",Password:""});
    _serviceControl.addHeader(header);

Which is in a file called _Super_AuthenticationServices.as. I pulled the Flex request from the network monitor.

A couple of points to note,

  1. The service isn't mine, but I assume it works as I can test it from another client successfully.
  2. Yes I know SOAP services are now depreciated and we should be moving all our code to WCF, it is in progress and will be brought in house eventually.
  3. We wanted to use Basic auth for the service but Flex doesn't allow me to add the HTTP headers to a SOAP request so that is out.
  4. All of this is run over HTTPS, because I know it is not secure as credentials are passed as plain text, once we have this running we will pass a single hashed string (same as basic auth) and unhash it on the server too, this way is just MUCH easier to debug.

Thank you for your advice.

Get number of files in folder with AS3

I made a flash webpage with a file-upload system for uploading pdf's to a subfolder in the same folder where the swf is hosted. I want to make a very simple system to count the number of files in that folder from inside the AS3 of the main webpage (with the purpose of displaying it somewhere in the flash page..). I still haven't found a straight answer on how to do it (or if it's even possible). I think that maybe i have to use an additional php script to count the files..

Any idea is welcome! Thx in advance!

Random Number/Frame function in Actionscript 3.0

I had an old piece of code in a Flash Movie that selected a random frame to start the clip. However, the random() function has been deprecated since Flash 5 and in ActionScript 3, it's been completely removed. Now I need to update some of the images in the movie but the timeline just skips right through the clips without stopping. Can anyone help me revise the code?

Here is what I had:

function randRange(min:Number, max:Number):Number {
    var randomNum:Number = Math.round(Math.random()*(max-min))+min;   
    return randomNum; 
}     
var myFrame; 
myFrame = randRange(2,7); 
gotoAndStop(myFrame);

If you'd like to see the existing clip in action you can view it here.

import issue of "serialization.json.JSON" class in actionscript:

I'm working on a project using actionscript and Flex. For some reason I have a problem importing the com.adobe.serialization.json.JSON class. When I'm working only with the FlexSDK files and try to use it I'm getting the following error:

Error:(142, 70) [..]: Error code: 1120: Access of undefined property JSON.

And of course IntelliJ marks this file and the import in red.

On the other hand when I import the corelib.swc that includes this file I get the following error:

Error:[..]: Can not resolve a multiname reference unambiguously. JSON (from /Volumes/backup/FlexSDK/frameworks/libs/air/airglobal.swc(JSON, Walker)) and com.adobe.serialization.json:JSON (from /Volumes/backup/.../libs/corelib.swc(com.adobe.serialization.json:JSON)) are available.

What is going on here? How can I solve this?

Thanks in advance.

My flash game doesn't work properly after being published

Strangely enough, the game actually worked properly when the .exe file is put inside the directory where the .as file is located. However, a problem always occurred when I changed the .exe file directory to a different location. When I entered a frame where the .as file is called to make the game play properly, the game always acts as if the .as file isn't even there.

In this case, the .as file is used to manage the visibility of buttons in the game screen and to create the game field itself. When that problem occurred, all buttons became visible and objects that was supposed to be created at that moment didn't appear at all.

Ah, and I changed the setting to Flash(swf) on the Publish section and HTML Wrapper and Win Projector on the Other Formats section when I published the game. My publish Target is Flash Player 11.2, and I'm using ActionScript 3.0.

Embedding png throws Error #1065: Variable FlexVersion is not defined

I've found several articles relating to variable FlexVersion and error 1065, but nothing seems to help. My Class (which I've stripped down to nothing in order to pinpoint the issue):

package {
import flash.display.Sprite;
import flash.display.Bitmap;

public class JMouse extends Sprite {
    [Embed(source = "../lib/jacobsLadder.png")]
    private var Picture:Class;
    //private var pic:Bitmap = new Picture(); // THIS LINE

    public function JMouse() {
        init();
    }
    private function init():void {
    }
}

throws the error when the line "THIS LINE" is not commented out. I've tried adding "as Bitmap" to the end of this line without luck. I am calling this class from my document class:

jMouse = new JMouse();

the file, jacobsLadder.png, is in my lib folder, and I used FlashDevelop to "Generate Embed Code." I am using FlashDevelop 5.0.1.3 for .NET 3.5

Any Ideas?

Air Android ANE - USB manifest

i have made a native Android app with Eclipse which controls a RFID USB scanner. These permissions are requested through the AndroidManifest.xml in the intent-filter and xml device filter tag, so when i plug the usb device in the android (minix) the permissions are given once and the scanner works perfectly.

Example of the manifest (in the native Android app):

<application  
        android:allowBackup="true"  
        android:icon="@drawable/ic_launcher"  
        android:label="@string/app_name"  
        android:theme="@style/AppTheme" >  
        <activity  
            android:name=".Main1Activity"  
            android:label="@string/title_activity_main1"  
            android:launchMode="singleTask"  
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >  
            <intent-filter>  
                <action android:name="android.intent.action.MAIN" />  
                <category android:name="android.intent.category.LAUNCHER" />  
            </intent-filter>  
            <intent-filter>  
                <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />  
                <action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />  
            </intent-filter>  
            <meta-data  
                android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"  
                android:resource="@xml/device_filter" />  
            <meta-data  
                android:name="android.hardware.usb.action.USB_DEVICE_DETACHED"  
                android:resource="@xml/device_filter" />  
        </activity>  
    </application> 

The problem is when i build the ANE and use this in an AIR Android app, these USB permissions are not requested so i don't have access to the device. What should i place in the AIR Android manifest to access the USB device, i cannot use the intent-filters and meta-data because i don't have access to the XML?

Thanks for your help :-)

Resize complete SWF in ScrollPane

Here you can see my code in the Action-section. I would like to resize the height and width property for both myScrollPane and AllElements.

//AllElements is a compiled SWF which holds all Controls
this.stage.scaleMode = StageScaleMode.NO_SCALE;
this.stage.align = StageAlign.TOP_LEFT;

stage.addEventListener(Event.RESIZE, stageResize);
function stageResize(event:Event):void{
    //Resize ScrollPane-Controls
    myScrollPane.width = stage.stageWidth;
    myScrollPane.height = stage.stageHeight;
    //Resize Source in ScrollPane
    myScrollPane.source.AllElements.width = stage.stageWidth;
    myScrollPane.source.AllElements.height = stage.stageHeight;
}

Is it possible to do this global for the whole AllElements and set the new Position for the controls?

Thanks in advance

AS linked library items with TextFields does not works

I try to use graphics resources(MovieClips, etc) from another SWF. I have a *.fla file, which has AS3 linked movie clip "GameInterface". Then I publish it as res.swf.

And in my AS3 project I'm using this code to add this MovieClip:

public function Main() {
    var myLoader:Loader = new Loader();
    var myUrlReq:URLRequest = new URLRequest("res.swf");
    myLoader.load(myUrlReq);
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
}

private function onLoaded(e: Event): void{
    var test:Class = e.target.applicationDomain.getDefinition("GameInterface") as Class;
    var testMC:MovieClip = new test() as MovieClip;
    addChild(testMC);
}

And it works fine, if there is no any TextFields in my GameInterface movie clip. But if I have a TextField in GameInterface, it raises error:

[Fault] exception, information=ReferenceError: Error #1065: Variable GameInterface is not defined.

So what am I doing wrong? How can I import MovieClips with TextFields, to use it in my project?

flashpunk ui wont show

According to a tutorial on tuts+(http://ift.tt/1fCQ4se), I have made everything so far to step 12. As I tried to test this Project nothing Pops up except the Default Flash Debugger which is actually blank. i'm not sure if the tutorial is too old or no longer compatible with Flashdevelop or flashpunk library. Btw. i'm working with an as 3 library called flashpunk.

What I seek: is that the ui Pops up according to that tutorial Unfortunately I can not provide the code because of the code Format error. and I tried to press ctrl and k. and pasted my code in them but it still didnt work. If possible, please add a working code snippet or a screenshot. Thanks in advance.

Do flash games work on all system platforms?

I'm developing a flash game using windows. But will these flash games actually work on linux and mac or do I need to work on something for that to be compatible?

AS3 Glitch (Timer Object)

So I was trying to make a AvoiderGame tutorial for my YT, and I found a glitch with the program. (It was telling me the Timer object accepts 0 parameters)

Then I thought that I might've missed a bracket or something somewhere which caused the error, but for now, it seems like a Flash Professional Glitch

INFORMATION:

File: Enemy.as (linked to the "Enemy" movieclip symbol in the main.fla file)

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

    public class Enemy extends MovieClip{
        private var speeds:Array = new Array();
        private var counter:Timer = new Timer(1); <-- Line 8
        private var speed:int = 0;

        public function Enemy(xPos:int, yPos:int, speeds:Array){
            x = xPos;
            y = yPos;
            this.speeds = speeds;
            initalize();

            counter.start();
            counter.addEventListener(TimerEvent.TIMER, update);
        }

        protected function initalize(){
            speed = speeds[0] + Math.round(Math.random()*(speeds[1] - speeds[0]));
        }

        protected function update(e:TimerEvent){
            y += speed;
        }

        public function setPos(xVal:int, yVal:int){
            x = xVal;
            y = yVal;
        }

        public function movePos(xVal:int, yVal:int){
            x += xVal;
            y += yVal;
        }
    }
}

(I replaced my username with "User" so people wont know my real name)

This Code gave me the following errors:

C:\Users\User\Desktop\Flash Stuff\Avoider DeluX\Enemy.as, Line 8, Column 35 1136: Incorrect number of arguments. Expected 0.

C:\Users\User\Desktop\Flash Stuff\Avoider DeluX\Enemy.as, Line 8, Column 35 1136: Incorrect number of arguments. Expected 0.

(yes, the errors did appear 2 times)

mx.DataGrid programmatically scrolling some columns at once

If there are some mistakes in English, I'd like to apologize.
I want to scroll datagrid programmatically by click buttonbar event.

Following code is work, but it scrolls one by one.
What I want is scrolling some columns at once, like clicking empty horizontalscrollbar area.
Any help would be greatly appreciated.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://ift.tt/1aBfKeP" layout="absolute" creationComplete="init()">
    <mx:Script>
        <![CDATA[
            import mx.events.ItemClickEvent;
            import mx.collections.ArrayCollection;

            private var arr:ArrayCollection = new ArrayCollection([
                {COL1:"aaa",COL2:"bbb",COL3:"ccc",COL4:"ddd",COL5:"eee",COL6:"fff",COL7:"ggg",COL8:"hhh",COL9:"iii",COL10:"jjj",COL11:"kkk",COL12:"lll",COL13:"mmm",COL14:"nnn",COL15:"ooo",COL16:"ppp",COL17:"qqq",COL18:"rrr",COL19:"sss",COL20:"ttt"}
            ]);
            public function init(): void
            {
                scrollController.dataProvider=["|<", "<", ">", ">|"];
                grid.dataProvider = arr;
            }

            public function doScroll(event: ItemClickEvent): void
            {
                if (event.index ==0)
                {
                    // force move to left end.
                    grid.horizontalScrollPosition = 0;
                }
                else if (event.index ==1){
                    // move left one by one
                    // *** I want modify here.
                    if (grid.horizontalScrollPosition > 0){
                        grid.horizontalScrollPosition -= 1;
                    }
                }
                else if (event.index ==2){
                    // move right one by one
                    // *** I want modify here too.
                    if (grid.horizontalScrollPosition < (grid.columnCount-1)){
                        grid.horizontalScrollPosition += 1;
                    }
                }
                else{
                    // force move to right end.
                    if (grid.horizontalScrollPosition < (grid.columnCount-1)){
                        grid.horizontalScrollPosition = grid.columnCount-1;
                    }
                }
            }

        ]]>
    </mx:Script>
    <mx:ButtonBar id="scrollController" y="0" itemClick="doScroll(event)"/>
    <mx:DataGrid id="grid" y="30" width="340" horizontalScrollPolicy="on">
        <mx:columns>
            <mx:DataGridColumn headerText="COL1" dataField="COL1" width="100"/>
            <mx:DataGridColumn headerText="COL2" dataField="COL2" width="100"/>
            <mx:DataGridColumn headerText="COL3" dataField="COL3" width="100"/>
            <mx:DataGridColumn headerText="COL4" dataField="COL4" width="100"/>
            <mx:DataGridColumn headerText="COL5" dataField="COL5" width="100"/>
            <mx:DataGridColumn headerText="COL6" dataField="COL6" width="100"/>
            <mx:DataGridColumn headerText="COL7" dataField="COL7" width="100"/>
            <mx:DataGridColumn headerText="COL8" dataField="COL8" width="100"/>
            <mx:DataGridColumn headerText="COL9" dataField="COL9" width="100"/>
            <mx:DataGridColumn headerText="COL10" dataField="COL10" width="100"/>
            <mx:DataGridColumn headerText="COL11" dataField="COL11" width="100"/>
            <mx:DataGridColumn headerText="COL12" dataField="COL12" width="100"/>
            <mx:DataGridColumn headerText="COL13" dataField="COL13" width="100"/>
            <mx:DataGridColumn headerText="COL14" dataField="COL14" width="100"/>
            <mx:DataGridColumn headerText="COL15" dataField="COL15" width="100"/>
            <mx:DataGridColumn headerText="COL16" dataField="COL16" width="100"/>
            <mx:DataGridColumn headerText="COL17" dataField="COL17" width="100"/>
            <mx:DataGridColumn headerText="COL18" dataField="COL18" width="100"/>
            <mx:DataGridColumn headerText="COL19" dataField="COL19" width="100"/>
            <mx:DataGridColumn headerText="COL20" dataField="COL20" width="100"/>
        </mx:columns>
    </mx:DataGrid>
</mx:Application>

Run demo on wonderfl

Play swf file using Embed or Object tag

I am trying to play local swf or flash files on my webpage. I ask client for file input, convert it into data uri and use data uri as source for embed tag or object tag, but it is not working. Please tell me what is wrong with my code.

HTML

<input id="swf_file" type="file" accept="/*" />
<Embed id="swf_player" />

Javascript

swf_file.onchange = function(){
    var files = this.files;
    var file = URL.createObjectURL(files[0]); 
    swf_player.src = file; 

};

Thanks for reading...

Security Error when trying to load ByteArray from mediaPromise

in a mobile application i need to send an image which the user either took with the camera or picked from a cameraroll. I am using the starling framework and feathersUI ( although i think this does not matter to problem ) When the mediapromise is loaded using loadFilePromise i use the following code to deal with the image data:

_mediaLoader = new Loader()
//loading the filePromise from CameraRoll
_mediaLoader.loadFilePromise(_mediaPromise);
_mediaLoader.contentLoaderInfo.addEventListener(starling.events.Event.COMPLETE, onLoadImageComplete);
private function onLoadImageComplete(event:flash.events.Event=null):void {
    //creating the starling texture to display the image inside the application
    var texture:Texture = Texture.fromBitmapData(Bitmap(_mediaLoader.content).bitmapData, false, false, 1);
    //now trying to load the content into a bytearray to send to the server later
    var bytes:ByteArray=_mediaLoader.contentLoaderInfo.bytes;
}

the last line of code results in a Security error: Error #2044: Unhandled SecurityErrorEvent:. text=Error #2121: Security sandbox violation: app:/myapp.swf: http://ift.tt/1U3x4SM cannot access . This may be worked around by calling Security.allowDomain.

I tried

Security.allowDomain("*") 

as a test but then i get: SecurityError: Error #3207: Application-sandbox content cannot access this feature.

As a workaround i write my own png ByteArray inside the Application from the loaders BitmapData using Adobes PNGEncoder Class:

var ba:ByteArray=PNGEncoder.encode(Bitmap(_mediaLoader.content).bitmapData)

But this takes a significant amount of time ...

I also tried the FileReference to load the image but

_mediaPromise.file 

and

_mediaPromise.relativePath 

are both null.

What am I doing wrong? Or is this a known problem ?

Thanks!

Movie Clip Object adding Multiple Times with Enter_Frame Event

Hey Guys so I am using TweenLite to act as a timer for Performance with Mobile usage. I ran into a little problem here that I can't seem to figure out. So In my ENTER_FRAME Listener I have this function difficultyController Where I add my TweenLite control like so:

    private function difficultyController():void 
    {
        if (nScore >= 10)
        {
            TweenLite.delayedCall(nChainsaw, addChainsaw);
            trace("DIFFICULTY_UPDATE");
        }
    }

In my addChainsaw Function I have the Movie Clip Objects added to the stage like so:

    private function addChainsaw():void 
    {
        TweenLite.delayedCall(nChainsaw, addChainsaw);
        var newChainsaw = new mcChainsaw();
        //Add Child
        addChild(newChainsaw);
        //Push Move CLips into array
        aChainsawArray.push(newChainsaw);
        trace(aChainsawArray.length + "chainsaw");
    }

Now I want the chainsaw Movie clip in the array to be added to the stage every 2 seconds which is what the value of nChainsaw is. Ill kill it off when the nScore reaches a higher number. But as of right now when I test the Game like so It adds Multiple Movie clips over and over again then freezes the game. I know it has to do with the ENTER_FRAME Listener But I don't know what else to do. SHould I just remove the TweenLite and add A Actual Timer and in the diffucultyController(); just add timer.start??

If anyone has anyother Ideas I would really Appreciate it thanks!

away3d collada not affected by PointLight, displays flat color

please see image below, i change the material of the meshes inside the collada file and set the material's lightPicker accordingly with a PointLight source.

it displays a flat color whereas the CubeGeometry i added to the scene goes very well with the same light source.

enter image description here

lundi 27 juillet 2015

Policy File Permissions issue on uploading image to GAE using Blobstore Python API with Flex app (.swf) from different domains

I am receiving error message while uploading image to Google App Engine using Blobstore Python API with my Flex app from different domains.

Error message:

===================== Start Error Message ===================

Request for resource at http://ift.tt/1evEtKH by requestor from http://localhost:9080/app/MerchantWebApp.swf is denied due to lack of policy file permissions.

Connection to http://ift.tt/1evEtKH halted - not permitted from http://localhost:9080/app/MerchantWebApp.swf

IO Error (Update Coupon Image): [SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2170: Security sandbox violation: http://localhost:9080/app/MerchantWebApp.swf cannot send HTTP headers to http://ift.tt/1evEtKH."]

======================== End Error Message =======================

My app.yaml file:

- url: /crossdomain\.xml
  static_files: site/crossdomain.xml
  upload: site/crossdomain.xml
  http_headers:
      Access-Control-Allow-Origin: "*"

My crossdomain.xml content:

<cross-domain-policy>
  <site-control permitted-cross-domain-policies="all"/>
  <allow-http-request-headers-from domain="*"/>
  <allow-access-from domain="*" secure="false" to-ports="*" />
</cross-domain-policy>

I have no problem accessing other folders of my GAE application from my localhost:9080, the only problem is I cannot upload image from my localhost:9080 to my GAE production server (http://ift.tt/1uZDCqm) using URLLoader (urlLoader.load(urlRequest)) from my Flex app.

It seem that the GAE admin folder "_ah/upload/" doesn't not recognise the crossdomain.xml on my root folder http://ift.tt/1evEu0X

Does anyone can help?

Thank you!

Joel

as3 What's the difference in declaring a variable?

Sometimes you declare a variable this way. Does it change the way the game works in anyway? I saw some people do it different ways of these two.

var number:Number = new Number();

Sometimes like this

var number:Number;

number = new Number();

draw empty mx:grid flex programmatically

I want to draw 2*2 mx:Grid and put a button on any one of these cells which will be calculated dynamically. So I want to create an empty 2*2 grid, and replace any one cell with the button.

-----------------
|        |       |
------------------
|        |  btn  |
------------------

How do I accomplish this?

Error #1063 when setting Boundary Parameters on startDrag Function

Hmmm.... the code below gives me this:

ArgumentError: Error #1063: Argument count mismatch on flash.display::Sprite/startDrag(). Expected 0, got 5.
    at z_fla::MainTimeline/itemStartDrag()[z_fla.MainTimeline::frame1:16]

I've marked line 16 with asterisks. When I remove the last four boundary parameters everything works fine. Anyone know what's wrong?

var i:int=0;


var bread:Bread=new Bread();
bread.x=200;
bread.y=200;
stage.addChild(bread);

var itemsAry:Array=[bread];

for(i=0;i<itemsAry.length;i++){
    itemsAry[i].addEventListener(MouseEvent.MOUSE_DOWN,itemStartDrag);
    itemsAry[i].addEventListener(MouseEvent.MOUSE_UP,itemStopDrag);
}
function itemStartDrag(e:MouseEvent){
    e.target.startDrag(true,20,20,stage.width-20,stage.height-20); *******
}
function itemStopDrag(e:MouseEvent){
    e.target.stopDrag();
}

Nape - Keeping the same physics behaviour over different screen sizes

Im wondering how to keep the same physics behaviour over different screen sizes?

For example, i have a wheel fixed on the middle of the stage. I have a mouse pivot joint that i use to spin the wheel.

The radius of the wheel depends on the screen size, it will always occupy about half of screen size.

Now, when i create a wheel on a bigger screen, it is feels as much heavier object. It is much harder to spin it then on a smaller screen size.

Im wondering what is the best practice way of making the physics simulation run exactly the same across all screen sizes?

How to create color picker in actionscript 3?

enter image description here

I want to create this color picker using actionscript 3... Any idea???

Why do my animation sounds play in the beginning of test movie?

I have a game where a cutscene comes in a specific order and after you press the play button, the play button page gets removed and we add another child which is the "animation movieclip page". This movieclip is a page with animations and sounds that play inside of it.

At first the menu page with the buttons come up, but animation page doesn't come up unless you press play.

Why do my sounds from the animation movieclip come up when it's not even added to the stage yet?

How to get render mode of any iOS application on runtime

Is there any way of knowing the render mode of an application at runtime on iOS device ? I need to get the render mode of my running application and pass on different logic based on whatever render mode(CPU, GPU and Direct) I get at runtime but I am struggling to find any such API or method that can solve my purpose.

Any suggestions ?

Thanks, Ken

How to inspect stageWebViewBridge in Adobe AIR instance with Google Chrome

I am having problem with HTML5 Audio tag in Samsung devices, so I need to debug the instance of stageWebViewBridge in Samsung S4. All other devices I tested my app on, have no problem. Main problem I encountered is, I am not being able to inspect the WebView with Chrome inspect [chrome://inspect/].

Although my device is detected and I can even inspect from Chrome for Android, I am not able to see my air app or its stageWebViewBridge instance listed anywhere.

I have managed to find some online resources which say, some of the developers are being able to inspect AIR stageWebView instance in android but not able to inspect in iOS, but that is a very different story. Also, I had read a Google documentation about setting

WebView.setWebContentsDebuggingEnabled(true)

from Remote debugging on Android with Chrome

Can anyone of you guide me how I can set above static variable to true in my AIR app so that, I can inspect?

Code of stageWebViewBridge instance:

var fm:String="http://ift.tt/1OvFA9z";
FM_Controller.swv = new StageWebViewBridge(10, 10, 500, 200, false);
FM_Controller.swv.loadString('<head></head><body><script>var intid;var pl=new Audio();window.document.body.appendChild(pl);pl.src="'+fm+'";pl.controls=true;var lastTime=0;function checkPlaying() { if((pl.currentTime==0 && !pl.paused) || lastTime!=pl.currentTime){lastTime=pl.currentTime;StageWebViewBridge.call("onStartPlaying",null);}};pl.addEventListener("abort",handleError);pl.addEventListener("error",handleError);pl.addEventListener("emptied",handleError);function handleError(){StageWebViewBridge.call("onErrorOccured",null);};function play(){pl.play();clearInterval(intid);intid=setInterval(checkPlaying,200);};function pause(){pl.pause();clearInterval(intid);};</script></body>');
FM_Controller.swv.addCallback('onStartPlaying', onStartPlaying);
FM_Controller.swv.addCallback('onErrorOccured', handleError);
stage.addChild(FM_Controller.swv);

I would be thankful to the person who can guide me in inspecting my app on android device with Google Chrome or help me solve audio not playing in Samsung device bug.

dimanche 26 juillet 2015

How do I code in actionscript the exact file location for several swf I have included for my apk?

In Air for Android Setting's 'Include files' part, I added test1.swf and test2.swf to the main file automatically included. Would the following be correct then:

myLoader.load(new URLRequest("test1.swf")

Or, is there any other folder I should include? Would the following be correct?

myLoader.load(new URLRequest("\..\..test1.swf")

Flash AS3, import old version of class

I am writing an .as file with a class in it, and using import to make it available in my .fla's code.

At first it worked fine. An in some of my .fla files, it still works fine.

But, one of my files is using an old version of the class, and ignoring any changes I make.

I've tried commenting out the import of the class, to see if I'd get a compiler error, but it doesn't give me an error. It still instantiates the old version of the class.

I've tried Clear Publish Cache, but it again still uses the old version of the class.

I've double checked that the class is not defined anywhere in the .fla file.

Accessing the public properties of currentTarget

I am new to Actionscript 3 programming. I am having trouble using e.currentTarget as a reference to an object I click on. This is a abbreviated code for the object:

public class Character extends Sprite
{
    private var _bodyPartLocations:Array = new Array();

    private var _head:Head
    private var _body:Body
    public var characterImage:Sprite = new Sprite

    private var _thumbnailBackground:CharacterThumbnailBackground
    private var _headScaled:Head
    public var thumbnail:Sprite = new Sprite

    public function Character() 
    {
        _bodyPartLocations = 
        [
            [50, 0], //Head
            [53, 80], //Body
        ];

        _head = new Head();
        _body = new Body();

        Util.addSprite(_head, characterImage, _bodyPartLocations[0][0], _bodyPartLocations[0][1]);
        Util.addSprite(_body, characterImage, _bodyPartLocations[1][0], _bodyPartLocations[1][1]);

        _thumbnailBackground = new CharacterThumbnailBackground();
        _headScaled = new Head;
        _headScaled.scaleX = 0.8;
        _headScaled.scaleY = 0.8;

        Util.addSprite(_thumbnailBackground, thumbnail, 0, 0);
        Util.addSprite(_headScaled, thumbnail, 0, 0);
    }
}

Essentially, I am trying to create two sprites (characterImage and thumbnail) that will be a part of the overall Character sprite. The Util class simply contains this shortcut for addChild and position for me:

static public function addSprite(addedSprite:Sprite, toSprite:Sprite, xPos:int = 0, yPos:int = 0):void 
    {
        toSprite.addChild(addedSprite);
        addedSprite.x = xPos;
        addedSprite.y = yPos;
    }

The problem I am having arises in my character creator menu screen. Currently, it simply is comprised of a space where character thumbnails are displayed (and stored in an array), a space to display the character image when a character's thumbnail is clicked on, and finally a "create character" button. When the button is clicked, a character is created, its thumbnail is given an event listener, and the thumbnail is added to show up on the menu (the position boolean check is simply my way of tying the character positions array with the characters array, I have omitted the other position checks):

private function createCharacterHandler(e:MouseEvent):void 
    {
        if (_characters.length < 6) 
        {
            var char:Character = new Character();
            char.thumbnail.addEventListener(MouseEvent.CLICK, characterClickHandler);

            if (_positionZero == false) 
            {
                Util.addSprite(char.thumbnail, this, _characterThumbnailPositions[0][0], _characterThumbnailPositions[0][1]);
                _positionZero = true;
            }
            _characters.push(char);
    }

And this brings me to the problem. If I click on the character thumbnail, this event handler executes:

private function characterClickHandler(e:MouseEvent):void 
    {
        var selectedChar:Character = e.currentTarget as Character;
        Util.addSprite(selectedChar.characterImage, this, _characterImagePosition[0][0], _characterImagePosition[0][1]);
    }

As you can see, I have attempted to use e.currentTarget to try and display the characterImage associated with the thumbnail of the character I clicked on. The code runs when I test it, however when I click on the thumbnail of a character I have generated, the Flash player stalls and I get this error:

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

Searching the Internet, I have seen others use e.currentTarget as a reference to objects that are clicked on (but I do not want to create an instance name for each character that I generate as I plan on having characters being generated and deleted regularly, so naming each one becomes too difficult). Where am I going wrong?

PHP Decrypt AS3 CBCMode

I have tried to decypt this encoding inside PHP without any luck. I have tried example like this:

mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encodedData, MCRYPT_MODE_CBC, $iv);

But it dosen't encode it. I send data from my flash program to websites as encoded but I'm unable to decrypt it.

Connect external swf button to main timeline

I am a newbie on Actionscipt 3.0 and I am looking for a little help. I would like to know how to connect the button from my external swf file to my main timeline. Thanks :]

AS3 Weird Preloader Glitch

I added a preloader in AS3 using the following code:

stop();
import flash.events.Event;
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(e:Event):void
{
 var total:Number = this.stage.loaderInfo.bytesTotal;
 var loaded:Number = this.stage.loaderInfo.bytesLoaded;
 if(total == loaded){
    gotoAndStop(3);
    }
}

The problem is that now when the game has loaded and goes to the third keyframe the buttons don't work anymore. This is the code in the third keyframe:

import flash.events.MouseEvent;
playBtn.addEventListener(MouseEvent.CLICK, playGameBtn);
function playGameBtn(event:MouseEvent):void
{
    gotoAndStop(5);
}

Before the preloader was added the buttons all worked perfectly, but i have no idea what caused the issue.

samedi 25 juillet 2015

How do i remove a Child that is Added and Defined in a Separate Function? (AS3)

I currently have the Code:

function timerHandlerR(e:TimerEvent):void{
if(RedTargetAdded){
    removeChild(RedTarget);
}
randomXR = Math.random()*500;
randomYR = Math.random()*300;
RedTarget.x = randomXR;
RedTarget.y = randomYR;
addChild(RedTarget);
RedTargetAdded = true;
RedTarget.addEventListener(MouseEvent.CLICK, clickHandlerR);
tween = new Tween(RedTarget, "alpha", Strong.easeOut, 0, 1, 3, true);
}

function clickHandlerR(e:Event):void{
var mySound:Sound = new Shooting(); 
mySound.play();
var breaking:Sound = new Break(); 
breaking.play();
points ++;
points_txt.text = points.toString();
removeChild(RedTarget);
}

However when trying to remove the child RedTarget within the clickHandlerR function it returns an error stating that it cannot as the object RedTarget is not a child of the caller. Is there any easy way to fix this.

PS. i have tried parent.removeChild(parent.child) and that did not work (unless i did it incorrectly)

AS3 AIR loading online mp3 - Error #2044: Unhandled IOErrorEvent:

I just got a new comp using windows 8 and installed creative cloud. I am using the Flash IDE and I am trying to load a sound from online. It's a simple script but I am getting this error below.

NOTE: I am using Air 17.0 for Android. It's not working. However, when I load this same script in the flash player it works.

As you can see it's a valid live link: http://ift.tt/1S1yK1s

But it won't play. Did abode block this streaming feature? What simple line am I missing. This was so easy before. Is it a setting on my new computer? Thanks for any tips.

package  {

import flash.display.MovieClip;
import flash.events.Event; 
import flash.media.Sound; 
import flash.net.URLRequest; 

    public class Main extends MovieClip {


        public function Main() {
            // constructor code
            var mySound:Sound = new Sound();
            mySound.load(new URLRequest("http://ift.tt/1S1yK1s"));
            mySound.play();
        }


    }

}

THE ERROR

Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.
    at Main()[C:\Flash Apps 2014\Real Projects\Fr Letherby\Main.as:13]
    at runtime::ContentPlayer/loadInitialContent()
    at runtime::ContentPlayer/playRawContent()
    at runtime::ContentPlayer/playContent()
    at runtime::AppRunner/run()
    at ADLAppEntry/run()
    at global/runtime::ADLEntry()
[UnloadSWF] Homily.swf
Test Movie terminated.

Action script 3.0 reusable button function

I am new to AS3.0 and am trying to create a reusable button class. I am working on a quiz game where I have multiple correct and incorrect buttons and instead of copying the same code over and over again I am trying to create a simple way to reuse the code. I am unaware how to do this. I have created various generic button classes and none have worked. I believe the best way would revolve around creating a generic class with a Boolean 'correct' and each button class extends this parent class and sets the correct Boolean true or false. In the parent class there would be a function saying if correct then go to next frame, if !correct go to lose frame. I have tried this but to no avail; any help?

What does the message "Test Movie Launch Failed" mean? (Flash Professional CC)

The Problem

When I was creating a test program using Flash Professional CC, I got the message "Test Movie Launch Failed" while compiling, and when I tried to open it, nothing happened and it didn't open. However, I got no compiler errors whatsoever, it just said "Test Movie Terminated." in the output.

What Might be Going on

I was thinking it might have been an error in my code, but I can't tell since the error message is extremely vague and no runtime errors appear.

So Here's my code (just in case if it's an error of the code)

Info:

Target: Air 3.6 for Desktop

Script: ActionScript 3.0

Objects:

Input Text Box with instance name of "writeT"

Dynamic Text Box with instance name of "readT"

MovieClip with instance name of "Write" (Too lazy to make buttons)

MovieClip with instance name of "Read"


import flash.filesystem.*;
import flash.events.MouseEvent;

Write.addEventListener(MouseEvent.CLICK, writeToFile);
Read.addEventListener(MouseEvent.CLICK, readFile);

var file:File = File.desktopDirectory.resolvePath("stuff.txt");
var fs:FileStream = new FileStream();

function writeToFile(e:MouseEvent):void{
    fs.open(file, FileMode.APPEND);
    var text:String = writeT.text;
    fs.writeUTF(text);
    writeT.text = "";
    fs.close();
}

function readFile(e:MouseEvent):void{
    fs.open(file, FileMode.READ);
    var text:String = fs.readUTF();
    readT.text = text;
    fs.close();
}

vendredi 24 juillet 2015

Open source library/framework for Facebook flash video embeds

I have .mp4 files that I would like to serve to Facebook for embedding in a player.

I need a simple to use Flash player that will allow me to do this. I would like to be able to use it by giving Facebook a link like this:

http://ift.tt/1ODpyei

I already have a embeddable HTML5 player, but I need to port it to Flash to allow Facebook embeds, so easy design customization would be preferable to make it as close to the HTML5 player as possible.

I would like suggestions on how to approach this and recommended libraries or frameworks to use.

I want to record my webcam and microphone in flex (builder)

I have spend the last few hours googling this and searching SO for something what i can work with.

My goal is to record my webcam and microphone using Flex and then hand that file over to another script that will upload it to my webserver. The uploading of the file is not part of this question as i am sure i can build that myself as long as i have access to the file once it is locally available.

This link has a working example of what i want to do: http://ift.tt/1DBu32E

The Github page there links to a series of actionscript files, but not a writing of how to put it all together.

I also tried http://ift.tt/1qibzPn, which does show my webcam on my screen and allows me to take a picture. But this is far from video and audio is still missing.

I am using Flex Builder 4.7 and so far i have not been able to get something working. I don't consider myself a flex / actionscript developer but more a web developer, so to build this from scratch is beyond my knowledge at this time.

What am i looking for?

A third party library for Flex with docs that will allow me to build this

OR

A tutorial or code example's that work with Flex Builder 4

Hoping someone can lend a hand.

Record live stream in gray-scale

I Developed Red 5 flex application for record live video stream. now I want to record same stream as gray scale.

This is code in action-script :

ns= new NetStream(nc);
ns.videoStreamSettings = h264Settings;
ns.publish(stream_id,"record");
ns.attachAudio(mic);
ns.attachCamera(cam);

Code Red5 Server :

public void recordShow() {
        IConnection conn = Red5.getConnectionLocal();
        logger.debug("Recording show for: {}", conn.getScope().getContextPath());
        String streamName = String.valueOf(System.currentTimeMillis());
        // Get a reference to the current broadcast stream.
        IBroadcastStream stream = app.getBroadcastStream(conn.getScope(), "hostStream");
        try {
            // Save the stream to disk.
            stream.saveAs(streamName, false);
        } catch (Exception e) {
            logger.error("Error while saving stream: {}", streamName);
        }
    }

I tried with filters, it show gray-scale but not record in gray-scale. How can I convert live stream in gray-scale, and record in gray-scale.

video stream store in buffer (locally) in as3

I am recording video using Red 5 and action-script, but some time red 5 flex connection close due to some network problem. I Want to store live video stream in buffer (locally, not more than 3 minute), if my red 5 connection close/fail/lost. It is possible to store video locally?

Flex DateChooser in chinease and japanease Style

How I can change the display of Month and Year display to Japanese style (i.e. Year Month) as in Header of Flex DateField. What I would like to convert the style July 2011年 to 2011年 7月.[![enter image description here][1]][2]
How can we change the calender header format ? i have used DateField in flex.

What's the OSX equivalent of AS3s ExternalInterface

AS3 has a method named ExternalInterface that allows an external process to call methods in a running as3 app and visa versa.

I'd like to accomplish the same thing with OSX. I'm pretty new to OSX and am unsure of what's available / what my options are.

What would be the best way to pass runtime parameters to an OSX app and return a result to the calling routine (python script, JS, .app or whatever)

Why not importing the this class? AS3

I try to follow this tutorial

link

This is my code:

import flash.display.Sprite;
import flash.events.Event;
import flash.display.ShaderInput;
import flash.events.KeyboardEvent;
import Input;                               //here is a problem
private function init(e:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            // entry point
            square = new Sprite();
            square.graphics.beginFill(0x333333);
            square.graphics.drawRect(0, 0, 30, 30);
            square.x = stage.stageWidth / 2 - square.width / 2;
            square.y = stage.stageHeight / 2 - square.height / 2;
            addChild(square);

          Input.initialize(stage);     //here is another problem

            //Add the refresh loop
            addEventListener(Event.ENTER_FRAME, refresh);
        }

         private function refresh(e:Event):void {
             trace("gigi");
        }

I receive this error:

Line 42 1120: Access of undefined property Input.
Line 7  1172: Definition Input could not be found.

Does anyone know why this error occurs? Unable to import class tutorial Input but it is used.

Thanks in advance!

Flex Mobile - stage.focus = null not working

I have a email validation in my text input field, user will get a prompt message on focus change if the validation gets failed. Here the problem is that my soft keyboard is not getting hide when the popup comes up. I tried using stage.focus = null, textInput.focusManager.deactivate() and a lot, but nothings worked. Finally I found my skniClass 'StageTextInputSkin' is the reason behind this issue. But I can't remove this skin from the textfields due to some other bug fixes. Can anyone help me on this? Thanks in advance.

jeudi 23 juillet 2015

How connect SQLite with Adobe Air for Android using Flash CS6 and AS3 language?

I am developing a small game for Air Android in flash CS6, this game I'm programming object-oriented with classes written in AS3.

I want you to help me write a class that connects to SQLite from scratch, please!

I googled but only there information to FLEX or code for insert into frames (and i get lost because i don't know that libraries to import), it's not what I want.

I want to create the connection class to use in my class Main.

I hope I have your support, thank you.

Excuse my English but I speak Spanish.

Flash as3 trouble with bitmap alpha tween

Im having a bitmap and holding it inside a spriteContainer.

This is how the bitmap is generated:

public function blit(o)
{
objectHolder=o;

var imgSheet:BitmapData=new sponsorsSheet;
var imgHolder=new BitmapData(400,400,true);
objectHolder.addChild(new Bitmap(imgHolder)); 

// the objectHolder is the sprite im animating.

//first timelinetween i add this image:

IMG = new blitSprite(imgSheet, R.img1, imgHolder);

imgHolder.fillRect(R.img1, 0x00FF00); 

// turns it green for testing purpose than when i add img 2:

IMG = new bitSprite(imgSheet, R.img2, imgHolder);

so i put a animate tween on the sprite holder that fades in and back out, than i request the script to clear the image by drawing the rectangle green. after that i ad a new image over that green rectangle. that all works fine untill i start the animation again

when it goes to alpha the first images apears again its like painting layers and slowely removing the top layer again.

is there any solution to this for example could i place a tween directly on the bitmap itself that was generated by the copypixel method? or is there any other method i should use instead?

SoundTransform panning not working on a rtmp stream with ActionScript 3.0

i'm having a strange problem, i'm using the SoundTransform function to play the sound of an RTMP stream from red5 server only on the left speaker and to lower it's volume with stream.soundTransform = new SoundTransform (0.5,-1.0); on Actionscript 3.0, but it is not working... This is somewhat strange, because for exactly the same code, if instead of the stream i enter an audio flv file or an mp3 file, it is working fine, so the SoundTransform class seems to have no effect on streams...

Can't get AIR app to display in landscape mode in iOS (AS3)

This issue is happening in iOS ONLY, all android and pc versions of the app display in landscape mode fine with no issues

I am trying to get the app to display in landscape mode in iOS OR at the very least be able to orient to landscape mode when the iphone/ipad is tilted to landscape position

However no matter what I try the app will always open in portrait mode The dimensions are 480x320 and I have tried setting the aspectratio in publish options to landscape, I have even tried

stage.setAspectRatio(StageAspectRatio.LANDSCAPE);

I have also tried adding "aspectRatio> landscape /aspectRatio>" to the XML file

I have been looking for DAYS for a fix on this issue and nothing works Please some one help!

Why am I getting this error? AS3

I have this short code:

        public function ball() 
        {

            minge.addEventListener(MouseEvent.CLICK, getBack);
        }

        private function getBack()
        {
        trace("test");  
        }

This error when I run:

Line 15 1120: Access of undefined property minge.

I do not understand why this error occurs ... I put a picture to see more clearly.

minge is an instance ... is an Assets

http://ift.tt/1OAqTm6

Can you tell me please what to do to solve this problem?

Thanks in advance!

As3 Flash Builder Starling project "Stopped Responding"

I am making an actionscript 3 mobile project in flash builder. Everything was working fine until yesterday when I was getting an error,

"initial content not found"

When I compiled this error would show up in a popup box in flash builder. I realized that the swf (mine is called Heads.swf) was missing from bin-debug. So I took an older Heads.swf that I had from before and put it in bin-debug. Well, that prevented the error from popping up, but now the app that plays in the simulator is not updated to what is it in the code. I can add traces, delete lines, etc., but the simulator just plays the old swf.

Cleaning the project and even making a new project and copying the src path isn't helping either. :/

Does anyone know why / what is this that is happening, and how do I fix it? Thanks.

Repeating structure in ActionScript 3.0

I'm trying to write a repeating structure that does all of this:

Declares and adds 50 enemies to the stage
Sets their y at -20
Sets their x at random on the stage width
Sets their rotation at random

MUST BE ACTIONSCRIPT 3.0!

Thanks!

Assistance with ActionScript 3.0 statement

I'd like to write a statement that tests to see if a user has a key and has more than 20 experience points. If the user has both the key and the points test to see if the user's name is "Joe", "Harry", or "Susan".

ACTIONSCRIPT 3.0 ONLY PLEASE!

Thanks!

Flash/AS3 - MovieClip into Bitmap

I need to turn a MovieClip that I have on the stage into a Bitmap. The function I have made for this halfway works; it does make a Bitmap from the MovieClip with the correct image, but it does not rotate it.

Here is the function

    function makeBitmapData(mov):BitmapData
{
    var bmpData:BitmapData = new BitmapData(mov.width, mov.height, true, 0);
    bmpData.draw(mov);
    this.addChild(new Bitmap(bmpData)); //Shows the bitmap on screen purely for example
    return bmpData;
}

Here is the output

Not rotating

How should I rotate the bitmap or just purely copy all the pixels in that bitmap, rotated and all?

ActionScript 2.0 large project compilation issues

I have a large ActionScript 2.0 project.Many feature additions are added to this project.All of a sudden ,once the CS5 started crashing and failing to compile.

I tried removing some traces from the files and it started compiling again. So the assumption is that the large code size is causing the problem. The classes has many inter dependencies and is a tedious task to refactor. Is this a known problem ? Is there any way to get the compilation done smoothly ?

Action Script 3 NumericStepper validation for empty value

I have a simple NumericStepper which looks like this:

<mx:NumericStepper id="nsPort"
minimum="0"
maximum="65535"
stepSize="1"
value="{PORT_DEFAULT}"/>

I wrote a Validator for it (which doesn't work as I expect):

<mx:NumberValidator
required="true"
source="{nsPort}"
property="value"/>

However, every time I don't enter anything into NumericStepper it passes zero, not NULL or something else, which is...well...a valid value. I suspect that this is done on purpose. So, how can I make blank value at NumbericStepper to be invalid? Please note that I'm restricted to a ver.3 of Action Script.

HTML Hyperlink to a specific scene in a swf file

I have an swf file with many scenes. I would like to be able to add multiple hyperlinks to a company Intranet site (set up on SharePoint) that link to specific scenes in the swf file. Is this possible? Thank you!

AS3 MouseMove laggy issue with transparency on FireFox

I'm using Custom MouseCursor when mousehover a movieclip

spectrum.addEventListener(MouseEvent.MOUSE_MOVE,function(e:MouseEvent):void{
            Mouse.hide();
            mouseCursor.visible = true;
            mouseCursor.startDrag(true);
            mouseCursor.mouseEnabled = false;
            mouseCursor.mouseChildren = false;
            e.updateAfterEvent();
});

But when I set the wmode='transparent'

it's hardly working on FireFox..Mousemove become super laggy..but it's working fine on Chrome and IE.

I also try EnterFRAME to use Custom Cursor, it's also laggy..

but if I set wmode ='window' Mousemove works again, not laggy anymore..

Why does mousemove is so laggy when wmode='transparent' on FireFox ? Can anyone help me ?

Flash AS3 Need help handling animations by script

Im trying to get a better solution for animating images like fade in slide to another location bump to another location fade out , bring in a new image, fade in, teleport to other location, let it fall down, slide out.

im in a learning progress of getting advanced with classes and my setup is like the following:

1 imgSheet, 1 tweenclass, 1 displayclass, 1 timerclass

so the display creates holderSprites, creates a bitmap out of the imagesheet and places it in the currentholderSprite, than the displayclass activates a animation function that animates the holder by triggering timers and tweens in those classes.

i understand using a timeline would be a easyer solution but this is for script learning purpose.

now my question is: Are there better solutions to handle this kind of animations and data passing other than using switch statements for everything. for example could i pass a tweenvar and timervar to the classes? if i did so how do i have to handle that variables change them and recall the functions so it becomes a animation?

simple example in script:

i send this to the bitmap creater:



     var rCutKongregate:Rectangle=new Rectangle(0,0,400,400);


the bitmap creater makes it a bitmap and places it in a sprite:



    public function displayImage(rn:Rectangle, o:Object):void
    { 
                            var imgSourceFile:BitmapData=new spriteSheet  ;
                var imgHolderData=new BitmapData(400,400,true,0x666666);
                var rCut:Rectangle=rn;
                var pCut:Point=new Point(0,0);
                imgHolderData.copyPixels(imgSourceFile, rCut, pCut);
                var imgHolder:Bitmap=new Bitmap(imgHolderData);

                           currentTempSprite.addChild(imgHolder);
                          } 


this is how the animation triggers timers/tweens



    switch (loopNumber)
                {
                    case 2 : timersHandling("07"); break;
                    case 4 : tweensHandling("04"); break;
                }

    public function tweenHandling(s:String)
            {
                switch (s) {

                    case "01" :var sFOTween:Tween=new Tween(object,"alpha",
    Strong.easeInOut,1,0,2,true); trace("tween1 started");break;
                    case "02" :var sFITween:Tween=new Tween(object,"alpha",
    Strong.easeInOut,0,1,2,true); trace("tween2 started");break;

    public function timersHandling(s:String)
            {           
                var timer01:Timer = new Timer(1000, 1);
                var timer02:Timer = new Timer(2000, 1);
    var timers:Array = new Array();
                timers.push({Object:timer01, name:"timer01"});
                timers.push({Object:timer02, name:"timer02"});
    switch (s) {

                    case "01" : timer01.start(); break;
                    case "02" : timer02.start(); break;


well as you might understand making animations manualy by triggering functions in such a way is prob the most amature way you could do it so help will be welcome.

How to simulate Geolocation service AS3

I'm creating an app that is using Geolocation servioce on phone o send location/time data over the internet. And that is working just fine. Problem is that I cannot test it in Flashdevelop, cause Geolocation is not supported, so I have to upload every time new code and test it on phone. Is there any way to simulate Geolocation service in Flashdevelop? Or generally, on desktop PC?

mercredi 22 juillet 2015

AS3/Air drawing slows down over time

I have an Air app written in AS3 using FlashDevelop that involves using the graphics.drawEllipse method to draw 96 ellipses on the stage each frame (20fps), updating their position and alpha. After a second or so they fade out and are removed.

graphics.clear();
graphics.beginFill( color, timer );
graphics.lineStyle( 0, color, timer );
graphics.drawEllipse( x, y, r, r );         
graphics.endFill();

The first 7 or so times these groups of 96 ellipses are spawned, they flow very smoothly across the screen as intended. After that they start to stutter like it's a framerate issue.

They are the only moving part in the scene and so are the only visible sign the system is struggling to draw them, but I am aware they may be the symptom rather than the cause of the slowdown. I have used the profiler and believe I have eliminated all the memory leaks.

I am wondering if anyone can see a problem with what I'm doing, or if not has any other suggestions with what could be causing the slowdown (I guess just general as3 things that could cause it).

Cannot view data returned by amfphp

I've recently set up amfphp 2.2.1 on my win7pro (iis7.x) local host in the hope of getting away from XML between phph and Flash. I Followed the inital 'hello world' tut on amfphp website and everything was great.. it worked. My problem started when I tried querying a mySQL db. my debug proxy says there is data being grabbed via amfphp/index.php (getAvailSvc/getBds) and it appears to be the data that I expected. When I try to view that data in Flash. When I try the simplest of functions

function handleResult(respond:Object):void{
    trace(respond);
    }

the trace give me [object Object],[object Object],[object Object]... etc

When I edit the trace to (respond.serverInfo.initialData) or my function to read the objects thus:

function handleResult(respond:Object):void{
        var h:Array = respond.serverInfo.initialData;
            for (var i:uint = 0; i < h.length; i++){
                trace (h[i][0]);
                }
    }

I get the following error:

TypeError: Error #1010: A term is undefined and has no properties. at amf_fla::MainTimeline/handleResult()

I've searched and searched the web for amfphp tuts and guidance but most, if not all, the stuff I found is circa 6-7 years old and relates only to mysql_query stuff and amfphp 1.9-. If anyone can help I'd appreciate your support and aplogise in advance if its me just being stupid.

debug proxy output: enter image description here

@Ariel Sommeria-Klein - raised here as suggested

Deal connection lost ActionScript 3

I have this code:

public function Json2Me(_urlJSON:String) {
            var loader:URLLoader = new URLLoader();
            var request:URLRequest = new URLRequest();
            request.url = _urlJSON;
            loader.addEventListener(Event.COMPLETE, onLoaderComplete);
            loader.addEventListener(IOErrorEvent.IO_ERROR,informadorIO);
            loader.load(request);
        }

        private function onLoaderComplete(e:Event):void{
            var loader:URLLoader = URLLoader(e.target);
            JSONEnviado = com.adobe.serialization.json.JSON.decode(loader.data);
            dispatchEvent(new Event("LanzaJSON"));
        }

        public function informadorIO(e:Event):void{
            trace(e);
        }

I need to protect my code against connection lost, so what I have to do to keep my project running?

Annotating an Image in AS3 with a Rectangle and Save Result

I am currently looking at a face detection example found in a zip file here:

Marilena_mod10.zip

The example loads an image and then highlights the face with a black rectangle. I would like to save the resulting image, in other words, annotate the image with a square and nothing else (just the image and square, not the entire stage).

So far I can save the image by processing it as bitmap data and resaving it, but I cannot save the 'square'. I've tried copying the line that draws the square and drawing it to another bitmap object, tried drawing it on a sprite, and I've tried using a matrix figuring it was being drawn out of bounds. No luck.

Below is the original code followed by my futile attempts (I realize it saves a blank white image, I was trying to see if I could just draw a square):

package
{
    import flash.display.StageScaleMode;
    import flash.display.StageAlign;
    import flash.display.Sprite;
    import flash.display.Loader;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Graphics;
    import flash.events.Event;
    import flash.geom.Rectangle;
    import flash.net.URLRequest;
    import flash.text.TextField;
    import jp.maaash.ObjectDetection.ObjectDetector;
    import jp.maaash.ObjectDetection.ObjectDetectorOptions;
    import jp.maaash.ObjectDetection.ObjectDetectorEvent;

    import flash.utils.getTimer;

    public class FaceDetector extends Sprite{
        private var debug :Boolean = true;

        private var detector    :ObjectDetector;
        private var options     :ObjectDetectorOptions;
        private var faceImage   :Loader;
        private var bmpTarget   :Bitmap;

        private var view :Sprite;
        private var faceRectContainer :Sprite;
        private var tf :TextField;

        private var lastTimer:int = 0;

        public function FaceDetector() {
            initUI();
            initDetector();
            faceImage.load( new URLRequest("013.jpg") );
        }

        private function initUI():void{
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;

            view = new Sprite;
            addChild(view);

            faceImage = new Loader;
            faceImage.contentLoaderInfo.addEventListener( Event.COMPLETE, function(e :Event) :void {
                startDetection();
            });
            view.addChild( faceImage );

            faceRectContainer = new Sprite;
            view.addChild( faceRectContainer );

            tf = new TextField;
            tf.x = 256;
            tf.width  = 600;
            tf.height = 300;
            tf.textColor = 0x000000;
            tf.multiline = true;
            view.addChild( tf );
        }

        private function initDetector():void{
            detector = new ObjectDetector;
            detector.options = getDetectorOptions();
            detector.addEventListener(ObjectDetectorEvent.DETECTION_COMPLETE,function( e :ObjectDetectorEvent ):void{
                logger("[ObjectDetectorEvent.COMPLETE]");
                tf.appendText( "\ntime: "+(new Date)+" "+e.type );
                detector.removeEventListener( ObjectDetectorEvent.DETECTION_COMPLETE, arguments.callee );

                if( e.rects ){
                    var g :Graphics = faceRectContainer.graphics;
                    g.clear();
                    g.lineStyle( 2 );   // black 2pix
                    e.rects.forEach( function( r :Rectangle, idx :int, arr :Array ) :void {
                        g.drawRect( r.x, r.y, r.width, r.height );
                    });
                }
            });

            detector.addEventListener( ObjectDetectorEvent.DETECTION_START, function(e :ObjectDetectorEvent) :void {
                tf.appendText( "\ntime: "+(new Date)+" "+e.type );
            });

        }

        private function startDetection():void{
            logger("[startDetection]");

            bmpTarget = new Bitmap( new BitmapData( faceImage.width, faceImage.height, false ) )
            bmpTarget.bitmapData.draw( faceImage );
            detector.detect( bmpTarget.bitmapData );
        }

        private function getDetectorOptions() :ObjectDetectorOptions {
            options = new ObjectDetectorOptions();
            options.min_size  = 50;
            return options;
        }

        private function logger(... args):void{
            if(!debug){ return; }
            trace( args, getTimer(),  getTimer() - lastTimer);
            lastTimer = getTimer();
        }
    }
}

My code:

package
{
    import flash.display.StageScaleMode;
    import flash.display.StageAlign;
    import flash.display.Sprite;
    import flash.display.Loader;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Graphics;
    import flash.events.Event;
    import flash.geom.*;//Rectangle;
    import flash.net.URLRequest;
    import flash.text.TextField;
    import jp.maaash.ObjectDetection.ObjectDetector;
    import jp.maaash.ObjectDetection.ObjectDetectorOptions;
    import jp.maaash.ObjectDetection.ObjectDetectorEvent;
    import com.adobe.images.*;

    import flash.utils.getTimer;

    ////
    import flash.filesystem.*;
    import flash.utils.ByteArray;
    ////

    public class FaceDetector extends Sprite{
        private var debug :Boolean = true;

        private var detector    :ObjectDetector;
        private var options     :ObjectDetectorOptions;
        private var faceImage   :Loader;
        private var bmpTarget   :Bitmap;

        private var view :Sprite;
        private var faceRectContainer :Sprite;
        private var tf :TextField;

        private var lastTimer:int = 0;

        public function FaceDetector() {
            initUI();
            initDetector();
            faceImage.load( new URLRequest("013.jpg") );
        }

        private function initUI():void{
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;

            view = new Sprite;
            addChild(view);

            faceImage = new Loader;
            faceImage.contentLoaderInfo.addEventListener( Event.COMPLETE, function(e :Event) :void {
                startDetection();
            });
            view.addChild( faceImage );

            faceRectContainer = new Sprite;
            view.addChild( faceRectContainer );

            tf = new TextField;
            tf.x = 256;
            tf.width  = 600;
            tf.height = 300;
            tf.textColor = 0x000000;
            tf.multiline = true;
            view.addChild( tf );
        }

        private function initDetector():void{
            detector = new ObjectDetector;
            detector.options = getDetectorOptions();
            detector.addEventListener(ObjectDetectorEvent.DETECTION_COMPLETE,function( e :ObjectDetectorEvent ):void{
                logger("[ObjectDetectorEvent.COMPLETE]");
                tf.appendText( "\ntime: "+(new Date)+" "+e.type );
                detector.removeEventListener( ObjectDetectorEvent.DETECTION_COMPLETE, arguments.callee );

                var rt:Sprite    = new Sprite();
                var bmprt:Bitmap = new Bitmap( new BitmapData( faceImage.width, faceImage.height, false ) );
                var matrix:Matrix = new Matrix();
                var rect:Rectangle = new Rectangle();

                if( e.rects ){
                    var g :Graphics = faceRectContainer.graphics;
                    g.clear();
                    g.lineStyle( 2 );   // black 2pix
                    e.rects.forEach( function( r :Rectangle, idx :int, arr :Array ) :void {
                        g.drawRect( r.x, r.y, r.width, r.height );

                        matrix.translate(-r.x, -r.y);
                        rect = r;
                        rt.graphics.drawRect(r.x, r.y, r.width, r.height );
                    });
                }

                var file:File                   = File.applicationStorageDirectory.resolvePath("testoutput.jpg");
                var fs:FileStream               = new FileStream();
                var byteArray:ByteArray;
                var jpgEncoder:JPGEncoder = new JPGEncoder( 90 );


                //rt.graphics.draw(g);

                bmpTarget.bitmapData.draw(rt);
                bmprt.bitmapData.draw(rt, matrix);

                byteArray     = jpgEncoder.encode( bmprt.bitmapData );
                fs.open(file, FileMode.WRITE);
                fs.writeBytes(byteArray);
                fs.close();

            });

            detector.addEventListener( ObjectDetectorEvent.DETECTION_START, function(e :ObjectDetectorEvent) :void {
                tf.appendText( "\ntime: "+(new Date)+" "+e.type );
            });

        }

        private function startDetection():void{
            logger("[startDetection]");
            bmpTarget = new Bitmap( new BitmapData( faceImage.width, faceImage.height, false ) )
            bmpTarget.bitmapData.draw( faceImage );
            detector.detect( bmpTarget.bitmapData );
        }

        private function getDetectorOptions() :ObjectDetectorOptions {
            options = new ObjectDetectorOptions();
            options.min_size  = 50;
            return options;
        }

        private function logger(... args):void{
            if(!debug){ return; }
            trace( args, getTimer(),  getTimer() - lastTimer);
            lastTimer = getTimer();
        }
    }
}

TL;DR:

How do you load an image, draw a square on it, and then save the result, assuming you already know how to load and save images?

Any help is appreciated, thanks in advance.

EDIT

Here is the final code for anyone interested:

package
{
    import flash.display.StageScaleMode;
    import flash.display.StageAlign;
    import flash.display.Sprite;
    import flash.display.Loader;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Graphics;
    import flash.events.Event;
    import flash.geom.*;//Rectangle;
    import flash.net.URLRequest;
    import flash.text.TextField;
    import jp.maaash.ObjectDetection.ObjectDetector;
    import jp.maaash.ObjectDetection.ObjectDetectorOptions;
    import jp.maaash.ObjectDetection.ObjectDetectorEvent;
    import com.adobe.images.*;

    import flash.utils.getTimer;

    ////
    import flash.filesystem.*;
    import flash.utils.ByteArray;
    ////

    public class FaceDetector extends Sprite{
        private var debug :Boolean = true;

        private var detector    :ObjectDetector;
        private var options     :ObjectDetectorOptions;
        private var faceImage   :Loader;
        private var bmpTarget   :Bitmap;

        private var view :Sprite;
        private var faceRectContainer :Sprite;
        private var tf :TextField;

        private var lastTimer:int = 0;

        public function FaceDetector() {
            initUI();
            initDetector();
            faceImage.load( new URLRequest("013.jpg") );
        }

        private function initUI():void{
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;

            view = new Sprite;
            addChild(view);

            faceImage = new Loader;
            faceImage.contentLoaderInfo.addEventListener( Event.COMPLETE, function(e :Event) :void {
                startDetection();
            });
            view.addChild( faceImage );

            faceRectContainer = new Sprite;
            view.addChild( faceRectContainer );

            tf = new TextField;
            tf.x = 256;
            tf.width  = 600;
            tf.height = 300;
            tf.textColor = 0x000000;
            tf.multiline = true;
            view.addChild( tf );
        }

        private function initDetector():void{
            detector = new ObjectDetector;
            detector.options = getDetectorOptions();
            detector.addEventListener(ObjectDetectorEvent.DETECTION_COMPLETE,function( e :ObjectDetectorEvent ):void{
                logger("[ObjectDetectorEvent.COMPLETE]");
                tf.appendText( "\ntime: "+(new Date)+" "+e.type );
                detector.removeEventListener( ObjectDetectorEvent.DETECTION_COMPLETE, arguments.callee );

                var bmprt:Bitmap = new Bitmap( new BitmapData( faceImage.width, faceImage.height, false ) );

                if( e.rects ){
                    var g :Graphics = faceRectContainer.graphics;
                    g.clear();
                    g.lineStyle(3, 0xFF0000, 1);    // black 2pix--- parameters(thicknes in pixels, color in hex, alpha (0-1))
                    e.rects.forEach( function( r :Rectangle, idx :int, arr :Array ) :void {
                        g.drawRect( r.x, r.y, r.width, r.height );
                    });
                }

                var file:File                   = File.applicationStorageDirectory.resolvePath("testoutput.jpg");
                var fs:FileStream               = new FileStream();
                var byteArray:ByteArray;
                var jpgEncoder:JPGEncoder = new JPGEncoder( 90 );

                bmprt.bitmapData.draw(faceImage);
                bmprt.bitmapData.draw(faceRectContainer);

                byteArray     = jpgEncoder.encode( bmprt.bitmapData );
                fs.open(file, FileMode.WRITE);
                fs.writeBytes(byteArray);
                fs.close();

            });

            detector.addEventListener( ObjectDetectorEvent.DETECTION_START, function(e :ObjectDetectorEvent) :void {
                tf.appendText( "\ntime: "+(new Date)+" "+e.type );
            });

        }

        private function startDetection():void{
            logger("[startDetection]");
            bmpTarget = new Bitmap( new BitmapData( faceImage.width, faceImage.height, false ) )
            bmpTarget.bitmapData.draw( faceImage );
            detector.detect( bmpTarget.bitmapData );
        }

        private function getDetectorOptions() :ObjectDetectorOptions {
            options = new ObjectDetectorOptions();
            options.min_size  = 50;
            return options;
        }

        private function logger(... args):void{
            if(!debug){ return; }
            trace( args, getTimer(),  getTimer() - lastTimer);
            lastTimer = getTimer();
        }
    }
}

Thanks to Vesper for the help.