dcsimg
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Pass parameter from first frame to class

  1. #1
    Member
    Join Date
    Nov 2002
    Posts
    43

    Pass parameter from first frame to class

    I have an application that gets its variable data in XML file.
    This application is used for different clients with different data.

    Some of the data I pass to the Document class from the first frame. I would prefer to pass url to the XML file the same way, without the necessity to update the document class. But now I have to hardcode this url in the class every time, because I cannot get parameters from the first frame to the class at once, only after some time (like after loading XML with hardcoded url).

    Is there a way to force executing of the code on the first frame before the code in the class will proceed?

  2. #2
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    well you have a dirty incorrectly written program is you have any code within the .fla and are using classes. What is your class linked to a MC? I'm surprised it even compiles....Are you getting any error messages.....you should have


    fla>>>>main/document class>>>>>>class packages.........where the class packages are bound togeather by the main class........see other posts on this page by me there is plenty of examples of what I speak of.
    ~calmchess~

  3. #3
    Member
    Join Date
    Nov 2002
    Posts
    43
    I didn't get you. What is so wrong with the code in the frame? I find it very convenient when I need to have multiple files that use the same document class.

    I put getters/setters in the class, and give values to some variables in the Fla file itself.
    I just want to be sure that these values were received before the rest of the code starts executing.

  4. #4
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    somebody else is going to have to answer this because I don't code that way ....never have never will.....sorry for dirting your post
    ~calmchess~

  5. #5
    Member
    Join Date
    Nov 2002
    Posts
    43
    So, what would be your solution in this case? If you needed multiple SWF files which differ only in some parameters?

  6. #6
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    well it depends on the use case if those parameters were static variables then i'd use an xml file to set the parameters I mean you could use the same xml file name with multiple .swf and just change the parameter inside it...........I use a single main.as file that you attach as the document class which would hold the xml call and it would bind all the class files togeather which gives me a central point to access the stage object create variables pass variables between classes......just allows me to build a highly robust flexiable structure.
    ~calmchess~

  7. #7
    Member
    Join Date
    Nov 2002
    Posts
    43
    Unfortunately, I have some constraints about file names. Particularly, files for all clients are stored in the same location, so XML names have to be different. Not just that, each client might use several files with one different parameter (DSS feed). This is why I find convenient to keep each client's parameters in separate XML, but still have to change at least two parameters (url to XML (which contains application data including url's to feed XML's), and "current feed" file combination) before I compile each SWF.

    I don't see any crime in assigning value to some variables in the first frame through setter function. It is very visual, and give opportunity to maintain application without going into the code (if, for example, somebody else has to do it).

    But I still don't know at what point the code in the first frame executes, and how to make the rest of the code to wait for it to happen.

    Actually, I just got the idea to put event dispatcher into the setter. That might work, I will try it.
    Last edited by olka_sb; 06-01-2010 at 10:55 AM.

  8. #8
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    well that would require a pretty extensive rewrite......what i had above just example.....keep doing what you doing.
    ~calmchess~

  9. #9
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    import Foldername.ClassName;
    var classname:ClassName = new ClassName(passparameter);
    ~calmchess~

  10. #10
    Member
    Join Date
    Nov 2002
    Posts
    43
    Event dispatcher works perfectly.
    Thank you, calmchess, the solution became obvious when I tried to explain you exactly what I need.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center