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

SWF Playback slow of Movie.

$
0
0

Ive got a FLV loaded into a flash file and some basic keyboard function to scroll back and forth through the embedded movie.

 

Going forwards is fine, but when I hit the back key is takes a long time to respond and then the fram rate drops.

 

Anyone got any ideas why?

 

I imported the FLV to the library and then dragged over to a layer. The FLV is only 2MB.

 

Here is the code, although its copied and adapted from another source.

 

package  {

 

          import flash.display.MovieClip;

          import flash.display.StageDisplayState;

          import flash.events.TimerEvent;

          import flash.utils.Timer;

          import flash.events.KeyboardEvent;

          import flash.ui.Keyboard;

          import com.greensock.TweenLite;

          import com.greensock.easing.*;

          import com.flupie.textanim.*;

 

 

          public class Presentation extends MovieClip

          {

                    private var isPlayingForward:Boolean;

                    private var timelineTimer:Timer;

 

                    public function Presentation()

                    {

                              try

                              {

                                        stage.displayState = StageDisplayState.FULL_SCREEN;

                              }

                              catch (err:SecurityError)

                              {

                                        trace("Must be in projector mode for full screen viewing");

                              }

 

                              isPlayingForward = true;

                              timelineTimer = new Timer(1000/stage.frameRate);

                              timelineTimer.addEventListener(TimerEvent.TIMER, timelineTimerHandler);

                              stage.addEventListener(KeyboardEvent.KEY_DOWN, keyboardHandler);

                    }

 

                    private function keyboardHandler(event:KeyboardEvent):void

                    {

                              if (event.keyCode == Keyboard.RIGHT)

                                        playForward();

                              if (event.keyCode == Keyboard.LEFT)

                                        playReverse();

                    }

 

                    private function timelineTimerHandler(te:TimerEvent):void

                    {

                              if (isPlayingForward) 

                                        this.nextFrame();

                              else

                                        this.prevFrame();

                    }

 

                    public function stopTimeline():void

                    {

                              stop();

                              timelineTimer.stop();

                    }

 

                    public function playForward():void

                    {

                              isPlayingForward = true;

                              timelineTimer.start();

                    }

 

                    public function playReverse():void

                    {

                              isPlayingForward = false;

                              timelineTimer.start();

                    }

 

          }

 

}


How can you use one NetStream to publish video and audio from another NetStream in AS3?

$
0
0

Let's say one of your client programs in AS3 is able to receive live video and audio from a NetStream and play it on the screen.  How could you make it also take that video/audio stream that it's receiving, copy it over into another NetStream, and publish it elsewhere?  I need to know how to do with this regardless of whether RTMP, RTMFP, or some mixture is involved.  The reason why the stream needs to be relayed this way is a real long story, but it's necessary in this particular case. Thanks!

SQL for AIR asynchronous vs synchronous question

$
0
0

Gidday guys

 

I've set up a SQLite database that's going to be processing up to 150 000 rows at a time.  I'm using parametized queries wrapped in a transaction, so it should all be pretty quick. I'm using asynchronous methods.

 

I've set the queries, and managed to get a static test query into the database using the parameters.  Wahooo!!!

 

However, now I've made it dynamic to receive bulk data, I'm getting the error:

 

"Operation cannot be performed while SQLStatement.executing is true"

 

I'm wondering if someone can

 

a) suggest whether synchronous might be a better option

 

or

 

b) guide me as to what sequence of functions and event listeners would fix my following set up...

 

THE PROCESS:

 

- I have a bunch of filenames in an array, that need to be tweaked before thrown into the database

- I set up the sql connection (leg work done earlier), the query statement, and then start a transaction:

 

insertStmt.sqlConnection = conn;

insertStmt.text = "INSERT OR IGNORE INTO tester3 VALUES (@col1, @col2) ";

conn.begin();

 

- array is thrown into a function which starts up an enterFrame iteration (so display doesn't freeze), where I tweak the filenames, and put each tweaked filename and some other data (also headed for the database) into an object, and deliver it to the function that prepares the data into the parameters...

 

prepareParameters({col1:col1var, col2:col2var});

 

prepareParameters(row:Object):void

{    

     insertStmt.parameters["@col1"] = row.col1;

     insertStmt.parameters["@col2"] = row.col2;

     insertStmt.execute();
}

 

- at the end of array loop, call function to end transaction

 

I think the problem is that the loop is sending the next object to prepareParameters() before the database has finished executing the last insert statement.

 

I tried setting up a results listener to try and make Flash not return back to the loop until the listener received something, but I get the same error.

 

My first thought was 'hey, shouldn't Flash wait until after insertStmt.execute(); has finished before returning to the loop that called it's function? But maybe that only happens in synchronous processing?

 

Thanks for your thoughts guys.

AS3 gotoAndPlay Frame in a prevFrame

$
0
0

I think this should be a easy fix. I am self taught using Flash and putting together a photo gallery. I have a 2 swf files that when you enter play from frames 1 through 15. I have a back button that I am trying to play frames 16 to 30. I am trying to use as little code as possible and the swf files are nested in a Movieclip. I am trying to target frame 16 in each of the swf movieclip when they hit the back button.

 

This is the code I have that works.

 

left_btn.addEventListener(MouseEvent.CLICK, backward);

function backward(e:Event):void {

   photos_mc.prevFrame();

}

 

 

What I like it to do is

 

left_btn.addEventListener(MouseEvent.CLICK, backward);

function backward(e:Event):void {

   photos_mc.prevFrame(16);

}

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!

How do I stop a timed event from happening?

$
0
0

I am making a game where a user clicks on insects and tries to get a good high score. When the user clicks on one insect, the insect plays an animation and stays in its spot for 2 seconds in this code:

import flash.events.MouseEvent;
import flash.display.MovieClip;
import fl.motion.Animator;
import flash.events.*;
play();
var mysound:squish = new squish(); 
this.addEventListener(MouseEvent.CLICK, kill);
this.dead = false;
function kill(e:MouseEvent):void 
{    this.dead=true;    mouseChildren=false    mysound.play();    gotoAndPlay(21);    this.removeEventListener(MouseEvent.CLICK, kill);    flash.utils.setTimeout(removeSelf,2000);

}

function removeSelf():void
{
    this.parent.removeChild(this);
}

 

When the user pauses the game, the enemies are stopped and they turn invisible. The only problem is that when the user clicks on the insects, and hits the pause button, the insects stay there for 2 seconds. How do I remove the timer when the person pauses the game so that no insects are on the screen?

launching an exe from a swf

$
0
0

It has been a long time since I played with anything in FLASH so there may not be a solution.

We have some exe files with training content that we want to host on our database.  We would like to have them play from a swf that opens a completion button on a new slide when the exe file finishes playing.  We usually use Captivate but I'm not having any luck having Captivate launch the exe files so I thought I'd see what you all might come up with.

Thank you,

Susan

Flash CS6; AS3: How to load image from a link on one frame and addChild(image) on other?

$
0
0

How can I addChild outside the frame of images loader function? When I try to addChild on the other frame of the same loader, I get an error.
I need to download all my 10 images only ONE TIME and place it on the screen in the other frames (to the same movie Clip).
Also I can only play this as3 coded frame once. I know how to add an array of images, but I only need to understand how to do it with one image.

 

 

Here is my loader for one image..


   var shirt1 =String("https://static.topsport.lt/sites/all/themes/topsport2/files/images/marskineliai_png/215.pn g");

   var img1Request:URLRequest=newURLRequest(shirt1);
  
var img1Loader:Loader=newLoader();
   img1Loader
.load(img1Request);
   myMovieClip
.removeChildAt(0);
   myMovieClip
.addChild(img1Loader);


What should I do when Sound.play() return null?

$
0
0

I have a small webbase project that load and play some mp3 sound. My problem is sometimes sound.play() return null, not a SoundChannel object. I found Adobe documents say:

A SoundChannel object, which you use to control the sound. This method returns null if you have no sound card or if you run out of available sound channels. The maximum number of sound channels available at once is 32.

My question is: The maximum number of sound channels available at once is 32 in my application or my computer? In both case, I don't think are many sound channels run at one time. Just about 4-5 sound channels.

 

So, what should I do when sound.play() return null? Talk to user something like "Sound channels not available now. Please refresh your browser and try again."?

Or an other way to catch event when sound play complete, change volume or stop sound at any time?

 

Thanks for advance!

Button to external Url

$
0
0

Hello i am trying to make an intro and have 2 buttons a replay and an enter

 

the replay one is working but every tweak i make to the external url wont.

 

the one time i had it working for my site it bugged ant went to the url like this

 

Myurl.com/intro (Where it was hosted)

 

Myurl.com/home (where it needed to go)

 

and it went to

 

Myurl.com/intro/myurl.com/home

 

i tweaked it but now the Enter site button does nothing

 

 

 

 

 

 

 

import mx.controls.Button;

replay.onRelease = function()

{

gotoAndPlay(1);

}

stop();

stopAllSounds()

Enter.onRelease = function ()

{

getURL("http://www.myurl.com/home")

}

Managing multiple collision detection between objects(not necessarily circles)

$
0
0

Hi.

 

I´d like to know if there´s any good tutorial, or if somebody knows, a way, to manage a multiple collision detection with pixel level detection, for objects, not necessarily circles, irregular objects.

 

Any help?

AS3: dynamically load images into MC

$
0
0

Hi,

 

Currently I have 20 separate png images in the library each made into a MC. So there are 20 MC's, each one holding a specific image for which it is the correct size.

 

What I would like to set up instead, and need some help with, is dynamically loading a different set of 20 images (that I can add to the library), each to one of the MC's.

 

I think that first I would need to create 20 empty MC's to hold one or another of these sets of 20 png's each.

 

What I need help with: how to script this so that 2 buttons could be used: one button would load the first set, each image into a specific empty MC which is sized to hold it (20 MC's total), and a second button to load the second set of 20 images, one each to a specific empty MC which also would be its correct size. I checked out the loader class but this seems to be for external URL's not images already in the library.

 

Any help, suggestions appreciated.

 

saratogacoach

Reverse Button Action from Frame 130 to 100

$
0
0

This is driving me up the wall, I have yet to finish the problem.

 

I am creating a presentation that simply scrolls text and a background image from right to left when I click a button. Simple enough, but all hell breaks loose when I want to do this in reverse. I can use the GoToAndPlay command, but this looks pretty unprofessional since it's used in a presentation in the event that I might have to go back. I'd rather flow than snap.

 

I literally am about to go crazy, and don't tell me to make a layer to fake a reverse.

 

I was able to start going backwards, but not stop, and I barely know the code yet. Been awhile since I opened this tedious program.

 

Button is called Backwards1.

Error #1056: Cannot create property 0 on String.

$
0
0

I found similar posts about this but was unable to find my situation.

 

I have 2 arrays, One is filled out earlier in the program by user inputs in the following format:

 

VideoArray[0] : nothing

VideoArray[1] : [Object]

VideoArray[1][0]: String (this string is inputed by the user in a text field)

VideoArray[1][1]: String (this string is inputed by the user in a text field)

 

It then follows the pattern of user inputs:

[2]:Object

[2][0]:string

[2][1]:string

[3]

[3][0]

[3][1]

... repeat for as long as the user inputs data.

 

I am trying to copy the data into another array using a series of loops since i wont know how many sets of data the user inputs. i dont need the object data in the new array. The new array (InfoArray) will be structured like so:

 

InfoArray[0]: String

InfoArray[1]: Number

InfoArray[2]: nothing

InfoArray[2][0]: VideoArray[1][0]

InfoArray[2][1]: VideoArray[1][1]

InfoArray[3][0]: VideoArray[2][0]

InfoArray[3][1]: VideoArray[2][1]

.. repeat untill all the data is copied.

 

 

 

 

I do this with the following:

 

 


ArrayCount = VideoArray.length + QuestionArray.length + 2



for(var i:int = 0; i<=ArrayCount; i++)



{




if (i == 0)




{





InfoArray[i]=ModuleName;




}else




{





if (i == 1)






{







InfoArray[i]=Number_Of_Videos;





}else






{







if(i <=Number_Of_Videos + 2)






{







InfoArray[i]=[];






for(var j:int = 0; j<=1; j++)






{







trace("i = "+i);







trace("j = "+j);







trace("VideoArray[i-1][j]: "+ VideoArray[i-1][j]);







InfoArray[i] = "Video: ";

Line 272




InfoArray[i][j] = VideoArray[i-1][j];






}





}else






{

(not sure why it copied the code like this, I couldnt find an "insert code" button)

 

When I run it I get my traces and the error:

i = 2

j = 0

VideoArray[i-1][j]: v1

ReferenceError: Error #1056: Cannot create property 0 on String.

          at BWSModuleGenerator_fla::MainTimeline/Compile_Info()[BWSModuleGenerator_fla.MainTimeline:: frame1:272]

 

Ive never gotten this error before, and im not sure whats wrong with my coding.

 

thanks for any help.

Passing values from one scene to another

$
0
0

good day, how can i pass a value coming from a textbox in scene1 to another textbox which is in scene2?


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

Detecting if ctrl is pressed when clicking a button?

$
0
0

Hi

 

What's the best way to detect if ctrl is being held down while a button on screen is being clicked?

 

Cheers

Problem trying write anything

$
0
0
When i tryed example "Hello world!" ( from Help ) - any line of code i write make all controls in swf showing their images for all states

here is screenshot http://serges.cz/error.PNG

Action Script 3 pause play and rewind (for Ten animations)

$
0
0

Dear People,

                    I have made a Flash animation that consists of 11,500 frames which has Ten animations in all.

I am trying to make play pause and rewind buttons for each of these animations especially as the rewind button has to go back to Ten different frame numbers.

    I have managed to make one set of buttons that work well BUT wont work on the Second animation or the third one etc to the Tenth one and am totally flummaxed.

    It is the final thing I have to do to finish the thing.

 

Here is the Action Script 3 for the Play Pause and replay buttons....

 

pauseIt.addEventListener(MouseEvent.CLICK, itClick);{

function itCLICK(event:MouseEvent):void{stop();}

}

playAnim.addEventListener(MouseEvent.CLICK, animCLick);{

function animClick(event:MouseEvent):void{play();}

}

rePlaymovie.addEventListener(MouseEvent.CLICK, playmovieClick);{

function playmovieClick(event:MouseEvent):void{gotoAndPlay(2);}

}

 

I wish I knew what to do but am totally lost and any help would be very much appreciated please and thanks (pretty please nicely)

All the very best to you all

Bee Nice

Using Away3D with Flash Professional

$
0
0

Hi guys,

 

Flash Rookie here.

 

I am simply trying to get up and running with flash professional and Away3D.

 

I tried following this guide: https://docs.google.com/document/pub?id=1K3L4JajVRPmsQ_v0RgYNQhRmgIcA4WvknwLIRKjPUyI

 

But even then I couldn't get it running.

 

Could somone please explain an obvious step by step process of (downloading, installing, linking to then running simple example in Away 3D.) Really clearly written as if talking to a child.

 

Thanks very much.

 

MrB

Viewing all 18626 articles
Browse latest View live


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