ActionScript 3.0 :: Path Or Target Frame Inside Of MovieClip?
Mar 8, 2009
I'm trying to reference a specific frame inside a MC in my .swf file from an .as file. What I want is to capture the current frame of the movie clip for the .as file. It's for the purpose of points when you shoot each plane. It's an easy trick of frame 1's plane would be worth 100 points, frame 2's plane 200 points, etc. I thought I'd write a line like this in my collision detection section of my .as file.
Code:
planePoints = currentFrame * 100;
The only problem is, of course, it grabs the current frame of the main .swf timeline that my flash file uses, and not the movieclip that's being called to produce the planes. So I thought I'd be able to specify a path to the movie clip (in this case it's called Airplane in the MC's linkage properties).
Code:
planePoints = Airplane.currentFrame * 100;
Then, of course, it freaks out and says that 'access of possibly undefined property currentFrame through a reference with static type Class.'
I still get confused with AS3 and the way items are handled vs AS2. I've lost track of how many times I type _root. Am I getting something basic mucked up here or should I be importing something in the package to get it to recognize the class?
I'm trying to control a movie clip called "nosotrosmc" with a frame label inside called "historia" but does not work Code: menu.nosotros.addEventListener(MouseEvent.CLICK, subSeccion); function subSeccion(e:MouseEvent){ trace(""+e.target.name+"boton clicked"); this.nosotrosmc.gotoAndStop("historia"); }
The output window show this: nosotrosboton clicked TypeError: Error #1009: Cannot access a property or method of a null object reference. at HomeSonny_fla::MainTimeline/subSeccion() I need to made a simple navigation, I'm a designer, not a programmer.
there is a button on 1st frame. there is a movie clip on frame 2. I named the movie clip as "ball_mc" I want to go to frame 2 when I click on button on 1st frame. I know that the code "gotoAndPlay(2);" on button will work. But for some reasons, i want to try another way.... i tried several codes:
I am wondering why the AS3 movieClip target path are soo complicated? I'm loading a simple external swf that contain a movieClip that I want to play with. But I can't find the proper syntaxe to call this movieClip..
var swfLoader:Loader = new Loader(); holderSWF.addChild(swfLoader); var externalSWF:URLRequest=new URLRequest("externalFile.swf"); swfLoader.contentLoaderInfo.addEventListener(Event .COMPLETE, loadProdComplete); swfLoader.load(externalSWF);
I've a main movie with a container movieclip to load an external swf file. That's working fine but I want to control the movieclips of externally loaded movie. I tried the below method but not work out. Script on the main movie _root.holder.loadMovie ("1.swf", mytarget); // This is working fine _root.holder.mytarget.<movieclipname of the externally loaded movie>.onRelease= function (){ // Do something. } But the above script not worked out.
How can I target a movieclip that is inside each item in the array using getChildByName. Heres my code so far: var aMC:Array=new Array(letter, envelope, parcel); if(i< aMC.length){ var myTargetName:String = aMC[i].target.name; var myTarget:DisplayObject = getChildByName(myTargetName); trace("Stamps Target: "+myTargetName); if (evt.target.dropTarget != null && evt.target.dropTarget == myTarget) { // do what ever here i++; }}
When I click on the button, it should bring me to a specific location which is inside the MovieClip, and that works. However, from inside that MC, I want to click on the same button, it should bring me on the main time line. How to do that? I am making of a variable (boolean) here. Is there something wrong in my code? (see path.fla)
(b) How do I remove a movie clip? (see path2.fla) When I clik on the square_btn, it brings me to a location inside that movie clip where there is an oval button. When I reach that oval button, I want the square_btn to me temporarily removed on that page.
Can i target the second key frame of an empty movieclip which is created by actionscript.as for example:this.createEmptyMovieClip("target_mc",1);I want to write some script on the second keyframe on the target_mc movie clip. Is that possible.
How can I get a button inside a movieclip link to a frame in another movieclip on the scene? I tried this code:
function gotoCenter(event:MouseEvent):void { MovieClip(root).centermc.gotoAndPlay(2); } skruetest.addEventListener(MouseEvent.CLICK, gotoCenter);
..where "skruetest" is the button, "centermc" is the movieclip where I want to go to frame 2. I don�t get errors with this code, but nothing happens when I click the button. What can I do?
I have a MovieClip that represents a playable character in my game. Inside of that MovieClip are three frames: One containing a single picture (standing), one containing a second MovieClip (walking) and the last containing a third MovieClip (jumping). Using the Properties tab, I gave each of the frames a name ("Stand", "Walk" and "Jump respectively).
What I want to do with Actionscript is gotoAndStop the "Jump" frame inside my character's MovieClip, and play the first frame of the MovieClip contained in that "Jump" frame. Something like this:
I am using Flash MX 2004, aka Flash 7, and Actionscript 1. What I have is a movie clip that plays on frame one. Its a variation of loading screen. What I want to do is make it so that when the movie clip is on its last frame (frame 100), then it switches to frame 2. NOT frame 2 of the movie clip, but frame 2 of the overall project.
Code: if (_root.loader._currentframe == 100) { _root.gotoAndPlay(2); } (movie clip is called loader)
I have also tried naming frame 2 "finishedLoading" and just "2", but it still will not go.What happens is, when the movie clip animation is finished and on frame 100, it just sits there. I had to put a stop(); in frame 1 so that the animation could play, but it stays stopped. This was all done after I tried the logical approach where inside of the movie clip on frame 100 of the movie clip, I made an "Actions" layer and on frame 100 keyframe, I put:
Code: gotoAndPlay(2); I also tried Code: gotoAndPlay("finishedLoading"); and Code: gotoAndPlay("2");
I have even resorted to the last resort. I put tried to make a variable so that when the movie clip is on frame 100, that "var finishedLoading" would be set to true, and then: Code: if (finishedLoading == true) { // } Inside of the comment would be gotoAndPlay(x);
I realise that I need to keep all my code on the main timeline, so now I need some serious help with targeting movieclips and buttons, when I use the target path tool (the little gun sight in the action script panel) it lets me navigate to the thing I want, but when I use it's suggestion it very often doesn't work, and I am left using trial and error to work it out. Ican get stuff to work, but I really have no idea why or how I am doing it, Sorry to be such a N00B, but I really think if I can work this out I am going to get
how do you specify the target path using "tellTarget"?Ex. The target movie clip is on the main timeline but the "tellTarget" script is on another. How would I code this? (or should I just use the standard "gotoAndPlay"?)Is tellTarget really even relevant anymore? It seems to me that with the release of FMX 2004, Macromedia advocates using gotoAndPlay more than tellTarget. Why would you use tellTarget when gotoAndPlay does essentially the same thing (or does it?)?
is there any way I can link a button inside a MC on frame1 to a frame inside another MC that is located on another frame.Ive got 2 frames in total. On the first frame Ive got an Mc and inside this one Ive got a button that needs to be linked to frame number 50 which is inside a MC located on frame number 2.
I have a time line with 2 frames only. On frame 1 I have a Movie Clip that contains a gallery and its called "gal1" on frame 2 I have another Movie clip called "gal2". Now I have 2 buttons to call each of these galleries which this code in them[code]...
But when I am in gal1 and I want to click on the second botton to call gal2 with the same exact code attached to button2, it doesn't work!
hi i am having trouble getting my buttons to work right in flash cs4. is it possible to have a button gotoandplay a frame inside a different movieclip? if so how?
Possible Duplicate: currentFrame of root timeline from inside object In flash with as3.0, I have to call a function on the main stage from a movieClip I have this method in a frame on my scene:
[Code]...
and I would like to be able to call that method from within a movieClip, how do I point to the method?
I was wondering if it's possible to change the frame of a movieclip (present on the stage) by going on a certain frame or clicking a button in the main movie, if you get what I mean. Let's just say I want to go to frame 2 in movieclip "Symbol". Also, would it be possible to do the opposite and go to a frame in the main movie from a movieclip?
Previously it was put as keepLevel1(event.target) at each seperate function. Now I would like to make it frun the functions after an object is successfully loaded. How should I change the (event.target) to?
ActionScript Code: private function startSearch(event:MouseEvent):void { var loadID:String; loadID=searchArea.text; myLoader2.load(new URLRequest("GetData.aspx?id="+loadID)); myLoader2.addEventListener(Event.COMPLETE,processXML2); [Code] .....
I've got a question about the path of the txt fileI can easily load a txt file in a movie if the txt is in the same folder as de .swf, but when i try to load a txt file from a different levelfor Example projects/com/1.txt i dïn't see any txtthe code is:loadVariablesNum(projects/com/1.txt,0) i know the code is wrong, but can somebody tell me what i have to do to get a txt form a different level.
im attempting to build my first site in flash, and it was all going ok till i decided to get clever!I did have snippets of a.s everywhere, but have been trying to move it all back to frame1 on the main timeline (issat best practice?)the problem im having is that a simple piece of code on a nav button just wont work.when the code was within the same movie as the button it was easy:
I've been working on a new issue while giving a break on cracking the other one.I have a movie clip acting as a button with rollover/rollout animation- we'll call it menu_mc for simple reference.I'm basically creating a rollover submenu. I've set it up a few different ways but the most user friendly has been hiding the submenu_mc (which has 4 linked buttons to root frame inside) by doing:_root.sub5_mc._visible = false;then inside the menu_mc with the rollover I have the submenu trigger set to show: _root.sub5_mc._visible = true;The links are working fine but the problem I am running into, is that the rollover state, once over the submenu_mc, does the rollout function and leaves the submenu_mc hanging there by itself- still functioning perfectly.You can go back over the menu_mc and it will play out the rollover again.On the other simple animated buttons (which do not have submenus) I have coded:
I have several website pages set up on different frames inside the content (which is a movieclip) of the home page - which is on frame 1 of the main timeline. The content movieclip name is contentMc.
My About page is at frame 10. There is a button on this page (called btnAbout_contactpg) that I want to make jump to my Contact page (frame 50) - all of which is nested under the main contentMc movieclip.
This is the pathway on my contentMc (where all of my pages are located), just in case that doesn't make sense: [URL]
I have looked at several different instructions online, but none of them seem to work.
EDIT:
I am also trying to get a button on my gallery page to load an external image, but it is not recognizing where the button is either:
btnGallery_1.addEventListener (MouseEvent.CLICK, showPic1); function showPic1 (e:MouseEvent) { var target:Object=e.target; var parent=target.parent; my_loader.load(new URLRequest("image-0.jpg")); }