Quantcast
Channel: Adobe Community : Popular Discussions - ActionScript 3
Viewing all 18626 articles
Browse latest View live

How do I create an email link in Flash using action script 3?

$
0
0

I am a Web Design student and I just finished a class on Adobe Flash. I have created a simple web page for a friend using Flash 5.0 with ActionScript 3.0.

I have an emaill address on my page but I do not know how to write the script to create the link. This is not a subject we covered in class, nor could I find the info I needed in out book or on-line.

Can someone please help me? I need specifics!

 

Thank you.

Su-Jobi Web Design (Name of my future business!!)


Tween to TweenLite and null references

$
0
0

Boy, it feels like I'm here a lot more than I used to be.

 

I'm currently switching tweens to use TweenLite and what happens is I now have a null reference.

 

What I don't understand is how to switch this code appropriately.  The object begin tweened then has to be capable of being dragged again once it's scaled back down and incapble of being dragged while it's scaled up.

 

function photoStartDrag(e:MouseEvent):void {    e.target.parent.startDrag();
}

function photoStopDrag(e:MouseEvent):void {
    e.target.parent.stopDrag();
}

function clickAndScale(e:MouseEvent):void {
    if (! scaled && clickable) {        /* Avoid unwanted clicks */                clickable = false;        addChild(imgScaleBg);                /* Cant drag when scaled or zooming */                e.target.parent.getChildAt(0).removeEventListener(MouseEvent.MOUSE_DOWN, photoStartDrag);                /* Get next highest depth */                setChildIndex(e.target.parent as Sprite, (numChildren - 1));                /* Get position */                positionX = e.target.parent.x;        positionY = e.target.parent.y;                TweenLite.to(e.target.parent, 1, {            x: stage.stageWidth / 4 - e.target.parent.width + 10,            y: stage.stageHeight / 4 - e.target.parent.height + 10,            scaleX: 1,            scaleY: 1,            ease: Bounce.easeOut,            overwrite: false,            onComplete: scaleUp});                //tween = new Tween(e.target.parent, "scaleX", Strong.easeOut, e.target.parent.scaleX, 1, 0.8, true);        //tween = new Tween(e.target.parent, "scaleY", Strong.easeOut, e.target.parent.scaleY, 1, 0.8, true);                //tween = new Tween(e.target.parent, "x", Strong.easeOut, e.target.parent.x, stage.stageWidth / 4 - e.target.parent.width + 10, 0.8, true);        //tween = new Tween(e.target.parent, "y", Strong.easeOut, e.target.parent.y, stage.stageHeight / 4 - e.target.parent.height + 10, 0.8, true);                //addEventListener(TweenEvent.MOTION_FINISH, scaleUp);            } else if (scaled && clickable) {        e.target.parent.getChildAt(2).visible = false;                TweenLite.to(e.target.parent, 1, {            x: positionX,            y: positionY,            scaleX: 0.2,            scaleY: 0.2,            ease: Bounce.easeOut,            overwrite: false,            onComplete: scaleDown});                //tween = new Tween(e.target.parent, "scaleX", Strong.easeOut, e.target.parent.scaleX, 0.2, 1, true);        //tween = new Tween(e.target.parent, "scaleY", Strong.easeOut, e.target.parent.scaleY, 0.2, 1, true);                //tween = new Tween(e.target.parent, "x", Strong.easeOut, e.target.parent.x, positionX, 0.2, true);        //tween = new Tween(e.target.parent, "y", Strong.easeOut, e.target.parent.y, positionY, 0.2, true);                //addEventListener(TweenEvent.MOTION_FINISH, scaleDown);    }
}

function scaleUp():void {
    scaled = true;    clickable = true;    tween.obj.getChildAt(2).visible = true;
}

function scaleDown():void {
    scaled = false;    removeChild(imgScaleBg);        tween.obj.getChildAt(0).addEventListener(MouseEvent.MOUSE_DOWN, photoStartDrag);
}

Stop and Play All Child MovieClips in Flash with Actionscript 3.0

$
0
0

I am stuck with the ActionScript here. I have a very complex animated flash movie for eLearning. These contain around 10 to 15 frames. In each frame I am having multiple movie clip symbols. The animation has been created using a blend of scripting and also normal flash animation.

Now I want to create pause and play functionality for the entire movie. I was able to create the pause function but when i try to play the movie it behaves very strange.

I was able to develop the pause functionality by refering to the below mentioned links:

http://www.unfocus.com/2009/12/07/stop-all-child-movieclips-in-flash-with-actionscript-3-0 /

http://www.curiousfind.com/blog/174

 

Any help in this regard is highly appreciated as i am approaching a deadline.

 

I am pasting the code below:

 

 

import flash.display.MovieClip;
import flash.display.DisplayObjectContainer;
import flash.utils.Timer;
import flash.events.TimerEvent;
import fl.transitions.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import flash.events.Event;
import flash.events.MouseEvent;

stop();


// function to stop all movieclips
function stopAll(content:DisplayObjectContainer):void
{
    if (content is MovieClip)
        (content as MovieClip).stop();
   
    if (content.numChildren)
    {
        var child:DisplayObjectContainer;
        for (var i:int, n:int = content.numChildren; i < n; ++i)
        {
            if (content.getChildAt(i) is DisplayObjectContainer)
            {
                child = content.getChildAt(i) as DisplayObjectContainer;
                if (child.numChildren)
                    stopAll(child);
                else if (child is MovieClip)
                    (child as MovieClip).stop();
            }
        }
    }
}

 

 

// function to play all movieclips
function playAll(content:DisplayObjectContainer):void
{
    if (content is MovieClip)
    {
        var movieClip:MovieClip = content as MovieClip;
        if (movieClip.currentFrame < movieClip.totalFrames) // if the main timeline has reached the end, don't play it
   movieClip.gotoAndPlay(currentFrame);
  }
    if (content.numChildren)
    {
        var child:DisplayObjectContainer;
        var n:int = content.numChildren;
        for (var i:int = 0; i < n; i++)
        {
            if (content.getChildAt(i) is DisplayObjectContainer)
            {
                child = content.getChildAt(i) as DisplayObjectContainer;
                if (child.numChildren)
                    playAll(child);
                else if (child is MovieClip)
                {
                    var childMovieClip:MovieClip = child as MovieClip;
                    if (childMovieClip.currentFrame < childMovieClip.totalFrames)
      //childMovieClip.play();
      childMovieClip.play();
     
     
                }
            }
        }
    }
}

 

 

function resetMovieClip(movieClip:MovieClip):MovieClip
{
    var sourceClass:Class = movieClip.constructor;
    var resetMovieClip:MovieClip = new sourceClass();
    return resetMovieClip;
}

pauseBtn.addEventListener(MouseEvent.CLICK, onClickStop_1);
function onClickStop_1(evt:MouseEvent):void
{
MovieClip(root).stopAll(this);
myTimer.stop();
}

playBtn.addEventListener(MouseEvent.CLICK, onClickPlay_1);
function onClickPlay_1(evt:MouseEvent):void
{

MovieClip(root).playAll(this);
myTimer.start();
}

 

 

Other code which helps in animating the movie and other functionalities are as pasted below:

 

stage.addEventListener(Event.RESIZE, mascot);
function mascot():void {
// Defining variables
var mc1:MovieClip = this.mascotAni;
var sw:Number = stage.stageWidth;
var sh:Number = stage.stageHeight;
// resizing movieclip
mc1.width = sw/3;
mc1.height = sh/3;
// positioning mc
mc1.x = (stage.stageWidth/2)-(mc1.width/2);
mc1.y = (stage.stageHeight/2)-(mc1.height/2);
// keeps the mc1 proportional
mc1.scaleX <= mc1.scaleY ? (mc1.scaleX = mc1.scaleY) : (mc1.scaleY = mc1.scaleX);
stage.removeEventListener(Event.RESIZE, mascot);
}
mascot();
this.mascotAni.y = 100;

function mascotReset():void
{
// Defining variables
var mc1:MovieClip = this.mascotAni;
stage.removeEventListener(Event.RESIZE, mascot);
mc1.width = 113.45;
mc1.height = 153.85;
mc1.x = (stage.stageWidth/2)-(mc1.width/2);
mc1.y = (stage.stageHeight/2)-(mc1.height/2);
// keeps the mc1 proportional
mc1.scaleX <= mc1.scaleY ? (mc1.scaleX = mc1.scaleY) : (mc1.scaleY = mc1.scaleX);
}


var interval:int;
var myTimer:Timer;

// function to pause timeline
function pauseClips(secs:int, myClip:MovieClip):void
{
interval = secs;
myTimer = new Timer(interval*1000,0);
myTimer.addEventListener(TimerEvent.TIMER, goNextFrm);
myTimer.start();
function goNextFrm(evt:TimerEvent):void
{
  myTimer.reset();
  myClip.nextFrame();
  myTimer.removeEventListener(TimerEvent.TIMER, goNextFrm);
}
}

// function to pause timeline on a particular label
function pauseClipsLabel(secs:int, myClip:MovieClip, myLabel:String):void
{
interval = secs;
myTimer = new Timer(interval*1000,0);
myTimer.addEventListener(TimerEvent.TIMER, goNextFrm);
myTimer.start();
function goNextFrm(evt:TimerEvent):void
{
  myClip.gotoAndStop(myLabel);
  myTimer.removeEventListener(TimerEvent.TIMER, goNextFrm);
}
}


MovieClip(root).pauseClips(4.5, this);

// function to fade clips
function fadeClips(target_mc:MovieClip, next_mc:MovieClip, from:Number, to:Number):void
{
var fadeTW:Tween = new Tween(target_mc, "alpha", Strong.easeInOut, from, to, 0.5, true);
fadeTW.addEventListener(TweenEvent.MOTION_FINISH, fadeFinish);
function fadeFinish(evt:TweenEvent):void
{
  next_mc.nextFrame();
  fadeTW.removeEventListener(TweenEvent.MOTION_FINISH, fadeFinish);
 
}
}

// function to fade clips with speed
function fadeClipsSpeed(target_mc:MovieClip, next_mc:MovieClip, from:Number, to:Number, speed:int):void
{
var fadeTW:Tween = new Tween(target_mc, "alpha", Strong.easeInOut, from, to, speed, true);
fadeTW.addEventListener(TweenEvent.MOTION_FINISH, fadeFinish);
function fadeFinish(evt:TweenEvent):void
{
  next_mc.nextFrame();
  fadeTW.removeEventListener(TweenEvent.MOTION_FINISH, fadeFinish);
}
}

// function to show screen transitions
function screenFx(target_mc:MovieClip, next_mc:MovieClip):void
{
//var tweenTW:Tween = new Tween(target_mc,"alpha",Strong.easeInOut,0,1,1.2,true);
var tranFx:TransitionManager = new TransitionManager(target_mc);
tranFx.startTransition({type:Iris, direction:Transition.OUT, duration:1.2, easing:Strong.easeOut, startPoint:5, shape:Iris.CIRCLE});
tranFx.addEventListener("allTransitionsOutDone",doneTrans);
function doneTrans(evt:Event):void
{
  next_mc.nextFrame();
  tranFx.removeEventListener("allTransitionsOutDone",doneTrans);
}
}

// function to show screen transitions inverse
function screenFxInv(target_mc:MovieClip, next_mc:MovieClip):void
{
var tweenTW:Tween = new Tween(target_mc,"alpha",Strong.easeInOut,0,1,1.2,true);
var tranFx:TransitionManager = new TransitionManager(target_mc);
tranFx.startTransition({type:Iris, direction:Transition.IN, duration:2, easing:Strong.easeOut, startPoint:5, shape:Iris.SQUARE});
tranFx.addEventListener("allTransitionsInDone",doneTrans);
function doneTrans(evt:Event):void
{
  next_mc.nextFrame();
  tranFx.removeEventListener("allTransitionsInDone",doneTrans);
}
}

// function to zoom in
function zoomFx(target_mc:MovieClip):void
{
//var tweenTW:Tween = new Tween(target_mc,"alpha",Strong.easeInOut,0,1,1.2,true);
var tranFx:TransitionManager = new TransitionManager(target_mc);
tranFx.startTransition({type:Zoom, direction:Transition.IN, duration:3, easing:Strong.easeOut});
//tranFx.addEventListener("allTransitionsInDone",doneTrans);
/*function doneTrans(evt:Event):void
{
  next_mc.nextFrame();
}*/
}

// Blinds Fx
function wipeFx(target_mc:MovieClip):void
{
var tranFx:TransitionManager = new TransitionManager(target_mc);
tranFx.startTransition({type:Wipe, direction:Transition.IN, duration:3, easing:Strong.easeOut, startPoint:9});
}

// Blinds Fx Center
function fadePixelFx(target_mc:MovieClip):void
{
var tranFx:TransitionManager = new TransitionManager(target_mc);
tranFx.startTransition({type:Fade, direction:Transition.IN, duration:1, easing:Strong.easeOut});
tranFx.startTransition({type:PixelDissolve, direction:Transition.IN, duration:1, easing:Strong.easeOut, xSections:100, ySections:100});

}

Converting Array and String

$
0
0

Hello, everyone.

I'm given an Array, it is not in format {abc:1, qwe:'ghj'}. The array looks like this:

new Array(["SMTH", 1, 2, 3], ["ANTH", 0, 0, 0, [4, 5, 6]], ["ZZZ", 8])

As you can see, it has only square brackets, and even in other square brackets.

 

The task is:

1) Convert this Array to String, because server only saves strings. Save it.

2) Load saved String and convert it to Array.

 

So, a usual task for the game.

 

Please, tell me, in what Language they may be converted, what should I do.

1) I've tried to convert (1) Array to String, so that square brackets remain, even in another [], but AS3 removes them. Well, I wrote my own function. Now the result (1) looks exactly like you saw above in bold letters.

2) But another problem exists: how to convert that string to Array back...

Array.match() says there is no array, seems like it doesn't notice square brackets at all.

I've tried split, IndexOf and others, but got stuck in those [[]]

Simple myString as Array also doesn't work.

 

I suppose, I'm doing it all wrong. So i've tried converting Array to JSON. It turned out to be too much odd symbols, it was saved, but i have an limitation of symbols count, so JSON is not the answer.

Error #2136: The SWF file

$
0
0

I am trying to learn how to use classes.The book i am using gave me this example.

 

In Vechile.as

package{

 

            import flash.display.MovieClip;

            import flash.events.Event;

           

            public class Vehicle extends MovieClip{

                       

                        public var _gasMileage:Number;

                        public var _fuelAvailable:Number;

                        public var _milesTraveled:Number =0;

                        public var _go:Boolean;

                       

                        public function Vehicle(mpg:Number=21, fuel:Number=18.5){

                                    _gasMileage=mpg;

                                    _fuelAvailable = fuel;

                                    this.addEventListener(Event.ENTER_FRAME, onLoop, false,

                                    0, true);

                        }

            public function onLoop (evt:Event):void{

                        if (_go){

                                    _fuelAvailable--;

                                    _milesTraveled+=_gasMileage;

                                    if (_fuelAvailable < 1){

                                                this.removeEventListener(Event.ENTER_FRAME,

                                                onLoop);

                                    }

                                    trace(this, _milesTraveled,_fuelAvailable);

                                    this.x=_milesTraveled;

                        }

            }

            public function go():void{

                        _go = true;

                        }

            }

}

 

In the main.fla

In frame 1

 

var vehicle:Vehicle = new Vehicle(21,18.5);

addChild(vehicle);

vehicle.go();

 

when I compile it gives an output error.

 

Error #2136: The SWF file file:///C|/Users/Ravenwind/Documents/Main.swf contains invalid data.

                at Vehicle/frame1()

I am stumped

what is the code for a reset button that puts the program to start?

$
0
0

What is the code?

 

reset_btn.addEventListener(MouseEvent.CLICK, reset);

function reset(event:MouseEvent):void
{
    
//Reset all variables and send the playhead to the appropriate frame
};

 

doesn't work!

5001: The name of the package does not reflect the location of this file.

$
0
0

  I recently published an fla file successfully.  I tested the movie and everything ran perfectly.  I came back two days later and opened the fla, tested the movie again and I got this message. I didn't delete or move or rename anything between now and the last time it worked.  All of the .as files are exactly where they were to start with.

Rotating Object Counterclockwise/Clockwise

$
0
0

Hi,

 

I'm not able to use tweening for rotation in a project because when exported for AIR Android, tween gets stuck or runs too slowly on the tablet device. (I also prefer not to use a tween plugin, if possible.)

 

Instead, I can use rotation, and it works very well on the device.

 

For example,

 

 

if (rotateT){
object.rotation += 5;
}

//coupled with

rotateT= true;
                            if (targetRotation < 180) {                                targetRotation = object.rotation + 90;                            }                            else {                                targetRotation = -targetRotation + 90;                            }                        }

 

This works well for clockwise rotation.

 

But, I need some help figuring out how to create a counterclockwise rotation using the same type scripting, if this is possible.

 

Any help appreciated.


AS3 Next and previous buttons - jump to keyframe

$
0
0

You know, I used to know AS2.  It was fun.  It was easy.  And then after a break I've tried to pick up AS3 and everything is going horribly, horribly wrong.  Even searching online forums I can't work out how to get the solution I need.  I could revert back to AS2, but I am determined I am not going to let AS3 beat me.  Someone please help!

 

I am trying to add Next and Back buttons that will jump users between keyframes.

 

I have a layer called Actions, and a layer called Buttons.  The Buttons layer has two buttons of different types with Instance Names of "btn_Next" and "btn_Back" respectively.

Both layers have keyframes at frame 30 and frame 60.

 

The actions on frame 30 and frame 60 both say "stop();"

 

At present the action on frame 1 on the Actions layer says:

 

import flash.events.MouseEvent;

 

stop();

 

btn_Back.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler1);

function mouseDownHandler1(event:MouseEvent):void

{

prevFrame();

}

 

btn_Next.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler2);

function mouseDownHandler2(event:MouseEvent):void

{

nextFrame();

}

 

When I press Ctrl + Enter I am currently getting the error message

 

"TypeError: Error #1123: Filter operator not supported on type builtin.as$0.MethodClosure. at [Filename]_fla::MainTimeline/frame1()"

 

and the buttons do nothing.

 

Where am I going wrong? 

 

The thing I get particularly confused about reading other posts is whether I need to reproduce this code on each keyframe, or only on Frame 1 of the Actions layer.  I tried adding it to each keyframe, but then got errors about duplicating my functions.  So I tried removing the functions from all keyframes after the first one, but that didn't work either. 

 

I tried changing my instance names on each keyframe and changing the code on each keyframe, but that didn't seem to work either.  And it seems like a really inefficient way to do things.

 

Someone please help me. 

 

Mary

Click, animate rotation of Object by +90° via AS3?

$
0
0

I have a button that will rotate an object in its parent by 90 degrees every time its clicked:

 

b_rotate_CW.addEventListener(MouseEvent.CLICK, rotateCW);

function rotateCW(event:MouseEvent):void

{

Object(this).parent.module.rotation += 90;

}

 

Which is fine, but I think it would be a nice touch if the object's rotation were animated.

 

 

I tried this:

 

import fl.transitions.Tween;

import fl.transitions.easing.*;

import fl.transitions.TweenEvent;

 

b_rotate_CW.addEventListener(MouseEvent.CLICK, rotateCW);

function rotateCW(event:MouseEvent):void

{

var rCW:Tween = new Tween(Object(this).parent.module, "rotate", Strong.easeOut, 0, +90, .5, true);

}

 

... but it does nothing at all, I am guessing that "rotate" is a property option, I can find no documentation for that, only x, y, their scale and alpha.

 

 

I'm sure this has been done by many, can anyone offer a helpful clue as to how this function would be properly coded?

 

Thanks!

Flash CS3 Play/Stop audio button problem

$
0
0

I made a play/stop audio button with this youtube tutorial (youtube.com/watch?v=XU6oMEFUFF8) but after the sound is finished I want the play button to show up agian.

Here is the actionscript:

import flash.events.MouseEvent;

play_btn.addEventListener(MouseEvent.CLICK,clickha ndler);
stop_btn.addEventListener(MouseEvent.CLICK,clickha ndler);
function clickhandler(event:MouseEvent):void{
swapChildren(play_btn,stop_btn);
}

what code should I add to my current code?

I also can send you the Fla.

How to interpret code from string in as3?

$
0
0

Hi,

 

It is possible for as3 to interpret/run a codeblock from a string?

I have, for example, the following string(from user input or a server txt file):

 

 

int var_1 = -4;
uint var_2 = 5;
number sum = Math.abs(var_1 + var_2);

 

The code above need to be translated into valid as3 sintax and executed at runtime.

 

Thank you

TypeError: Error #1009: Cannot access a property or method of a null object reference.

$
0
0

The problem I’m having is when I run the program and click on button3 to bring me to page3, I get the error message:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

                at Untitled_fla::MainTimeline/frame1()

                at flash.display::MovieClip/gotoAndStop()

                at Untitled_fla::MainTimeline/gohome1()

I’m just trying to use button3 to bring me to the third page which is page3. Everything else is working fine. Any help would be great!

import flash.events.MouseEvent;

import flash.net.URLRequest;

 

 

stop();

home1.addEventListener(MouseEvent.CLICK, gohome1);

function gohome1 (event:MouseEvent):void{

   gotoAndStop(1);

}

  1. bios.addEventListener(MouseEvent.CLICK, gobios);

function gobios (event:MouseEvent):void{

   gotoAndStop(2);

}

button3.addEventListener(MouseEvent.CLICK, goabout1);

function goabout1 (event:MouseEvent):void{

   gotoAndStop(3);

    

}

How do you obfuscate APK for Android that is published with Flash Pro CC ?

$
0
0

I created an application for Android smartphones using Flash Pro CC.

I don't know much about obfuscating APK files but I heard that APK can be easily decompiled and therefore my AS file sourcecode is vulnerable. So I started searching on google and found that ProGuard does obfuscation. But it's for Eclipse so I guess i can't use ProGuard for my app which is created using Flash Pro CC. Is there any way to obfuscate my APK? or is there any other way to protect my APK?

Button to go to the previous Frame and scene the user was on

$
0
0

i have a button in flash that when its clicked i want it to go back to the previous scene and frame the user was on any AS3 to do this ?


AS3 - New movieclip instance

$
0
0

I have 3 types of mc's. I would like to create a new instance of a random mc of one of those types. I wrote somenthing like this but I receive an error:

Error #1007: Instantiation attempted on a non-constructor.

 

i tried something like this:

 

var newMC:* = new match[i] as match[i];

 

match is an array that contains the 3 types of mc's. match[i] will be something like [object orange], so I want to create a new instance of orange mc.

 

How can I do that?

AS3 SharedObject From Input to dynamic text field in other frames..

$
0
0

Hello I Have script:

 

var gTeams:Array = new Array(teamName1,teamName2, teamName3);

var so:SharedObject=SharedObject.getLocal("dataSO");

var shared_data:String;

 

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

    if (so.data["team_name_" + i]) {

        gTeams[i].text = so.data["team_name_" + i];

    }

}

function saveTextF():void{

for(i=0;i<gTeams.length;i++){

so.data["team_name_"+i]=gTeams[i].text;

}

so.flush();

}

 

In other frames I have dynamic text fields:

tName1, tName2, tName3.

 

But I cant get text from input text fields.

How I can do that?


Thanks for your help

Unloading an swf movie from the swf itself in AS3

$
0
0

I've found many posts in this forum about this but neither solution has worked for me. My setup is as basic as you would think. Main movie loads external swf movie after a mouse click. I need to close that loaded swf from a button located inside the external swf itself. I've come up with codes that won't give errors but won't work either. One thing different in my case is that my main movie is a projector .exe file. I never thought it would be relevant but given the situation I'm starting to think it could be.

 

I'm loading the external swf with this code:

 

z5990_btn.addEventListener(MouseEvent.CLICK,loadCard);

function loadCard(event:MouseEvent) {

 

          trace("you clicked me");

 

          var loadit = new Loader();

 

          addChild(loadit);

 

          var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);

 

          loadit.load(new URLRequest("casas/Zurich5990.swf"), _lc);

 

}

 

Then trying to unload from a code attached to the close button inside external swf...

 

close_btn.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);

function fl_MouseClickHandler_2(event:MouseEvent):void

 

{

    MovieClip(this.parent.parent).loadit.unloadAndStop;

}

 

This is at least the third method I've tried so if anyone could help me I would thank you a lot.

How to make Responsive Resolution in Adobe Flash CS6 or AS3?

$
0
0

I have project make an android application for education, i use software Adobe Flash CS6.  I wanna ask to anybody who can help me or understand about as3 especially about responsive resolution. I use resolution 800 x 480 px in my project, when i publish the project and i try in my handphone which have screen 5.0 inch the application not fullscreen but there are space in right and left.

 

Does the application need a script or any other settings when publish? What script i should used for responsive resolution?

I hope anybody can help me

Thank youuu

ActionScript 3 On Click

$
0
0

I only want this code to run when a certain button is pressed, I also want it to stop running when another button is pressed. The code is below:

 

package{

     import flash.events.MouseEvent;

    import flash.display.MovieClip;

    import flash.events.KeyboardEvent;

    import flash.ui.Keyboard;

    import flash.events.Event; //used for ENTER_FRAME event

 

    public class Main extends MovieClip{

    

        //constants

        const gravity:Number = 1.5;            //gravity of the game

        const dist_btw_obstacles:Number = 300; //distance between two obstacles

        const ob_speed:Number = 8;             //speed of the obstacle

        const jump_force:Number = 15;          //force with which it jumps

    

        //variables

        var player:Player = new Player();   

        var lastob:Obstacle = new Obstacle();  //varible to store the last obstacle in the obstacle array

        var obstacles:Array = new Array();     //an array to store all the obstacles

        var yspeed:Number = 0;                 //A variable representing the vertical speed of the bird

        var score:Number = 0;                  //A variable representing the score

 

    

        public function Main(){

         

          init();

        }

    

        function init():void {

            //initialize all the variables

            player = new Player();

            lastob = new Obstacle();

            obstacles = new Array();

            yspeed = 0;

            score = 0;

        

            //add player to center of the stage the stage

            player.x = stage.stageWidth/2;

            player.y = stage.stageHeight/2;

            addChild(player);

        

            //create 3 obstacles ()

            createObstacle();

            createObstacle();

            createObstacle();

        

            //Add EnterFrame EventListeners (which is called every frame) and KeyBoard EventListeners

            addEventListener(Event.ENTER_FRAME,onEnterFrameHandler);

            stage.addEventListener(KeyboardEvent.KEY_UP, key_up);

        }

    

        private function key_up(event:KeyboardEvent){

            if(event.keyCode == Keyboard.SPACE){

                //If space is pressed then make the bird

                yspeed = -jump_force;

            }

        }

    

        function restart(){

            if(contains(player))

                removeChild(player);

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

                    if(contains(obstacles[i]) && obstacles[i] != null)

                    removeChild(obstacles[i]);

                    obstacles[i] = null;

                }

                obstacles.slice(0);

                init();

        }

    

        function onEnterFrameHandler(event:Event){

            //update player

            yspeed += gravity;

            player.y += yspeed;

        

            //restart if the player touches the ground

            if(player.y + player.height/2 > stage.stageHeight){

                restart();

            }

        

            //Don't allow the bird to go above the screen

            if(player.y - player.height/2 < 0){

                player.y = player.height/2;

            }

        

            //update obstacles

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

                updateObstacle(i);

            }

        

            //display the score

            scoretxt.text = String(score);

        }

    

        //This functions update the obstacle

        function updateObstacle(i:int){

            var ob:Obstacle = obstacles[i];

        

            if(ob == null)

            return;

            ob.x -= ob_speed;

        

            if(ob.x < -ob.width){

                //if an obstacle reaches left of the stage then change its position to the back of the last obstacle

                changeObstacle(ob);

            }

        

            //If the bird hits an obstacle then restart the game

            if(ob.hitTestPoint(player.x + player.width/2,player.y + player.height/2,true)

               || ob.hitTestPoint(player.x + player.width/2,player.y - player.height/2,true)

               || ob.hitTestPoint(player.x - player.width/2,player.y + player.height/2,true)

               || ob.hitTestPoint(player.x - player.width/2,player.y - player.height/2,true)){

                restart();

            }

        

            //If the bird got through the obstacle without hitting it then increase the score

            if((player.x - player.width/2 > ob.x + ob.width/2) && !ob.covered){

                ++score;

                ob.covered = true;

            }

        }

    

        //This function changes the position of the obstacle such that it will be the last obstacle and it also randomizes its y position

        function changeObstacle(ob:Obstacle){

            ob.x = lastob.x + dist_btw_obstacles;

            ob.y = 100+Math.random()*(stage.stageHeight-200);

            lastob = ob;

            ob.covered = false;

        }

    

        //this function creates an obstacle

        function createObstacle(){

            var ob:Obstacle = new Obstacle();

            if(lastob.x == 0)

            ob.x = 800;

            else

            ob.x = lastob.x + dist_btw_obstacles;

            ob.y = 100+Math.random()*(stage.stageHeight-200);

            addChild(ob);

            obstacles.push(ob);

            lastob = ob;

        }

    

    

    }

}

Viewing all 18626 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>