Friday, July 6, 2012

[Action Script] MovieClip: Next frame every interval July,2012

I'm programming a simple shooter in which enemies enter from the right and the player is at the left. This enemy is a MC with 2 frames, which I want to alternate every set number of pixels. Here is the code:
Code: package  {
       
        import flash.display.MovieClip;
        import flash.events.*;
       
        public class Enemy extends MovieClip {
               
                var OrigX:int;
               
                public function Enemy() {
                        this.gotoAndStop(1);
                        this.addEventListener(Event.ENTER_FRAME, loop);
                        OrigX = this.x;
                }
               
                function loop(event:Event) {
                        this.x -= 1;
                        if (OrigX - this.x >= 15) {
                                this.nextFrame();
                                OrigX = this.x;
                        }
                }
        }
       
}The MC doesn't change frames as it should...It only changes frames once, and that is after it is beyond the left edge of the stage.
I have also tried Code: addEventListenerinstead of Code: this.addEventListenerif that matters.
(Thanks in advance.)
MovieClip: Next frame every interval

Thursday, July 5, 2012

[Action Script] input text box and conditional statement July,2012

Hi all,

I have created an input field using as3
the user enter a nummber (only numbers are ccepted)
the code compares this value to one stored previousliy in the program
if the two values matches the program go to a frame labled "sl_bt"
else it go to another one labled "hp1

i get error 1046

this the code:

stop();
var input1_txt:Number;
var answer1:Number = (input1.text);
check1_btn.addEventListener(MouseEvent.CLICK, checkanswer1);
function checkanswer1(e:MouseEvent):void
{
if (answer1 == 9)
{
gotoAndStop("sl_bt");
} else {
gotoAndStop("hp1");
}
}
input text box and conditional statement

[Action Script] how can i give pop-up / more information July,2012

i have an application color design for fixie bike.
sorry i can share it, because i currently have 2 posts :(
i want to make more features for that application, such as giving pop-up information.
let me explain it.
when the user click a part of bike(movieclip), she/he will be given an information.
such as, when the user click on frame and the frame being red color, the information that will be shown is "red color will look harmoniuos with white color".

how can i make it?
is there need a database?

-thanks-
how can i give pop-up / more information

[Action Script] New guy looking for help July,2012

Hey all,

I'm new here! So hello everybody! :-)

I'm currently trying to learn Actionscript 3 for use in building games. I have basic programming knowledge from learning some PHP and JavaScript so I know the basics about variables, conditional logic, etc etc.

I'm a little weak in the OOP side of things though. I'm currently reading Essential Actionscript 3 and I'm learning from it, though some things bend my mind a little bit.

I'm looking for something very specific. A person that is willing to work with me. Not like all day everyday or anything but someone that is willing to like give me assignments and then look at my work and answer questions.

I've followed tutorials, videos, and guides and I learn some stuff. But it's just not the same as actually having a person saying "NO! YOU DON'T DO IT THAT WAY!!!" :-P

I have 3 ideas for games I want to make, if someone is willing to help me out perhaps we could use those ideas and I could learn while working toward one of them.

Of course anyone that helps me will be given credit and thanks.

Thank you guys ahead of time! :-)
New guy looking for help

[Action Script] [AS3] Problem with checking for bullet collision July,2012

Hello
The following piece of code checks whether a bullet has collided with an enemy or a wall and acts accordingly, the problem is that if a bullet collides with an enemy and a wall it gives an error, this also happens when shooting in random directions and hitting walls and enemies.
After the error enemies are taken down with one shot, not two and if there is more than one enemy on stage the bullets just pass straight through them.

Here is the code:
Code: if (pistolBulletCount>0)
                                {
                                               
                                                for (var j:int = 0; j < zombieArmy.length; j++)
                                                {
                                                        enemy = zombieArmy[j];
                                                        // if the collsision occured remove the bullet and update health of enemy
                                                        for (var s:int = 0; s < pistolBullets.length; s++)
                                                        {
                                                                var blts:PistolBullet = pistolBullets[s];
                                                        }
                                                        if (enemy.hitTestObject(blts))
                                                        {
                                                                // if the enemy is dead, remove him as well
                                                                if (enemy.updateHealth(-50) <= 0)
                                                                {
                                                                        zombieArmy.splice(j, 1);
                                                                        enemy.parent.removeChild(enemy);
                                                                        zombienum--;
                                                                }
                                                                //RETURN; HERE TO AVOID ERROR
                                                        }
                                                }
                                       
                                       
                                                //Bullet Movement
                                                        for (var i:int = 0; i < pistolBullets.length; i++)
                                                        {
                                                                var pistolBlts:PistolBullet = pistolBullets[i];
                                                                pistolBlts.x-=xSpeed;
                                                                pistolBlts.y-=ySpeed;
                                                               
                                                                if (zombienum>0)
                                                                {
                                                                        if (pistolBlts.hitTestObject(enemy))
                                                                        {
                                                                                removeChild(pistolBlts);
                                                                                pistolBulletCount--;
                                                                        }
                                                                }
                                                               
                                                                if (pistolBlts.hitTestObject(wall))
                                                                        {                               
                                                                                if (PixelPerfectCollisionDetection.isColliding( pistolBlts, wall, this, true ) )
                                                                                {
                                                                                        removeChild(pistolBlts);
                                                                                        pistolBulletCount--;
                                                                                }
                                                                        }
                                                        }
                                }Here is the error:
Code: ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
        at flash.display::DisplayObjectContainer/removeChild()
        at MojaGra/Tick()
        at flash.utils::Timer/_timerDispatch()
        at flash.utils::Timer/tick()Any suggestions and help is appreciated as I checked and modified this code for quite a bit with no success.
[AS3] Problem with checking for bullet collision

[Action Script] as3 components live preview question July,2012

I want to make a component that I can specify how many points I want to draw dot to dot (its for a level editor, to export lines for physics engine)

something like this

(broken)

I want to be able to drag the dots around and have live preview automatically update the lineTo method and show me what it would look like

im not sure how to achieve this

any tips i'd greatly appreciate!
as3 components live preview question

[Action Script] Push values into a multi-dimensional array? July,2012

Code: var oArray:Array = new Array(new Array(), new Array());


for (var i:uint=0; i<numChildren; i++)
{
        getChildAt(i).addEventListener(MouseEvent.MOUSE_DOWN,down);

// how to push array values into a multi-dimensional array?
        oArray[i][0] = getChildAt(i).x;
        oArray[i][1] = getChildAt(i).y;
//
}

trace(oArray[1][0] + " " + oArray[1][1]);How can I push values into a multi-dimensional array?
Push values into a multi-dimensional array?

Wednesday, July 4, 2012

[Action Script] Scroll Pane custom skin July,2012

Hi Guys,

I've used a scroll pane to display a movie clip, and used custom skinning to change the look of the scroll pane,

the instance name of my scroll pane is sp,

sp.source = growth_mc;
sp.update();
sp.scrollDrag = false;
empty_mc = new MovieClip();

var emptytemp_mc:MovieClip = new MovieClip();
sp.setStyle("disabledSkin",emptytemp_mc);
sp.setStyle("upSkin",emptytemp_mc);
sp.setStyle("downArrowDisabledSkin",emptytemp_mc);
sp.setStyle("downArrowDownSkin",emptytemp_mc);
sp.setStyle("downArrowOverSkin",emptytemp_mc);
sp.setStyle("downArrowUpSkin",emptytemp_mc);
sp.setStyle("upArrowDisabledSkin",emptytemp_mc);
sp.setStyle("upArrowDownSkin",emptytemp_mc);
sp.setStyle("upArrowOverSkin",emptytemp_mc);
sp.setStyle("upArrowUpSkin",emptytemp_mc);
sp.setStyle("thumbIcon",emptytemp_mc);

var tempscrollthumb:scrollthumb_mc = new scrollthumb_mc();
sp.setStyle("thumbDownSkin",tempscrollthumb);
sp.setStyle("thumbOverSkin",tempscrollthumb);
sp.setStyle("thumbUpSkin",tempscrollthumb);

var tempscrolllong_mc:scrolllong_mc = new scrolllong_mc();
sp.setStyle("trackDownSkin",tempscrolllong_mc);
sp.setStyle("trackOverSkin",tempscrolllong_mc);
sp.setStyle("trackUpSkin",tempscrolllong_mc);

whats happening is that only the horizontal scroll bar shows the custom skin,
the vertical scroll bar does not reflect the custom skin, moreover the vertical scroll is not seen at all.

I can't find a solution to this, please help.
Scroll Pane custom skin

[Action Script] Simple AS3.0 question July,2012

if i have too much ENTER_FRAME function in my action script , does it cause any problem ,i got like 6 ENTER FRAME now but i got no problem , but dose it cause any thing ?
Simple AS3.0 question

[Action Script] Need Flash Programmer July,2012

I need help with a game I am currently creating, so I thought I would post here and perhaps get some assistance.

A little background: My game is a fighting game and features live action video. I have rented out a studio and recorded ALL possible fighting moves (and then some) between two actresses and essentially incorporated about 100 video segments into a Flash file and am in the process of making an interactive menu/battle system.

The game: Basically, you take on the role of the main character (an actress) and you must defeat your nemesis (another actress) through a series of combat-minigames. Punch, kick and slap your way to victory! Each game segment is played a bit differently (The camera jumps from 1st person & 3rd person combat) but it essentially plays out the same way.

Who I am seeking: I need someone to help me draw a better interface and help me create the battle system (its basically a gotoandplay project, healthbars, button presses and such.) I do have a small paypal budget so I can actually pay you :) Also, the end product will be sold, will be happy to discuss royalties and such. Please contact me ASAP!
Need Flash Programmer

[Action Script] Swf a little bit bigger on html than original swf file, problem July,2012

Hey Guys!
I have a silly problem with swf files displayed on simple html...

For sake of simplicity,
I have a swf file that is called test.swf and its size is 550x400

From dreamweaver on a test.html script I have the following:

Code: <body>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="550" height="400">
      <param name="movie" value="test.swf" />
      <param name="quality" value="high" />
      <embed src="test.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="550" height="400"></embed>
    </object>


</body>When I open test.html with explorer...I can see that test.swf is slightly bigger than the original .swf... any ideas on how this can be fixed??
Thanks a lot in advance!!
Cheers!
Swf a little bit bigger on html than original swf file, problem

[Action Script] Code conversion from AS2 to AS3 help! July,2012

Hello all,
Im in need of some help in converting a few blocks of code from AS2 to AS3. I will not be using these codes in external .as files, and will need them to be used directly on the stage in the main timeline of the specific movieclips. One deals with conditional statement that scales a background image up when the browser window becomes larger than the specified stage size within the code, but remains the same size when on smaller monitors. Code is below:

if (Stage.width>1920 || Stage.height>1200)
{
mainSitebg._width = Stage.width;
mainSitebg._height = Stage.height;

mainSitebg._xscale > mainSitebg._yscale ?
mainSitebg._yscale = mainSitebg._xscale :

mainSitebg._xscale = mainSitebg._yscale;
}
var stageL:Object = new Object();
stageL.onResize = function() {

if (Stage.width>1920 || Stage.height>1200)
{

mainSitebg._width = Stage.width;
mainSitebg._height = Stage.height;

mainSitebg._xscale > mainSitebg._yscale ?
mainSitebg._yscale = mainSitebg._xscale :


mainSitebg._xscale = mainSitebg._yscale;
}
Stage.addListener(stageL);

The next bit of code deals with a parallax effect with individual movieclips. That code is below also:

orig_x = this._x;
orig_y = this._y;
profundidad = 20;
this.swapDepths(profundidad);

onEnterFrame = function() {
dest_x = (((210 - _root._xmouse)/400) * profundidad) + orig_x;
incr_x = (dest_x - this._x)/10;
this._x += incr_x;
dest_y = (((130 - _root._ymouse)/330) * profundidad) + orig_y;
incr_y = (dest_y - this._y)/10;
this._y += incr_y;
}

Ant help would be very much appretiated! Thank you to anyone that may help!
Cheers!
Code conversion from AS2 to AS3 help!

[Action Script] [AS3] game development help July,2012

Hi I need help with my game project. This game is very simple but since I am new to OOP I am not able to proceed further.The game is of a character running left or right avoiding falling objects and collecting some objects in the way.
I am using random number to add these objects to the stage. The problem is I want these objects to appear only once.
Also I need to check for collision with the hero which has a different custom class Hero attached to it.

Please help.

--------------------------------------------
This is the custom class file for new objects to be collected:
-----------------------------------------------
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.ui.Keyboard;
import flash.ui.Mouse;
import flash.text.TextField;
import flash.events.TimerEvent;
import flash.utils.Timer;
import BaseObject;
import Hero;

public class Collectibles extends MovieClip{

private var collectiblesTimer:Timer = new Timer(5000);
private var object1:Object1 = new Object1;
public var gameFinished:GameFinishedScreen = new GameFinishedScreen;
public var newObject:MovieClip;
public function Collectibles() {
// constructor code
collectiblesTimer.addEventListener(TimerEvent.TIME R,addRandomObjects);
collectiblesTimer.start();

//initialise the game finished screen
//gameFinished.nextLevel.buttonMode = true;
//gameFinished.nextLevel.addEventListenerMouseEvent. CLICK,onGameFinished);
}

public function addRandomObjects(evt:TimerEvent): void {
//create an instance of a random object
var randomNumber:Number = Math.random();
var objectCount:int = 0;

// 0 .... 1
if (randomNumber >= 0 && randomNumber <= 0.2) {
newObject = new Object1();
objectCount += 1;
trace(objectCount);
newObject.amountPointsWorth = 20;
}
if (randomNumber >= 0.2 && randomNumber <= 0.4) {
newObject = new Object2();
objectCount += 1;
trace(objectCount);
newObject.amountPointsWorth = 30;
}
if (randomNumber >= 0.4 && randomNumber <= 0.6) {
newObject = new Object3();
objectCount += 1;
trace(objectCount);
newObject.amountPointsWorth = 100;
}
if (randomNumber >= 0.6 && randomNumber <= 0.8) {
newObject = new Object4();
objectCount += 1;
trace(objectCount);
newObject.amountPointsWorth = 100;
}
if (randomNumber >= 0.8 && randomNumber <= 1) {
newObject = new Object5();
objectCount += 1;
trace(objectCount);
newObject.amountPointsWorth = 50;
}
if(objectCount == 5) {
trace("objectCount" + objectCount);
}
// limit the objects
newObject.x = Math.random() * stage.stageWidth;
newObject.y = Math.random() * (stage.stageHeight - 150);

// limit the boundaries for the new Object
if(newObject.x > stage.stageWidth){
newObject.x = stage.stageWidth - newObject.width;
}
if(newObject.y <= 200){
newObject.y = 200 + newObject.width/2;
}
if(newObject.y >= 300){
newObject.y = 300 - newObject.width/2;
}

addChild(newObject);
/*if(newObject.hitTestObject(hero)){
testCollisionObjects();
}*/
}
public function testCollisionObjects() {
trace("this will work");
// check for collision of new object with the hero
/*if(newObject.hitTestObject(hero)){
trace("new object hits hero");
}*/

}
}

}
--------------------------------------
[AS3] game development help

Tuesday, July 3, 2012

[Action Script] Errors with URLLoader/URLRequest July,2012

Hi, I am trying to import data from a text file and have come across a tutorial on loading data from external documents on the Adobe Help Resource Center for Flex 3.0. I have followed the instructions on their tutorial and oddly when I type the code in one way I get no errors but when typed another, equally valid way, I get errors. I am wondering why this is happening because I find things like this extremely annoyning. ;-)

Here are the two code formats:

This example works fine:
Code: <fx:Script>
        <![CDATA[
var loader:URLLoader = new URLLoader(new URLRequest("params.txt"));
        ]]>
</fx:Script>This code gives the error "1120: Access of undefined property loader"
Code: <fx:Script>
        <![CDATA[                       
                    var request:URLRequest = new URLRequest("params.txt");
                    var loader:URLLoader = new URLLoader();
                    loader.load(request);
                       
        ]]>
</fx:Script>
Errors with URLLoader/URLRequest

[Action Script] Error Message with controlBarContent July,2012

I am trying to add a control bar to a container and am coming across the following errer:

"Could not resolve <s:controlBarContent> to a component implementation"

I get the error with every container type I have tried thus far except for Application and Panel. The problem with using an Application container, however, is this component is not the main application and I get an error at compile time when I try to use the control bar contents in an Application container. Panel works fine but I don't want the control bar at the bottom of the container and I don't want a Panel heading.

It seems like I should be able to add a control bar to any kind of container I want. Can anyone help me out with this?

Thanks.
Error Message with controlBarContent

[Action Script] Playing a MC defined by XML July,2012

Solved
Playing a MC defined by XML

[Action Script] multi touch draw two lines July,2012

Hi All
I am trying to write an app that allows users on multi touch devices to draw. I want it so that more then one touch point can draw. so if touch the device with left index finger and at the same time your right index finger both fingers can draw independent lines. I can trace multiple touch events fine the problem I am having is that my line to code always seems to jump to the newer event. Creating some cool artsy drawings but not what I am after. I tried for each event creating a new sprite and various other approaches.

Any direction on this would help.
multi touch draw two lines

[Action Script] import.flash.events problem June,2012

ActionScript Code: package com.pageevents{import flash.events.*;    public class PageEvent extends Event {        public static const HOMEPG_COMPLETE:String = "homePageReady!";        public var msgStr:String = "none";        public function PageEvent (type:String,bubbles:Boolean = false,cancelable:Boolean = false,msgStr:String = "none") {            super(type, bubbles, cancelable);            this.msgStr = msgStr;        }        public override function clone( ):Event {            return new PageEvent(type, bubbles, cancelable, msgStr);        }        public override function toString( ):String{            return formatToString("PageEvent", "type", "bubbles","cancelable", "eventPhase", "msgStr");        }    }}

At the moment, this is my code, my problem is: I keep getting this error
Quote: K:\untitled folder\PageEvent.as, Line 1 5001: The name of package 'PageEvent' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. K:\untitled folder\PageEvent.as the file is named PageEvent.as, but why does it not work?

Help ASAP please.
import.flash.events problem

[Action Script] How do you prevent External SWF from instantiating specific classes? July,2012

Hi I am developing an application that requires third party SWFs to be loaded into my application. Here is a list of some of the classes that I'd like to prevent instantiation of:

- flash.media.Sound
- flash.display.NativeWindow (Air)
- flash.display.Loader
- flash.display.ServerSocket

I'd like to extend these classes with my own so that I can filter content in these classes. The extensions will be available to 3rd party developers in my program's SDK. Is it possible to prevent these classes from being loaded inside of the external SWF?

ALSO: I will be loading the external SWFs as binary using the URLLoader (not the Loader) then loading the bytes using the Loader object's 'loadBytes' method. I will be passing in a LoaderContext object with 'allowScriptImport' set to true, a null SecurityDomain, and a null ApplicationDomain.

Please help. Thank you.
How do you prevent External SWF from instantiating specific classes?

Monday, July 2, 2012

[Action Script] Button to MovieClip July,2012

Hi there,

The 'Home' screen of the game I'm working on has 3 links. Play / Credits / How to Play.

The Play button does work, but the Credits and How to Play buttons don't. I can't figure out what it is I'm doing wrong. I think it's going wrong in the 'Doument Class' file.

Please, can someone help me? I'm stuck.

Code 'Home Screen':


public function CreditsScreen()
{
ButtonCredits.addEventListener( MouseEvent.CLICK, onClickCredits );
}

public function onClickCredits( event:MouseEvent ):void
{
dispatchEvent( new NavigationEvent( NavigationEvent.CREDITS ) );
}

public function HowToPlayScreen()
{
ButtonHowToPlay.addEventListener( MouseEvent.CLICK, onClickHowToPlay );
}

public function onClickHowToPlay( event:MouseEvent ):void
{
dispatchEvent( new NavigationEvent( NavigationEvent.HOWTOPLAY ) );
}
}
}

Code 'Navigation Event':


package
{
import flash.events.Event;
public class NavigationEvent extends Event
{
public static const REPLAY:String = "replay";
public static const PLAY:String = "play";
public static const HOME:String = "home";
public static const CREDITS:String = "credits";
public static const HOWTOPLAY:String = "howtoplay";

public function NavigationEvent( type:String )
{
super( type );
}
}
}

Code 'Document Class':

package
{
import flash.display.MovieClip;
public class DocumentClass extends MovieClip
{
public var homeScreen:HomeScreen;
public var playScreen: DoodleSpaceInvaders;
public var gameOverScreen:GameOverScreen;
public var creditsScreen:CreditsScreen;
public var howToPlayScreen:HowToPlayScreen;

public function showCreditsScreen():void
{
creditsScreen = new CreditsScreen();
creditsScreen.addEventListener( NavigationEvent.CREDITS, onRequestCredits );
creditsScreen.x = 0;
creditsScreen.y = 0;
addChild( creditsScreen );
}

public function onRequestCredits( navigationEvent:NavigationEvent ):void
{
creditsScreen = new CreditsScreen();
creditsScreen.addEventListener( NavigationEvent.CREDITS, onRequestCredits );
creditsScreen.x = 0;
creditsScreen.y = 0;
addChild( creditsScreen );

homeScreen = null;
}

public function showHowToPlayScreen():void
{
howToPlayScreen = new HowToPlayScreen();
howToPlayScreen.addEventListener( NavigationEvent.HOWTOPLAY, onRequestHowToPlay );
howToPlayScreen.x = 0;
howToPlayScreen.y = 0;
addChild( howToPlayScreen );
}

public function onRequestHowToPlay( navigationEvent:NavigationEvent ):void
{
howToPlayScreen = new HowToPlayScreen();
howToPlayScreen.addEventListener( NavigationEvent.HOWTOPLAY, onRequestHowToPlay );
howToPlayScreen.x = 0;
howToPlayScreen.y = 0;
addChild( howToPlayScreen );

homeScreen = null;
}
}
}
Button to MovieClip

[Action Script] Character Movement to mouseclick? July,2012

I was wondering how I would setup a file to animate a movieclip to move to wherever the mouse was clicked, like a person walking to the clicked position BUT I want to be able to make it stop if it encounters a wall, and then not be able to move through that wall. I have basic experience in flash, and I know my way around, but I have no clue how I would go about doing this.
Thanks!
Character Movement to mouseclick?

[Action Script] Movie Clip Buttons: Code for Each Button "Overlapping"? July,2012

I have a set of movie clip buttons (please see the attached graphic), which during testing I've found that if I run the mouse over each of them, quickly, in succession, some of the buttons get "stuck" in the "over" mode, (the white text). The button cannot be reset to the "up" mode (gray text) until I roll over the stuck button again.

Here's the code for HOME, which are how the remaining six buttons are coded:

Code: //++++++++++++++++
// "HOME" button
//
btnHome.addEventListener(MouseEvent.ROLL_OVER, mouseRollOver);
function mouseRollOver(evt:MouseEvent):void
{
        btnHome.addEventListener(MouseEvent.ROLL_OUT, mouseRollOut);
        btnHome.gotoAndPlay("rollOver");

}

function mouseRollOut(evt:MouseEvent):void
{
        btnHome.gotoAndPlay("rollOut");

}

btnHome.addEventListener(MouseEvent.CLICK, mouseClick);
function mouseClick(evt:MouseEvent):void
{
        btnHome.removeEventListener(MouseEvent.ROLL_OUT, mouseRollOut);
        btnHome.removeEventListener(MouseEvent.ROLL_OVER, mouseRollOver);

        btnHome.hitAreaHome.mouseEnabled = false;
       
}

//++++++++++++++++
// "BIO" button
//What I think is happening is that as I roll out of one button and roll over another, the roll over code for that other button is maybe interfering with the completion of either the roll out function or animation for the previous button.

What can I do to ensure that one button's code/ animations complete its cycles regardless of what other button(s) I may roll over/ out of?
Attached Thumbnails Click image for larger versionName:	movieClipButtonTroubles.jpgViews:	N/ASize:	11.2 KBID:	38579 
Movie Clip Buttons: Code for Each Button "Overlapping"?

[Action Script] Actionscript.org Malware Warning? July,2012

I'm getting a Warning in Google Chrome when accessing this site - it occurred today... My friend's getting it too, anyone else experiencing this as well??
Actionscript.org Malware Warning?

[Action Script] How to tween an object to target without any tween libraries and without easing? June,2012

So I want to tween an object to targetX and targetY without any tween libraries and without easing.

I have always used greensock for all my tweens and for this case greensock's DynamicPropsPlugin would be perfect, but its only for club members......

This time I need to tween an object to target which will be changing dynamically.

I know how to tween objects with easing, but this time I need to tween an object without it, so after reaching its first target it would continue smoothly to next target.

This is code that works, but the problem is the easing:

ActionScript Code: package  {    import flash.display.*;    import flash.events.*;        /**     * ...     * @author fjo     */    [SWF(width="1200", height="600", frameRate="30", backgroundColor="#ffffff")]    public class Test extends Sprite     {                // first target coordinates        private var targetX:Number=600;        private var targetY:Number = 450;                // second target coordinates        private var targetX2:Number=900;        private var targetY2:Number = 300;                // check if first target is reached        private var _pointReached:Boolean                // object to tween        private var _ball:Sprite;                public function Test()         {            init()        }                private function init():void         {            // simple ball             _ball = new Sprite();            _ball.graphics.beginFill(0xff0000);            _ball.graphics.drawCircle( -50, -50, 50);            _ball.graphics.endFill();            addChild(_ball);                        addEventListener(Event.ENTER_FRAME, onLoop);        }            private function onLoop(e:Event):void         {            var vx:Number;             var vy:Number;                         if (_pointReached) { // next target                // easing                vx = (targetX2 - _ball.x) * .2;                vy = (targetY2 - _ball.y) * .2;            }else {                // easing                vx = (targetX - _ball.x) * .2;                vy = (targetY - _ball.y) * .2;            }                        // check distance            var dx:Number = targetX - _ball.x;            var dy:Number = targetY - _ball.y;            var dist:Number = Math.sqrt(dx * dx + dy * dy);                        // some lousy distance checking            if (dist <= 1) {                // first target point reached                _pointReached = true;            }                        // tween an object            _ball.x += vx;            _ball.y += vy;                    }            }}
Any thoughts?
Thanks!
How to tween an object to target without any tween libraries and without easing?

[Action Script] .as packages associated with individual scenes? June,2012

Hello, this my first posting on here so please be gentle!

In a single flash project is it possible to have individual .as packages that are associated with individual scenes?

Say I have 5 scenes in a project and I want each scene to have it's own package, so as I switch between scenes the relevant package is used. How do I go about doing this?

Do I use a document class that brings in .as packages for each scene?

Let me know if I'm not explaining well what I'm looking achieve, or if attaching an example project would be useful.

I have very little experience of Action Script so if anyone can give me some pointers as to what I should look at / any tutorials that would be much appreciated.

Apologies if this should be on the newbies forum, I'm not sure how basic/advanced this is
.as packages associated with individual scenes?

Sunday, July 1, 2012

[Action Script] Protect swf from decompilation July,2012

Hi,

I have a game that i now want to sell in the market, its a simple games yet i have worked hard and see that every thing is good and find a good buyer for it, just today i came across a software that claims to decompile any flash file, how do i protect my game from being decompiled and remain safe, what is it that you guys do to protect your swf, please suggest me ways and tools to do so that no one can hack my game and copy it or atleast protect my actionscript code.....

Thanks

Jin
Protect swf from decompilation

[Action Script] Converting from AS 2.0 to AS 3.0 July,2012

I am trying to position a MovieClip from XML file, in my project i'm using ActionScript 3.0 and i have got a code from the ActionScript 2.0 forum which is working perfectly fine, so i want to convert the below code to ActionScript 3.0

Can somebody help me in converting the below code from ActionScript 2.0 to ActionScript 3.0 ?

Thanks

Code:
myXML = new XML();
myXML.ignoreWhite = true;
myXML.load('xml.xml');

var map:Array = new Array();

myXML.onLoad = function() {
aNode = this.firstChild.childNodes;
len = aNode.length;
for (var i=0; i<len; i++) {
obj = {}
obj.xpos = aNode[i].attributes.xpos;
obj.ypos = aNode[i].attributes.ypos;
map.push(obj);
dups(i);
}
};

function dups(i){
duplicateMovieClip(_root.button, "knop"+i, i+1000);
ref = _root["knop"+i];
ref._x = map[i].xpos;
ref._y = map[i].ypos;
trace(map[i].xpos);
trace(map[i].xpos);
};
Attached Files File Type: zip Flash-XML.zip (10.0 KB)
Converting from AS 2.0 to AS 3.0

[Action Script] 3rd party software for flash(CyanBlue) July,2012

yeah some one(CyanBlue) told me that i can store my video source inside my exe file , package all file with just one exe file and it work but problem is once i publish it out my project wont work ,do any know what is the problem ? the software (northcode).

do any one know any kind of software can store video source inside exe ,same like northcode , and thank CyanBlue , i wanted to pm you but you your forum say don't pm you ,thank again that all you guys trying to help me , i really appreciate it.:p

i just wanted my file to keep it simple , i dont wanted a extra folder for video source.
3rd party software for flash(CyanBlue)

[Action Script] URLLoader 2 PNGs at Once July,2012

Hi,

I am using an URLLoader to save a PNG to the server via php and all works well but is it possible to send 2 pictures in the same request (or possibly more relevantly separate them at the other end)?

Thanks in advance,
Norman
URLLoader 2 PNGs at Once

[Action Script] Underlying windows don't detect clicks through transparent Windows June,2012

Users report that on OSX 10.6.8 clicks are not passed through the invisible window of my AIR application.

The application (Prioritizer) works fine on Windows and on my own MacBook but has a problem on some OSX 10.6.8 installations.

Prioritizer is a sticky notes-like app for creating an overview of projects, like a skin over your desktop wallpaper. Because it's meant to be always running, it should only show in the system tray (when on Windows) and not in the taskbar. The result is that you see little boxes with the titles of your projects alongside items on your desktop. Of course, clicking next to the projects, where desktop icons (or underlying windows) visible, should activate these windows/icons. This doesn't happen on the MacBooks of some of my users!

On my Windows laptop and my test MacBook the behavior is just as expected, under all OSX versions I tried: 10.5, 10.6, 10.6.8 and 10.7. On the users' MacBooks with OSX 10.6.8 I can reproduce the problem myself.

I have no idea if this is something I can fix, as it seems to have something to do with the permissions are granted to AIR by OSX... What do you think?

I also posted this issue on stackexchange, but so far nobody has replied even after a week. I hope over here somebody has a clue!

This is the code I wrote to make a maximized window without system chrome. I close the default window and create a new one (called trayedWindow):

ActionScript Code: function createTrayedWindow():void{        var nativeWindowOptions:NativeWindowInitOptions = new NativeWindowInitOptions();        nativeWindowOptions.type = NativeWindowType.UTILITY;        nativeWindowOptions.systemChrome = NativeWindowSystemChrome.NONE;        nativeWindowOptions.transparent = true;        trayedWindow = new NativeWindow(nativeWindowOptions);        trayedWindow.stage.align = "TL";        trayedWindow.stage.scaleMode = "noScale";                   trayedWindow.title = "Prioritizer";        trayedWindow.visible = false;        initializeInterface();    }On getprioritizer.com there are screenshots of the application which may clarify what I mean.
Underlying windows don't detect clicks through transparent Windows

[Action Script] on mouseclick logic for timeline animation June,2012

So there is a movieclip that goes through certain stages in a Breaking,BrokenLooping,Fixing,brokenPermenant animation cycle

I'm just starting to make the actionscript for it but I'm not sure how to go about it, or if the logic is sound. I am a bit new to actionscript

i assume i can make a function like this
Quote: function myButtonAction(eventObject:MouseEvent) {
trace("you clicked on the button ");
}
myButton.addEventListener(MouseEvent.CLICK, myButtonAction); where myButton is the instance of a button movieclip ontop of the movieclip

__________________________________________________ __________

The general idea is that randomly things will break and stick in a broken loop, then you have to start taping the screen to repair it until fixed or else it permanently breaks

*note that the fixing animation cycle is backwards so that positive on the timeline is it slowly breaking - you tap to reverse frames and "repair"


the logic goes like this (at the start of the looping broken animation)
on user input (mouseclick)
-goto frame (xx) (end of fixing animation)
-stop() for 1 second (stopping so it doesnt just enter next animation cycle)
..... -if user input yes (tap/click)
......... -go back one frame [currentframe -1]
......... -stop() for 0.100 seconds then play()
......... - or if time between taps is less than 0.100, then play
..... -if user input is no (no tap/click)
......... -play()


I'm not sure if that handles all the possibilities but i guess ill find out as i go.

does anyone have any advice on how to start this or if i am missing anything?
on mouseclick logic for timeline animation

Saturday, June 30, 2012

[Action Script] Efficient ActionScript 3.0 June,2012

I use FlashDevelop 4.01 to write small ActionScript projects and have messed around with Mobile Adobe Air ActionScript 3.0 Apps. My question is for anyone who would like to answer, for them to share experience, or to help point me in a better direction. Here is a small code example of a Pong type ball bouncing around a 500 x 500 px screen.

Main.as -
Code: package
{
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.display.StageScaleMode;
        import flash.display.StageAlign;
       
        [SWF(width="500", 
                height="500",
                frameRate="30", 
                backgroundColor="#000000", 
                pageTitle="AdvEngine - Flash Version 1.0")]
        public class Main extends Sprite
        {
                public static const WIDTH:uint = 500;
                public static const HEIGHT:uint = 500;
               
                private var ball:Ball = new Ball();
               
                public function Main():void
                {
                        addEventListener(Event.ADDED_TO_STAGE, init);
                        addEventListener(Event.ENTER_FRAME, update);
                        addChild( ball );
                }
               
                private function init(e:Event = null):void
                {
                        removeEventListener(Event.ADDED_TO_STAGE, init);
                        stage.scaleMode = StageScaleMode.NO_SCALE;
                        stage.align = StageAlign.TOP_LEFT;
                }
               
                private function update(event:Event):void {
                        ball.update();
                }
               
        }
       
}
Ball.as -
Code: package
{
        import flash.geom.Point;
        import flash.display.Bitmap;
        import flash.display.BitmapData;
       
        public class Ball extends Bitmap
        {
               
                private var fp:Point        = new Point(0, 0);
                private var dx:int                = 5;
                private var dy:int                = 4;
               
                public function Ball()
                {
                        super( new BitmapData( 10, 10, false, 0xffffff ) );
                        cacheAsBitmap = true;
                }
               
                public function update():void {
                       
                        fp.x = x + dx;
                        fp.y = y + dy;
                       
                        // test horz boundaries
                        if ( fp.x < 0 ) {
                                fp.x = 0;
                                dx *= -1;
                        }else if ( Main.WIDTH < (fp.x + width) ) {
                                fp.x = Main.WIDTH - width;
                                dx *= -1;
                        }
                       
                        //test vert boundaries
                        if ( fp.y < 0 ) {
                                fp.y = 0;
                                dy *= -1;
                        }else if ( Main.HEIGHT < (fp.y + height) ) {
                                fp.y = Main.HEIGHT - height;
                                dy *= -1;
                        }
                       
                        x = fp.x;
                        y = fp.y;
                       
                }
        }

}When the movie starts up it is choppy, for maybe the first 3 seconds, then it evens out, but continues to look choppy every now and then. Changing the frame rate to 60 instead of 30 makes it move without any choppy-ness on the computer, but for some reason my phone won't allow more than 35 - 40 fps. I thought using Bitmaps and cacheAsBitmap and cacheAsBitmapMatrix would be the best options I had for hitting that frame rate each time, but it still seems choppy. I thought 30 would be more than enough for solid fps.

- Is there a way to give more initial memory to the application? Would this help?

- Is there a way to push rendering to the GPU effectively instead of CPU ( I know the application.xml file in the mobile development has a tag <renderMode> which can be changed to gpu, but this has always slowed my application to 19 - 22 fps...

- Any ideas would be awesome. Or let me know if the above code runs perfectly smooth for you.

Thanks ahead of time
Efficient ActionScript 3.0

[Action Script] Button-controlled fade June,2012

I have two keyframes containing images, and a button on the first. I would like to find out how to script that button to, when rolled over, fade to the second frame, and fade back to the first frame when the mouse is rolled off.
Button-controlled fade

[Action Script] Preloader loads too fast June,2012

Hii,

My preloader is in frame one and it has only 6 kb of data, its for a game, it loads really fast , i really would like it to show up for atleast 4-5 seconds before it goes to game play page .....

i am using the below code on the Preloader.as

//////////////////////////////
var percent:int = Math.round(e.bytesLoaded / e.bytesTotal * 100);
progressBar.width = percent / 100 * progressArea.width;
percentageText.text = percent + "%";

///////////////////////////////


can some one help me to find a way that he preloader loads a little slower and shows up for a few seconds ...


I am using the concept of loading content in frame 2 by changing the action script settings in flash cs4 ......

Thanks

Jin
Preloader loads too fast

[Action Script] Optional parameters June,2012

Hey guys, I've got the following code
Code: function menuFade(button1:TextField, button2:TextField) {
                if(fadeIn) {
                        button1.alpha = 1;
                        button2.alpha = 1;
                }
                if(!fadeIn) {
                        button1.alpha = 0.2;
                        button2.alpha = 0.2;
                }
}But I want button2 to be optional, and I can't get that to work. Can someone help me on this?
Optional parameters

[Action Script] removeChild error 2007 June,2012

First off I'd like to say I did a search on this and although there are many subjects on the matter, none really apply to mine.

My problem is this: There is an enemy on the stage(enemyTwo) in which I remove if its health meter gets below a certain point. You lower the enemy's health by hitting it with little daggers that you throw.

Everything works fine up to a point, the health bar slowly goes down and the enemy even seems to disappear when the removeChild/enemyTwo = null directives are called, however, there seems to be a small window of time where the daggers will hit an invisible version of the enemy which in turn gives me the "Error #2007: Parameter hitTestObject must be non-null" error which in turn causes other things to go awry or Id just ignore it =).


ActionScript Code: public function checkCollisionWithEnemies(bullet:MovieClip)        {                        if(enemyTwo != null)            {                if(enemyTwo.hitTestObject(bullet))                {                    enemyTwo.subObject.meter.width -= 10;                    removeChild(bullet);                                                            if(enemyTwo.subObject.meter.width < 3)                    {                                                enemyTwo.stop();                        removeChild(enemyTwo);                        enemyTwo = null;                                            }                }                                            }         }
ActionScript Code: private function onEnter(evt:Event):void        {                        y -= 10;            rotation += 20;                        MovieClip(parent).checkCollisionWithEnemies(this);                                }
Any insight would be appreciated.
removeChild error 2007

[Action Script] Way of Communication between Flash(ActionScript) and HTML.) June,2012

Hello there.!

Greetings from my side.!!

I am searching a way so as data can be shared as I/O between HTML and ActionScript code.
Is there any way to achieve this.?
Kindly, Suggest me.!
Way of Communication between Flash(ActionScript) and HTML.)

Friday, June 29, 2012

[Action Script] Hello Countdown Timer June,2012

Hello,

I was wondering if someone could break down the following code for me and make it a bit easier so that i can just set a start date / end date.

Thanks.
Code: function displayDifference()
{
    nowTime = new Date();
    hoursLeft = ((((16-nowTime.getDate())*24) + (20 - nowTime.getHours())));
        //hoursLeft = (4 - nowTime.getDate()) * 24 + (19 - nowTime.getHours());
    if (hoursLeft >= 0)
    {
        timeRemaining.text = hoursLeft + ":" + padString(59 - nowTime.getMinutes()) + ":" + padString(59 - nowTime.getSeconds()) + "";
    }
    else
    {
        timeRemaining.text = "0H 0M 0S";
    } // end else if
} // End of the functionWhat i want to do is have a Start date of a value such as July 1st
and end date of July 31st

i'm not sure how similar this is to javascript esentially i want it to be like this.

Code: /* Date Animation  starts here*/
                                $(function () {
                                var austDay = new Date();
                                var austDay = new Date("June 30, 2012 21:00:00");
                                $('#countdown').countdown({until: austDay, layout:
                                                                '<div id="days" class="numbers">{dnn}</div>'+
                                                                '<div class="spacer"></div>'+
                                                                '<div id="hours" class="numbers">{hnn}</div>'+
                                                                '<div class="spacer"></div>'+
                                                                '<div id="minutes" class="numbers">{mnn}</div>'+
                                                                '<div class="spacer"></div>'+
                                                                '<div id="seconds" class="numbers">{snn}</div>'+
                                                                '</div>'});
                                                                });});
Hello Countdown Timer

[Action Script] Can't copy file (SQLite) June,2012

I just wrote a simple AIR program using SQLite but can't seem to copy it (using Save As)

When the first square is pressed a number is multiplied by 1.5

When the second square is pressed the database is updated with the new number

The AIR program saves the number in the databank but the copied program doesn't

Am I going mad?





import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.data.SQLStatement;
import flash.data.SQLConnection;
import flash.filesystem.File;
import flash.events.SQLEvent;
import flash.net.Responder;
import flash.errors.SQLError;
import flash.data.SQLResult;


var ones2:Number = new Number();
ones2 = 1;

var but:Sprite = new Sprite();
but.graphics.beginFill(0x555555);
but.graphics.drawRect(0,0,40,40);
but.graphics.endFill();
but.x = 50;but.y = 50;
addChild(but);

var but2:Sprite = new Sprite();
but2.graphics.beginFill(0x555555);
but2.graphics.drawRect(0,0,40,40);
but2.graphics.endFill();
but2.x = 120;but2.y = 50;
addChild(but2);


but.addEventListener(MouseEvent.CLICK, butClick);
function butClick(event:MouseEvent):void
{
ones2 = ones2 * 1.5;
trace(ones2);
}


// ************************************************** **************************************


var connect:SQLConnection = new SQLConnection();

opendatabase();

function opendatabase():void
{
var testFile:File = File.applicationStorageDirectory.resolvePath("name File.db");
connect = new SQLConnection();
connect.addEventListener(SQLEvent.OPEN, onOpen);
connect.openAsync(testFile, SQLMode.CREATE);
}

function onOpen(SQLEvent):void
{
var stat:SQLStatement = new SQLStatement();
stat.sqlConnection = connect;
stat.text = "CREATE TABLE IF NOT EXISTS tester2 (id INTEGER PRIMARY KEY AUTOINCREMENT, one NUMERIC)";
stat.execute(-1, new Responder(onCreate, err));
}


function onCreate(SQLEvent):void
{
var stat:SQLStatement = new SQLStatement();
stat.sqlConnection = connect;
stat.text = "SELECT one FROM tester2 ORDER BY id";
stat.execute(-1, new Responder(onSelec, err));

}

function onSelec(event:SQLResult):void
{
if (event.data != null)
{
for (var i:int = 0;i<event.data.length;i++){
trace(event.data[i].one);
ones2 = event.data[i].one;
}
}
}

/* ******************
* *
* Button 2 *
* *
****************** */

but2.addEventListener(MouseEvent.CLICK, go1);
function go1(event:MouseEvent):void
{
var stat:SQLStatement = new SQLStatement();
stat.sqlConnection = connect;
stat.text = "UPDATE tester2 SET one = "+ones2+"";
stat.execute(-1,new Responder(onCreate,err));
}






function err(error:SQLError):void
{
trace(error.message);
trace(error.details);
}
Can't copy file (SQLite)

[Action Script] Restart the timer June,2012

I know you have all seen this hundred of times but I just can't make it work :S
Its Flash 5.
ActionScript Code: x = random(8) + 1;image = "a"+x;holder.attachMovie(image, "new1",5);gotoAndPlay(2);trace(image);i = 1;function wait() { p = i++;    trace(p);    if(p == 5) {        clearInterval(myTimer);        x = random(8) + 1;        image = "a"+x;        holder.attachMovie(image, "new1",5);        trace(image);        gotoAndPlay(2);    }}myTimer = setInterval(wait, 1000);As you can see it generates the random number,put an "a" in front of it and loads image under that name from library,then waits 5 sec and do the same..the thing is that I don't know how to restart the timer so it starts from 0 again and return at the begin of the function...I hope you understand what I mean :D

Another question..I have created an application for my nokia 7230 in flash 5 but i can't fscommand it to be fullscreen,can you help me out with this one too?

Thanks :P
Restart the timer

[Action Script] how do I escape double quotes when declaring a variable. June,2012

understand I have simplified my actual code to just cover my exact need.

I need to store ""michael080900.txt""

var new_variable
text1.text = "Michael080900.txt";
new_variable = text1.text;
with the quotes

because I need to make this line look like this, but it HAS to be from a variable otherwise the rest of my code is pointless.

my_data.load("michael080900.txt");
needs to become this so that I can load it from a flashvars and it read in the text file from a dynamically generated name.

my_data.load(new_story);
how do I escape double quotes when declaring a variable.

[Action Script] help with package June,2012

Error says: "The name of package '@' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file"
although the name of package is zoo, not @
Code: package zoo
{

}
help with package

[Action Script] 3D drawing - circle on a sphere June,2012

Hiya,

I was wondering if anyone could point me in the right direction. I'm looking for a way to draw a circle on 3D sphere.

I have a 3D sphere of the world, on it there's a few cities. What I want is to have these cities each have a circle covering the surrounding area on the 3D earth.

I'm using Away3D 4.0, but as this is more of a math issue rather than an engine issue it might not be too relevant. As for my math skills, they used to be really good, but haven't used my 3D maths in a few years. So you might have to bare with me.

Thanks
3D drawing - circle on a sphere

Thursday, June 28, 2012

[Action Script] Clock Countdown Function Help June,2012

Hello,

I was wondering if someone could break down the following code for me and make it a bit easier so that i can just set a start date / end date.

Thanks.
Code: function displayDifference()
{
    nowTime = new Date();
    hoursLeft = ((((16-nowTime.getDate())*24) + (20 - nowTime.getHours())));
        //hoursLeft = (4 - nowTime.getDate()) * 24 + (19 - nowTime.getHours());
    if (hoursLeft >= 0)
    {
        timeRemaining.text = hoursLeft + ":" + padString(59 - nowTime.getMinutes()) + ":" + padString(59 - nowTime.getSeconds()) + "";
    }
    else
    {
        timeRemaining.text = "0H 0M 0S";
    } // end else if
} // End of the functionWhat i want to do is have a Start date of a value such as July 1st
and end date of July 31st

i'm not sure how similar this is to javascript esentially i want it to be like this.

Code: /* Date Animation  starts here*/
                                $(function () {
                                var austDay = new Date();
                                var austDay = new Date("June 30, 2012 21:00:00");
                                $('#countdown').countdown({until: austDay, layout:
                                                                '<div id="days" class="numbers">{dnn}</div>'+
                                                                '<div class="spacer"></div>'+
                                                                '<div id="hours" class="numbers">{hnn}</div>'+
                                                                '<div class="spacer"></div>'+
                                                                '<div id="minutes" class="numbers">{mnn}</div>'+
                                                                '<div class="spacer"></div>'+
                                                                '<div id="seconds" class="numbers">{snn}</div>'+
                                                                '</div>'});
                                                                });});
Clock Countdown Function Help

[Action Script] Dynamic image loaded into a Masked layer June,2012

I am trying to load images into a masked layer but the image just appears unmasked. Here is the code I am using to load the image. As you can see it is pretty standard stuff. You will note, though, that I am adding the child at the level of the masked layer.

ActionScript Code: public function loadImage(url:String):void {            imageLoader = new Loader();            imageLoader.load(new URLRequest("_art/" + url));            imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading);            imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);                    }        public function imageLoaded(e:Event):void {            _parent.parent.mcOcular.addChildAt(imageLoader, 0);loadImage("butterfly.png")
I am creating a training tool to teach students how to use a light microscope. There will be anywhere from 10 to 30 slides that they can choose from and place on the tray. I load the image in the round viewport once they place the slide. The image loads properly, but it is not adhering to the round viewport mask. The whole image is seen on stage.

What might I be doing wrong? Has anyone else had this issue and, if so, what can I do to fix it. This is all in AS3, of course.

Thanks in Advance guys!
Dynamic image loaded into a Masked layer

[Action Script] Event Handler Function to Change States in another Component June,2012

Here is my situation. I have an application with an options menu. In its 'Main' component I have created an options menu that includes a drop down menu. This drop down menu allows the user to select between Type 1 and Type 2, which represent two different components (named type1 and type2, respectively) that take turns displaying below the options menu in the 'Main' component, depending on which one is selected.

If I have Type 1 selected then I would also like to have a few checkboxes in the option menu that allow the user to change views within the 'type1' component. I have created 4 different states in the 'type1' component, so I need to figure out how to create an event handler that sits in the 'Main' component but controls the state of the 'type1' component.

Is this possible? I tried to do the following to no avail:

Code: //Method executed when Type 1(A) checkbox is selected in the 'Main' component
//This method and its associated checkbox sit in the 'Main' component
protected function type1AHandler(event:Event):void
{
      type1.currentState = 'A'                                               
}Any ideas how to create an event handler that changes the state of a component that is instantiated in the active component? Thanks!
Event Handler Function to Change States in another Component

[Action Script] Connecting Flash to Php/MySQL June,2012

Hello. I am having a problem connecting flash to php/mysql. Here is my flash code:

Code: var lvSend:LoadVars = new LoadVars();
var lvReceive:LoadVars = new LoadVars();

register_button.onRelease = function() {
        var valid:Boolean = validateForm();
        if(valid){
        //gather information and put in loadvars object
        lvSend.username = username1.text;
        lvSend.password = password1.text;
        lvSend.email = email1.text;
        lvSend.sendAndLoad("register.php", lvReceive, "POST");
        username1.text = "";
        password1.text = "";
        email1.text = "";
        gotoAndStop(1);
}
}
        lvReceive.onLoad = function(success:Boolean) {
if (success) {
    trace("ok");
}
else {
    trace("error");
    }
        }
function validateForm():Boolean{
        if(username1.text == "" || password1.text == "" || email1.text == ""){
                return false;               
}
        return true;
}Here is my php code:
Code: <?PHP
//Database Information
$dbhost = "xxxxxxxx";
$dbname = "xxxxxxxxx";
$dbuser = "xxxxxxxx";
$dbpass = "xxxxxxxx";
//Connect to Database
mysql_connect($dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname)or die(mysql_error());
$email = $_POST['email'];
$username = $_POST['username'];
$password = $_POST['password'];
//If no errors present with the username use a query to insert the data into the database.
$query = "INSERT INTO users(email,username,password)
VALUES('$email','$username','$password')";
mysql_query($query)or die(mysql_error());
mysql_close();
//Lets check to see if the username already exists
$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");
$username_exist = mysql_num_rows($checkuser);
if($username_exist > 0){
echo "I'm sorry but they username you have chosen is already in use. Please pick another.";
unset($username);
include 'play.swf';
exit();
}
//If no errors present with the username use a query to insert the data into the database.
$query = "INSERT INTO users(email, username, password)
VALUES('$email', '$username', '$password')";
mysql_query($query)or die(mysql_error());
mysql_close();
echo "You have successfully been registered!";
//Mail user their information
$yoursite = 'MonkeyIsland';
$webmaster = 'xxxxxxxxx';
$youremail = 'xxxxxxxx';
$subject = "You have been registered";
$message = "Dear $username, you have been successfully registered at xxxxxx!
Here is your login information:
Username = $username
Password = $password
Please don't share this information with anyone.
Thanks,
$webmaster";
mail($email, $subject, $message, "From: $yoursite <$youremail>\nX-Mailer:PHP/" . phpversion());
echo "Your information has been mailed to your email address.";
?>I was wondering what could possibly be the problem. My button works and all, its just that it doesn't send it to the database. Can anyone give me any sort of help? I'll take any answers. Thanks!
Connecting Flash to Php/MySQL

[Action Script] how do i put a timer in properly? June,2012

I 've been away from Flash Prof. for quite a bit of time?

the lesson (that was ..seemed great;is great.)taught how to make a Timer-
var myTimer:Timer = new Timer(8000); // 1 second
myTimer.addEventListener(TimerEvent.TIMER, runMany);
myTimer.start();

function runMany(event:TimerEvent):void {
trace("runMany() called @ " + getTimer() + " ms");

say, i want to put this in Frame 1 Actions:how would i key it??

I tried copy & Paste into Frame 1 Actions(this)
I got - Expecting RightBrace before end of program?? Any Suggestions??
how do i put a timer in properly?

[Action Script] Creating Charts with Step Functions June,2012

Hi, I am trying to create a chart with an x-axis of days that has two series, a column and line series. The column series will have a bar for each day and I want the line series to be constant across a group of 7 days and then jump to a different level, where it will remain constant for another 7 days (i.e. create a step function). I am using an ArrayCollection object for the data so I currently have something like this:

Code: <fx:Script>
    <![CDATA[
         
          import mx.collections.ArrayCollection;

          [Bindable]
          private var levels:ArrayCollection = new ArrayCollection([
                      {DaysLeft: 14, Daily: 8, WeeklyAvg: 12.86},
                      {DaysLeft: 13, Daily: 10, WeeklyAvg: 12.86},
                      {DaysLeft: 12, Daily: 9, WeeklyAvg: 12.86},
                      {DaysLeft: 11, Daily: 14, WeeklyAvg: 12.86},
                      {DaysLeft: 10, Daily: 12, WeeklyAvg: 12.86},
                      {DaysLeft: 9, Daily: 18, WeeklyAvg: 12.86},
                      {DaysLeft: 8, Daily: 19, WeeklyAvg: 12.86},
                      {DaysLeft: 7, Daily: 20, WeeklyAvg: 15.86},
                      {DaysLeft: 6, Daily: 19, WeeklyAvg: 15.86},
                      {DaysLeft: 5, Daily: 22, WeeklyAvg: 15.86},
                      {DaysLeft: 4, Daily: 14, WeeklyAvg: 15.86},
                      {DaysLeft: 3, Daily: 13, WeeklyAvg: 15.86},
                      {DaysLeft: 2, Daily: 11, WeeklyAvg: 15.86},
                      {DaysLeft: 1, Daily: 12, WeeklyAvg: 15.86},  ])

    ]]>
</fx:Script>In the chart MXML code I have the following series declared:

Code: <mx:series>

      <mx:ColumnSeries xField="DaysLeft"
                    yField="Daily"
                    displayName="Days Left">
      </mx:ColumnSeries>

      <mx:LineSeries xField="DaysLeft"
                          yField="WeeklyAvg"
                displayName="Weekly Out at Current Pace">
      </mx:LineSeries>

</mx:series>This of course gives a straight line that changes values from 12.86 to 15.86 from day 7 to day 8. How could I make this line change values between day 7 and day 8 in the form of a step function?

Thank you very much for helping!
Creating Charts with Step Functions

Wednesday, June 27, 2012

[Action Script] Stencyl - A good tool? June,2012

Hi,
I'm used to working with Unity3D and I like the fact that it has a nice user interface, while keeping the ability to use code and create your own behaviours. I've seen that Unity3D now has Flash support, but this license costs an additional $400, and I started looking into some equivalents, dedicated to flash development, and stumbled upon Stencyl (stencyl.com). Now, I've seen on the site that Stencyl requires no coding, but does have a coding feature. Can I get your opinion on this engine, do you think it's worth using? Or do you know a better alternative?

Thanks,
Arne Gevaert
Stencyl - A good tool?

[Action Script] keyListener functions differently after first time on frame June,2012

A while ago I asked on these forums how to implement a pause feature in my game. It works great! However, I've just noticed that when you leave the frame (each frame of the main timeline holds the MCs for one level of the game) and return to it, pausing no longer works. I did some tracing to try and uncover what was happening, and it seems that anytime beyond my first "visit" to the frame, it fails to toggle isPaused = !isPaused and it executes pauseHUD == false AND pauseHUD == true. I've included the code (and omitted everything that is not relevant) below.

Code: onClipEvent (load) {

//Creates a listener for the Space Bar key and sets isPaused variable
var isPaused:Boolean = false;
var keyListener:Object = new Object();

//variable for pause sound and HUD
var pauseHUD = false;

//Loads the pause sound
pause_sound = new Sound();
pause_sound.attachSound("pause");

Key.addListener(keyListener);

keyListener.onKeyUp = function():Void
{
    if(Key.getCode() == Key.SPACE)
    {
        //toggle pause state
        isPaused = !isPaused;
                //start sound if not already playing
                if (pauseHUD == false) {

                        pause_sound.start();
                        pauseHUD = true;
                        trace("Executing A");
                        //code that shows HUD omitted

                } else if (pauseHUD == true) {

                        pauseHUD = false;
                        trace("Executing B");
                        //code that hides HUD omitted

                }
               
    }
}


function onEnterFrame():Void
{
       
 trace("isPaused = "+isPaused);
 trace("pauseHUD = "+pauseHUD);
       
    if(isPaused)
    {

    //code that pauses player and shows pause menu omitted
       
    }
    else
    {

    //code that unpauses player and hides pause menu omitted

    }
       
}In the interest of being thorough here's what I see in OUTPUT on my first visit to the frame when I press spacebar:

isPaused = false
pauseHUD = false
Executing A
isPaused = true
pauseHUD = true

And here's what I see on any subsequent visits when I press spacebar:

isPaused = false
pauseHUD = false
Executing A
Executing B
isPaused = false
pauseHUD = false

Any clue as to why this is and what I can do to prevent it from happening?
keyListener functions differently after first time on frame