ActionScript 2.0 :: Adding An OnPress Handler To Movieclip Part Of Class
Apr 16, 2007
I'm having a problem with my following situation: I made a class "Scrollbar" which I can use to create a scrollbar for a certain movieclip.This movieclip extended class (Scrollbar) has 3 movieclips (see code below):1 - which has the complete scrollbar1.1 - which has the background for the scrollbar.1.2 - which has the slider for the scrollbarNow, I'm trying to make an onPress handler inside my class, I tried to override the onPress() handler of the MovieClip class but it doesn't work.[code]
I have an MC that has a graphic. I have faked buttons for just the over state, so it shows a border around a portion of the graphic. That works fine until I added this to the MC:
I have an mc with a button nested inside and on this button I have AS for the rollOver and rollOut to play certain frames of the mc. The problem is when I use this mc (called 'mybutton_mc') in a menu system and I want to add AS to it to navigate to different areas, ie adding onPress to this mc, it kill's the AS on the rollOver and rollOut functions of the button within.
If I have the following on the timeline in my FLV, it works and attaches my movie from the library to the stage. If I do the same from my class, it does not. var myMC:ToolTipMc = new ToolTipMc(); addChild(myMC);
I am not sure if this is possible, but can I add a custom property to the MovieClip class. I'd like to add a tooltip-functionality to some things so I'd just need a "tip"-property in which I can store a String. Would this work, or do I have to create a new Class extending MovieClip?
I have a MovieClip with multiple child MovieClips. I would like to add a class to each child MovieClip. Unfortunately, I can't just create the class and mc.addChild(class) because classes aren't display objects.
Actionscript 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,
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()
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
I have been trying to add a movieclip to my .fla file from a class.my main fla file: main.flaactionscript file: script.asthey stay in the same directory.script.as file as follows:
package { import flash.display.* public class MyClass extends MovieClip
Okay, so I decided to try putting some child movieclip switches into the .as instead of in the frames. After a lot of Googling and reading, I think I learned that each of those movieclips need to be in their own .as. Anyway, I tried to do it and the movieclip, which is located in the .fla library and does have export checked off, is not showing up when I play the file. The movieclip has this .as to itself:
I have a game here, and I would like to add event handlers to my buttons to change the time. I know how to do all this, I'm just having troubling actually adding the event listeners to my buttons in my .as file. I have a button named "btnEasy" with the Linkage as "btnEasy" as well.I am getting this error: "1061: Call to a possibly undefined method AddEventListener through a reference with a static type Class".[code]
I am new to Flex. What I am looking for here is adding a click handler on all the items created by a SkinnableDataContainer. I tried several things that didn't work, and I have no idea what is the right way to do it.
<s:SkinnableDataContainer id="teamList" itemRenderer="TeamSummaryRenderer"> <s:dataProvider><s:ArrayList> <fx:Object teamName="A super team 1"/> <fx:Object teamName="A super team 2"/> <fx:Object teamName="A super team 3"/> </s:ArrayList></s:dataProvider> </s:SkinnableDataContainer>
Furthermore, I don't want to declare the handler in my custom TeamSummaryRenderer component. I would prefer that the handler code stays at application level.
I'm trying to add a custom callback handler to a NetStream client in a p2p application. The problem is, when I add such a handler, the NetStream Client doesn't function as it did before. It seems the NetStream.client object is changed. I know the default object is this. But changing the client to this doesn't solve the problem. The remoteControlStream, is the incoming stream. And the localControl stream is the stream being published. This is the localControlStream that's being send by the peer, and received as remoteControlStream:
private function initLocalControlStream():void{ localControlStream = new NetStream(nc, NetStream.DIRECT_CONNECTIONS); localControlStream.addEventListener(NetStatusEvent.NET_STATUS, localControlHandler); localControlStream.publish(myPeerID+"control"); var localControlStreamClient:Object = new Object(); [Code] .....
The onPeerConnect method of the localControlStream doesn't get called when I connect when the above handler is added. When I remove the that handler, the onPeerConnect method gets called. Obviously the problem is the NetStream.client.
I have a class which controls a movie clip. The movie clip has a button in it. The problem is that I cannot use the class members in the onPress function of the button.[code]
I have a class which controls a movie clip. The movie clip has a button in it. The problem is that I cannot use the class members in the onPress function of the button.
[AS] class Controller { private var id:Number; // I have tried public also private var myClip:MovieClip; // The clip that has the button
I am trying to create a little chess similar game as part of my studies. Well I am actually new on AS, but I experimented a little bit and already found out some things...
The Facts: I already created a little Chess-similar-Board with 9x9 fields. I created an Array with the coordinates of each field and another one with the fieldnames. when i click on my "hero" a call the function showMoves(), which (how could it be) shows me the possible moves. (i pasted the code for run here)
I have created a simple grid on my canvas.First I defined an empty movieclip (wrapper) for my grid, then I draw lines onto it to make the grid.Now, I want to click on the grid and get the x/y of where I clicked so I can determine where in the grid i am. But my trace in the onPress event does not show.I'm under the impression that my mcGrid has a 0x0 width and height. When I trace the mcGrid._width in the bottom it outputs "0" so maybe that's why it is not working? Here is my code:
ActionScript Code: _root.createEmptyMovieClip("mcGrid", 1); for (var i=0; i<12; i++) { var clipName = "mcHorizontal_"+i;
I'm trying to make an onPress function for a MC inside a MC and I have figured it will look something like this: _root.mc1.mc2.onPress = function(){} It won't work though. What to do? (Now I see, I have that mc2 on the 2nd frame inside mc1... if I put it also on the first frame it works fine, but I don't want it on the first frame).
I am trying to build a drop down menu using fuse kit. I somewhat understand the fuse kit, or the stuff I need to alpha, slide, tween and the whatnots. I have a menu button, (button_mc) press it once and the sub menu appears. Press it again and the sub menu disappears But how do I write the code. So It will work?
button_mc.onPress1 = function() { Some code that make the menu appear } button_mc.onPress2 = function() { Some code that make the menu disappear
I have a scrollBar movieClip inside an interface that is not always responding to the onPress event. Sometimes, it works fine, and sometimes I have to roll off of the scrollBarMC for the cursor to change back to the finger and respond to the onPress event. Other times, it responds more than once to the event on just one click.
I realize that there could be other issues within my interface's code, however, when I trace my function calls they seems to not execute or execute more than once. Has anyone else ever run across such an issue with the movieClip.onPress event? Below is the code for the scrollBar mc. Anyone see something glaring?
So far I have created/hacked about some code for an infinite scrolling menu bar, and am trying to create the rollover and release actions for each menu title. After researching it seemed best that the buttons were made from movies clips as apposed to the 'button' type, but I am not sure if this is the case. The problem I am having is that I am unable to get the Contact movie clip to recognise the onPress or an onRollOver and I am not sure why. The .fla file is available here and this is the code I tried to get it to work.
Code: _root.scrolling_mc._root.menu_mc._root.contact_mc.onPress = function () { if(contact_mc.hitTest(_xmouse, _ymouse, true) ) { trace("Does this button work?!"); }
I also tried: Code: _root.scrolling_mc._root.menu_mc._root.contact_mc.onRollOver = function () { trace("Does this button work?!"); } I understand I am probably on the wrong tracks with the use of _root. but I need to somehow trigger the nested movieclips.
Lets say I have attached a movieclip from the library according to an array.length and I want to assign an onPress or onRelease on these movieclips attached lets say the length of the array was 4 .. so if I want to assign onRelease to this movieclips how do I do that?
I'm trying to make it so that when a user inputs the correct word an event happens. It almost works except that the event doesn't fire until the NEXT keystroke. Is there a way to test for the word AFTER the keystroke has become part of WriteInOneText.text, without adding a separate button or anything? Here's the code:
In my FLA file (FLASH-8, AS-2)? in the library I have a movieclip named "mc" which is just one frame and in it specifies a property "price" like this: this.price="three";
In the main scene I have this code:
attachMovie("mc","t1",1) t1.onPress=function(){trace(t1.price)}; //returns the correct value "three" trace(t1.price); //returns "undefined"
Why the first trace(t1.price) returns the correct value and the second one returns "undefined"?And how do I make this property available without using onPress? The objective is to output the pictures of a set of movieclips and place the price of each picture under it using a dynamic textfield