Can't move variables outside of a function

Lukas Miškauskas
function playvideo(path:String, wid:Number=1280, heigt:Number=720):void
{
    var nc:NetConnection = new NetConnection();
    nc.connect(null);
    var ns:NetStream = new NetStream(nc);
    ns.client = this;
    ns.addEventListener(NetStatusEvent.NET_STATUS, statusChanged);
    ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
    SoundMixer.stopAll();
    var vid:Video = new Video(); 
    ns.play(path);
    vid.width = wid;
    vid.height = heigt;
    vid.attachNetStream(ns);
    mc_bg.removeChildAt(0);
    mc_bg.addChild(vid);
}

Greetings, here's my "playvideo" function. whenever I try to move variables outside of function to control the video from elsewhere(for example "vid"), specific movieclips and buttons dissapear(are not shown on the stage). Is that some kind of a bug or am I doing something wrong? Thanks!

Álvaro Touzón

do this:

var vid:Video = new Video(); 
function playvideo(path:String, wid:Number=1280, heigt:Number=720):void
{
    var nc:NetConnection = new NetConnection();
    nc.connect(null);
    var ns:NetStream = new NetStream(nc);
    ns.client = this;
    ns.addEventListener(NetStatusEvent.NET_STATUS, statusChanged);
    ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
    SoundMixer.stopAll();

    ns.play(path);
    vid.width = wid;
    vid.height = heigt;
    vid.attachNetStream(ns);
    mc_bg.removeChildAt(0);
    mc_bg.addChild(vid);
}

And same for any var, declare outside function

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Can't use variables outside of function in javascript

From Dev

Can't get data outside a service function

From Dev

Using variables outside a function

From Dev

Can I access static variables inside a function from outside

From Dev

Move function outside class definition

From Dev

Why can't I refactor this anonymous function outside the enclosing function?

From Dev

Can't define variables after a function call

From Dev

Can't define variables after a function call

From Dev

Can't update all variables from function

From Dev

Can't pass global variables inside a function

From Dev

can't use variables in jquery function

From Dev

Can't use variable outside function even after setting it global

From Dev

Can't connect function imported outside of class qt

From Dev

I can't use a variable outside of Wordpress shortcode function

From Dev

Can't access variable outside the function scope in JS

From Dev

Why can't I get the geolocation just outside that function

From Dev

Can't reach results of Papa Parse outside the 'complete' function

From Dev

Accessing variables outside a function in Python

From Dev

Accessing Variables outside of a function in swift

From Dev

Python Access Variables Outside of Function

From Dev

PHP variables not changing outside of function

From Dev

Accessing variables outside of a class and function

From Dev

PHP variables not changing outside of function

From Dev

Accessing outside variables inside the 'then' function

From Java

Rust - How can I return multiple variables from a function such that they are accessible outside the scope the function is called in?

From Dev

How can I use declared variables of a function outside the function but keeping their values in javascript?

From Dev

Why can't I move a mutable function that contains a moved future?

From Dev

Can't move composer

From Dev

Can't move composer

Related Related

  1. 1

    Can't use variables outside of function in javascript

  2. 2

    Can't get data outside a service function

  3. 3

    Using variables outside a function

  4. 4

    Can I access static variables inside a function from outside

  5. 5

    Move function outside class definition

  6. 6

    Why can't I refactor this anonymous function outside the enclosing function?

  7. 7

    Can't define variables after a function call

  8. 8

    Can't define variables after a function call

  9. 9

    Can't update all variables from function

  10. 10

    Can't pass global variables inside a function

  11. 11

    can't use variables in jquery function

  12. 12

    Can't use variable outside function even after setting it global

  13. 13

    Can't connect function imported outside of class qt

  14. 14

    I can't use a variable outside of Wordpress shortcode function

  15. 15

    Can't access variable outside the function scope in JS

  16. 16

    Why can't I get the geolocation just outside that function

  17. 17

    Can't reach results of Papa Parse outside the 'complete' function

  18. 18

    Accessing variables outside a function in Python

  19. 19

    Accessing Variables outside of a function in swift

  20. 20

    Python Access Variables Outside of Function

  21. 21

    PHP variables not changing outside of function

  22. 22

    Accessing variables outside of a class and function

  23. 23

    PHP variables not changing outside of function

  24. 24

    Accessing outside variables inside the 'then' function

  25. 25

    Rust - How can I return multiple variables from a function such that they are accessible outside the scope the function is called in?

  26. 26

    How can I use declared variables of a function outside the function but keeping their values in javascript?

  27. 27

    Why can't I move a mutable function that contains a moved future?

  28. 28

    Can't move composer

  29. 29

    Can't move composer

HotTag

Archive