ActionScript 2.0 :: Flash8 - Passing MC Coordinates To A Function Within A Class
Jul 21, 2009
I have a class named Test in Test.as file :
Code:
class Test{
public function set movePlayer(_Playah:MovieClip):Void {
trace(_Playah._x);
[Code]....
and when I "run" this function in my .fla file, its says "undefined" (for this position) how to "pass" MC informations to a function inside a class (x,y coordinates, rotation..) although when I trace only "_Playah" it shows the correct name of MC i've passed to it.
View 2 Replies
Similar Posts:
Apr 27, 2011
I keep getting this error #2007 i want to parse the stage and pass a bullet object to a class function that function is called every ENTER_FRAME in the class itself
because the bullet object is added to the stage and on the bullet, there is a event listener to call a function in a class every ENTER_FRAME
but now i want to delete this bullet as it leaves the screen on the top because bullets in this game can only fly upward.
this is some of the code so far in the class itself:
ActionScript Code:
package classes {
import flash.media.Sound;
[Code].....
View 5 Replies
Feb 8, 2006
when I have access to my variables. I have the the follow code:
class Slider {
var myVar = 4;
function Slider () {[code]....
The slider function is being called first to update the myVar value then the findValue function is called. How do I get the find Value function to output 6 ? I want a function that updates the main classes' variable so thet I can use it from any function.
View 1 Replies
Jan 31, 2008
I am wanted to know how can i pass a parameter to the function which I'm calling using Delegate class. I know to pass params having static values such as true / false or a static string "hello".
Code:
var myFunc:Function = btn.onRelease = Delegate.create(tihs, releaseHandler);
myFunc.str = "hello";
function releaseHandler()
[code]....
Here str can be retrieved as 'arguments.caller.str' inside the function.But in case i want to pass the reference of the 'btn' button. Then how can i do this ?
View 3 Replies
Sep 8, 2009
I saw a post that touched on this, but I thought it deserved a thread of its own for explicit verification. It seemed that some of the resident geniuses here had given the thumbs-up to passing your whole doc or app class to a function. Please correct me if I'm wrong, as this sounds convenient but I assumed it would cause heart attacks and CPU meltdowns.
EXAMPLE: Say I have an app class that controls my entire game (or slideshow), and it has an ENTER_FRAME scrolling function that's 50 lines long with tons of conditionals so I want to take it out and make it an external file. I pop it into a new .as file but now all my variables are out of scope. I could pass them each individually, but there are so many it's impractical. So my question is: good or bad practice to pass the entire class?
[Code]...
View 4 Replies
Mar 25, 2010
I want to create a MovieClip, pass this MovieClip to a function in another class where it will be modified.The problem is, when I pass the MovieClip as a parameter to a function and start making changes, the changes are only made locally. The "copy" of the MovieClip inside the function gets changed, but the "real" MovieClip back in my main game class remains unchanged. Here's the code from my Main class:
Code:
var resourceLoader:ExternalResourceLoader = new ExternalResourceLoader();
var myMovieClip:MovieClip;[code].....
View 4 Replies
Jul 8, 2009
I am building a project where I have 15 'islands' inside one big 'ocean' movie clip. I created navigation buttons so you can explore the Ocean movie clip and look around the islands. my problem comes when i want to 'zoom into an island'
So basically on the stage i have a movie clip called- Ocean_mc, and inside it are 15 movie clips, one of them (for this example) is a movie clip called GreenIsland_mc.
when a user clicks the GreenIsland_mc it needs to expand and place itself centre stage, then when clicked again in needs to colaps back to where it came from. The problem is that when GreenIsland_mc expands it needs to expand to coordinates relative to the stage, but when I shrink it back again it need to find the original coordinates relative to its place inside the Ocean_mc movie clip.
[Code]...
View 1 Replies
Mar 3, 2009
Ive got a script lined up:
Code:
onEnterFrame = function(){
if(aktiverPublisering == "true"){
function avpubliser(){
[code]....
Ive checked if "aktiverPublisering" traces "true", and it does (it declares "true" through a button)... So, here's the weird part...i cant get a trace inside the IF statement i.e. its not working...
View 2 Replies
Mar 12, 2009
So I have a laser game I'm working on and I have a setInterval set up for when the laser button is pressed that it shows the laser for a little bit before removing the incoming asteroid and hiding the laser. I have a four of these buttons each with different colored lasers. So I thought it would be easy to pass the movie clip in through the function, cause I've done that with regular functions. Problem is, I don't know how to do that with a setInterval function. The way I have it set up shows the lasers then crashes and just shows a blank screen. Here is a bit of my code:
Code:
function laserMultiFire(laser:MovieClip) {
if(astroid == true){
_root[laser + "L"]._visible = true;
[code]....
The btnMulti is one of the buttons, and there are three movie clips that represent the lasers, the ones I'm trying to show and hide here are mcLaserMulti, mcLaserMultiL, and mcLaserMultiR.
View 1 Replies
Jan 7, 2007
how to pass variables from a parent swf to a child swf loaded into a movieclip container within the parent swf.
View 6 Replies
Jan 24, 2010
Basically, I wanted to 'save' the time thats been recorded in each of the 5 'games', so at the end there is a 'scores' page, with your times for each of the games.
I have managed to get the timer working for the games itself, but cannot find / work a method which saves them to the last frame?
I thought possibly converting the 'elapsed_time' into a different var (t1,t2 etc..) for each of the games? - doesn't seem to work timer_not_saving.fla
View 1 Replies
May 21, 2010
I've made a XML based Mp3 player using Flash 8 and AS2. The player is working just fine, I mean playing song on previous and next button. Now I want to enlarge this and my idea is to list all the mp3s on a PhP page and allow user to listen to any song randomly. This means, user can click any song name and that song will start playing in the player.
My problem over here is; the song listing and the player will be on one single page and clicking on any song wont reload that page to play the selected song but just reload the content of the mp3 player.
I know this can be done in Javascript. My thought on this is:
On clicking each song name, I need to call a JS function and pass to it the "ID" of the song. This JS function needs to pass "that ID" to the swf which will play the song.
Keeping aside the complexity involve in ActionScript to fetch the song name as per the passed ID, I need to know how to pass this ID from JS to AS
View 1 Replies
Apr 21, 2010
How do I execute callback functions dynamically by passing a function in as an argument to another function?
Look at this example:
Code:
package {
public class myClass extends MovieClip {
public function myClass(callback) {
[code]....
View 2 Replies
Oct 12, 2010
i have a movie clip which is exported for ActionScript , i want to get a variable from the document class into the movie clip class i tried this but there was an error !!
ActionScript Code:
var main:Main=new Main();
main.txtScore.text="hello";
View 1 Replies
Jul 7, 2009
I have a simple game that allows the player to drag counters around a board (just a background image).There are 23 counters created in the main .as class by calling another class, called "Units.as". The counters are added into an array in the main class like this:counterarray[0] = new Units("1",2);(where "1" and 2 define the label and colour of the counter)I do this for all 23 counters.[code]The class Units.as defines the counters as rectangles and places mouse listeners so they can be dragged around.My problem: I want to save the information about the counters to a shared object, but if you move a counter around, the counterarray[0].x and .y remain stubbornly where I originally set them - as 100 and 50.
I tried passing the x and y co-ordinates to Units (e.g. counterarray[0] = new Units("1",2,100,50); ) but while this works for placing the units, the value of counterarray[0].x is now zero and doesn't change when the counter is dragged around.I've only been using AS3 for a couple of weeks so suspect I am missing something obvious, but I've spent the last couple of days searching the internet & can't find it.
View 5 Replies
Mar 1, 2011
I created a movieclip with a star. Then, I creates a document class and I named it as Main.as.
In that document class I wrote:
package
{
import flash.display.*;
public class Main extends MovieClip
[Code]....
I´m not posting here all the code, but you can easily see that I´m using x_origin and y_origin variables to keep the original position of the movie clip. I will use them to move the star back to the original position.
The problem is that instead of being 20 and 30 respectively, tracing them I see that they are both ZERO. So when I drop the star, instead of going to x=20,y=30 it moves back to x=0 and y=0. I´ve to get the star position relative to stage, but I can´t find anyway!
View 4 Replies
Dec 28, 2009
I'm trying to create a class which will create a tween for several different instances of an object. I am creating the instances in the Document Class. The trick is, I would like to specify how long each tween will take.
Here's what I have so far:
DOCUMENT CLASS
ActionScript Code:
package {
import flash.display.MovieClip;
import mcCloud;
[Code].....
As you can see, I have a variable "myTime" which syncs the timer and the tween. This causes to tween to repeat and the clouds to continually scroll across the stage. How can I determine the var myTime at the time I create each instance of the Movie Clip mcCloud?
View 6 Replies
Sep 16, 2009
I need to pass a variable to a function inside a function. However this parameter (i) seems not to be passed (to function ...onRollOver). This is required to attach a textfield to a movieclip (reading the adress and showing it as a tooltip).
ActionScript Code:
for (i=0; i<array_BE_ElecCities.length; i++) {
var attachElecCity = mc_map.mc_places.attachMovie("Plant",
[code].....
View 1 Replies
Aug 6, 2009
I've got a document class (EgoGame.as) and another class (Ball.as) which has been duplicated to deal with several different video pieces. Inside the document class is a list of 'if' statements which decide which video should be played. At the moment I'm doing it the old fashioned way whereby if the condition is true....it tells the relevant Ball class to gotoAndPlay a certain frame within the linked movieclip...
[Code]...
View 1 Replies
Dec 15, 2009
how do use a function from a doc class.... to call a function to work on in
[Code]...
View 2 Replies
Oct 2, 2009
The order of events are this. From the main stage I load a movie clip (movie clip 1), within that movie clip I have a button that loads another movie clip (movie clip 2) and also starts a timer that will automatically unload movie clip 2 . Within movie clip 2 I would like to create a button that stops the timer on movie clip 1 and starts it again.
I need to stop a function in movie clip 1 from movie clip 2 and then start that same function on movie clip 1 from movie clip 2.
This is the code I am using
This is the movie clip 1 code:
PHP Code:
function moreTimerFun(moreTime) {
this.onEnterFrame = function() {
if ((getTimer()/1000)-moreTime>7) {
delete this.onEnterFrame;
[Code].....
View 3 Replies
Oct 6, 2009
I really just want to know how to trigger a function when my movie hits a certain frame.
I made a very simple flash show to try to illustrate my problem a little more clearly. I have a green and a gray button. Using the 'switch_buttons' command I turned the gray button invisible at the beginning. What I then want to happen is that on the 10th frame the green button will become invisible and the gray button will appear. But I haven't had any luck. It seems like I need to call a function to switch the buttons somehow.
View 3 Replies
Dec 19, 2011
I was trying to convert global coordinates to local coordinates of a UIComplenent in my flex project using below code using below code
var gp:Point = new Point(e.stageX,e.stageY); //global point
var lp:Point = uic.globalToLocal(gp); //local point
uic is UIComponent in which I have subclass of Sprite for drawing something I have set the sprite's mouseEnabled and mouseChildren to false to not interrupt the mouse event. above code is within uic's mousemove event where I was tracing the gp and lp gp was giving correct value and suprisingly lp was giving negetive values. when I move the move to the top left corner of uic i expect lp to be 0,0 but it is giving the -width of of uic. I broke my head for hours and ended up finding an alternate by using offsets. Infact my original code was much simpler like this which was same issue
var lp:Point = new Point(e.localX,e.localY);
I am not sure what exactly is causing this problem. the workaround had lot of issues and it creating a mess in my rest of the algorithms.Just now I found even more interesting thing (which is actually weird). for some reason I went and create a new lp2
var lp2:Point = new Point(e.localX,e.localY);
now surprisingly it was giving correct values as expected and I went back and changed the code as
var gp:Point = new Point(e.stageX,e.stageY); //global point
var lp:Point = uic.globalToLocal(gp); //local point
var lp2:Point = new Point(e.localX,e.localY);
var lp2:Point = uic.globalToLocal(gp);
now it is expected to have all the lp, lp2 and lp3 variables to be same but weiredly lp two is giving wrong value and lp2 and lp3 were giving correct. I am suspecting using the variable lp has something to do. I am not sure about that but above proves it so right now I am using lp2.
View 1 Replies
May 21, 2007
I was reading the 'Isometric Transformations' tutorial by Danko Kozar and I have a few questions. I understand what all the code does, but not how it does it. First of all, how does the following code work:
transforms x,y,z coordinates into Flash x coordinate
xFla = function (x, y, z) {
// cartesian coordinates[code].....
I understand that it converts 3d coordinates to 2d coordinates, but I don't understand how. What numbers whould be punched into x, y, and z to acquire certain desired effects?Also, what's the difference between moveTo and lineTo:
red line
style(1, "0xFF0000", 100);
plot(0, 0, 0);
draw(200, 0, 0);
View 4 Replies
Mar 5, 2009
i have a movieclip on the main timeline, and inside that mc I have 1 button on first frame and 1 button of second frame...From the main timeline i run this script for frame 1 button...
publisering2.avpubliser_btn.onRelease = function(){
publisering2.gotoAndStop(2);
}
And this works fine.. however, i run the exact same script for the button on frame 2, ofcourse changing the path and gotoAndStop(1) instead... And this isnt working.. The button's over frame works so its activated...
View 3 Replies
Apr 14, 2009
Right now, I have a gallery with many different thumbnails each individual movie clip symbols and not button symbols and each movie clip has a rollover and rollout function assigned to them which are all basically the same for each thumbnail.
Following is an example from a small section of the gallery thumbnails.
web04.btn04.onRollOver = function() {
this.gotoAndPlay(2);
};
web04.btn04.onRollOut = function() {
[Code]....
The above shows two groups of thumbnails grouped into individual movie clips (web01, web02, web03) each movie clip containing 3 thumbnails (btn04, sub04_1, sub04_2). I had done it this way for grouping and ease of animation.
I was wondering if it was possible to create just one function which executes the rollover and rollout functions so the script window would not be filled with so much repeated script.
View 1 Replies
Sep 11, 2010
I have a function in a mc and I want to use it in another mc.
But I does not seem to call it.
I guess I can make the function global in some way, or?
View 1 Replies
Sep 27, 2006
I have the following code that lists 5 buttons with dynamic texts... when pressing each button a popUp_mc window will appear with some content show in dynamic text. Only one of these 5 buttons have some images that will have symbols_mc appear... in this case I just alpha this symbol to 100 only for this button, but for the rest alpha = 0. The button the I want to show the symbol is the third one. I'm a bit confused on how to show this symbol according to the following code below.
[Code]....
View 7 Replies
May 3, 2010
Im making a little app in flash using papervision I want to make a regular movieClip show up in the same place as a papervision object. The coordinates seem like perspective is affecting the number displayed.
View 2 Replies
Mar 14, 2009
The problem: combining onRelease or onRollOut in a single function.
It goes something like this:
button.onRelease , button.onRollOut = function() {
// do whatever
}
View 1 Replies