how to call reference or a function from onEnterFrame Function?

View: New views
2 Messages — Rating Filter:   Alert me  

how to call reference or a function from onEnterFrame Function?

by Karsten Knetsch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi there,

i´m new to mtasc, new to as and i´ve got some problems i can´t get solved.

therefore i hope you can help me, because i´ve got no clue how to solve.

by the way - sorry for my poor english!

i´m trying to build a slideshow (in the end) with mtasc.
in the constructor i create several empty movie clips, these movie clips
also creates one empty movie clip, which loads an picture from a directory.
after displaying the first picture i want to make some changes something
like the _alpha values, or maybe i want to swap the depths of the clips,
actually i don´t know for sure. but that´s not my problem!

and now to my problems ( please look at lines in the sourcecode with
this ----> ).

when the first clip and picture has loaded, i would like to make some
actions, but no one of my actions is running successfully.
in the onEnterFrame Function i can call the textfield
(scope.headline....) and make some changes, but i can´t call one of the
dynamic mc´s to load a new picture for example
(picture[1].pic.loadMovie("Pics/2.jpg");). neither the code is inserted
"before" the "delete _root.onEnterFrame" nor "after" the "delete
_root.onEnterFrame".

just one annotation: i have put some of my code before and after the
"delete this.onEnterFrame", this is why i don´t know, wether the problem
lays in the fact, that the execution of my code is at this time deleted
or not. i hope you could unsterstand me!?

The dynamic mc´s (picture[1].... in the onEnterFrame Functions are
undefined, how can i get access to them in the onEnterFrame Function?

and the next big question is how to call the sliding function() within
the onEnterFrame Function. when i call the function sliding() before the
onEnterFrame functions, it will run successfully. but when i try to
compile the code just with "sliding();" in the onEnterFrame Function, i
get an "type error or unknown variable sliding".
only when i wrote "this.sliding();" i get no errors, but the function
call is not working.


here´s my code:

class Show {

static var app : Show;

var count=6;

function Show() {

for(var i=1; i<=count; i++) {
//set the first dynamic mc on top of the dynamic mc´s
var index=(count+1)-i;

var scope:MovieClip = _root;

//a dynamic textfield for some inner traces
scope.createTextField("headline",99,20,20,730,176);
scope.headline.txt="trace";
scope.headline.html=true;
scope.headline.selectable=false;
scope.headline.multiline=false;
scope.headline.wordWrap=false;
scope.headline.htmlText="<font face='Arial' size='14'
color='#ffffff'>"+scope.headline.txt+"</font>";


var picturemc:Array = new Array;
picturemc[i] = scope.createEmptyMovieClip("picmc"+i, index);
var picnr = i;
picturemc[i].createEmptyMovieClip("pic", 0);

picturemc[i].pic.loadMovie("Pics/"+picnr+".jpg");


---->//sliding();
if(i==1) {
_root.onEnterFrame = function() {
if(picturemc[1].getBytesLoaded()==picturemc[1].getBytesTotal()) {
scope.headline.txt="loaded";
scope.headline.htmlText="<font face='Arial' size='14'
color='#ffffff'>"+scope.headline.txt+"</font>";

----> //picturemc[1].pic.loadMovie("Pics/2.jpg");
---- > //sliding(); //cannot compile -> type error or unknown variable
sliding
---- > //this.sliding(); //can compile but the call is not working

delete _root.onEnterFrame;

----> //picturemc[1].pic.loadMovie("Pics/2.jpg");
----> //sliding(); //cannot compile -> type error or unknown variable
sliding
---- > //this.sliding(); //can compile but the call is not working
} //end if(...)
} //end this.onEnterFrame
} //end if(...)
} //end for(...)
} //end Show()

public function sliding():Void {

//first only some test actions
_root.headline.txt="sliding()";
_root.headline.htmlText="<font face='Arial' size='14'
color='#ffffff'>"+_root.headline.txt+"</font>";
}


// entry point
static function main(mc) {
app = new Show();
}
}

--
MTASC : no more coffee break while compiling

Re: how to call reference or a function from onEnterFrame Function?

by ronatartifact :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You are in the wrong forum for that type of question. If your code works
with Flash and does not work with mtasc, then you will get a lot of
attention here
Try flashcoders for general help in writing ActionScript.

Ron

Karsten Knetsch wrote:

> Hi there,
>
> i´m new to mtasc, new to as and i´ve got some problems i can´t get
> solved.
>
> therefore i hope you can help me, because i´ve got no clue how to solve.
>
> by the way - sorry for my poor english!
>
> i´m trying to build a slideshow (in the end) with mtasc.
> in the constructor i create several empty movie clips, these movie
> clips also creates one empty movie clip, which loads an picture from a
> directory.
> after displaying the first picture i want to make some changes
> something like the _alpha values, or maybe i want to swap the depths
> of the clips, actually i don´t know for sure. but that´s not my problem!
>
> and now to my problems ( please look at lines in the sourcecode with
> this ----> ).
>
> when the first clip and picture has loaded, i would like to make some
> actions, but no one of my actions is running successfully.
> in the onEnterFrame Function i can call the textfield
> (scope.headline....) and make some changes, but i can´t call one of
> the dynamic mc´s to load a new picture for example
> (picture[1].pic.loadMovie("Pics/2.jpg");). neither the code is
> inserted "before" the "delete _root.onEnterFrame" nor "after" the
> "delete _root.onEnterFrame".
>
> just one annotation: i have put some of my code before and after the
> "delete this.onEnterFrame", this is why i don´t know, wether the
> problem lays in the fact, that the execution of my code is at this
> time deleted or not. i hope you could unsterstand me!?
>
> The dynamic mc´s (picture[1].... in the onEnterFrame Functions are
> undefined, how can i get access to them in the onEnterFrame Function?
>
> and the next big question is how to call the sliding function() within
> the onEnterFrame Function. when i call the function sliding() before
> the onEnterFrame functions, it will run successfully. but when i try
> to compile the code just with "sliding();" in the onEnterFrame
> Function, i get an "type error or unknown variable sliding".
> only when i wrote "this.sliding();" i get no errors, but the function
> call is not working.
>
>
> here´s my code:
>
> class Show {
>
> static var app : Show;
>
> var count=6;
>
> function Show() {
>
> for(var i=1; i<=count; i++) {
> //set the first dynamic mc on top of the dynamic mc´s
> var index=(count+1)-i;
>
> var scope:MovieClip = _root;
>
> //a dynamic textfield for some inner traces
> scope.createTextField("headline",99,20,20,730,176);
> scope.headline.txt="trace";
> scope.headline.html=true;
> scope.headline.selectable=false;
> scope.headline.multiline=false;
> scope.headline.wordWrap=false;
> scope.headline.htmlText="<font face='Arial' size='14'
> color='#ffffff'>"+scope.headline.txt+"</font>";
>
>
> var picturemc:Array = new Array;
> picturemc[i] = scope.createEmptyMovieClip("picmc"+i, index);
> var picnr = i;
> picturemc[i].createEmptyMovieClip("pic", 0);
>
> picturemc[i].pic.loadMovie("Pics/"+picnr+".jpg");
>
>
> ---->//sliding();
> if(i==1) {
> _root.onEnterFrame = function() {
> if(picturemc[1].getBytesLoaded()==picturemc[1].getBytesTotal()) {
> scope.headline.txt="loaded";
> scope.headline.htmlText="<font face='Arial' size='14'
> color='#ffffff'>"+scope.headline.txt+"</font>";
>
> ----> //picturemc[1].pic.loadMovie("Pics/2.jpg");
> ---- > //sliding(); //cannot compile -> type error or unknown variable
> sliding
> ---- > //this.sliding(); //can compile but the call is not working
>
> delete _root.onEnterFrame;
>
> ----> //picturemc[1].pic.loadMovie("Pics/2.jpg");
> ----> //sliding(); //cannot compile -> type error or unknown variable
> sliding
> ---- > //this.sliding(); //can compile but the call is not working
> } //end if(...)
> } //end this.onEnterFrame
> } //end if(...)
> } //end for(...)
> } //end Show()
>
> public function sliding():Void {
>
> //first only some test actions
> _root.headline.txt="sliding()";
> _root.headline.htmlText="<font face='Arial' size='14'
> color='#ffffff'>"+_root.headline.txt+"</font>";
> }
>
>
> // entry point
> static function main(mc) {
> app = new Show();
> }
> }
>

--
MTASC : no more coffee break while compiling