Coercing string to MovieClip class

I've been learning coercion between String and Number and
simple stuff, but now I have a class that the books don't cover.
This is best explained by example (this isn't the end goal, just a
learning example).
On the stage in frame 1, I have a MovieClip instance named
shape_mc.

In your first post you create a variable fubar with no
particular type and then make it a String by concatenating two
other variables. Next you attempt to cast String to MovieClip -
this is what is wrong with the code. Casting works only if an
object somehow is related to other object - in this instance if
fubar data type was related somehow to MovieClip (by extension for
example).
In order to use a string to point to an object - you need to
use an associative array syntax:
parentObject["string"] - given that an object "string" is in
the scope of parentObject.
The following syntax will work (if the movieclip is in the
scope of "this"):
var pre:String="shape";
var suf:String="_mc";
var fubar:* = MovieClip(this[pre + suf]);
Again, the key is to use a correct scope.
As for the flv files, there is no need to cast at all. FLVs
are not MovieClips. It is not clear how you want to play FLVs. Are
they on the server? If so - you need the url to them only (which
are strings). If they are progressive (downloaded via http) your
code may look something like:
var flvURL:String;
function clickListener(e:MouseEvent):void{
flvURL = e.target.name.toString().split("_")[0] + "_flv";
//some time later:
netStream.play(flvURL);
Of course this is just a concept - real code should be
different.

Similar Messages

  • Replacement for multiple inheritance in MovieClip class

    Hello
    I need your opinion about a problem.
    Commonly, when you need to replace multiple inheritance, you do it by making an aggregation with one of the class involved.
    But in case of MovieClip attached class, there is one more class involved in the process : the MovieClip class, and this class can't be the one aggregated because every class attached to a MovieClip need to inherits from it.
    The problem is if the other class can't be also aggregated because it has some abstract class behaviour, for instance, call of a virtual function.
    A solution could be making the abstract class inherit from the MovieClip class, but what if you want to reuse its behaviour in a class which have nothing to do with MovieClip ?

    This is Not Supported in WebLogic that the Remote Interface extends other Interfaces. Because Annotation Processor just looks up inside the implemented interface methods. The actual interface which is Implemented by the Bean Class. So the Methods declared inside the Interface B and Interface C will be ignored and will not be available as part of the generated Stubs. Thats why u are getting NoSuchMethodError.
    You can even contact Oracle Support on this...there are 3-4 Cases on it. And the Solution is Work As Designed.
    Workaround is : edit your interface A as following
    Declare all the Business Methods only in the Remote Interface and not inside it's Super Interfaces.
    Example:
    @Stateless(name="A")
    @Remote({A.class})
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public class AImpl implements A {
    @Override
    public void writeA() {
    System.out.println("A");
    @Override
    public void writeB() {
    System.out.println("B");
    @Override
    public void writeC() {
    System.out.println("C");
    @Remote
    @JNDIName(A.JNDI_NAME)
    public interface A extends B, C {
    public static String JNDI_NAME = "A_JNDI_NAME";
    void writeA();
    void writeB();
    void writeC();
    Thanks
    Jay SenSharma
    http://jaysensharma.wordpress.com (WebLogic Wonders Are Here)

  • Is it possible to pass a string representing a class name in java as an arg

    Hi, this is probably a bit of a stupid question, but one that has me quite confused all the same!
    Is it possible to pass a string or class name etc. representing a type of class in java, to a method so that instead of having to redefine a method with say the following args:
    public SolarPanels[] bestPVPanels(int budget, int percent) {
            HashMap<Integer, SolarPanels> panelsMap    = new HashMap<Integer, SolarPanels>();
    }As at present needing to create a methods bestWindTurbine() and many others exactly the same, but for the type, I would instead like to be able to create a method like:
    public Object[] bestRenewable(int budget, int percent, String aClassName) {
            HashMap<Integer, aClassName > renewableMap    = new HashMap<Integer, aClassName >();
    }But cant sus how to do this as passing a String is off course going to cause problems unless its it possible to cast a string to a class name, any help or advance would be much appreciated.
    Thanks in advance
    Pat Nevin

    pNev wrote:
    But cant sus how to do this as passing a String is off course going to cause problems unless its it possible to cast a string to a class nameIt's not. You can do things like
    Class.forName(classNameInString);But that will only return a Class object.
    And as Java generics are erased at runtime, passing the class name to the method is useless as it is too late to use it anyways.
    Ah, Peter's way is what I was thinking of. Too early in the morning.
    Edited by: Kayaman on 23.6.2010 10:02

  • Custom MovieClip class and loadMovie

    Hi, I am trying to create a custom MovieClip class with
    loadMovie, but it doesn't work.
    I created a movie clip symbol and action script linked to it,
    such as:
    class CustomMovieClip extends MovieClip { ... custom
    functions to define the behavior, onPress, onMouseMove, etc ... }
    It works all fine until I call loadMovie on an instance,
    trying to change the shape.
    As I searched, I figured loadMovie can mess you up if you do
    somthing like mc.onPress = .... but
    is this the case for a custom class? Hope not.
    Any help???

    Solved the issue myself. I write it here so other people can
    find it.
    Basically, you can't do loadMovie directly to CustomMovieClip
    class instance.
    It will mess up all the methods you have defined in the
    class.
    Workaround is to do loadMovie to a variable in the class.
    Complete working example is here:
    1. Create a project MCTest.flp
    2. Prepare Movie1.swf (a simple shape)
    3. Create a Flash document MCTest.fla
    4. Create a ActionScript file CustomMovieClip.as:
    class CustomMovieClip extends MovieClip {
    function onPress() {
    trace("onPress");
    6. Create a symbol CustomMovieClipContent:
    Behavior: Movie Clip
    Draw nothing.
    5. Create a symbol CustomMovieClip:
    Behavior: Movie Clip
    Identifier: CustomMovieClip
    AS 2.0 Class: CustomMovieClip
    Export for ActionScript: Yes
    Export in first frame: Yes
    Open editor and drag&drop CustomMovieClipContent, name
    it 'contents'
    6. Edit ActionScript in MCTest.fla>Scene 1>Layer
    1>1st Frame
    attachMovie("CustomMovieClip", "customMovieClip1", 0,
    {_x:100, _y:100});
    customMovieClip1.contents.loadMovie("Movie1.swf");
    7. Preview and you see two movie clips.
    Click on the object, and "onPress" is printed in the output.

  • I need help extending the MovieClip class

    I want to add a property to the MovieClip class. I just have a bunch of MovieClips that are placed on the stage by reading an XML file and creating lots of clips according to the information in them. Now, I need to know which MovieClips were created below previous clips, and I figure that the easiest way to do so would be by extending the MovieClip class and add an order property.
    I have some problems though: I don't know how to set or get this order property within the main clip, I don't know how to place this clip within my movie, and I don't know how to create them dynamically (do I just do something like var myNewObjectOfExtendedClass : myExtendedClassName = new myExtendedClassName?)
    This is the code I have on my extended class, called Expando.as:
    class Expando extends MovieClip {
    private var _order:Number;
    public function get order():Number {
    return _order;
    public function set order(nOrder:Number):Void {
    _order = nOrder;

    You mean the Tree component?
    My concern with the Tree component (at least the AS2 version) is that I don't see a way to have each node in the Tree have different hit areas with different outcomes.
    The tree that I build must have up to 7 levels within each main branch, and not all of them behave the same way. In some branches, clicking the icon next to the label will have a completely different outcome than clicking on the label, which may or may not return a function. Each of those sublevels also need to support different icons, depending on what information is represented by it.
    Sample:
    • Reminders
    My Reminders
    Manual Reminders
    Escalated Reminders
    • Cases
    Name Actions < ---- this is where the problem begins. Clicking on the icon where the bullet should be should do something different than clicking on the name, which should do something different than clicking on the word ActionsThis is information about that referral that includes who referred them, the date of the referral, their full address. This information usually takes up 2 lines, sometimes 3
    Assignment   <------- you can only open see these leaves if you click on the bullet icon for the previous node; you can't open this by clicking on the text.
    Eligibility
    Etc., depending on what information has been appended
    • Suppliers
    Anyway, if the Tree Component can indeed support these features, I'd like to know where to find information about it please
    In my search for that information, I concluded that I'd probably be better served by building my own MovieClip that can handle these requirements. I did have a working Tree component pretty quickly as I started this project, but then I got more familiar with the app that I'm building the training for and noticed these requirements.
    Of course, maybe all these features are supported by the AS3 Tree component. The problem is that I'm a lot worse with AS3 than I am with AS2 heh.

  • Use String as name class

    Hello, I have a class name on a string variable, and a method name on other string variable. I would like use this strings to invoke class and it's method, how can i do it? Thanks�����
    For example:
    String class_name = car //name of a class
    String method_name = getOwner // class car method
    // How can I invoke the class and method with this strings?

    // How can I invoke the class and method with this
    strings?Java isn't designed to handle this kind of programming. Java uses strong type checking to make programs more safe. If you often end up wanting to do this why not use a more free-wheeling scripting language instead, such as Groovy,
    http://www-128.ibm.com/developerworks/java/library/j-pg07195.html

  • 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.

    Your as-file must be named MC_Rectangle.as (same upper/lower
    case as in the Class name)
    Ad 1) You have to declare sequence as a public property
    "public var sequence;" or - better - define a getter-function for
    sequence.
    Ad 2) mc_rect.setSequence(8); e. g. (you must write "public"
    in the Class-declaration of setSequence)
    Ad 3) mc_rect.addSequence(); e. g. (you must write "public"
    in the Class-declaration of addSequence)
    ... and yes, your methods can return a value: Replace "void"
    with the proper data type (int, String, ...) and place a "return
    myNumber;" or the like in the method's body.

  • How to use MovieClip class

    How to display the MovieClip in the stage?

    My code doesn't work,how to modify?
    my code is :
    package com.example.programmingas3.mc
    import flash.display.MovieClip;
    import flash.text.TextField;
    import mx.core.UIComponent;
    public class MovieClipExample extends UIComponent {
    public var mc:MovieClip;
    public function MovieClipExample() {
    mc=new MovieClip();
    var outputText:TextField = new TextField();
    outputText.text = getPropertiesString();
    outputText.width = 100;
    outputText.height = 30;
    mc.addChild(outputText);
    private function getPropertiesString():String {
    var str:String = ""
    + "currentFrame: " + mc.currentFrame + ","
    + "currentLabel: " + mc.currentLabel + ","
    + "currentScene: " + mc.currentScene + ","
    + "framesLoaded: " + mc.framesLoaded + ","
    + "totalFrames: " + mc.totalFrames + ","
    + "trackAsMenu: " + mc.trackAsMenu + ",";
    return str;
    my mxml code is :
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    xmlns:example="com.example.programmingas3.mc.*"
    xmlns="*"
    paddingTop="0"
    width="100%"
    height="100%"
    layout="vertical" >
    <mx:Panel width="550" height="400" layout="absolute">
    <example:MovieClipExample id="myMovie" width="500"
    height="300" >
    </example:MovieClipExample>
    </mx:Panel>
    </mx:Application>

  • How to convert a String variable as class name and method name?

    i have two classes
    class Student
    public String insertStudent(String sname)
    { return("Student has been inserted ");     }
    class Teacher
    public String execute(String methodName, String className)
    {  //return statement of the method 'insertStudent' in the class 'Student'; }
    }Now, i have a class with the main method. Here, i would like to call the method *'insertStudent'* of class *'Student'*
    using the method *'execute'* of class *'Teacher',* passing the method-name and the class-name (viz. insertStudent, Student) as the
    String parameter.
    Can anyone please help me out. Thanks
    regards,
    chinglai

    You should have just added that as a comment on your [initial posting|http://forums.sun.com/thread.jspa?threadID=5334953] instead of starting a new thread.
    Now, i have a class with the main method. Here, i would like to call the method 'insertStudent' of class 'Student'using the method 'execute' of class 'Teacher', passing the method-name and the class-name (viz. insertStudent, Student) as the
    String parameter.
    Why oh why? What do you want to achieve?
    Let me tell you: there is a way to do what you try to do, but it's not recommended and should be used only very sparingly. Especially not in anything like your code, that resembles normal business logic (as opposed to an application framework such as Spring, for example).
    Can you explain what exactly you want to do with that? Why should a Teacher be able to call any random method ony any other class. And what good would that do?

  • Reference to string from another class

    I've searched google and this forum a bit, but can't seem to find an answer. I'd say the thing I'm looking for is really simple and essential, so I must be a moron. But anyways; I want to get the output of the "process" thing in another class. How do I reference to that string fomr outside it's class?
    Thanks.
    public class ReadInput {
         private static void printCommands() {
             System.out.println("blabla");
             System.out.println("blabla");
             System.out.println("blabla");
    public static void process(String in) {
              Do something with the String "in" here. Say, eventually rename it to "output".
    public static void doReadFromStdin() {
         try {
             BufferedReader inStream = new BufferedReader (
                                             new InputStreamReader(System.in)
             String inLine = "";
             String in = inLine;
             while ( !(in.equalsIgnoreCase("quit"))
                     !(in.equalsIgnoreCase("exit")) ) {
                 System.out.print("prompt> ");
                 in = inStream.readLine();
                 process(in);
         } catch (IOException e) {
             System.out.println("IOException: " + e);
    public static void main(String[] args) {
          printCommands();
         doReadFromStdin();
    }

    Maybe this might help
    Igor_Pavlove wrote:
    public static void process(String in) {     
    Do something with the String "in" here. Say, eventually rename it to "output".
    public static String process(String in){
      //Do something, e.g.
      String temp = "ifeeltired";
      return temp;  //Returns the String temp when this method is called.
    public static void main(String[] args) {
         printCommands();
    doReadFromStdin();
    public static void main(String[] args){
      String temp = "thisisaroughexamples";
      String result = this.process(temp); //Returns a string and stores it in result
      CreatePlural.print(result);  //This is possible because the method print() in CreatePlural is static and an instance of CreatePlural is not required.
    }Edited by: Melanie_Green on Feb 2, 2009 6:46 AM
    Edited by: Melanie_Green on Feb 2, 2009 6:47 AM

  • Returning a string from one class to another

    I have a file from where i creating an object of another class and calling the fuctionsl
    This is how i am doing
    public login()
    String input =new String (passwordField.getPassword());
         input= input.trim();
    tempuser= userField.getText();
              db2sqln patientsqln =new db2sqln(); //creating an object
              patientsqln.connectdb2();// calling a connect to database function
              patientsqln.dbselect(tempuser);// passing the login informaiont
    in patientsqln i am getting the password from the database and want to pass it back to login class so that i can compare the entered password and the database password
    here is i am using my patientsqln.dbselect()
    //public void dbselect(String userinput)
              try
              Statement stmt = con.createStatement();
              String select = "Select patientpass from patient where PATIENTUSER="+"'"+userinput+"'";
              ResultSet rs = stmt.executeQuery(select);
              while (rs.next())
              name=rs.getString("PATIENTPASS");
              name = name.trim();
              System.out.println(name+"from db2sqln");
              rs.close();
    My question is that everything else works fine, but i donot get any password back in login() class it returns null value. looks like i am not returing the string back. how should i do that
    I am comparing like this
    if(input.equals("name"))
    System.out.println("Correct password");
    else{
    System.out.println("Incorrect password");
    //

    I have a file from where i creating an object of another class and calling the fuctionsl
    This is how i am doing
    public login()
    String input =new String (passwordField.getPassword());
    input= input.trim();
    tempuser= userField.getText();
    db2sqln patientsqln =new db2sqln(); //creating an object
    patientsqln.connectdb2();// calling a connect to database function
    patientsqln.dbselect(tempuser);// passing the login informaiont
    in patientsqln i am getting the password from the database and want to pass it back to login class so that i can compare the entered password and the database password
    here is i am using my patientsqln.dbselect()
    //public void dbselect(String userinput)
    try
    Statement stmt = con.createStatement();
    String select = "Select patientpass from patient where PATIENTUSER="+"'"+userinput+"'";
    ResultSet rs = stmt.executeQuery(select);
    while (rs.next())
    name=rs.getString("PATIENTPASS");
    name = name.trim();
    System.out.println(name+"from db2sqln");
    rs.close();
    My question is that everything else works fine, but i donot get any password back in login() class it returns null value. looks like i am not returing the string back. how should i do that
    I am comparing like this
    if(input.equals("name"))
    System.out.println("Correct password");
    else{
    System.out.println("Incorrect password");
    //

  • Determine a string from main class in an outside class

    Hello there,
    This might be stupid question but I cant think, I am so very tired. Okay here is the question, is there any way we could see or the get the value of a string(just a string which is set in main class'A', its already set, we cannot make it static r anything like that)in a method outside that main class, probably in a method 'x' in class'C'.
    Thanks
    potti

    Yes, you can, in many ways, or else Java would be moot. Excluding the static way of doing it, which by the way is evil, your class C can make an instance of class A and then access it either as a public field or as the value returned by a public method. You can also use inheritance, but it's pointless in this case, inheritance is meant to abstract, extend functionality, and prevent having to rewrite code. It's not meant for accessing fields. And by the way, inheritance, too, is evil.
    This is one way to do it.
    class A {
         public String s = "great balls of fire";
    public class C {
         public static void main(String[] args) {
              A myInstance = new A();
              String s = myInstance.s;
              System.out.println(s);
    }This is the preferred way to do it, as it encapsulates the String. The idea of encapsulation is to access fields by a method instead of directly since interfaces are less likely to change than an object's data and in the case that the object's data does change and the interface does not, the changes will remain local.
    class A {
         private String s = "great balls of fire";
         public String getS() { return s; }
    public class C {
         public static void main(String[] args) {
              A a = new A();
              String s = a.getS();
              System.out.println(s);
    }

  • How to disply empty cell from a string using stringtokenizer class

    Hello All
    I had wriiten a small program to read the string and split the string into different tuples.When i had empty cell in string i am unable to display it. Can any body help me out pls?
    code given below
    import java.io.*;
    import java.util.StringTokenizer;
    class Tokenize {
    // Create BufferedReader class instance
    static InputStreamReader input = new InputStreamReader(System.in);
    static BufferedReader keyboardInput = new BufferedReader(input);
    static String record;
    /* Main method */
    public static void main(String[] args) throws IOException {
         //declare the string variables
         String text,delim,var,delimv,vname;
         String X = "x";
         int i = 1;
         //read the inputs from keyboard for variables and delimv
         System.out.print("What is your variable names? ");
    var = keyboardInput.readLine();
    System.out.println("variable are :" + var );
         System.out.print("What is your separator? ");
         delimv = keyboardInput.readLine();
         //read the inputs from keyboard for string and delim
    System.out.print("What is your String? ");
    text = keyboardInput.readLine();
    System.out.println("String is :" + text );
         System.out.print("What is your separator? ");
         delim = keyboardInput.readLine();
         //create the stringtokenizer class instance
         StringTokenizer vt = new StringTokenizer(var,delimv);
         StringTokenizer st = new StringTokenizer(text,delim);
         //print the nexttokens as long as tokens and variables are available
         while (vt.hasMoreTokens()) {
         while (st.hasMoreTokens()) {
         vname = vt.nextToken();
         //     if(st.nextElement() == X){
         // System.out.println("filed is empty");
         // System.out.println(vname + "= ");
         System.out.println(vname + "=" + st.nextToken());
                   //nextToken());
    Variables name : cat1,cat2,cat3,cat4,cat5,cat6,cat7,cat8,cat9,cat10,cat11
    String name : Produkten;Voor hem;;Funny Mask ;12.50;4.90;17.40;1-5 dagen;0;http://www.eroticastore.nl/ProductDetails.asp?ProductId=21733&ReferrerId=134;http://www.eroticastore.nl/ProductImages/thumb_3300000510.jpg
    Note : Empty cell is in between "Voor hem" and "Funny Mask"
    Thanks In advance,
    Murali

    When you post code, please use [code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read.

  • In Range and Coerce, STRING

    Hola a todo el mundo,
    La funcion "In Range and Coerce" para cadenas de caracteres, tiene un comportamiento que no acabo de entender.
    Si mi limite superior es z y mi limite inferior es a, si pongo d obtengo un PASS. Hasta aquí todo correcto.
    ¿Por qué obtengo también un PASS si pongo d seguido de cualquier texto? ¿Como es posible que solo evalue el primer digito?
    Es decir: "alaglhzafgkhjzs" esta dentro de "a" y "z"??         ......      al parecer la respuesta es sí.
    Con imagenes:
    Muchas gracias por todo

    Hola de nuevo,
    He hecho un vi que realiza lo que esperaba encontrarme. Lo dejo en Labview 8.5 por si a alguien le ha sucedido lo mismo.
    Gracias
    Adjuntos:
    In Range String.vi ‏14 KB

  • Re: Passing a string from Java class to JSP

    How can I pass a string from a function within my bean class to my JSP page?
    I would like to pass something like this with the necessary params filled in:
    String myString ="Successful <b>" + Sales.getActionType() + "</b> was made on <b>" + (new Date()).toString();
    The ActionType will be either a BUY or SELL and the current date need to be added in.
    Thank you in advance!

    SOLVED THE PROBLEM!!!

Maybe you are looking for

  • How can i stop my iphone from allowing computers to download photos when connected?

    eg. if someone steals my phone and plug into there computer the windows photo download box pops up when connected and allows photos to be downloaded even with passcode. It doesnt make sence to me that if you try and get on my phone you cant look at a

  • The iPod could not be restored - error code 1433

    Just today I went to sync my 4th generation 20GB iPod with my Mac and iTunes gave me the following error message: "iTunes has detected an iPod that appears to be corrupted. You may need to restore this iPod before it can be used with iTunes. You may

  • Adobe Acrobat Pro freezing on duplex printing

    In adobe acrobat pro X when printing 2 or more pages duplexed on a Canon iR-adv c5045/5051 adobe acrobat freezes and crashes and the job never makes it to the printer, on adobe reader x free edition this is not hte case and prints without a problem.

  • How can I force valueChange in client listener to fire

    I've ADF fusion web application version 11.1.1.6 and I've input text it value is #{row.bindings.ManagerId.inputValue == 1}and client listener on it         <af:inputText id="it12"                       value="#{row.bindings.ManagerId.inputValue == 1}

  • Problem during Extention of VO

    I search in forum but did n't get any appropriate solution Steps I followed? -- UnZip the classes --I extended one VO (Its is Without Expert Mode) --Make substituion for that VO --Changed Manually the page for appearing that VO attribute on   Table o