ActionScript 3.0 :: Set Class To A Button?
Jun 30, 2009I have created a button on stage and I want to link it to a custom class like this
Code:
button_on_stage = new makebutton();
and this is my class
[code].....
I have created a button on stage and I want to link it to a custom class like this
Code:
button_on_stage = new makebutton();
and this is my class
[code].....
I use two classes for my current project, a document class and a menuscreen class. I have a function in my document class called startGame that i want to run from the menuscreen class when a button is clicked. I'm nearly there but i'm getting an error when i try to run it: 1136: Incorrect number of arguments. Expected 1. The error is at line 17 in the menuscreen class, the line that tries to run the function from the document class. I don't understand what kind of argument it wants. Also, i'm not sure if the startGame function should be (event:Event) Hope someone can enlighten me on what's wrong!
[Code]...
I have some AS3 code which I was hoping would create a re-usable button class but it does not. I just get a blank canvas. I am not getting any errors. Code is attached. Anyone see what is wrong?
View 2 Repliesi am trying to define a button state class where i can give the class some params and have it load a thumbnail (large files were a previous problem for me on this) that will be displayed upon rollOver. i'm having some troubles with a couple of key points:
1. i don't know how to pass in a reference to a movieClip that i can refer to in order to change its state (x location, for example) 2. i don't know how to send a status message to the host script (main timeline AS code will need to deal with such a message) after the img has been loaded
*both of these would REALLY help me understand some of the mechanics involved with AS2 OO programming,
[Code]...
I have one fla file which has a button(Sign in) and some movieclips(User name and password) in it. I have attached an actionscript(login.as) to this fla which contains a class definition (login class) and i want to get the instance on the button (sing in button) and add the onclick and same sort of events to this button.
View 0 RepliesI need some assistance with making this button class file go to a frame label in the FLA. This is new for me so bare with me, but my goal is to have complete external control over creating buttons and adding new ones as they will change frequently. [code]...
View 6 RepliesI got a Website.as file that loads 4 library's movie clip's on the stage in certain positions.Clip_A, Middle, Menu, Clip_D Clip_A loads on the top left side , Menu on top right , Middle in Middle and Clip_D low right position.What i need to do and understand is how can i tell this class to find a button inside Menu and play a certain frame in Middle?I added this code in Website.as but i get errors
menu.menu_buttons.about_us.addEventListener(MouseEvent.CLICK, about_us_onClick);
function about_us_onClick(event:MouseEvent):void
{
middle.gotoAndPlay(215);
}
the error i get is this
1046: Type was not found or was not a compile-time constant: MouseEvent.How can i make this work?
I have an AS file named MovieClipTLnd which I created to add a property to the MovieClip class, plus a function to trace the current value of the property I added. I works out just fine. But when I do the same trying to extend the Button Class, it won't work.
check the last lines of this LiveDoc, a few days ago someone posted a comment regarding this problem
[URL]
I know there are some workarounds for this problem... like embedding the button into movieclips and assigning properties as objects, but I need to know if it's possible to Extend the Built-in Button class itself just like it can be done with the MovieClip Class.
I am trying to create a button class that will gotoAndStop at a specific frame, however I seem unable to... My code is as follows:
[Code]....
The error I get is error 1180:Call to a possible undefined method gotoAndStop.
I have an AS file named MovieClipTLnd which I created to add a property to the MovieClip class, plus a function to trace the current value of the property I added.I works out just fine.But when I do the same trying to extend the Button Class, it won't work.check the last lines of this LiveDoc, a few days ago someone posted a comment regarding this problemknow there are some workarounds for this problem... like embedding the button into movieclips and assigning properties as objects, but I need to know if it's possible to Extend the Built-in Button class itself just like it can be done with the MovieClip Class.
View 1 RepliesI'm trying to create an Event Listener used with all buttons placed on the stage rather than a listener for each button object.Are coding examples of a class listener?
View 5 RepliesIm just learning classes and objects.... and read that a movie clip is (or has) a movie clip class... So I'd figure that buttons and graphic symbols also are classes? If yes, why are they called 'symbols' instead of 'classes' by Flash dialog?
View 4 RepliesI have many buttons in Main.mxml. I'm trying to move the button functionality into a Class and have Event Listeners inside the class respond to Click and call other functions. I have written:
Main.mxml
<mx:Button x="23.5" y="10" label="checker" click="{goListen()}" />
<mx:Button id="btnT1" x="252.5" y="10" label="t1" />
[code].....
I'm so use to timeline code, that this baffles me. How do I get a button class to recognize a button instance on stage?
[Code]...
Error: 1120: undefined property The error indicates it's the mouse event, not my instance name mc. LINK TO THE FILE
I video playing using the FLVPlayback component. I know I can use one of multiple skins provided by adobe but I need to make my own simple play and pause buttons. I also need to do this within a class.
What I have is the FLVPlayback component called vid which fetches the video from an XML file and works fine. I also have a button called btn_play and the following code in the class file:
...
btn_play.addEventListener (MouseEvent.CLICK, playvid);
...
public function playvid (e:Event) {
}
...
Im not sure what code to use to make the video actually play. Also will need one for pause too. how I can assign keyboard entry to these buttons or just the video i.e. pressing p on the keyboard makes it play etc id be grateful :)
I have a Document Class called Main.as. I tested that it works using a simple trace statement and that outputs fine. I instantiated a Button control and tried to add it to the stage but I keep getting the error thrown below. The code for Main.as is simple and at the end of this thread. I tried all different ways to add the Button to the stage but couldn't figure it out.[code]...
View 3 RepliesI'm trying out a game from a tutorial for a project, and I'm trying to load the next game from within the first .swf by means of a button, in this case loadButton, when this MC displays on the main swf (this is the GameOver menu screen). The syntax seems fine and there are no errors displaying, but the .swf itself isn't loading.The startLoad function I'm having problems with is at the bottom. I've tried loading external .swfs before but that was without classes... this is my first try with classes so I'm not sure if I named the public functions wrongly or put the wrong codes in the wrong places, screwed up my public vars, etc.
ActionScript Code:
package
{
[code].......
Basically I have a media gallery loading xml through a document class. I have buttons set up to load different Movieclips from the library, and inside these movieclips is the media gallery with the xml.
My question is.. What can I use for my buttons that can replace the default "xml path"?
Like in a way of "deleting the default xmlPath" and over riding it with a new one?
Here's the code on the stage of the fla, with different buttons...
ActionScript Code:
/*
These Variables are different MovieClips for the building to load
Choose based on your liking
*/
[Code].....
I have a AS file called medaigallery.as which i can load as a Class but i need to load it when a button is pressed, or alternatively load the class from a frame in the timeline.
At the moment the Class is loaded by just linking to it in the Class box in the Properties window, which just loads this AS file at runtime, but is there any way to do either of the above?
Does anyone know of a way to have something in a class, run a function in the main .fla? I have a class that creates a drop down menu and I would like that when a btn is clicked, a function is run.....but it is important that this function is in the main .fla and not in the class.
View 2 RepliesI would like to do what is shown in the linked tutorial but for Actionscript 3. [code]
View 2 RepliesIve been using Flash since version 4, mainly just to draw and create Frame by Frame Animations. Only recently have found a need for dynamic applications.Ive been following the tutorial for the simple photo gallery/portfolio here.URL...Ive noticed that the way the buttons/thumbnails created in this example doesnt give me control over the way the buttons themselves behave on the individual level. Such as things like different colors/sounds/ on events, or whatever. Can anyone help me to understand how to make a button class or something that may already have these properties set, and then dynamically assign it to the thumbnails?
View 8 Replieshow do I do this when the button is already animating using a tween class.
I want the button to be pulsating, then when you rollover it, it expands and stays until you roll off. However, when you rollover here, it keeps pulsating.
Here's what my script looks like:
//tween the button
var button_scaleX:Tween = new Tween(audioButton, "_xscale", Regular.easeOut, 100, scaleUp, 1, true);
[Code]....
I want to use the TimelineLite class when I press a button. I have this code in the main timeline:
Code:
TweenLite.delayedCall(0, myFunction, ["param1", 2]);
function myFunction(param1:String, param2:Number):void
{
[Code].....
This code allows me to send a movieclip called my_mc to a frame that I want with a time delay. How can I do to call the function by pressing a button and not with a delayed call?
I've got the following movie online to look at:(disregard background, temporary image)URL...I have 3 icons (will be 4, the photos at the bottom of the movie).When hovering over a button, it should rise up around 50px, and on mouse out, it should drop back down to its original position.If you look at the movie, it does that, however, if you move around the images a bit you'll see that at some points it picks up 2 photos/buttons at a time (since they're overlapping a bit I imagine), but the BIG problem is that sometimes, when picking up both images, they do not return to their original position when mousing OUT as they should, they remain suspended as if they are stuck at the end of the onmouseover function and can't come back down.[code]
View 2 RepliesActionscript Code:
public function Main():void {
var my1:MovieClip = new Sp();
var my2:MovieClip = new Jp();
var my3:SimpleButton = new But();
var rel;
for (var i:Number = 0; i < 3; i++) {
rel = "my" + (i + 1);
trace(rel);
addChild(rel);
}
See the above script, Here I don't wanna add the MovieClip and button class separately using "addChild" like,
Actionscript Code:
addChild(my1);addChild(my2);addChild(my3);
So I used for loop function. But it is showing error:
TypeError: Error #1034: Type Coercion failed: cannot convert "my1" to flash.display.DisplayObject.
at com.priyan::Main()
at mainFile_fla::MainTimeline/frame1()
I have a class file which prints a flash object. I don't want the print job to activate until a button is clicked. The print activation is a package and referenced by the document class. How would I code this to activate only when a button is pressed/ Currently it activates when the movie is played.
View 14 Repliesi have a sequence of buttons and each button has its own icon. I was wondering if I have to create a Spark skin file for each button in order to assign its icon.
View 1 RepliesI have a document class with a button script in it that is being completely ignored when I run my movie. I am also having bizarre trace results when I try to get the names of movie clips that are nested. [URL]
View 8 RepliesI'm putting together a portfolio site in the external method of using a document class structure.
Of the classes I have involved thus far include:
:: Master.as
and a
:: Intro.as
The Master class loads the Intro class (and others as well). The Intro class has the button event to trigger the Preloader. However, I want the button to trigger the Preloader as a separate class. Meaning, I don't want to build the entire function set inside the Intro class. I'm trying to build everything around the Master class and not go of in a tangent based around one event.
The problem I'm having is passing variable instance information in the Intro class to an external class whether it's a Preloader or otherwise.
I see tutorials for Preloaders, but how do people incorporate them into a pre-existing class structure? That is, in a modular fashion so I could re-use the Preloader class somewhere else? What's a common structure philosophy that's used to pass info?