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