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