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

target a movieclip from inside another movieclip

$
0
0

target a movieclip from inside another movieclip

i want gotoandplay symbol timeline from main time line

 

Clicking 1 , i want to goto inside 5 . not 5  timeline . it is main timeline . but i want to go symbol timeline of 5

So the code i am using is :

stop();

movieClip_1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene);

 

 

function fl_ClickToGoToScene(event:MouseEvent):void

{

  MovieClip(circle).gotoAndPlay(1);

}

instace.jpg

 

here i wan to go

 

ok.jpg

 

 



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

$
0
0

Having an issue with creating a website in Animate CC with ActionScript3.

Any help would be appreciated.

Basically I am trying to get buttons "home" "about" "services" "contact" to work when clicked.

 

import flash.events.MouseEvent;

 

stop();

 

header_mc.home_btn.addEventListener(MouseEvent.CLICK, gohome);

 

function gohome (event:MouseEvent):void{

  gotoAndStop(1);

}

 

header_mc.about_btn.addEventListener(MouseEvent.CLICK, goabout);

 

function goabout (event:MouseEvent):void{

  gotoAndStop(2);

}

 

header_mc.services_btn.addEventListener(MouseEvent.CLICK, goservices);

 

function goservices (event:MouseEvent):void{

  gotoAndStop(3);

}

 

header_mc.contact_btn.addEventListener(MouseEvent.CLICK, gocontact);

 

function gocontact (event:MouseEvent):void{

  gotoAndStop(4);

}

 

 

Ran test after permitting debugging and got

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

  at WORKINGwebsite_fla::MainTimeline/frame1()[WORKINGwebsite_fla.MainTimeline::frame1:3]

Adobe Air load external swf with actionscript not working in iOS

$
0
0

Dear All,

 

I'm working on adobe air project for iPad app. I'm loading multiple external swf files which will download from the server in runtime. Downloaded files has actionscript and it doesn't work in the app. I have read some forums and it says that iOS doesn't Allowactionscript Byte Code(ABC) from the downloaded external swf. And that forums seems very old. Still the same status continues or Is there any solution found in latest for that? Please help me.

 

Thanks in advance,

Guru

Help! How to create a count up in Animate?

$
0
0

I'm creating an animated info graphic about tigers and need a count up from 0 to 3200 to show the current population of tigers in Asia.

This is my current Code:

 

import flash.display.*;
import flash.events.*;
import flash.utils.*;


var countUpInc:int = 20;  
var totalSecs:int = 1000;  
var count = 0;     
var countTimer:Timer = new Timer(countUpInc);  
countTimer.addEventListener(TimerEvent.TIMER, timerHandler);  
countTimer.start();      
function timerHandler(e:TimerEvent): void {    if (count !== 3200) {   
count = count + countUpInc;
counter.text = count;
trace(count);  }   
} 

 

the code runs in console but when line 19 is uncommented it crashes at 1280.

 

I get the error:

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

at TigerInfographic_fla::MainTimeline/timerHandler()[TigerInfographic_fla.MainTimeline::fram e210:17]

at flash.utils::Timer/_timerDispatch()

at flash.utils::Timer/tick() "

 

i don't know how to fix it.

.fla file: NBeaulieu_FinalAnimation.zip - Google Drive

my as3 code does not play on scene 2

$
0
0

I have created a simple animation in the fist scene that goes to a navigation screen and stops. When the user clicks on the first button "Try Surfing Animation" it should go and play scene 2 which I have called TrySuf. I do not know why this code does not play on scene 2. I am using Adobe flash. I am using AS3 code. I have shared the file on my google drive. Please let me know if you cannot access it from google drive as I find an alternative way of demonstrating my file. Any help will be much appreciated.

 

https://drive.google.com/open?id=1lz1aaXx3RUjOQep9o8fna2-3Shpp-Yc8

 

Thank you in advance

 

Adobe Animate CC 2019- gotoAndStop Problem

$
0
0

Hi,

I just updated my Animate. But I have a problem. I wrote easy code: "gotoAndStop", but it didn't worked.

AS3 quit command

$
0
0
Maybe a very noob question, but there's a lot of nothing on the web about exiting a flash movie when a button is clicked. I followed the tutorial for creating an invisible button provided with CS3, which seems to work great. And, I managed to get a few simple lines of code that was suggested in the tutorial, which was totally unpractical and useless, except to verify the button fire event was ok.

Here's the code from the tutorial:

inv_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
navigateToURL(new URLRequest("http://www.myurl.com/example.html"));
trace("You clicked me.");
}

This works great. Trace gives the message and the url does show up in a separate browser.
I don't actually want the trace in the production file. Instead I expect the movie to stop and window to close, leaving the new URL to present to the user.

If I do something like:

inv_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
navigateToURL(new URLRequest("http://www.myurl.com/example.html"));
trace("You clicked me.");
fscommand("quit");
}

(or just leave out the trace), they still work, but the movie just continues and does not "quit".
There is no error message.

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

$
0
0

I need a little help. I'm making a game, and everything works fine except for the fact that I have 2 errors, one that doesn't bother me as I can still use the button, but the other one won't let me use the button.

 

Error:

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

    at Untitled_2_fla::MainTimeline/frame2()[Untitled_2_fla.MainTimeline::frame2:207]

    at flash.display::MovieClip/gotoAndStop()

    at Untitled_2_fla::MainTimeline/PlayBtn()[Untitled_2_fla.MainTimeline::frame1:13]

 

 

//Magyx Placement RedAtk.addEventListener(MouseEvent.CLICK, RedAttack); function RedAttack(Event:MouseEvent):void {     gotoAndStop(19) }

 

 

That's where Frane2:207 is, I don't see anything wrong with it, considering all my other ones are the same

 

 

nextBlueAtk.addEventListener(MouseEvent.CLICK, NWA); function NWA(Event:MouseEvent):void {     gotoAndStop(23) } nextGreyAtk.addEventListener(MouseEvent.CLICK, NGA); function NGA(Event:MouseEvent):void {     gotoAndStop(27) } nextGreenAtk.addEventListener(MouseEvent.CLICK, NGRA); function NGRA(Event:MouseEvent):void {     gotoAndStop(31) }

 

 

I get no errors for those ones.

 

And frame1:13?

 

 

function PlayBtn(event:MouseEvent):void {     gotoAndStop(2) }

 

 

Someone please help, I want to continue working on this game!


Frame advance by touch screen pressed and dragged.

$
0
0

Hello users, I have a question regarding evolution. I would like to know if there is a method to advance or regress a given frame from the touchscreen by dragging the screen from right to left to advance 1 frame, say so.

can anybody help me? I'm grateful now!

 

Untitled-1.gif

Create simple action script pause function to hold timeline for x seconds

$
0
0

I am wondering why it seems preferable in Animate CC to add frames rather than use action script to pause a frame for a set time before proceeding.

 

It would seem simpler to have a variable which can be adjusted very simply to alter the pause time - whereas amending the frames is a longer process.

 

Does any one use such a script? Or would they suggest there are reasons to not use this approach? I would add that the style of graphics I am thinking about here are simple frame changes, with no audio.

Swipe Previous/Next Frame (I have 20 Frame)

$
0
0

I'm making an android app with adobe flash CS6 AS 3.0, i want to use swipe to move next/previous frames, but have problem ie frame move irregularly from frame 1 to 2 to 3 to 2 again then directly to frame 4. this is my script

 

 

Stop ();

Multitouch.inputMode = MultitouchInputMode.GESTURE;

Stage.addEventListener (TransformGestureEvent.GESTURE_SWIPE, fl_SwipeToGoToNextOrPreviousFrame);

 

Function fl_SwipeToGoToNextOrPreviousFrame (event: TransformGestureEvent): void

{

If (event.offsetX == 1)

{

PrevFrame ();

}

If (event.offsetX == -1)

{.

NextFrame ();

}

}

 

 

Please solve the problem

Replacing an instance on the stage with an instance from library

$
0
0

I have several instances (movieclips) in the library that will be placed on the stage when the user clicks the appropriate button.

My first thought was to create a container for the movieclips to load into:

var mcContainer: Sprite = new Sprite();

addChild(mcContainer);

 

This is the code for one of the buttons:

btnStep1.addEventListener(MouseEvent.CLICK, Step1);

function Step1(event: MouseEvent): void {

var Step1: Step1;

Step1 = new Step1();

mcContainer.addChild(Step1);

Step1.x = 238;

Step1.y = 167;

trace: ("Step1");

}

 

I was hoping that loading movieclip Step2 into the mcContainer would automatically remove Step1 movieclip.

The end user has the ability to click any one of 6 buttons so I could not use removeChild since it could be one of a possible 6 movieclips loaded.

 

What am trying to achieve to load an instance from the library with a mouse click and if the user clicks one of 5 other buttons, the corresponding instance loads and replaces the instance currently on the stage.

 

1120: Access of undefined property

$
0
0

Hello, All

 

I am trying To navigate from scene 3 to  scene 2 through button but i get

1120: Access of undefined property


and after i google all possible solutions and not fix the issue.

 

i came here to try to find any help to fix this issue.

 

you will find FLA file attached below

https://www.dropbox.com/s/s6bc60trazgqpxg/Untitled-8.fla?dl=0

 

 

Regards

What's registration point?

$
0
0

Hello there!!

 

I wanted to know please what's exactly the concept called:" registration point"

 

I'll be glad if someone here will explain me clearly and in detail what this term means.

 

Thanks in advance!!

 

Atar.

Duplicate function definition error

$
0
0

Hello all!

 

One of the the most annoying errors to get is the "duplicate function definition" error! I appreciate that Flash doesn't want to see the same function twice...

 

... But what about the same function used in two different sections (labels) of one site? I've got two different slideshows in two different sections of my site, and I need the same function called out for each.

 

The function is function nextImage():void

 

If I remove it one, that slideshow doesn't work (remains fixed on image 1 of the slideshow).. if I keep it in, nothing works!

 

Any ideas for a work-around? I had wanted to use the same script for both slideshows, but forget that! So, I found another script for a different type of slideshow. I thought I'd be safe taking that approach. Apparently not.

 

Thanks!!!


How to obtain instance name of Movie Clip?

$
0
0

Hello!

 

Is there a way to get the instance name of a move clip once it's on the stage?  In my dress up game, I need to know which items are on the doll in order to keep them visible.  My drag and drop feature uses an array and currentTarget:

 

 

var dragArray:Array = [Doll.Drawers.Dress1, Doll.Drawers.Dress2, Doll.Drawers.Dress3, Doll.Drawers.Dress4];                    for(var i:int = 0; i < dragArray.length; i++)             {                    dragArray[i].buttonMode = true;                    dragArray[i].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);                    dragArray[i].addEventListener(MouseEvent.MOUSE_UP, item_onMouseUp);            }


function item_onMouseDown(event:MouseEvent):void 
          {               var clip:MovieClip = MovieClip(event.currentTarget);               clip.startDrag();          }  
function item_onMouseUp(event:MouseEvent):void           {               var clip:MovieClip = MovieClip(event.currentTarget);               clip.stopDrag();               if(clip.hitTestObject(Doll.Skins))                    {                             //Here's where the problem starts!   ----------------------------------------------  //                              trace("It's on the doll!");                    }          }

 

It can successfully run this code.  However, instead of tracing "It's on the doll!", I'd like to turn the currentTarget into it's instance name, which should be "Doll.Drawers.Dress1" etc... and then store that name in an array.

 

How would I do this?

 

I've looked into e.target.name, but I keep getting errors...

GoTo next frame after droping all the right pieces

$
0
0

Kindly need a help

i had this script of drag and drop game

but i have one one problem to go to the next frame after i drop all the objects to target

 

anyone have solution?

 

import flash.events.MouseEvent;
import flash.display.DisplayObject;


var objectoriginalX:Number;
var objectoriginalY:Number;


blue.buttonMode = true;
blue.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
blue.addEventListener(MouseEvent.MOUSE_UP, dropObject);   


red.buttonMode = true;
red.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
red.addEventListener(MouseEvent.MOUSE_UP, dropObject);


green.buttonMode = true;
green.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
green.addEventListener(MouseEvent.MOUSE_UP, dropObject);


function pickupObject(event:MouseEvent):void
{
event.target.startDrag();
event.target.parent.addChild(event.target);
objectoriginalX = event.target.x;
objectoriginalY = event.target.y;
}


function dropObject(event:MouseEvent):void
{
event.target.stopDrag();
var matchingTargetName:String = "target" + event.target.name;
var matchingTarget:DisplayObject = getChildByName(matchingTargetName);
if(event.target.dropTarget != null && event.target.dropTarget.parent == matchingTarget)
{
event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
event.target.removeEventListener(MouseEvent.MOUSE_UP, dropObject);
event.target.buttonMode = false;
event.target.x = matchingTarget.x;
event.target.y = matchingTarget.y;
}
else
{
event.target.x = objectoriginalX;
event.target.y = objectoriginalY;
}
}

Hide Layer in AS3

$
0
0

Hi

I want to know how can I hide a particular layer during a mouse click event.

 

Thanks

Ankur

Button navigation between frames?

$
0
0

I am having problems doing button navigation between frames.  I have followed a few tutorials and am 99.9% sure I am doing what is shown.  I can get the button to move forward to an other frame but the button I creat there that I would like to go back to frame 1 gives me an error.

"Scene 1, Layer 'Layer_4', Frame 2, Line 9, Column 1    1120: Access of undefined property back_bt."

 

back_bt is the instance name of the button.

 

Here is the code from a simple mock up that I am just trying to get to work.

 

On Frame one with my play_bt  buttion(I am even using the code snippet generated code)

stop()

 

play_bt.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

 

function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void

{

    gotoAndStop(2);

}

 

On Frame two with my back_bt button (Again I am using the code snippet generated code)

stop()

 

back_bt.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_2);

 

function fl_ClickToGoToAndStopAtFrame_2(event:MouseEvent):void

{

    gotoAndStop(1);

}

 

 

I know the first button works(all I have to do is comment out the button on frame two).  I also know I could do this on frame one and hide the different backgrounds and buttons.  I did that with this code.

 

yes_but.addEventListener(MouseEvent.CLICK, clickListner);

no_but.addEventListener(MouseEvent.CLICK, clickListner2);

back.addEventListener(MouseEvent.CLICK, clickListner4);

 

var startGame:int = 0

 

leave.visible = false

back.visible = false

 

//no_but.addEventListener(MouseEvent.CLICK, ClickListner2);

//stop()

 

 

function clickListner(event:MouseEvent): void

{

    trace("Yes Button")

    startGame = 1

}

 

function clickListner2(event:MouseEvent):void

{

    trace("No Button")

    //gotoAndStop(5);

    start_up.visible = false

    no_but.visible = false

    yes_but.visible = false

    back.visible = true

    leave.visible = true

}

 

 

function clickListner4(event:MouseEvent): void

{

    start_up.visible = true

    no_but.visible = true

    yes_but.visible = true

    leave.visible = false

    back.visible = false

}

 

 

But I want to be able to go back and forth to different parts of the timeline.  Is this no longer possible in ActionScript 3.0?  Like you can't pass data back and forth to a symbol action script, I believe you use to be able to use _root.(variable name) to access a variable on the main time line.  This no longer works.  I am hoping there is a way to create buttons on different frames on the time line.  Any help in this matter ill be much appreciated.  Thanks

ArgumentError: Error #1063

$
0
0

Total time fine, playing fine, scrubber click fine. But

only if i move scrubber message is showing in output

 

ArgumentError: Error #1063: Argument count mismatch on Player_as3_fla::MainTimeline/videoStatus(). Expected 1, got 0.

          at Function/http://adobe.com/AS3/2006/builtin::apply()

          at SetIntervalTimer/onTimer()

          at flash.utils::Timer/_timerDispatch()

          at flash.utils::Timer/tick()

 

Now My script is

var newMeta:Object = new Object();

newMeta.onMetaData = onMetaData;

 

ns.client=this;

var amountLoaded:Number;

var duration = Number;

var vFrame:MovieClip=new MovieClip();

this.addChild(vFrame);

vFrame.addEventListener(Event.ENTER_FRAME, videoStatus);

 

 

function onMetaData(newMeta:Object):void

{

    duration = newMeta.duration;

 

          var durmin = duration/60;

                    var hours = Math.floor(durmin/60);

          if (duration>=3600) {

          var minutes = Math.floor(durmin%60);

          }

          else{

                     minutes = Math.floor(duration/60);

          }

          var seconds = Math.floor(duration%60);

          if (hours2<10) {

                    hours = "0"+hours;

          }

          if (minutes<10) {

                    minutes = "0"+minutes;

          }

          if (seconds<10) {

                    seconds = "0"+seconds;

          }

controls.totalTime.text= hours+":"+minutes+":"+seconds;

 

}

 

 

function videoStatus(event:Event):void

{

          amountLoaded = ns.bytesLoaded/ns.bytesTotal;

          controls.seekbar.loadBar.width = amountLoaded*330;

          controls.seekbar.scrub.x = ns.time/duration*320;

}

Viewing all 18626 articles
Browse latest View live


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