ActionScript 3.0 :: Target/control .fla Movieclip From .as Class File?
Jun 18, 2009
I have a Bullet class - which defines and controls the firing of bullets (and works perfectly in all ways) - and now I'd like to add to it the ability to detect if it has hit a spaceship-movieclip sitting in my main .fla's timeline - what's the proper syntax to do this?
here's my code:
Code:
public function moveBullet(e:Event): void {
this.y = this.y - 20; // moves bullet up-screen, shooting vertically
if (this.y <= 0) {
[Code].....
View 8 Replies
Similar Posts:
Dec 12, 2009
me only still learning as3, i've checked google there and back, but somehow i can't find the answer for this: how to target a movieclip instance which is already on the stage from within a class file? i mean, targeting it from the document class file is easy, but what is i want to target it from another class file?
View 2 Replies
Dec 17, 2010
i am making a drag drop game. i created a doc class for the dragged items . i want to make the hit test with some movie clips on the stage but inside the class they are not seen by there names. how to perform my hit test
this is my code,and target1_mc &target2_mc are movie clips on the stage
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.text.TextField;
[Code].....
View 5 Replies
May 11, 2010
is there any way to target a MovieClip from an external class that's NOT the Document Class?
Is it correct to have the Document Class as Main AND View?
View 1 Replies
Jun 22, 2011
Is there any way to get the name of the MovieClip that a class extends?Lets say I have an MC on stage called boxMC exported for AS using a class box which extends MovieClip.If I trace (this) within my class I will get the name of the class, if I trace (parent) I will get the name of the main MovieClip that boxMC sits within. So how can I target boxMC?Basically I want to be able to return the name of the MovieClip that the class is extending
View 2 Replies
Mar 18, 2009
I need to call the class into to my control as file. The problem I'm getting now is this error. "environmentTab.lightsButton.addEventListener(MouseEvent.CLICK, selectLights);" environmentTab is a instance name of a movie clip that is on the stage of my .
View 2 Replies
Dec 18, 2010
this is the code and the movieclips are target1_mc & target2_mc
package { import flash.display.MovieClip; import flash.events.MouseEvent; import flash.text.TextField;
public class recipeMC extends MovieClip {
[Code].....
View 1 Replies
Oct 20, 2010
Is it possible to handle/control a movieclip that's on stage through a class? (not the main class)?
View 4 Replies
Jun 14, 2010
I was wondering if there is a way to control the volume of a movieclip directly without using the sound class? Or is there a way to control the volume of the entire swf?
View 1 Replies
Jan 13, 2009
I have a menu btn that is created via an external class. I want to move the main timeline of my flash file to a frame label but I'm having a hard time referencing the main timeline via my external class code.
How do I control the timeline via this external class.
View 3 Replies
Jun 1, 2011
I have a movieclip instance named 'placeholder' on the canvas, and I want to change the alpha of the named movieclip from it's class without effecting the alpha of all the movieclips of the same type. How would I specifically target the named movieclip instance that is on the canvas?
View 3 Replies
Aug 30, 2010
qi have a movieclip which is added to the stage:
var profileholder:profileHolder=new profileHolder ;
inside of profileholder is another movieclip(infoBtn) that acts as a button.when the mouse is over profileholder i want to do something with infoBtn like:
//profOver is the over state of profileholder
function profOver(e:Event) {
e.target.infoBtn.alpha=1;
}
this doesn't work and brings up this error:ReferenceError: Error #1069: Property infoBtn not found on flash.display.Loader and there is no default value.
at main_fla::MainTimeline/profOver()
i also tried:
function profOver(e:Event) {
var item:profileHolder=e.target as profileHolder;
item.infoBtn.alpha=1;
}
and get this error:TypeError: Error #1009: Cannot access a property or method of a null object reference.
View 1 Replies
May 4, 2011
Here is what I am looking to do. Currently I have a drag and drop built in AS 3 that works perfectly fine, but I'm looking to add one more functionality. What I want to happen is when I drop the correct drag item on it's correct target piece (which is a movie clip) I want my target movie clip to go a head one frame.
So as an example I'm dragging a piece of paper onto a movie clip of of a waste basket. When I drop the piece of paper on it the waste basket, the waste basket movie clip moves a head one frame which shows a crumpled up piece of paper in it. Here is my current code for my drop eventlistener:
function dropMe(event:MouseEvent):void{ event.currentTarget.stopDrag(); if(event.currentTarget.hitTestObject(event.currentTarget._targetPiece )) { event.currentTarget.x = 950; event.currentTarget.y = 100; event.currentTarget.removeEventListener(MouseEvent.MOUSE_DOWN, dragMe); event.currentTarget.buttonMode = false; } else { event.currentTarget.x = event.currentTarget._origX; event.currentTarget.y = event.currentTarget._origY; }}
View 1 Replies
Oct 1, 2011
i have made a list control. i want to display the name of the objects in it in a text control box
the code i am using here is
public function add(event:MouseEvent):void
{
var str:String;
str = mylistcontrol.dataProvider.getItemAt(0).toString();
[Code]....
The problem with this code is i am using index value of 0. however i want to display the name of object on which i have clicked or which is highlighted.
View 1 Replies
Oct 22, 2010
What is the best method to add a listener to a movieclip in a class file? I created a loading animation on the main timeline and I tried making it into a class. I can get all the graphics drawn and placed, but can't see to figure out how to add the listener in the class.
View 3 Replies
Jul 30, 2011
I am trying to access/target a movieclip on the stage in my .FLA file from a AS3 class file Main.as but I can't get it to work.[code]...
View 7 Replies
Mar 3, 2009
I'm loading a SWF-File containing a movieclip(testButton).
Code:
<mx:SWFLoader id="testSWF" x="0" y="0" complete="testSWFHandler(event)" source="assets/testButton.swf"/>
[code].....
View 6 Replies
Nov 4, 2009
possible to create a movieclip and apply it to a class file that you could make? I mean...When you have a movieclip in the library in flash and have it be exported for actionscript...is it possible to do this for movieclip made in actionscript?
View 21 Replies
Jan 15, 2009
Does flash have an equivalent to Flex'sApplication.application.[insert application method or propertyI want to get access from an as3 class file to the mainstage. a call to this.root from the stage to the class will notwork because I need the root object stage to execute an addChild
View 6 Replies
Mar 8, 2007
I am starting to learn coding the class... I tried to declare a movieclip variable in a class file. But it shows an error.[code]
View 3 Replies
Jan 19, 2009
I am currently using an external Class file for an instance in my .fla project. It creates an instance of that specific class and has it carry out some functions.I want to access a MovieClip on the stage in the .fla file in the external Class file. How can I do this?For example, the Class file creates an instance of that class, and I want the x and y coordinates of that instance to be equal to that of let's say circle_mc. Now circle_mc is on the stage of the .fla file, and therefore cannot be accessed. How can I get around this?
View 5 Replies
Jan 8, 2010
I'm doing a project that makes a movieclip draggable in different droptarget movieclip. When it is dragged in the 1st target an animation is triggered and so as the rest of the droptargets.Here's my initial code that does'nt work:
btn1.buttonMode = true;
b1OrigX = btn1._x;b1OrigY = btn1._y;
//btn1btn1.onPress = function(){ startDrag(this);}//droptarget = box1btn1.onRelease = function(){ stopDrag(); //droptarge1t
[code]....
View 2 Replies
Apr 17, 2009
Instead of posting my entire files and such, I'll make a brief example of my situation and my desired outcome.My files consist of my document class entitled Engine.as and another class Abilities.as all within the same folder.On my stage I have a MovieClip with the instance name of item1_mc. On its personal timeline I have 2 frames, one entitled "inactive" and the other "active". Here's a sample of very similar code....
Code:
package
{
import flash.display.MovieClip;
[code]....
How do I access item1_mc? In reality I have 6 different clips and I desire to access much more than frame changes...what's the overall best way to be able to interact with an item placed on the stage via an external .as file that is not the document class?
View 11 Replies
Dec 13, 2009
I need to pass a variable value contained within a MovieClip to my class file. The MovieClip is my preloader, to which my code will show that upon the initial launch of the SWF. Until the variable is sent, my code assumes the preloader is still running and therefore will not progress. Originally, it was working when I had my class file extend MovieClip and then used this code in the preloader MC:
[Code]....
View 1 Replies
Jul 13, 2010
I am trying to write a class file for loading a movieclip but it is not working. I am not even getting any error message.
[Code]...
View 1 Replies
Nov 21, 2010
I've been searching around all afternoon, and am pulling my hair out. 1) I have a movieclip instance on stage (simple graphical element that represents platforms for a hero to run and jump along). I have placed it on the stage with an external class engine.as and in this class it is called myPlatform and is an object of Platforms.as. The movieClip is called platforms and from a trace(myPlatform.name) the instance name is instance3.
2) I am attempting to access the properties of myPlatform in an Enterframe event loop in my character control and collision class (called hero.as)
Basically here is the bit of code I am trying implement within Hero.as :
[Code]...
This all worked when I was writing actionscipt within the FLA file, on the timeline frame 1. I simply don't know how to access myPlatform from within the external Hero.as class! Do I need to create a variable? Is there a really easy way to do this with some syntax/command that I have not learned yet?
View 3 Replies
Jun 10, 2010
I am trying to target a TLF Textfield within a movieclip from that movieclips custom class, but the class can't find the instance name. When I trace out the child name it comes up with a random instance name, not the instance name I set on the stage. When I try and target it from the movieclip's timeline it works fine. Is there a class I need to include in my custom class, or is this a bug? I would love to move from dynamic text fields to TLF, but this is a big hurdle.
View 10 Replies
Oct 2, 2009
I am trying got get the parent of a class so I can set a variable. first I problem I have is I cant even trace parent. I have a simple class nothing in it except a trace(parent) I instantiate it on the main timeline of a fla and it returns null. I have tried to trace root and it returns null as well. the class extends movie clip or sprite
View 7 Replies
Apr 29, 2010
i'm trying to target a function in one class from another. i'm able to call the function using(public static function imagecount()) but i can't a variable out side of that function. when i do i get this error:
1120: Access of undefined property _imagecount.
so below from call 'person' i want to call fucntion 'imagecount' in class 'model'. the call works but when i try and define a variable in class 'model' that is incremented in the 'imagecount' function i get the above error. it seem that my function has to be of type public static to be accessed from the other class.
///////////////// model class
package com.model
{
import flash.events.*;
[Code]....
View 3 Replies
Nov 21, 2009
I have a custom class which uses some buttons on the stage. Or at least is trying to.say have this code in the customClass.as file
package{
import flash.events.*;
import flash.display.MovieClip
[code].....
View 5 Replies