Pass the URLLoader() variable between classes

I have two classes. See below.

What I want to do is quite simple, but I do not know how to do. I want the URLFactory for create table and store it in the variable 'dataArray' and use the table in the main class, by calling the GetList() class URLFactory. I have returns nothing... Please help

Basically, I need to set a variable equal to URLLoader.data (var something: String = URLLoader.data) so I can use this variable in other classes. WHY ISN'T IT EASIER? Please, I beg you. A solution would be much appreciated.

package classFiles
{
import flash.display.MovieClip;
Import classFiles.URLFactory;

SerializableAttribute public class MainClass extends MovieClip {}
private var _UrlDriver:URLFactory;

public void MainClass() {}
_UrlDriver = new URLFactory ('url');
var temp: Array = _UrlDriver.GetList ();

}

}

}

package classFiles
{
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.display.MovieClip;
import flash.events.Event;
import flash.sampler.Sample;

SerializableAttribute public class extends MovieClip {} URLFactory

private var loader: URLLoader;
public var textData:String;
public var dataArray:Array;

public void URLFactory(url:String) {}
textData = "";
this.dataArray = new Array();
loader = new URLLoader();
loader.addEventListener (Event.COMPLETE, HandleComplete);
Loader.Load (new URLRequest (url));

Temp = CreateDataArray();
}

function HandleComplete(e:Event):void {}

textData = loader.data;

trace (dataArray);

}

function CreateDataArray (): void {}

trace (dataArray);
dataArray = textData.split ("\n");
dataArray = textData.split('","');
}

public void GetList (): Array {}

return dataArray.

}
}

}

Yes, the data loading is not instantaneous.  This is why you use a complete listener in your factory.

Similarly, you must use a listener in your main class to check if the data is ready.

p.s. Please check the useful/correct.

Tags: Adobe Animate

Similar Questions

  • Pass the timeline variable to one of my classes!

    Hello!
    The title says it all.

    I need to pass a boolean variable is set to false for one of my classes called "Edit".

    It is passed to true when one of the functions of this class is managed.

    I tried a few ways different, but had no luck.

    Someone has an idea?

    If you instantiate the class in the timeline panel, you can simply call a method in the class - passing the variable as a parameter.

    easyGame.setTimelineVar (myVar);

    And have another method that allows you to retrieve the value:

    myVar = easyGame.getTimelineVar ();

  • Passing variables between classes

    I think I'm doing this more difficult than it really is. I would like to pass a variable of a class to another, once a file has been loaded. Currently I have a ListLoader that querys a PHP/mySQL which returns the XML of the class. I would like to create another class that processes this XML but I don't know how he pass only after it is loaded. It's getter/setter methods, or am I missing something really simple (or something else entirely)?

    Here are the two classes, with that I fight.

    Because the ListLoader makes the loading and the panels there appear, the panels need to know when the XML is available. If the panels accessed the magazine to the list, they either need to keep control if their XML is loaded, or subscribe to the magazine as a listener. It is better for the charger inform services' (the signs) when to use the XML.

    Better yet, if signs are essentially "views", take the treatment on the XML panels and give him the charger, then pass the XML transformed like a string or an object, or whether you need. In this way, the charger is the 'supply' and not the display panel, and the two don't get merged.

    The next step is to put in another class - essentially a data model that stores everything that has need of a Panel, so you might have different versions of panels, all you have access to the same data model. This class would then become the "model", and the Panel becomes the "viewer". (do a search for 'model view controller' - it's a basic OOP structure that goes a long way to help you think about OBJECT oriented programming, even if you do do not match exactly).

  • How to pass a variable between classes?

    Hello

    I created a class .as MovieClip to a MovieClip that contains 7 buttons. I use a table of these buttons and an array of labels of image on the timeline of the MovieClip parent to navigate in the labels.

    ...
    
    private function clickHandler(event:MouseEvent):void 
            {
    //Sets the current button listed in the button array    
     currentButton = MovieClip(event.currentTarget);
                index = buttonArray.indexOf(currentButton);
            
    //Uses the index variable to find the corresponding frame label from the label array            
    MovieClip(root).gotoAndStop(labelArray[index]);
            }
    
    ...
    

    This works perfectly.

    Now I have another .as MovieClip class, I created a simple MP3 player MovieClip. I'm pulling in a XML data of each mp3, including the URL, etc... All works perfectly.

    I'm trying to use the variable "index" of the class Nav.as in the class AudioPlayer.as to play the corresponding number of the song. By calling "playSong (index);

    "playSong (index);" works in a test file, when I tested the navigation tables and the corresponding number xml concept. I need to shoot the variable 'index' from Nav.as to AudioPlayer.as.

    ...
    
    private function playSong(mySong:Number):void 
            {            
                var myURL = my_songs[mySong].@URL;        
            
                if (my_channel) {
                    my_channel.stop();
                }
            
                my_sound = new Sound();
                my_sound.load(new URLRequest(myURL));
                my_channel = my_sound.play();
            }
    
    private function onPlay(e:MouseEvent):void {            
         playSong(index);
            }
    

    It works perfectly when tested. For example: "playSong (2)" or "playSong (5)" plays the song number correct.

    Thank you in advance!

    You should not have a currentIndex in each class, simply on the mother of the other 2 classes. When you say 'this.parent' you access the parent display object. This is where you want currentIndex to exist. If both classes are on the same display list then 'this.parent' will be the same parent and therefore the same variable.

    I didn't know what kind of display object container parent was (MovieClip, Sprite, etc.), so I've referenced it let go like: 'object (this.parent) .currentIndex '.

    Should be in NAV. As:

    Object (this.parent) .currentIndex = buttonArray.indexOf (currentButton);

    AudioPlayer.as should be read through:

    playSong (Object (this.parent) .currentIndex);

  • reset of movieclip between levels and passing the required variables

    Hello

    I am currently working on my first flash game and were able to get close enough everything works...

    I can play individually at each level by manually changing the variable "level =" (at any level I want to play) in actionscript code...

    Now I need to find the right way to reset the movie after each level, but still pass the variable Timer "currentTime" and "level"...

    Is there a usual way to do this?

    Can I use the variables I saved in the init() function...

    I really hope someone can help I'm so close being completed...

    Use the trace() function to debug your problems.  What is the next show:

    If ((level == 71) & (gamePage.a1.hitTestObject (gamePage.h1) & gamePage.h1.occupied == true) {})

    spinSpinner();

    Level = 1;

    trace (mainTimer);

    mainTimer.reset ();

    mainTimer.start ();

    removeChildAt (0);

    addChildAt (completePage, 0);

    } else {}

    gamePage.helpIcons.gotoAndStop ('icon7');

    }

  • How to pass the PHP variable to menu jQuery Modal popup

    Hello

    Need help to find how to pass a variable in php (which is recovered in a while loop) in a modal window.

    There is a list of users on the page (shown with a while loop), with buttons Remove next to each of them.

    When the administrator clicks the button Delete for that specific user, a modal window appears confirming their action.

    I can't find a simple way to communicate the id of the user to be removed the modal (where the query is performed, once 'Yes to confirm deletion' is clicked).

    I deleted the jQuery, seeing as how this could change how the modal opens and closes.

    This is the modal:

    < div class = "modal" >

    < div class = "modal_wrapper" >

    < div class = "modal_title" > are you sure you want to delete this user? < / div >

    < div class = "modal_content" >

    < div class = "modal_button_no" > n < / div >

    < div class = "modal_button_yes" > Yes, delete it < / div >

    < / div >

    < / div >

    < / div >

    < div class = "delete_btn" > delete user < / div >

    The variable with the user name is:

    $user_id

    Any help would be much appreciated!

    Thank you

    It is a fairly simple procedure. Personally I'm not sure that its worth the effort for a box of administration but good we all have different opinions - there is no wrong or it.

    Suppose that your buttons delete on your page are anchor tags and you have locked down your database of names to create anchor tags. The value of dir below has been inserted via php through loop and is your RegID.

    Delete

    Delete

    Delete

    Delete

    When you click the anchor tag (that class name "delete") opens a lightbox. You also have to collect the value of "dir" at the time the lightbox opens - happening of value to a hidden in the lighbox code entry field.

    The value of the "dir" command is passed to the light table in a hidden form field:

    "You have a delete button in the light table with the class of ' delete_record ':

    Delete the record

    When the user clicks on the button Delete in the light table the value of hidden form field is harvested and forwarded to your page of delete_record.php via the jquery/ajax script below, were also on the same page.

    Your delete_record.php would look like below, assuming that you use mysqli or if you are using mysql then you would follow the same delete procedure as usual.

    <>

    $conn = new mysqli ('localhost', 'root', 'root', 'name');

    {if ($conn-> connect_errno)}

    echo $conn-> connect_error;

    Die (' sorry, can not connect to the moment, try again later ');

    }

    ?>

    <>

    delete the record

    $record_id = $conn-> real_escape_string (stripslashes (trim($_POST['record_id'])));

    $conn-> query ("' DELETE FROM names WHERE record_id = ' $record_id ' '");

    $record_deleted = "true";

    ?>

    An alert box will appear at the end, confirming that the record has been deleted. You do not have to deploy an ugly alert box - you sends the data to the device of light therapy from the delete_record.php page in a few nice melted in

    If you want to be more subtle about it.

  • OBIEE11g - by passing the quick values between pages of dashboard

    Hello

    I'm working on OBIEE 11.1.1.3 and need help on the question of the value of guests passing between the dashboard pages.

    Scenario:
    -J' built 2 reports of the separate fact tables. Customers and products are the common dimensions between these fact tables. Temporal dimension is different for each of them.
    -J' have a dashboard and 2 pages it contains - Page1 and Page2.

    Page1:
    -J' have a dashboard guest with filters product, customer and year.
    -J' have a relationship with the product, customer, year and income of the columns.
    -J' have an Action - "Click here" link, which directs the user to page 2.

    Page2:
    -J' have a dashboard guest with filters product, customer and week.
    -J' have a relationship with the customer, product, week and Total Volume of the columns.

    I select some values in Page1 guests and generate a report. Then I click on the "Click here" action link, which will take me to page 2.

    Now, on page 2, I want the common guests (product and customer) have default selected as the values that were selected in the common guests on Page1. And, as a result, the report on page 2 must be generated.

    Tried solutions:
    1. added the below javascript in page 1, but the link that is clicked, does nothing.

    < script >
    function navigateToPage2()
    {
    DashboardChangePage ('path to Page2');
    }
    < /script >
    Click here

    2. I put a Variable presentation when you select a value in a prompt on Page1. But I am unable to set this as the default valie variable in the corresponding prompt on Page2.

    Ask what the experts kindly suggest how I can get this to work.

    Thank you and best regards,
    Rahul

    Published by: Rahul December 1st, 2011 05:10

    Hello Rahul,

    This is a bug in 11.1.1.3, application of patch 10381088 solve this problem.

    Bug 10381088: dash PROMPT VALS NOT KEPT WHEN you NAVIGATE TO OTHER PAGES IN the dashboard

    Rgds,
    DpKa

  • Passing the form variables to a thank you page.

    Hi all

    I have put code in place so my survey form transmitting data hidden on a confirmation page and displays the appropriate data. for example

    tag_reportid = 222776

    tag_displayname = Point 26



    My form script is:

    " < form name ="catwebformform3235"method ="post"onsubmit ="return checkWholeForm3235 (this)"enctype =" multipart/form-data"action =" https://BAFs.worldsecuresystems.com/FormProcessv2.aspx?WebFormID=72629 & pageid = %2thankyou.htm? name = {tag_reportid} & amp; titlename = {tag_displayname} & amp; OID = {module_oid} & amp; OTYPE = {module_otype} & amp; EID = {module_eid} & amp; CID = {module_cid} & amp; CC = {module_urlcountrycode} & amp; Sponsor = {module_siteurl, true, true} ">"

    What I see on the receipt/thank you page, is that only the name field has been spent... thankyou.htm? name = 222776,... then it is not passing the titlename field.

    In fact, it seems that it won't any variable after this first field 'name '.

    How can I get the form to send any variable I need more on page of thanks? Thanks in advance.

    Sure thing if your not comfortable with javascript, I created this one liner for you and an example of work (I wrapped the shape with a border of style so that you can see on the page, obviously to remove when you want to go live). I coded only the first two points, if you find that you do others (of course), and then wrap them also.

    Form here

    Example:

    https://jsfiddle.NET/rsy9bxyp/1/

  • Pass the .swc variable to main application...

    Hello

    I'm trying to retrieve data from a compiled .swc that is loaded into the main application. I have a generic function as follows:

    public void onSubFormFinishClick(event:MouseEvent):void

    {

    var applicationCompletedVar:int = 1;

    trace ("Full Application =" + applicationCompletedVar);

    }

    ... which is executed when the user clicks on the button in the custom .swc. I want to be able to pass this parameter to the main application. Can someone provide examples of how to achieve this? Using external swf loading in a swf Flash, I have just shipped a new event and listen for this event and take action after hearing the past event. being new Flex, I don't know how to proceed.

    Thx for any help,

    ~ Chipleh

    Set the public variable in the main application for example,

    public var Valeurdonnees: String = "Hello";

    Assign the value to the dataValue component SWC file using FlexGlobals as:

    FlexGlobals.topLevelApplication.dataValue = 'Hello friend ';

    Now draw the value in the handler in the main application that handle the event dispatched from CFC. Gets the update of dataValue.

  • By passing the package variables to the package...

    Hello world

    I have the following problem:

    Package A compiled in scenario A - not referencing not date of process.
    Package B compiled in scenario B with declare the flow variable called ProcessDate.
    Package MAIN calling declare variable ProcessDate, then calling scenario A, then B Scenario and then ENDS.

    MAIN scenario created with the ProcessDate startup parameter.

    So I want to start the MAIN scenario, with a parameter to ProcessDate. He asks me for the setting, but then scenario B fails as if he did not get the parameter. However, when I run the only TI, scenario B works very well after asking for the value of the parameter.

    any help appreciated.
    Thank you!
    Nick

    Hi Nick,

    When you drop scenario B in the main package, please do not forget to pass the variable processdate to scenario B. This can be done by using the additional Variables tab in the scenario using the menu drop down.

    Thank you
    Ritika

  • Passing the Captivate Variables to Embedded SWFs.

    Does anyone know how to pass a variable of Captivate to an embedded swf? I will elaborate on our situation for clarity. Finally, we Captivate allows you to create Scorm packages for use in Moodle. In this particular case, we have a Captivate project where we have several slides. On each slide, we want to import a swf created in Flash. Now, this Flash swf is configured to analyze an external XML file, determine which slide containing the swf on and then read the correct video for this slide. This file has a list of video sites (URL) and is organized by slides. The question we are hung up is how to pass the variable of Captivate (cpInfoCurrentSlide) for the current slide to the embedded swf. Someone saw?

    S

    Of course you can do it.

    Here is a list of all the variables: http://www.cpguru.com/2009/04/28/system-variables-in-captivate-4-%e2%80%93-a-complete-list /

    I'm not aware of any written documentation, but it is just like when you take a variable.

    Example:

    _root.rdcmndNextSlide = 1; will send your project to the next page.

    / Michael

    Visit my Captivate blog with tips & tricks, tutorials and widgets.

  • Access a public variable between classes

    Hello

    I have two classes running... one is a class of documents (EgoGame.as) and another is a class linked to several similar clips (Ball.as).

    I'm trying to access a public Ball.as variable that has been declared in the class statement EgoGame.as.

    When I run the test output includes the following...

    1120: access of undefined property _ballPlaced.


    Here is my code.  What I'm trying to do is remove the Ball.as event listeners when the _ballPlaced variable is true, so that the user cannot drag and drop the balls after that that they were placed in a box... pointers greatly appreciated!

    Document class
    EgoGame.as

    package
    {
        import flash.display.MovieClip;
        import flash.display.DisplayObject;
        import flash.events.MouseEvent;
        import Ball;
            
        public class EgoGame extends MovieClip
        {
            public var __zoneFull:Array = new Array(false, false, false);
            
            public var __ballPlaced:Array = new Array(false, false, false);
            
            public function EgoGame()
            {
                ball0_mc.addEventListener(MouseEvent.MOUSE_DOWN, zoneEmpty);
                ball1_mc.addEventListener(MouseEvent.MOUSE_DOWN, zoneEmpty);
                ball2_mc.addEventListener(MouseEvent.MOUSE_DOWN, zoneEmpty);
                
                ball0_mc.addEventListener(MouseEvent.MOUSE_UP, zoneFill);
                ball2_mc.addEventListener(MouseEvent.MOUSE_UP, zoneFill);
                ball1_mc.addEventListener(MouseEvent.MOUSE_UP, zoneFill);
                
                ball0_mc.addEventListener(MouseEvent.MOUSE_UP, playMovie);
                ball1_mc.addEventListener(MouseEvent.MOUSE_UP, playMovie);
                ball2_mc.addEventListener(MouseEvent.MOUSE_UP, playMovie);
                
                }
            
            private function zoneEmpty(event:MouseEvent):void
            {
                if(event.target.hitTestObject(zone0_mc) && _zoneFull[0] == true)
                {
                    _zoneFull[0] = false;
                    _ballPlaced[event.target.name.substring(4,5)] = false;
                }
                else if(event.target.hitTestObject(zone1_mc) && _zoneFull[1] == true)
                {
                    _zoneFull[1] = false;
                    _ballPlaced[event.target.name.substring(4,5)] = false;
                }
                else if(event.target.hitTestObject(zone2_mc) && _zoneFull[2] == true)
                {
                    _zoneFull[2] = false;
                    _ballPlaced[event.target.name.substring(4,5)] = false;
                }
                else
                {
                    event.target.x = event.target._startX;
                    event.target.y = event.target._startY;
                    _ballPlaced[event.target.name.substring(4,5)] = false;
                }   
            }
            
            private function zoneFill(event:MouseEvent):void
            {
                if(event.target.hitTestObject(zone0_mc) && _zoneFull[0] == false)
                {
                    event.target.x = zone0_mc.x;
                    event.target.y = zone0_mc.y;
                    _zoneFull[0] = true;
                    _ballPlaced[event.target.name.substring(4,5)] = true;
                }
                else if(event.target.hitTestObject(zone1_mc) && _zoneFull[1] == false)
                {
                    event.target.x = zone1_mc.x;
                    event.target.y = zone1_mc.y;
                    _zoneFull[1] = true;
                    _ballPlaced[event.target.name.substring(4,5)] = true;
                }
                else if(event.target.hitTestObject(zone2_mc) && _zoneFull[2] == false)
                {
                    event.target.x = zone2_mc.x;
                    event.target.y = zone2_mc.y;
                    _zoneFull[2] = true;
                    _ballPlaced[event.target.name.substring(4,5)] = true;
                }
                else
                {
                    event.target.x = event.target._startX;
                    event.target.y = event.target._startY;
                    _ballPlaced[event.target.name.substring(4,5)] =false;
                }
            }
            
            private function playMovie(event:MouseEvent):void
            {
                if (_ballPlaced[0] == true)
                {
                    ball0_mc.gotoAndPlay(2);
                }
                else
                {
                    ball0_mc.gotoAndStop(1);
                }
                
                if (_ballPlaced[1] == true)
                {
                    ball1_mc.gotoAndPlay(2);
                }
                else
                {
                    ball1_mc.gotoAndStop(1);
                }
                
                if (_ballPlaced[2] == true)
                {
                    ball2_mc.gotoAndPlay(2);
                }
                else
                {
                    ball2_mc.gotoAndStop(1);
                }
            }
            
            
        }
    }


    Ball.As

    package
    {
        import flash.display.MovieClip;
        import flash.events.MouseEvent;
        import flash.display.DisplayObject;
        import EgoGame;
        
        public class Ball extends MovieClip
        {
            // public var _hitTarget:MovieClip;
            public var _startX:Number;
            public var _startY:Number;
            
            public function Ball()
            {
                _startX = this.x;
                _startY = this.y;
                this.buttonMode = true;
                this.addEventListener(MouseEvent.MOUSE_DOWN, dragIt);
                this.addEventListener(MouseEvent.MOUSE_UP, dropIt);
            }
            
            private function dragIt(event:MouseEvent):void
            {
                this.startDrag();
            }
            
            public function dropIt(event:MouseEvent):void
            {
                this.stopDrag();
            }
            
            public function lockBall(event:MouseEvent):void
            {
                if(_ballPlaced[this.name.substring(4,5)] == true)
                {
                    this.removeEventListener(MouseEvent.MOUSE_DOWN, dragIt);
                    this.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
                }
            }
            
        }
    }

    each place you have a ball of reference you have access to the lockBall() method.  so, if ball0_mc is a member of Ball class, you can use:

    ball0_mc.lockBall ();

  • How to pass the global variable...

    Hello

    I have a report in a page and form in another page...

    If I clicked on the icon change in the report page it navigates to the form in another page...

    In this im report have "bill_amount" as one of the column, if I clicked on the icon change report page means, it will go to the form in another page...

    This form consist of one text field which is "bill_amount"...

    Since the report that I bill_amount for each entry, if I clicked on the icon change the means of the respective row, it does not appear automatically the respective bill_amount in the text in the form field...

    I created a report separately on the sql_query table... I created a form with a single field 'bill_amount '...

    Given that I na not create a report and a form based on the table... If I have created as it means if I clicked on the icon change it will show the datas respective in the form... since I created a report and form separately...

    If it is possible to create a global variable... who will bring the value of the "invoice amount" in the relationship and you will go the respective value in the form field on the next page...

    I don't want to put the value in the form field by restricting by request... She must take through the global variable...

    How can I reach it...

    It is urgent...

    concerning
    Mini

    Hello

    In her edit link column u give, the respective form field name, and the name of the column in the report inside...

    So that the value in the report of the corresponding column will be inserted into the corresponding field in the form...

    (IE) like this

    > p1_item_name---> #corresponding report name column #.

    Concerning
    GTA...

  • pass variables between classes

    Hello! I'm new to flash actionscript and I make a small game right now. I thought to create separate movieclips for each level of play and their assigned separate classes is cleaner and easier to code.

    for example: -.

    level 1 - level1.as

    level 2 - level2.as

    Level3 - level3.as

    My problem is how to pass variables (such as health, score, etc.) to a higher level?

    Please help I'm stuck on this and I have searched a lot but couldn't get the right answer...

    Oh, and I use cs3 flash with actionscript 3.0

    I don't think you really understand what are classes and movieclips.

    MovieClips are display objects; your character, the enemy, elements, platforms< these="" will="" be="">

    Classes can be used to define new elements or extend those which already exist, such as an object or a MovieClip.

    For the purposes of making a game, I would separate levels of executives.

    do level 1 on a frame labeled "level 1".

    and level 2 on a frame labeled "level 2".

    variables will carry an image to the image.

    Use gotoAndStop (frame_label) to switch between levels

    * Make sure you use stop(); on the first image to prevent bike between the frames.

    * You can make the frames between each level that has the code "gotoAndStop(previous level)" to prevent people to hit 'play' on the swf file and the cycling through your levels.

    You can also search for SharedObjects as a method of storage of variables even after that the swf file is closed.

  • To access the added Variables of Classes dynamically

    I'm not sure what the terminology is here, but it's what I do.

    I added the officials in the field via a loop and add to the screen

         // loop through all of the elements and setup the forums
            for (int i = 0; i < size; i++)
            {
                c_ForumSelect frm = new c_ForumSelect();
                frm = (c_ForumSelect) v_forums.elementAt(i);
                hfm_forumselect new_forum = new hfm_forumselect(frm);
                mainManager.add(new_forum);
            }
    

    I wrote the code that allows to "highlight" the domain manager.

    Is there a way to 'read' the Manager added variables?

    For example, if I had a Variable called 'ID' within the hfm_forumselect... How I acceding that when sound highlighted on the main screen of the user interface...?

    Who is?

    You can add them to a datastructure, a vector, for example. When you add them. Or add the database instead. or you can use the container Manager, navigation using getFieldCount and getField (index).

Maybe you are looking for