Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6256005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:28:11+00:00 2026-05-24T14:28:11+00:00

I have a function in my flash AS3 file. I’d like to pass a

  • 0

I have a function in my flash AS3 file. I’d like to pass a parameter when calling this function and have that parameter become the name of a new FLV playback component I’m declaring;

function newVideo(myVideoName){
var [myVideoName]:FLVPlayback = new FLVPlayback();
}

—
edit – I now have the following code. How would I add the FLV playback component to the stage?

> function newVideo(myVideoName:String):FLVPlayback {
>    
>     var flvP:FLVPlayback = new FLVPlayback();
>     flvP.name = myVideoName;
      flvP.source = "argentinaTrailer.f4v"; 
>     return flvP;
   }
> 
>  var myPlayer:FLVPlayback = newVideo('player1');
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T14:28:13+00:00Added an answer on May 24, 2026 at 2:28 pm

    What you are doing here is not allowed. The notation for creating and accessing objects using a string reference (this['someObject']) does not permit you to cast a type. Furthermore, objects created in this fashion cannot then be directly accessed using that name without using the identifier notation:

    this['foo']:Object = {}; // fails, 1078: Label must be a simple identifier.
    this['foo']        = {}; // works
    

    and

    this['foo'] = {};
    trace(this.foo);    // fails, 1120: Access of undefined property foo.
    trace(this['foo']); // works, [object Object]
    

    So, to make your function work it should be written:

    function newVideo(myVideoName:String):void
    {
        this[myVideoName] = new FLVPlayback();
    }
    

    but you will only then be able to access the player by using that same string reference, like this:

    this[myVideoName].play();
    

    Furthermore, none of the above is giving the instance of the FLVPlayback component a name. What it is doing is defining the name of a reference to your FLVPlayback. If you are intending to create an FLVPlayback that has an instance name of myVideoName then you should create a function that looks like this:

    function newVideo(myVideoName:String):FLVPlayback
    {
        var flvP:FLVPlayback = new FLVPlayback();
        flvP.name = myVideoName;
        return flvP;
    }
    

    What this does is creates a new instance of the FLVPlayback component, assigns it an instance name, and returns a reference to it. You would use it like this:

    var myPlayer:FLVPlayback = newVideo('player1');
    addChild(myPlayer);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have some code like this in AS3 for(...) thing = new
In my Java code I have function that gets file from the client in
Has anyone ever encountered an issue like this with Flash[as3] in IE8? I've noticed
I'm building an animation in flash and as3, I have a function in which
i have a problem using AS3 - Flash CS3 gives me this Error message:
I have a content scroller in my Flash CS5/AS3 project that I want to
I've got a Flash AS3 animation that is completely coded in an .as file.
I have an Flash AS3 project that loads external SWFs and controls them in
When I attempt to create a new flash list component from my as3 file
I have a Flash CS4 AS3 swf (host) that loads a Flash 8 AS2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.