Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash








[F8] Call Function In A Class From LoadVars


I need to call a function defined inside a class i´ve created, but the function must be called from an loadVars.onLoad(success) object nested inside another function of the same class.

The problem is i can´t use the absolute path from the _root since i use more than one instance of the class.

Using _parent won´t work even if i try to do this:
loadVarsName._parent = this;
This statement works when the loadVars is not inside a class, but when i put it inside my class it stops working.

here is the code on my example.as file.

class example extends MovieClip {
}
public function callNewFunction() {
trace ("function called");
}
public function loadArds() {
var loadedTxt:LoadVars = new LoadVars();
loadedTxt.load("file.txt");
loadedTxt.onLoad = function(success) {
if (success) {
callNewFunction(); //here is my problem!!! no relative path can get me there.
}
}
}
}
//End Class


please help!!!!!!!!!! Thanks!




FlashKit > Flash Help > Flash ActionScript
Posted on: 07-27-2006, 08:23 PM


View Complete Forum Thread with Replies

Sponsored Links:

Call Function In A Class From LoadVars With Relative Path Needed. Please Help
Hi all, i´m new here. I´ve been searching an answer to my problem but haven´t found it yet. If someone can help, i´ll be really grateful!

I need to call a function defined inside a class i´ve created, but the function must be called from an loadVars.onLoad(success) object nested inside another function from the same class.

The problem is i can´t use the absolute path from the _root since i use more than one instance of the class.

Using _parent won´t work even if i try to do this:
loadVarsName._parent = this;
This statement works when the loadVars is not inside a class, but when i put it inside my class it stops working.

here is the code on my example.as file.

class example extends MovieClip {
}
public function callNewFunction() {
trace ("function called");
}
public function loadArds() {
var loadedTxt:LoadVars = new LoadVars();
loadedTxt.load("file.txt");
loadedTxt.onLoad = function(success) {
if (success) {
callNewFunction(); //here is my problem!!! no relative path can get me there.
}
}
}
}
//End Class


please help!!!!!!!!!! Thanks!

View Replies !    View Related
Call Function Of Document Class From MovieClip Class
How can I run a function of the main document class from a class of a MovieClip? I usually just used MovieClip(parent).function(), but now my MovieClip has another parent. Or what do I have to pass to the MovieClip class when creating the MovieClip to acess the main document class?

View Replies !    View Related
Call Function In Parent Class From Child Class
Right, so I have a main Document class called Bundl where I'm loading all my other classes (navigation, portfolio, ...). What I'm trying to accomplish is to call a function inside my main Bundl class from a click from the navigation class.

The situation in code:
The Bundl Class (located in the root folder)

Code:
package {
import be.bundl.Navigation;

public class Bundl extends Sprite {
//vars called here

public function Bundl() {
nav=new Navigation("xml/navigation.xml");
addChild(nav);
}
//some more irrelevant functions here

//the function I need to call from the Navigation Class
public function portfolioXML(newXML:String):void {
portfolio=new Portfolio(newXML);
contentContainer.addChild(portfolio);
}
}
}
The code from Navigation class (located in /be/bundl)

Code:
//inside the btnClick function
var test:Bundl = new Bundl();
test.portfolioXML(_someVar)
Which results in an :
Error: Error #2136: The SWF file file:///Macintosh%20HD/Users/cerbellum/Projects/Bundl/site/FINAL/FULL.swf contains invalid data.at be.bundl::Navigation/btnClick()

I'm guessing this is due to the fact that I'm calling the parent class in a child or something like that, but how do I get this done otherwise? I must totally be overlooking something here.

Thanks in advance,
Kevin

View Replies !    View Related
Can't Call My Function From Another Class?
Hi everybody,

I'm working on a flash site and after the intro a button shows up (I made a class for it). In the class I have a function that needs to tell the movie to go on, when the button is released..

The button workes fine, but on release I'd like to call a function thats in my document class. I tried using parent and traced it and stuff, when I trace it, it says it traces the 'unight' object like I called my document class.

But when I export the movie it keeps telling me its a call to a possibly undefined method.

I'm importing the unight class like this: ' import unight.* ';
When I trie to import the function like: ' import unight.removeLogo ';
it gives lots of more errors..

I'm a beginner and very stuck here, I think it's something I dont know about?

Are a method and a function the same, cause I don't know anymore now?

Thank you for your help!

View Replies !    View Related
Call A Function From Another Class
I havent yet tried to call functions from other classes.

Lets say i have a class1 with function called makeBackground()

In class2 i want to call that function how do i do that without caling my constructor.

I have tried the following without any luck.


Code:
var _class1:class1 = new class1()
_class1.makeBackground();
And then at the top.


Code:
private var _class1:class1;

View Replies !    View Related
Call A Function In Another Class
Hey I just threw myself into the as3 fire this past monday on a project at work, not only that but I decided to be cool and use classes, which I have only a small amount of experience with, anyways, I couldn't really find an answer to my question so hopefully some kind soul could help me out.

basically, I want to call a function that is in an external class:

so I have my main class which is good, but then I want to call a function in another class, in as2 you'd do it like this foldername.foldername.asfile.functionname, but it doesn't seem to want to work in as3.

any thoughts?

View Replies !    View Related
Call A Function From Document Class?
I have an actions frame inside a MovieClip that features an event listener which triggers a function. The problem is, I'd like the function to live in the main document class.

How do I access this function?

View Replies !    View Related
[AS3]Call Function Outside Of A Class File
hello there,

I like to call a function that is outside of the class file.

for example

main.fla

Code:
function callmepls(){
trace("yes");
}
Calling.as

Code:
package{
public class Calling{
callmepls();
public function Calling(){
}
}
}

View Replies !    View Related
Class: Can't Call A Function Using OnPress()
Can someone please tell me how I can create a Class that uses a for loop to create buttons. What I have noticed is that when the user presses a button, it can not call functions or call variables outside the onPress().

Here is a sample of my code:
__________________________________________________ ____________

class garClass {
var some_var:String = "blah"
function garClass() {
}
function createDD(lev) {
for (var i:Number = 0; i<3; i++) {
trace(i);
var dd:MovieClip = lev.attachMovie("mcID", "mc"+i, i, {_x:50, _y:75*i});
dd.onPress = function() {
this.startDrag(false);
////////////////////////////////////////////////////////////////////////////////
// Why can't I call a function while inside a button function?????
///////////////////////////////////////////////////////////////////////////////
call_some_function();
////////////////////////////////////////////////////////////////////////////////
// Why can't I call this variable
///////////////////////////////////////////////////////////////////////////////
trace("var = "+some_var);
};
dd.onRelease = function() {
this.stopDrag();
};
}
}
function call_some_function() {
trace("I'm waiting");
}
}

View Replies !    View Related
Best Way To Call A Function On The Root From A Class
Hi!
i'm new to this forum and i've a question.

I'm building a navigation menu in an application and each menu item is an object of a class i've defined (navigationItem).
When the user clicks on the navigationItem, there's an eventHandler which calls a method inside the package.

From this i'd like to call a function that's in the root of the movie.
I would like to know what's the best and more correct way to do this.

Maybe something like:

ActionScript Code:
private function navigateFromMainMenu(event:MouseEvent):void {
          MovieClip(root).functionToBeCalledOnTheRoot(parameters);
}

..but i'm not sure that's the best way to use MovieClip(root)
Thanks in advance
ciao
g

View Replies !    View Related
Class Constructor Won't Call Function
Hello,

I attached a pared down version of my .as file, which is imported into my flash (.fla) file. I can't seem to call the initCircularArray function from my class constructor. The trace function in the initCircularArray never gets called, and the onLoad(success) trace returns 'true'. Any idea what I might be doing wrong?

Thanks,
Dave









Attach Code

class CircularArray {
var circularArray:Array = new Array();
public function CircularArray(inXML:String) {
var newXML = new XML(); //the XML file
newXML.load(inXML);
newXML.ignoreWhite = true;
newXML.onLoad = function(success:Boolean) {
if(success) {
trace("XML loaded: " + success);
initCircularArray(newXML);
}
}
}
public function initCircularArray(newXML:XML) {
trace("

GOT HERE

");
}
}

View Replies !    View Related
How To Call A Function Inside A Class?
Hello, i am trying to fire a function onPress .. this function is inside a class.
In this function i refer to another function inside the calss to call a Tween. It never arrives in the second function.

I tried to make an example.

In the fla file i have:
var test:makeMovie = new makeMovie(this);


You will see a red squere and you can press on it. It should run the tween class. Am i using the delegate class wrong?









Attach Code

import mx.transitions.Tween;
import mx.transitions.easing.*;
import mx.utils.Delegate;


class makeMovie extends MovieClip {

private var parentMc:MovieClip;
private var Container:MovieClip;


function makeMovie(parentMc:MovieClip) {
this.parentMc = parentMc;
makeSquare();
}

private function makeSquare() {
var Container:MovieClip = parentMc.createEmptyMovieClip("container_MC", parentMc.getNextHighestDepth());
Container.beginFill(0xFF0000);
Container.moveTo(0,0);
Container.lineTo(200,0);
Container.lineTo(200,200);
Container.lineTo(0,200);
Container.lineTo(0,0);
Container.endFill();
Container.onPress = setAlpha;
}


private function setAlpha() {
trace("init this?");
Delegate.create(this,setTween);

}

private function setTween() {
trace("tween");
var alphaTween:Tween = new Tween(Container, "_alpha", Strong.easeOut, 0, 100, 2, true);

}
}

View Replies !    View Related
Call Function Inside A Class
Hello.

I've got some problems trying to call a function inside a mc in a class.

For example:


Code:
class Foo {
private my_mc:MovieClip;
private my_mc2:MovieClip;

public function Foo(mc:MovieClip, mc2:MovieClip) {
my_mc = mc; // call the class, passing as parameter a movie clip
my_mc2 = mc2;

applyAS();
}

public function applyAS():Void {
getMC2Height(); // Here the trace output prints the my_mc2._height
my_mc.onEnterFrame = function():Void {
getMC2Height(); // Here, doesnt =/
}
}

public function getMC2Height():Void {
trace(my_mc2._height);
}
}
I didnt have such experience on AS2 OOP, but this is make me real crazy... Any suggestions about the class are welcome too.

View Replies !    View Related
[AS2] Is It Possible The Class Can Call The Function That In The Timeline?
Is it possible the class can call the function that in the timeline?

coz I want to use freetransform actionscript to apply "myMovie" class function ....
but the error msg: **Error** There is no method with the name 'addFreeTransform'.

Thanks for help...

in myMovie.as

Code:
class myMovie extends MovieClip{

static var EmptyMovieNum:Number=0;

function EmptyMovie()
{
EmptyMovieNum++;
}

static function getMovieNum():Number
{
var A:Number = EmptyMovieNum;
return A;
}

static function setMovieNum(A:Number)
{
EmptyMovieNum = A;
}

function onPress():Void
{
this.addFreeTransform(mystyle);
}
in my FLA file, same as http://www.senocular.com/flash/actio...eeTransform.as

Code:
FreeTransformStyle = function(linestyle, fillstyle, layout, autoRaise, autoRemove, sizeRestrict){
if (linestyle != undefined) this.linestyle = linestyle;
if (fillstyle != undefined) this.fillstyle = fillstyle;
if (layout != undefined) this.layout = layout;
if (autoRaise != undefined) this.autoRaise = autoRaise;
if (autoRemove != undefined) this.autoRemove = autoRemove;
if (sizeRestrict != undefined) this.sizeRestrict = sizeRestrict;
this._freetransforms = [];
this._arms = [];
return this;
}
FreeTransformStyle.prototype.linestyle = [0,0x000000,100];

....
(skip)
....

MovieClip.prototype.addFreeTransform = function(style){
if (this._FTobject) this.removeFreeTransform();
this._FTobject = new FreeTransform(this,style);
}

View Replies !    View Related
Using OnKeyDown Within A Class To Call A Function
Hello, I'm having a bit of trouble with some of the functions in a class I am making. I want to see if a button was pressed, then change some variables, and finally call the update function. My problem is that I cannot call the function updateit() once a key has been pressed. Any help would be greatly appreciated. Here's the simplified code:

public function updateit():Void{
trace("updateit worked");
}

public function navigate():Void {
var myListener = new Object();
myListener.onKeyDown = function() {
if (Key.isDown(Key.RIGHT)) {
//change some variables
trace("right");
updateit();
}
if (Key.isDown(Key.LEFT)) {
//change some variables
trace("left");
updateit();
}
if (Key.isDown(Key.UP)) {
//change some variables
trace("up");
updateit();
}
if (Key.isDown(Key.DOWN)) {
//change some variables
trace("down");
updateit();
}
};
Key.addListener(myListener);
}

Thanks for taking a look at it for me.

View Replies !    View Related
Call A Function From The Main Stage From A Class
hello

is there a way i can call a function from the main stage from a class

what i have is a file loading that has text in a external class what i am trying to do is load is tell the main stage that the file has loaded

View Replies !    View Related
Cannot Call Function Within Same Class - Newbie @ Flash
Hi to all ,

I m a new member to Actionscript.org. I have been working to create a flash site to display pictures. However, I run into a problem that I could not understand at all. The following is the code of a class in my program. What this piece of code is trying to do is to load an xml file and then store the data into an array. After the xml is loaded (line marked *), the function initAlbumList is called. However, it seems that the program never enter the function ("in AlbumList" is never printed) and only "after AlbumList" is printed in the output console. I could not understand why is this


class IndexPanel extends MovieClip
{
private var albArr : Array;
private var root : Object;

public function loadAlbum(path) : Void
{
var alb_xml = new XML();
alb_xml.ignoreWhite = true;
alb_xml.load(path);

alb_xml.onLoad = function(succes)
{
* if (succes)
{
root = this.firstChild;
trace("XML file loaded Index");
initAlbumList();
trace("after initAlbumList");

} else
{
trace("Error loading XML document Index");
}
}
}

private function initAlbumList() : Void
{
trace("in initAlbumList");
var idxInfo = root.childNodes[0];
:
}
}

View Replies !    View Related
Getting A Class To Call A Function On The Main Timeline
Is there anyway to get an object created from a class to call a function on the main timeline? ie

main:

Code:
function tester(objectHandle:MyClass){
trace(objectHandle);
}
class:

Code:
mysterykeywordtoaccessmain.tester(this);
This possible even? Im trying to massively shortcut a destruction function by passing the stage a reference to the object which is then removed and set to null so in a sense destroying itself but from the stage.

View Replies !    View Related
Best Practice To Call A Function From A Parent Class
Hi there I have a topic, would love to hear some discussion:

Currently this is how I reference vars/instances from a parent class by using a static function and I wonder if there is a better way to do it.

I have a main document class Main.as with a public static function called mainFunction().

ActionScript Code:
public static function mainFunction( _mc:MovieClip, _nVar:Number ):void
{
               
    // do something
    _mc.someBtnOnMainStage_btn.somevar = _nVar; 

}

I have a movieclip on the stage called someClip_mc with linkage to its own class called SomeClip.as. At the top of this class I import the document class. Then I call the mainFunction() like so:

ActionScript Code:
import Main;

Main.mainFunction( MovieClip(this.parent), someVariableFromThisClass );

This can be tricky if the static function has many variables from its own class. Any thoughts?

Thanks
//

View Replies !    View Related
How To Call Function On Class Event Handler
Hi friends..i have simple question about how to call a function on a class but i dont know how to do it, would you mind to help me,please.
I have a class :


Code:

class MyClass{
private var lvSendState:LoadVars;
private var lvLoadState:LoadVars;

public function Test(){
trace("function Test Run");
}

public function LoadSomeThing():Void{
lvSend=new LoadVars();
lvLoad=new LoadVars();
lvSend.sendAndLoad("some url", lvLoad);
lvLoad.onLoad = function(){
//try to call function Test
Test(); //This is doesn't work
}
}
}
I try to call function Test on lvLoad.onload but i doesn't work,does any body tell me how to call it ? thanks in advance

View Replies !    View Related
Call Stage Level Function From Class
I have a external class that extends SimpleButton, I've been trying to call both functions and set the properties of objects on the maintimeline of the fla.

I've tried passing in the stage object to the class constructor, tried calling this.parent from the class etc but still can't get it to work.. where am I going wrong?

thanks.

View Replies !    View Related
Call A Dynamic Function From Within A Custom Class
Hello All

i have created a class that so far works great.

what i need to do is get that class to accept a function as one of its parameters.

so for example:

example.getClass(function_name);

and when the class is finshed to use the passed function name to call a internal function in the flash movie

I don't even know where to begin or what its called to even do a search on it.

any help or pointers would be greatly appreciated

View Replies !    View Related
LoadVars .onload Function & Class Properties
I am using a LoadVars() object inside a class. It's loading an external text file, and all is working in that regard. Here's part of the code that checks when the text file has been loaded; I named the loadvars object "load_info":
- - - - - - - - - - - - - - - - - - - - - - - - - - -
load_info.onLoad = function(true) {
if (true) {
...bunch of statements...
}
}
- - - - - - - - - - - - - - - - - - - - - - - - - - -
But within the above function literal I need to be able to reference and set some of the properties of the class, and my first mistake was assuming using 'this' would do so, but it would be referencing the function object, and not the class object, as I soon found out.

I have looked at other ways of doing the onLoad-true-checking function, but I'm still at a loss.

(I also tried the dumb solution of creating new _root variables as means to transfer back and forth the class property values--it doesn't seem to work for what I'm doing... the problem being that there are many instances of the class object setting the same _root variable)

Thanks.

View Replies !    View Related
[F8] How Do You Call A Function In A Function In A Class?
I have this class..

class Bob {
function Bob(){
initiate code
}

function loadImages(){
Load images code...
image.onEnterFrame = function(){
if loaded {
this.nextFunction();
}
}
}

function nextFunction(){
do this
}
}


basically, i have a function that loads images.. and i need to have it automatically do another function in that class once the images are loaded..

how do i wait til they're loaded in the class? cause if i put it in "onEnterFrame" , 'this' no longer refers to the class, it refers to the onEnterFrame..

so how do i refer back to the class?
or how do i determine if the images are loaded all in the one class?

View Replies !    View Related
Call Function From A Function In A Class?
i havee..

class testClass
{

function testClass()
{
giveFunctions(mc1);
}

function traceIt(tag)
{
trace(tag);
}

function giveFunctions(mc:MovieClip)
{
mc.onRollOver = function()
{
traceIt("SUP");
}
}

}



How do i make the giveFunctions function access the class?

cause it defines a rollover function for an MC.. but in that rollover function, it has to re-reference a different function in the class..

how does that work?

there'll be more variables and it'll be more complex..



I had like,

function giveFunction(mc:MovieClip,tag)
{
mc.sett = this.traceIt;
mc.mca = mc;
mc.tag = tag;

mc.onRollOver = function()
{
this.sett(this.mca,this.tag);
}
}




that works, but it like.. pulls the traceIt function out of the class so it couldn't reference any other variables if it needed to

View Replies !    View Related
How To Call A JavaScript Function Using The Flash.external.ExternalInterface; Class
Hi

Could someone please tell me the proper syntax to use to call
a JavaScript function called "refresh()" from my Flash movie using
the import flash.external.ExternalInterface; class

This is the function I want to call.
The function is designed to refresh the webpge containing my Flash movie.


Code:
<script language="JavaScript">
<!--

var sURL = unescape(window.location.pathname);

function refresh()
{
window.location.href = sURL;
}
//-->
</script>

<script language="JavaScript1.1">
<!--
function refresh()
{
window.location.replace( sURL );
}
//-->
</script>

<script language="JavaScript1.2">
<!--
function refresh()
{
window.location.reload( false );
}
//-->
</script>
</head>

<body>

<script language="JavaScript">
<!--
// we put this here so we can see something change
document.write('<b>' + (new Date).toLocaleString() + '</b>');
//-->
</script>

View Replies !    View Related
Call Function, Pass Value, Access Variable In Movieclip Class From Main Stage
i am new to flash as.
I got quite confused on some problems. as the function here is quite different from c and asp.net.

I have a movieClip named MC, and it's enabled with action script, with the class name MC_Rectangle
and a Stage.


I override the MC_Rectangle class file in a mc_rectangle.as external file.
here is the code:

package{
import flash.display.*;
import flash.events.*;

public class MC_Rectangle extends MovieClip {
var sequence:int = new int();

function setSequence(data:int):void{
sequence = data;
...
}

function addSequence():void{
sequence ++;
...
}

...
}
}


I have new a object in the main stage var mc_rect:MC_Rectangle = new MC_Rectangle()
question:
in main stage:
1. how can i access the variable "sequence" in "mc_rect"
2. how can i pass parametre from main stage to mc_rect via function setSequence(data:int)?
3. how can i call the function in addSequence() in mc_rect.

in asp.net, i usually use mc_rect.sequenct, mc_rect.setSequence(data), mc_rect.addSequence() to achieve my goals......

btw, can function in mc_rect return out result to main stage?

thanks in advance.

View Replies !    View Related
How To Call A Function First And Create A Delay And Call Another Function
Hi, I am new to actionscript. Is it possible for me to call a function first and call the second function after a short delay.

I try to use this codes. But it didnt work

function a(){
trace("A");
setInterval(b(), 1000);

}

function b(){
trace("b");
}

View Replies !    View Related
Can't Call Function Created Via Eval Using ExternalInterface.call
I have created a flash movie that acts as an MP3 player. Using ExternalInterface, I pass an array containing cue points in the song to the flash move so that it makes a callback to javascript when it hits certain points in the song. Since I want to deal with these callbacks differently for each song, I have made it so that I can dyanmically change the function that is called from Flash (to Javascript). Here is the code for that piece:

ExternalInterface.addCallback("setCuePointFunction ToCall", this, setCuePointFunctionToCall);

var cuePointFunctionToCall:String='';
var intCurrentCuePoint:Number=0;

function setCuePointFunctionToCall(strFunctionName){
_root.cuePointFunctionToCall=strFunctionName;
}

function reportToJavascript_CuePoint(intCuePointID:Number){
ExternalInterface.call(_root.cuePointFunctionToCal l, intCuePointID);
_root.intCurrentCuePoint++;
}

This works perfectly as long as the function that cuePointFunctionToCall refers to is defined in a script block on the HTML page. However, this project is an AJAX-style thing, and I need to be able to define the function that is triggered on a cue point in code that is dynamically executed at run-time via an "eval' call.

Here's the code that talks to actionscript. This appears in a script block on the main page (not via eval).

function setCuePointFunctionToCall(strFunctionName) {
thisMovie("PushPuppets_Media_Center").setCuePointF unctionToCall(strFunctionName);
//alert(strURL);
}

function thisMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}

Here's the code that is dyamically being executed via an eval statement in javascript:

setCuePointFunctionToCall("cuePointNew");

function cuePointNew(lngCuePointID) {
alert('New function, cue point: ' + lngCuePointID);
}

This does not work. But if I copy the above function block to the main page (not in the code that is executed via an eval) it does work. I am certain that setCuePointFunctionToCall is being executed properly via the eval - it is definitely changing the function that actionscript will call. This is apparent since it is calling the right function when the function is declared on the HTML page (not in the AJAX-style eval call). So I'm guessing that this has something to do with the scope in which eval operates.

I encountered a very similar problem when I tried redefining a function in the eval call that was already defined on the main page. It just didn't take.

Please let me know if you have any suggestions.

Thanks,

Erich

View Replies !    View Related
LoadVars()...how Do I Call Randomly?
As I mentioned before, I'm trying to switch over to loadVars instead of the now (apparently) outdated loadVariablesNum. However, I can't seem to figure out how to do something that is very easy with my loadVariablesNum.

I have a random facts section with a text file with 155 random science facts. For one thing, the new Math.random is no good for creating random variables...unless you want something between 0 and 1. Very annoying. So, good old random(0,topnumber) for me.

Anyway, the old code ran like this

Code:
function factreload() {
newfact = random(factsText.numFacts);
myFacts = eval("fact"+newfact+"txt");
}
and every time you press a button or call factreload, it would change the fact being displayed. Now, however, after having used the loadVars() tool, I can't seem to figure out how I call the various variables out of my newly created TextObject. Can anyone help? The text file is loaded into an object called factsHolder...

Code:
factsHolder = new loadVars();
factsHolder.load("facts.txt");
factsHolder.onLoad = function(success) {
};
Or do I have to stick with the loadVariablesNum? Does anyone know what can be done?

View Replies !    View Related
Call Class Getter & Setter From Another Class
I have 2 classes (triangle.as and circle.as) each of the classes draws a shape and another shape inside a movieclip which acts as a button.
Then from the document root (main.as) I create an instance of the triangle.as (tri) and the circle.as (cir) and add them to the displaylist.
when run displays a triangle + button and a circle + button on the stage.

The triangle class has getter and setter functions which are getValue & setValue.

when I call these getter and setter functions from main.as

tri.setValue = 100;
trace(tri.getValue);

everything works fine, but then when I try

tri.setValue = 100;
trace(tri.getValue);

from within the circle class the error says it doesn't recognize 'tri' which I can understand as it is referencing another class outside of the current class it is called in.

I did try....

parent.tri.setValue = 100;
trace(parent.tri.getValue);

but made no difference.

So the problem is how to reference a classes getter & setter functions from within another class.

Any help would be much appreciated. Thanks

View Replies !    View Related
Call Class Method Inside Another Class.
Hello, I have one class that creates another object from another custom class. Then it calls a method from the newly created class. I want this class to then call a parent's method after it's completed.

Something like this:

PHP Code:



//First Class
class FirstClass{
    function FirstClass(){
        var newClass:SecondClass = new SecondClass();
        newClass.doSometing();
    }
    public function doSomethingAfter():Void{
        // Do this after newClass.doSomethign is done
    }
}

// Second Class
class SecondClass{
    private var _mc:MovieClip;
    private var _incrVar:Number;
    function SecondClass(){
        _mc = _root.createEmptyMovieClip(...);
        _incVar = 0;
    }
    public function doSomthing():Void{
        _mc.onEnterFrame = function():Void{
            _incVar++;
            if(_incVar > 10){
                delete this.onEnterFrame;
                // This is where I would now like to call
                // a method of First Class.. but How?
            }
        }
    }





I know that I could pass the FirstClass object as a parameter to the SecondClass's doSomething function.. but I was wondering if there was another easier way I do not know about to call the parent or calling classes methods. Or maybe there is a way for FirstClass to detect when SecondClass is finished with what it must do before moving on without having to have SecondClass call a FirstClass method?

Thanks!

View Replies !    View Related
How Do I Call A Method Of The Document Class From Another Class?
I am creating instances of another class from inside my document class. I want these instances to communicate with the document class, how is this accomplished in AS3?

For example, the document class creates a series of boxes with something like:

var box = new Box();

The document class can now call methods of box with box.method(). The question is how can box call methods within the document class?

View Replies !    View Related
Call A Method In A Class That Instantiaded The Class You're In
ok, I have a document class called GameManager()

in GameManager(), I instantiate a class named Map()

in Map() I distribute tiles.

I want mouse events on these tiles to communicate with variables and methods in GameManager() ( and/or MAP() )

I'm having a brainFart on how to do this... any help?

thanx

View Replies !    View Related
Call A Function In A Duplicated Movie Clip Form Another Function : (
i have a movie clip on my root name "pl".
on command, it duplicates with instance name as "y0","y1", etc.

here is the method :

function callPL(transmit,receive,addy,level) {

var newName = "y"+_root.x;
duplicateMovieClip("_root.pl",newName,101);
_root[newName]._x = 400;
_root[newName]._y = 400;

_root.[newName].start(transmit,receive,addy,level); //look here
}


there i attempt to call a function of the newly duplicated clip call "start()".
Start() function is written on the first frame of the movieclip like this :


function start(a,b,address,level) {
a.sendAndLoad(address,b,"Post");

this.path = b;

b.onLoad=function(success) {
gotoAndPlay("start");
}
}


however it seems like the function callPL() could not invoke function start() of the new movieClip.I have no idea how is it so.
Even when i trigger it with a onLoad handler it still doesnt work
pls shed some light.

View Replies !    View Related
Calling Constructor In Condition: A Function Call On A Non-function Was Attempted.
Hi guys,

Please help me somebody with this cos I have really no idea. I have made a simply condition calling a constructor of a class. Today I had to add an "else if", what caused the compilator to show me "A function call on a non-function was attempted."...

ActionScript Code:
function loadIt() {    if (var1 == "1") {        var a:SomeClass = new SomeClass(true);    } else if(var2 == "1"){         var a:SomeClass = new SomeClass(false); //<- if this is not here, everything works fine    } else {        var b:SomeOtherClass = new SomeOtherClass();        b.init();    }}

Any ideas? Thanks for any help!

Poco

View Replies !    View Related
Filling Function Arguments With Array Items, Function.call()
HI!

I have this code but I cannot work out how to fill in function parameters based on an array and it's length, see line 7

ActionScript Code:
import com.robertpenner.easing.Cubic;MovieClip.prototype.framesTimeout = function(func:Function, frames:Number, args:Array) {    var t:Number = 0;    var mc:MovieClip = this.createEmptyMovieClip(String(new Date().getTime()), this.getNextHighestDepth());    mc.onEnterFrame = function() {        if (t == frames) {            func.call(this._parent,args);            delete this.onEnterFrame;            this.removeMovieClip();        } else {            t++;        }    };};MovieClip.prototype.movex = function(x:Number, frames:Number) {    trace(x+" "+frames)    delete this.movex.onEnterFrame;    this.movex.removeMovieClip();    if (!frames) {        frames = 20;    }    var t:Number = 0;    var sx:Number = this._x;    var ax:Number = x-this._x;    var mc:MovieClip = this.createEmptyMovieClip("movex", this.getNextHighestDepth());    mc.onEnterFrame = function() {        if (t == frames) {            delete this.onEnterFrame;            this.removeMovieClip();        } else {            t++;            this._parent._x = Cubic.easeOut(t, sx, ax, frames);        }    };};MovieClip.prototype.otherfunction = function(param1, param2, param3, param4){    trace(param1+" "+param2+" "+param3+" "+param4)}mc.framesTimeout(movex, 50, [100, 50]) mc.framesTimeout(otherfunction, 200, ["asd", 1, 2, 55])

Is it possible to call a function and fill in the parameters based on an array and it's lenth?

View Replies !    View Related
My Function Isn't Functioning/Actionscript To Call A Function Flash MX 2004
Hello,

Well in theory I know how to create a function but for some reason I am unable to call it.

Can someone take a look at it and tell me what went wrong. Basically when I go to "a certain page" I want to click on a button and have it go to another page known as "pics" it then will load a jpeg there known as jpeg loader. Now I know it works properly without a functin, but because I am lazy I do not want to write more code than I have to, there are like 300 differnt jpegs I have to load. Thus I need to create a function.

here is my AS


ActionScript Code:
//this is on frame one of my root timeline
//I am trying to call the function "display" on release of my button
 
omnihotelButton.onRelease = display ("J010 Omni Hotel.jpg");
 
 
//this is my function that I set up it is also on my root, but on a different frame
//this function is named display and it goes to the "pics" page and stops
where it then loads a jpeg which is et up as my variable.
//the xscale and the yscale are just setting up my size of the jpeg.
 
function display(jpeg){
    _root.gotoAndStop("pics");
    jpegLoad_mc.loadMovie(jpeg);
    jpegLoad_mc._xscale=90;
    jpegLoad_mc._yscale=90;
}

View Replies !    View Related
Function Calling From The _root But Call A Function Within A Instance
I have created a new instance 'Check_1' to work as a checkbox with a set of propertys and functions.

All ive done is created the functions in a script in the first frame of the instance-movie these are...

Simple......
================================================== =======

selected = -1;
function select_frame (FrameNum) {
gotoAndPlay (FrameNum);
}
function change_select () {
select_frame(2);
trace (selected);
}
function change_unselect () {
select_frame(1);
selected = -1;
}

================================================== =======

now from the _root i wish to call the above functions to change the instance propertys, it all works fine from within the instance but i also need to use the functions for that instance from the _root...

iv'e tried the follow with no joy...


_level0.Check_1.change_select()


Any light would be greatly appreciated.

View Replies !    View Related
Inside XmlOnload Function Can Not Call Other Function Directly
I have a question, why the test function can not be called ?
Thanks.

Code:
class testClass {
public function testClass() {
var XMLData:XML = new XML();
XMLData.load("coonfig.xml");
XMLData.onLoad = this.xmlOnLoad;
}
public function xmlOnLoad(success:Boolean) {
if (success) {
// this.test();
test();
}
}
public function test () {
trace("test success");
}
}

View Replies !    View Related
Cannot Call Button Function Within Another Event Function
Hopefully someone can help me out with this one. I'm importing XML in order to draw images into an animated scrollbar, and would like to nest a button function within the function urlLoaded as listed below:

import caurina.transitions.*;

var urlCall:URLRequest = new URLRequest("pics/hotel_dreams/hotel_dreams.xml");
var urlLoader:URLLoader = new URLLoader();
var xml:XML;
var xmlList:XMLList;
urlLoader.load(urlCall);
urlLoader.addEventListener(Event.COMPLETE,urlLoade d);

var arrayThumb:Array = new Array();
var photoContainer:Sprite = new Sprite();
addChild(photoContainer);
photoContainer.mask=thumb_holder;


function urlLoaded(event:Event):void {


xml = XML(event.target.data);
xmlList = xml.children();
trace(xmlList.length())
for (var i:int=0; i<xmlList.length(); i++) {
var thumb:Thumbnail = new Thumbnail(xmlList[i].url);
arrayThumb.push(thumb);
arrayThumb[i].y = 67.5;
arrayThumb[i].x = xml.children().x_position[i];
photoContainer.addChild(thumb);
arrayThumb[i].gallery = xml.children().gallery[i];

trace(arrayThumb[i].gallery);


}


}

my hope is to create a button that looks something similar to the following in order to execute an if then statement within the function controlling the visibility of images from the XML based on their gallery property value.

btn_gallery_2.addEventListener(MouseEvent.CLICK, open_gallery_2);
function open_gallery_2(event:MouseEvent) {

if (arrayThumb[i].gallery == 2) {
arrayThumb[i].visible = true
}

}

I have been trying to nest within the urlLoaded function to no avail. By running trace statements I can see that [i] is inaccessible when nested within another function within urlLoaded and when completely outside of the urlLoaded function.

The Thumbnail class referenced is in an .as file that looks like this:

package {
import flash.display.Sprite;
import flash.display.Loader;
import flash.net.URLRequest;

public class Thumbnail extends Sprite {

private var url:String;
private var loader:Loader;
private var urlRequest:URLRequest;
public var gallery:Number

function Thumbnail(source:String):void {
gallery = 0
url=source;
drawLoader();

}

{
private function drawLoader():void {

urlRequest=new URLRequest(url);
loader=new Loader ;
loader.mouseEnabled=false;
loader.load(urlRequest);
loader.x=-0;
loader.y=-68
;
addChild(loader);

}}}}

I have the suspicion that I am missing something very basic. If anyone out there might be able to give me some insight, then I would be appreciative.

thanks very much

View Replies !    View Related
String With Function Name To Call Function?
hi guys,

it so happened that I have to call some function from XML. What is the best way to do this??

say i have a class "ABC.as" with a function "def()" can I do this:


Code:
var abc:ABC = new ABC();
var strg:String = "def()";

//then i call the function...

abc.strg;
is this going to work?? else is there any solution can let me do something similiar?

thanks!

View Replies !    View Related
Call A Function From Inside Another Function?
Hey Guys,

Having a bit of a problem here

Just say this was the case on the main timeline


ActionScript Code:
function topFunction(){
trace("you just called the topFunction")
}

function testFunction(){
function nestedFunction(){
topFunction();
}
}

How the hell do i run the topFunction from inside nestedFunction();. In AS2 if i wanted to reference it i would type _root.topFunction(); but now I don't know how to get to it.

I just need to know how to reference variables and functions from anywhere in my actionscript if i'm in another scope or in another MC.

Thanks guys

View Replies !    View Related
[AS]Call A Function After Another Function Ends
Hi,

I have a question: How i make (if it's possible to do this) to call a function after another function is finished. I have 4 function:

ActionScript Code:
function tween1 () {//some tweens}function tween2 () {//some tweens}function tween3 () {//some tweens}function tween4 () {//some tweens}


And i want to play first tween1 and then tween2, when tween2 ends then play tween3 and so on!

It's this possible?

Thanks, btibia.

View Replies !    View Related
Pass Function Name To Function And Call
bit stuck on this.

any help much appreciated!


ActionScript Code:
func_1(mc10, 'func_2',[id1, add]);
 
function func_1(tofade, oncompletecall, var){
 
//fade out 'tofade'
//then call oncompletecall(func_2) function..
 
how do i form the call to func_2?
 
}
 
function fun_2(id1, add){
do something...
}

View Replies !    View Related
Call A Function Inside A Function
I have a function that attaches a movie clip and names it movieClip_1. I now need the to call the same function again to create movieClip_2 when you click movieClip_1.

View Replies !    View Related
Calling A Function In Main Class From A Loaded Swfs Document Class
Hi
I have a main.swf that loads page.swf. They each have a document class called "Main" and "Page".

How can I call a function in Main from Page?

In AS2 this would be somthing like _parent.myFunction();


Cheers

View Replies !    View Related
How Do I Call A Class ?
Hi everyone,

I have a class with some buttons in it, when I click the button "a", I call a function and what I want know is to call a class everytime I enter that function. Hope someone can help me on this.


Thanks in advance.

View Replies !    View Related
How To Call A Class
Hi,



How can I call a class from my .fla file and tell it to execute all the code inside the constructor?

package{

public class Sample extends MovieClip{

public function Sample (){

function SomeName(){

//some code

}

public function Sample2(){

//some code

}

}

}

}

Let’s pretend that this function will move, rotate and scale any object tied to it. Also pretend that this will be applied to many objects.

How could I call this class from my .fla? Would this be something like this?

// create an instance of the class?

var myClass:Sample = new Sample();

//then apply this to an object?

myMc.myClass();

I don’t want to pass any parameters just use the code inside the class.

Thanks,
fs_tigre

View Replies !    View Related
How Do I Call A Class ?
Hi everyone,
I have a class with some buttons in it, when I click the button "a", I call a function and what I want know is to call a class everytime I enter that function. Hope someone can help me on this.

Thanks in advance.

View Replies !    View Related
How To Call A Class
Hi,

How can I call a class from my .fla file and tell it to execute all the code inside the constructor?

package{
public class Sample extends MovieClip{
public function Sample (){
function SomeName(){
//some code
}
public function Sample2(){
//some code
}
}
}
}

Let’s pretend that this function will move, rotate and scale any object tied to it. Also pretend that this will be applied to many objects.

How could I call this class from my .fla? Would this be something like this?

// create an instance of the class?
var myClass:Sample = new Sample();
//then apply this to an object?
myMc.myClass();

I don’t want to pass any parameters just use the code inside the class.
Thanks,
fs_tigre

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved