Adobe CC Flash AS3 Click tag - actionscript-3

I recently switched over from Adobe CS6 to Adobe CC. In the new Adobe CC Flash, it no longer supports action script 2. I need to create an AS3, click tag. Is there a universal AS3 clickTag code you know of that is used? I've googled it, but found some unreliable results.

I'm assuming that you mean you want to have a button react to a click? If so, you simply have to create a button object, and then add a listener for that button where you choose 1) the event you want to listen for, in this case a click, and 2) the code you wish to execute when that event is fired, in most cases this is a function call.
For exaxmple, the following code was placed on the first frame of an .FLA:
import flash.events.MouseEvent;
var myButton:SimpleButton = new SimpleButton();
var myButtonSprite:Sprite = new Sprite();
myButtonSprite.graphics.lineStyle(1, 0x555555);
myButtonSprite.graphics.beginFill(0xff000,1);
myButtonSprite.graphics.drawRect(0,0,200,30);
myButtonSprite.graphics.endFill();
myButton.overState = myButton.downState = myButton.upState = myButton.hitTestState = myButtonSprite;
myButton.addEventListener(MouseEvent.CLICK,buttonClickHandler);
addChild(myButton);
function buttonClickHandler(e:MouseEvent):void {
trace("YAY! My Button was clicked!");
}
To give credit where it is due, the code for creating the button dynamically that you see above is showcased here: Create a Button with only code AS3
If you already have a button on your stage that you want to wire up with a click event you simply have to give the button an instance name and then use that instance name in the code. In the following example, the instance name of the button on the stage is myButton:
myButton.addEventListener(MouseEvent.CLICK,buttonClickHandler);
function buttonClickHandler(e:MouseEvent):void {
trace("YAY! My Button was clicked!");
}

Related

adding event listener of the closing and changing the FLA document for the SWF extension panel. using ActionScript, JSFL

I have an extension SWF panel and a list of movie clips of the currently open document on it. I want to clear my list when the user closes the current document. Also, I want to add some alert "You have to select the previous document you were work on" - when the user selects other open .fla document and tries to press some button on the SWF panel to edit some MC from the list. So I want to know if has Adobe Animate the ability to listen to closing and changing of documents?
thank you for advance for any hints
an answer from adobe community support:
Yes, there is such a possibility. You can register a javascript function to be executed when certain system event occurs:
enter code herefl.addEventListener( eventType, callbackFunction );
The possible system events are:
"documentNew", "documentOpened", "documentClosed", "mouseMove", "documentChanged", "layerChanged", "timelineChanged", "frameChanged", “”, "prePublish", "postPublish", "selectionChanged", and "dpiChanged".
Also, in Flash CS4 and above, you have the possibility to refer a particular swf panel. In combination with ExternalInterface class and MMExecute method in AS, you can build a two-way communication between the two environments.
Example:
// JSFL
var docChangedID = fl.addEventListener( "documentChanged", onDocumentChangedHandler );
function onDocumentChangedHandler(){
var panel = fl.getSwfPanel( "<my panel swf file name >", false );
panel.call( "AScustomEventName" );
}
// AS
import adobe.utils.MMExecute;
import flash.external.ExternalInterface;
ExternalInterface.addCallback( "AScustomEventName", this.myASMethod );
function myASMethod() : void {
// your stuff here
MMExecute( "some jsfl code or path to a jsfl script" );
}

AS3: How to Control Sound Channel of Another Scene from Inside a MovieClip?

can you help me? Im a beginer im programming and I'm just barely know as3. I have a problem controlling my bg sound using as3 script from inside a movieclip.
I have an as3 flash project with multiple scene (let's say it sceneA and sceneB), and i placed my sound channel script at SceneA frame 1. I've been able to stop and play my music from sceneA without any trouble. Now at sceneB i have a movieclip and inside it, there's button stop and play. The problem is, I can't use the same method from sceneA to control my music from inside the movieclip of sceneB. How can i do it? Please i need your help.
Here's my sound channel script from sceneA frame 1:
var bgm:bgSound = new bgSound();
var sChnl:SoundChannel = new SoundChannel();
var myVolume:SoundTransform = newSoundTransform();
sChnl = bgm.play(0,999,myVolume);
Here's my sceneA button stop script, this button is called btnStop:
function musicStop(event:MouseEvent):void
{
SoundMixer.stopAll();
bntStop.visible=false;
btnPlay.visible=true;
}
Here's the play button called btnPlay:
function musicPlay(event:MouseEvent):void
{
sChnl = bgm.Play(0,999,myVolume);
bntStop.visible=true;
btnPlay.visible=false;
}
I tried the button play script from sceneA in my SceneB button play and it give me an error:
Symbol 'Symbol 1', Layer 'btn control', frame 1, Line 22 1120: Access of undefined property bgm.
That's one of the error massage, the other two is the same just that the bgm is myVolume and sChnl.
I have tried this function before
MovieClip(root).sChnl = bgm.Play(0,999,myMusic);
But it's not working.

Flash CS6 Button Not Working Despite No Compiler/Output Errors

I'm using Flash CS6, AS3 to create buttons for my project. Below is my code:
Intro_btn.addEventListener(MouseEvent.MOUSE_DOWN, Intro_func);
function Intro_func(event:MouseEvent):void {
gotoAndStop("Intro");
}
No errors appear when I run it on the output and compiler panel, and the same happens when I run it through the debugger. Also, I have used the exact same code for five other buttons, and they have no problems working. Please can someone tell me what is wrong with my code???
I would need to know more info of your code and the type of buttons you're using, however I would try this steps:
1.- add a Button component from the component inspector, set its instance name, and add that same function to the Click event:
newButton.addEventListener(MouseEvent.CLICK, Intro_func);
function Intro_func(event:MouseEvent):void {
trace("function executed");
gotoAndStop("Intro");
}
2.- run your app and test if the action is executed with this new button. If this test pass, then your problem is your button.
check this on your button:
check the base class of the button (be sure its a MovieClip or a Button class)
check if your button is enabled/disabled.
check if your button or its children has mouseEnabled and mouseChildren set as
true.
check there is no other object on top of the button either in your artboard or added by code at runtime.
I finally would suggest you to set useHandCursor = true; this will replace your mouse pointer arrow to a hand when you move over your button (this is just to test that your button is actually interacting with mouse).
hope this helps.
sorry for the delay, But I've found your solution, It's easier than you thought: your frame is delayed.
your Intro_btn script is on frame 10, however in frame one you're telling it to go to frame 9 (the "Erhu" frame label) so the actions to setup the event listener are never being called.
Also keep in mind the following:
objects exists only in their frames life time, if you have an object from frame 5 to 10, it will only exist in there, so moving to a previous or later frame (e.g. frames 4 and 11) will internally delete the object in memory along with their asociated actions, in english:
you placed the button in frame 10 and added its MOUSE_DOWN listener however, if you go back to frame 0, since the button doesn't exists in this frame it will be deleted from memory along with its listeners, so if you go from frame 0 to any other frame different than 10, your button will never have its listeners associated.
So my suggestion:
1.- add your function into frame 0:
function Intro_func(event:MouseEvent):void {
trace("function executed");
gotoAndStop("Intro");
}
2.- create a new layer. In this layer add a keyframe at the same position where your Intro_btn is(frame 10), and fill the rest of the timeline of this layer with empty frames (no keyframes), finally in the same layer add in frame 10 your listener Intro_btn.addEventListener. this way, the action is available for every subsecuent frame from frame 10.
hope this solves your problem.

My AS3 code will not run my animation properly

I want to be able to press any key on my keyboard so as to appear to be typing my specific
text. No matter what key is pressed, the same scripted text appears, letter by letter(one per keystroke)/frame by frame. Can anyone help me here? As it stands, my animation just continues to loop unless I hit enter (then it stops until pressed again.)
stop();
var keyList:Object = new Object();
keyList.onKeyUp = function () {
nextFrame();
}
Key.addListener(keyList);
stop();
Using Flash cc-thanks
Your code appears to be AS2 rather than AS3?
If your looking for AS3 functionality, you'll want to do something like listen to the stage for keyboard events, and then have an event handler that progresses the frame.
stage.addEventListener(KeyboardEvent.KEY_DOWN,_handleKeyboardPress);
function _handleKeyboardPress(e:KeyboardEvent)
{
nextFrame();
}
Your code looks as though it would work if you are publishing to AS2 though?

actionscript 3 popup window - not js

Im doing a program in AS3 and, i'm trying to do the following:
Lets say I have a button, which have onClick event, and when the event is triggered, the popup window will appear.
And in this popup window there is going to be an animation (countdown) of 2020 (this is just an example).
Is there a way to do this without javascript. Because i'm not doing this for website, its going to be a animation.
Hope i was clear.
Thanks
In Flash,create a movie clip, give it an instance name of "countdown_mc", put the countdown animation inside it.This will be your "alert" type window.
Now, in the movieclip containing "countdown_mc", add a new layer and on the same frame bring up the action editor(F9) and write the following: countdown_mc.visible=false;
When you push the button it should make countdown_mc.visible=true and maybe do an optional growing animation;
Also on this frame add a listener for countdown_mc so that when the user clicks on the window it disappears(countdown_mc.visible=false);
For animations add download tweenmax from http://www.greensock.com/tweenmax/, extract the archive in the folder that contains your fla and add the following to your code:
import com.greensock.*;
TweenMax.from(countdown_mc,0.5,{scaleX:0,scaleY:0});