Dynamics of code in loop problem with event handlers

Hello

What I'm trying to do, is to assign dynamically a deployment and behavior pleased each movieclip with a certain name on my stage. I'm a loop through and attach a function to the event of each movieclip. So far, it works. All the clips on roller and more doing something. However the problem I'm having is dynamically changing values in each function for each different movieclip in a loop. For example, I store the clip I'm targeting original X and Y coordinates in an array that I push in the value to each loop. I draw it to test and trace it correctly on each loop of each value of X and Y for this clip. The problem I have is I am tempted to call orgX and orgy to each loop and attach that to each function, but all the clips using the last value in the table. It is not dynamically attaching the new orgX and orgy to each individual event deployment clips. All deployment events and more are called for each clip, but when I try to put any dynamic code in the function he always uses only the last value. Even if I put a trace in the RollOver event and try to find the instance name of movieclip clips all the clips to trace the last name of the clip on working capital. My logic looks OK but it has to do with how flash events attached runtime? How can I solve this problem?

These tables are not something and orgX and orgy change values with each iteration of the loop for. at the moment where you deploying your movieclip orgX and orgy will be the last value in the loop for.

to remedy to try:

Tags: Adobe Animate

Similar Questions

  • problems with event handlers

    Hello world. I have a problem with the start of the event handlers in InDesign CS3. The example code I wrote the tutorial book, will not work. The message that I get when I open a new document is: "error string: the requested operation could not be performed because the object no longer exists." Here's the code I used:

    --------------------------------------

    main();
    main() {} function
    myEventListener var = app.addEventListener ("afterNew", myDisplayEventType, true);
    }

    function myDisplayEventType (myEvent) {}
    Alert ("this event is the" + myEvent.eventType + "event.");
    }

    ------------------------------------

    What's not here? Thanks in advance,

    mileking

    Hi mileking.

    Use the code example below:

    Code example
    #targetengine "session".
    main();
    main() {} function
    myEventListener var = app.addEventListener ("afterNew", myDisplayEventType, false);
    }

    function myDisplayEventType (myEvent) {}
    Alert ("this event is the" + myEvent.eventType + "event.");
    }

    Kind regards

    River. P

  • Problem with event handlers

    Hello

    It seems that my event handlers do not work for some reason any. Could someone help me please?

    That's what I do:

    (1) create a simple Java class (with all necessary libraries) and compile to setMiddleName.jar:

    --

    bunch of pre-treat;

    import...

    public class setMiddleName implements {PreProcessHandler}

    public setMiddleName() {}

    Super();

    }

    @Override

    Public Sub initialize (HashMap < String, String > parameters) {}

    }

    @Override

    public EventResult run (long processId, long eventId, orchestration of the Orchestration)

    {

    Parameters HashMap < String, Serializable > = orchestration.getParameters ();

    String middleName = getParamaterValue (settings, "First name");

    If ((middleName == null) | middleName.equals("")) {}

    String firstName = getParamaterValue (settings, "First name");

    middleName = firstName.substring (0, 1);

    orchestration.addParameter ("middle name", middleName);

    }

    return new EventResult();

    }

    private String getParamaterValue (< String, Serializable > HashMap parameters,

    String key) {}

    {if (Parameters.ContainsKey (Key))}

    String value = (parameters.get (key) instanceof ContextAware)? (String) ((ContextAware) settings)

    .get (Key)). GetObjectValue(): parameters.get (key) (string);

    Returns the value;

    }

    else {}

    Returns a null value.

    }

    }

    @Override

    public BulkEventResult run (long arg0, long arg1, arg2 BulkOrchestration) {}

    TODO self-generating method stub

    Returns a null value.

    }

    @Override

    public void offset (long arg0, arg1 is long,

    {AbstractGenericOrchestration arg2)

    TODO self-generating method stub

    }

    @Override

    public cancel Boolean (long arg0, arg1 is long,

    {AbstractGenericOrchestration arg2)

    TODO self-generating method stub

    Returns false;

    }

    }

    --

    (2) create plugin.xml

    --

    <? XML version = "1.0" encoding = "UTF-8"? >

    " < oimplugins xmlns: xsi =" http://www.w3.org/2001/XMLSchema-instance ">

    < pluginpoint = "oracle.iam.platform.kernel.spi.EventHandler plugins" >

    < pluginclass = "preprocess.setMiddleName plugin" version = "1.0"

    name = "setMiddleName" / >

    < / plugins >

    < / oimplugins >

    --

    (3) package zip file with the following content:

    --

    /plugin. XML

    /lib/setMiddleName.jar

    --

    and copy it to /oracle/plugins/setMiddleName.zip

    (4) create EventHandlers.xml and put it in /oracle/eventhandlers/metadata/preProcessEH/EventHandlers.xml

    --

    <? XML version = "1.0" encoding = "UTF-8"? >

    " < eventhandlers xmlns =" http://www.Oracle.com/schema/OIM/platform/kernel "" xmlns: xsi = " http://www.w3.org/2001/XMLSchema-instance " xsi: schemaLocation = " http://www.Oracle.com/Schema/OIM/Platform/kernel orchestration - handlers.xsd" >

    < entity-type of the action handler = "User" operation = "CREATE" name = "setMiddleName" Stadium = "preprocess" order = "1050" sync = "TRUE" / >

    < / eventhandlers >

    --

    (5) change ant.properties:

    --

    WLS. Home=/Oracle/MW/wlserver_10.3/

    IOM. Home = / Oracle/MW/Oracle_IDM1/Server

    Login.config = ${IOM. Home}/config/authwl.conf

    MW. Home = / Oracle/MW

    --

    and call 'Ant f pluginregistration.xml register' and specify the location of setMiddleName.zip. Result: [echo] Plugin version 1.0 reregistered preprocess.setMiddleName, BUILD successfully.

    (6) Edit weblogic.properties:

    --

    wls_servername = oim_server1

    application_name = OIMMetadata

    metadata_from_loc = / oracle/eventhandlers

    --

    and call. / weblogicImportMetadata.sh, which translates as:

    --

    Now to the tree of domainRuntime. It is a tree read-only with DomainMBean as the root.

    For further assistance, use the help (domainRuntime)

    Disconnected from the weblogic server: AdminServer

    End of import of metadata script...

    Leaving WebLogic Scripting Tool.

    --

    7)./PurgeCache.sh call all THE

    (8) restart IOM

    (9) result: the event handler does nothing. I don't have the impression to be called never, I tried to add logging resulting not in what either.

    Using the administration console export tool, I check that the handler is however there (it shows as/metadata/preProcessEH and I can export).

    What I am doing wrong? I forgot something?

    Thank you

    Max

    Hello

    In your EventHandlers.xml

    "http://www.Oracle.com/Schema/OIM/Platform/kernel" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" "xsi: schemaLocation =" "http://www.oracle.com/schema/oim/platform/kernel orchestration - handlers.xsd" > "

    I don't see the class?

    See the example below

    <>

    Class = "Oracle.OIM.extensions.PreProcess.SamplePreprocessExtension"

    entity-type = 'User '.

    operation = "CRΘER."

    name = "SetUserMiddleName".

    Stadium = "pretreatment".

    order = "1000".

    Sync = "TRUE" / >

  • Problems with events in flex

    Hello. I'm a guy AS2 and Flash CS3. I started to learn AS3 and Flex 3 transfer. But I had a problem w / events in AS3. I add a component of the canvas to the scene. On this canvas, I added 3 different events: mouse down, mouse move, and mouse upwards. When the mouse move is triggered, it is impossible for me to get the mouse an event triggered, and vice versa, when the mouse upward is triggered, there is no way to get the mouse don't move event triggered. Is there someone to help this newbie with this problem? Any help will be much appreciated.

    Code:

    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML layout "="absolute">
    < mx:canvas id = "myCanvas" x = "50" y = "50" width = "500" height = "500" click = "event_1 (); "mouseMove ="event_2 (); "mouseUp ="event_3 (); ">
    < / mx:Canvas >

    < mx:Script >
    <! [CDATA]
    Import mx.controls.Alert;
    import flash.events. *;
    public function event_1 (): void
    {Alert.show ("first event fired") ;}}
    public function event_2 (): void
    {Alert.show ("Second event fired") ;}}
    public function event_3 (): void
    {(Alert.show ("troisième événement déclenché) ;}}
    < / mx:Script >
    < / mx:Application >

    The problem is that your event listeners are not properly configured.

    Your "p1" to listen for the 'mouseUp' event because he was managing the events at this time.

    This is your modified and test code, as long as the mouse is down on the canvas, she fares at the time where you 'mouseUp' stop drawing.


    http://www.Adobe.com/2006/mxml"layout ="absolute"creationComplete =" initApp () ">"

    import com.myDomain.Lines.Main;
    Mx.graphics import. *;
    Import mx.binding.utils.BindingUtils;
    import flash.events.IOErrorEvent;
    import flash.events.Event;
    import flash.display. *;
    Import mx.controls.Alert;
    import com.myDomain.Lines.Main;
      
    public var p1:Main;
    public var pre:Number = 0;
      
    public function initApp (): void
    {
    P1 = new Main();
    this.addChild (p1);
              
    }
     
    public function prepToDraw (): void
    {
    pre = 1;
    }
     
    public void startDraw(event:MouseEvent):void
    {
    if(pre == 1)
    {
    P1. Graphics.Clear ();
    var newColor:int = 0xFF00FF;
    var iniX:Number = mouseX;
    var iniY:Number = mouseY;
    var lineWidth:Number = 10;
    P1. Graphics.LineStyle (width of stripe, newColor);
    P1. Graphics.MoveTo (gwenael, iniY);
    }
       
    imageView.addEventListener (MouseEvent.MOUSE_MOVE, drawLine);
    P1.addEventListener (MouseEvent.MOUSE_UP, stopDraw);
    }
      
    public void drawLine(event:MouseEvent):void
    {
    if(pre == 1)
    {
    P1. Graphics.LineTo (mouseX, mouseY);
    }
    }
    public void stopDraw(event:MouseEvent):void
    {
    imageView.removeEventListener (MouseEvent.MOUSE_MOVE, drawLine);
    }
     
     
    ]]>


     
    mouseDown = "{startDraw (event)}" > "
     



    HTH,

    Kenny

  • "I use CS2 in Windows XP sp2, 32-bit, interested in CS3 &amp; tried to download &amp; install, giving message" "code error 1720" problem with a script required for this installation and windows package install ".

    Currently I am interested in CS3 & CS2 user, so I doenloaded CS3 but gives the time installation message "Error 1720, there is a problem with this windows package install." A script is required for this installation to complete, contact technical support.

    Google search for help with the problem of Windows...

    https://www.Google.com/search?q=Error+1720&SourceID=IE7&RLS=com.Microsoft: en - US: IE - address & ie = & oe = & gws_rd = ssl

  • Management events JFXPanel drag a expensive impact on performance with event handlers

    We have a drag event handler, which is a bit expensive, takes something like 20 ms. However, the code must be run synchronously.

    Is no problem in a pure environment of JavaFX, less events drag are created when the CPU load is high.

    However, when they are incorporated in the Swing using JFXPanel, this adaptation doesn't kick in, many events drag is created and the application become slow.

    Is it possible to imitate what JavaFX in the JFXPanel scenario?

    The code below is a stand-alone example that shows what I'm describing.

    Some results I got:

    -eventHandlerSleep = 5 - noswing-128 events > drag

    -eventHandlerSleep = 30 - noswing - > 46 events drag

    -eventHandlerSleep = 5-> 136 events drag

    -eventHandlerSleep = 30-> 135 events drag

    {code} import java.util.Arrays;

    Javax.swing import. *;

    import com.sun.glass.ui.Robot;

    Import javafx.application.Application;

    Import javafx.application.Platform;

    Import javafx.embed.swing.JFXPanel;

    Import javafx.event.EventHandler;

    Import javafx.scene.Scene;

    Import javafx.scene.input.MouseEvent;

    Import javafx.scene.layout.BorderPane;

    Import javafx.stage.Stage;

    public class DragHandlingTester {}

    private static long EVENT_HANDLER_SLEEP = 30;

    Public Shared Sub main (String [] args) {}

    for (String arg: args) {}

    If (arg.startsWith("-eventHandlerSleep=")) {}

    EVENT_HANDLER_SLEEP = Long.parseLong (arg.split ("=") [1]);

    }

    }

    If (Arrays.asList (args).contains("-noswing")) {}

    Application.Launch (JavaFXDragHandlingTestApp.class, args);

    } else {}

    new SwingDragHandlingTestApp();

    }

    }

    public static class SwingDragHandlingTestApp {}

    {SwingDragHandlingTestApp()}

    JFrame frame = new JFrame();

    final JFXPanel fxMainPanel = new JFXPanel();

    Platform.runLater (new Runnable() {}

    @Override

    public void run() {}

    DragTestScene dragTestScene = new DragTestScene();

    fxMainPanel.setScene (dragTestScene.createScene ());

    }

    });

    frame.setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE);

    frame.getContentPane () .add (fxMainPanel);

    frame.setSize (800, 600);

    frame.setVisible (true);

    }

    }

    NotInheritable public class JavaFXDragHandlingTestApp extends Application {}

    @Override

    {} public void start (point primaryStage)

    primaryStage.setWidth (800);

    primaryStage.setHeight (600);

    primaryStage.setX (0.0);

    primaryStage.setY (0.0);

    DragTestScene dragTestScene = new DragTestScene();

    primaryStage.setScene (dragTestScene.createScene ());

    primaryStage.show ();

    }

    }

    public static class DragTestScene {}

    private int Queens = 0;

    public createScene() {} Scene

    New Thread (new Runnable() {}

    @Override

    public void run() {}

    try {}

    After 1 second, drag the mouse through the window

    Thread.Sleep (1000);

    Robot robot = com.sun.glass.ui.Application.GetApplication () .createRobot ();

    robot.mouseMove (50, 50);

    robot.mousePress (1);

    for (int i = 20 & lt; 700; I = i + 5) {}

    robot.mouseMove (i, 50);

    Thread.Sleep (10);

    }

    robot.mouseRelease (1);

    } catch (Exception e) {}

    e.printStackTrace ();

    }

    }

    ({. start()});

    BorderPane borderPane = new BorderPane();

    borderPane.setOnMouseDragged (new EventHandler() {}

    @Override

    public void handle (MouseEvent mouseEvent) {}

    Drag Queens ++;

    try {}

    Thread.Sleep (EVENT_HANDLER_SLEEP);

    } catch (InterruptedException ignored) {}

    }

    System.out.println ("number of events slide:" + drag);

    }

    });

    new back stage (borderPane);

    }

    }

    }

    {code}

    Yes, it is a known problem or expected, even if I don't remember the JavaFX bugs filed on this issue. JFXPanel is known to have some different problems with the sending of the event, such as Swing and live JavaFX on two threads. Drag-and - drop are required to be synchronous, so we enter a nested event loop while sending events to the Swing DND to JavaFX. It is the source of performance issues that you observe.

  • How to reference clips video parent/child with event handlers?

    I wonder how to reference correctly clips video parent/child, creating event handlers?

    I have a button in a movie clip, which is located in a clip.

    That's what my manager looks like now:

    This. DropMenus.DMSeats.ButtonSeats.addEventListener ("click", SeatsOver);

    The button instance name is ButtonSeats

    It is, I get this:

    TypeError: Error #1009: cannot access a property or method of a null object reference.

    Any idea where I could go wrong?

    Also, if I were to move the listener to drain directly into the clip where the button, how could I make reference to the parent/parent timeline (the main timeline)? Am I right to understand that .This refers only to the current clip?

    Thank you!

    You can place your code in a function that is called when your objects exist.

  • Problem with event listener

    Hello

    We have an event listener that does not seem to receive all events insertion of a table.

    Here is the SYS. Order ADD_LISTENER that we use:

    call the SYS. ADD_LISTENER ('tpch ', 'SQLFIRE', 'lineitem', 'demo.vmware.sqlfire.greenplum.MultiHubProxyDispatcher',' connectionurl = jdbc:sqlfire: | numproxies = 4 | sqlfire = username: password = sqlfire ", null);

    MultiHubProxyDispatcher() code distributes the rows inserted between the four tables proxy (proxy_0 through proxy_4). I have attached the MultiHubProxyDispatcher() code in this post.

    Thus, after 2400 lines are inserted in the lines of only about 125 lineitem table are spread to each of the tables four proxy.

    sqlf > select count (*) in the sqlfire.lineitem;
    1
    -----------
    2400

    1 selected line
    sqlf > select count (*) in the sqlfire.proxy_0;
    1
    -----------
    125

    1 selected line
    sqlf > select count (*) in the sqlfire.proxy_0;
    1
    -----------
    125

    1 selected line
    sqlf > select count (*) in the sqlfire.proxy_1;
    1
    -----------
    129

    1 selected line

    This same event receiver code worked with SQLFire v1.0, we have recently updated to v1.0.3.1 and that's when we started to see the problem. I don't see anything unusual in the newspapers. Is there something that has changed with the SYS. Order ADD_LISTENER are we missing?

    Thank you
    Sean

    Hi Sean,.

    I think you want to attach the code for demo.vmware.sqlfire.greenplum.MultiHubProxyDispatcher but I see only MicroBatchListener.

    Looks like you are using both the AsyncEventListener, but also the listener to table which could be added through the SYS. Procedure ADD_LISTENER.

    Can you please write how you use the combination.

    Please note async event listener cannot be added through sys.ad_listener.

    Thank you

    Neeraj

  • Invalid code redemption after problems with the serial number.

    I was somehow began with two cats today in dealing with this problem.  I have all new software to Lightroom which was given to me as a gift.  I inserted the disc and downloaded on my computer, went to retrieve my serial number and that's when the problem started.  I got my redemption code, got my serial number, you click on the option 'Download', an error window emerged saying "the Web page could not be loaded at this time" and when I went back to get the serial number (press arrow to the left), he had disappeared.  It now has an invalid redemption code.  Help!  How can I use my software, get my serial number or get a new serial number?

    http://helpx.Adobe.com/x-productkb/policy-pricing/serial-number-retrieval-process-FAQ.html

  • Problem with event CreateJS

    I am trying to add an event listener to one of my symbols in Flash. Here is the code:

    / * js

    This.Stop ();

    function handleMouseEvent (evt)

    {

    evt.target.gotoAndStop ("over");

    }

    this.addEventListener ('mouseover', handleMouseEvent);

    internship. Update();

    */

    The symbol has been created on the stage and when published by using the CreateJS extension, it errors every time in the browser to the line where I use the addEventListner method. The error is basically saying there is no method like the one defined. Now, in this video of Grant Skinner, it does basically the same thing but with an older version of the API CreateJS: lish-to-html5-using-the-adobe-flash-professional-toolkit-for-createjs/ http://tv.adobe.com/watch/getting-started-with-flash-professional-toolkit-for-createjs/pub

    Why it doesn't work in my example?

    The issue is that toolkitforcreatejs is using Easeljs version 0.5.0 new event model was introduced in version 0.6.0. Update of version 0.6, and it should work for you.

  • (Error code: sec_error_revoked_certificate) No problem with Safari loading. Help, please

    This problem started 29/7 pm. No problem to access the site before this date. Air card has something to do with it?

    You can uncheck "use the OCSP protocol to confirm the current validity.

    Who should access the site.

    Make sure that you cancel the change once you are done with the site, and check the box to verify certificates online.

    You can contact the site and inform them about this issue.

  • problems with the titles of sensitive bootstrap css pages

    Hello

    To get a little more familiar with the concept of reagent and "bootstrap", I downloaded a boot-gen-4 data model. This comes with a lot of explanation, that is not the issue. My problem is that it seems as if I should add the title (my company) on each page I do. I thought that would be a set time in css (custom.css or bootstrap.css or...)

    No matter what I try I can't get my title is displayed on each site. Maybe I should strip the model of all the example pages, I know not (the only place to add your title (company name) seems to be in the index.html file.

    I have to admit that I'm not a css and still less specialist "bootstrap" etc., so maybe someone can give me some info that helps me understand a little better.

    And if this all sounds a little vague, let me know, I could send code or whatever is needed...

    Thanks in advance,

    Karin

    PS. I hope that this post ended up in the right forum...)

    It is not a bootstrap or emit css, it is an HTML element.

    The title is a pair of tags located on thesection of each page.

    (the tag on this page code is

    problems with the titles of different pages in Res... | Adobe community)

    For SEO purposes, it is best to have a different, valid title on each page.

    If you use a template, letpair of tags in an editable region.<p class="reply">

  • I have a problem with connecting to Skype, get error code 1001 on my event viewer

    I have the latest version of Skype installed and have not been able to connect. I had Skype for over a year and my computer has developed a problem with a memory stick and after that I came back from the repair shop, it didn't work. They had removed Skype from my system so I reinstalled and cannot connect.

    And this is related to the Windows XP files, folders and search for how?

    Ask here:

    SKYPE FORUMS:
    http://Forum.Skype.com/

  • Problem with the change in value of listbox event

    Hello

    I have a problem with the help of Listbox value change event. The code that I have attached is a simplified version of the largest program, but the problem is the same. One of the loops of Nonna is responsible for handlig occurring events ant the other is responsible for the execution of the program. In the project of oryginal I use a listbox control to determine which plots graphic display of a waveform is visible (first position of the listbox-> only plot first visible etc.). In the attached vi, I just show the current value of the listbox control. The problem is the event runs only once and then the program crashes. I want to be able to change the value of the listbox work both at idle and in State of a program, but when I put the structure of the event in both States, he does not. I'd be very grateful if someone smarter than me could tell me where I made my mistake. I want my program to be able to manage the keys and listbox events in States (slow down and knit) program.

    You have two structures of event in two cases different from the structure of the case, and both are tuned to listbox events has changed. Because only once can be triggered at any time, the VI crashes (lock events the front panel (default) until the event can complement).

    You must use a unique event structure managing all events.

    The overall program architecture looks like inside-out for me.

    For the buttosn, you must use action lock (switch not release!) and use the value changed events.

  • What are the Causes of 'loop Hang"problem with file i/o when using timed multiple loops on one OR cRIO-9012?

    Normal 0 false false false fr X-NONE X-NONE / * Style Definitions * / table. MsoNormalTable {mso-style-name : « Table Normal » ; mso-tstyle-rowband-taille : 0 ; mso-tstyle-colband-taille : 0 ; mso-style-noshow:yes ; mso-style-priorité : 99 ; mso-style-qformat:yes ; mso-style-parent : » « ;" mso-rembourrage-alt : 0 à 5.4pt 0 à 5.4pt ; mso-para-marge-top : 0 ; mso-para-marge-droit : 0 ; mso-para-marge-bas : 10.0pt ; mso-para-marge-left : 0 ; ligne-hauteur : 115 % ; mso-pagination : widow-orphelin ; police-taille : 11.0pt ; famille de police : « Calibri », « sans-serif » ; mso-ascii-font-family : Calibri ; mso-ascii-theme-font : minor-latin ; mso-hansi-font-family : Calibri ; mso-hansi-theme-font : minor-latin ;}

    I experienced a problem with an application. I think I've isolated the problem in the "Timed loop question - Source Code.zip" attached source code. A detailed list of my results are in the attached document "Timed loop detailed question - Results.docx.

    Overview - it seems to be closely related to the IO files and the use of "Timed loops" on the OR cRIO-9012

    1. If I activate the e/s in two loops, then two loops crash simultaneously

    2. If I activate only the e/s in a loop, then only this loop crashes

    3. If I activate the e/s in two loops and make a 'While' loop earrings, then it don't crash

    4. If it is wrote nothing in the file I/o, then it don't crash

    5. If the reference to the file is left open instead of opening and closing on each call, so it don't crash

    6. If I try to run it on "My Computer", then it don't crash

    7. If the IO is only activated in a loop and programmed to wait for one second between the file access, then it always crashes

    In my real application, any given row is only writing (at least) once a minute, but I couldn't still my application to plant within a period of 24 hours by writing a single error of a single loop once per minute, with a low CPU use. It was the impulse to test the seventh point above.

    It seems that the best solution was to open the reference to the file and let it open. I think it is a good practice in general and I'll do the update in the application. This should solve the problem, but it is very difficult to verify this due to the sporadic nature of the question. As such, I'd like to understand what was causing the problem so I can verify that it was fixed. So far, my attempts to create a single, coherent theory able to explain all aspects of this issue have failed.

    I just wanted to know at all that there has been a request for corrective action (CAR #214156) has filed for this issue to be fixed in a future release. This seems to be a problem with the VxWorks operating system, we use in real time. We have additional cRIO chassis which have a Pharlap OS where it does not work. For now, you can search for this CAR ID notes to see if this problem has been resolved for publication in the future.

    Currently, there are two solutions, we have identified for this problem:

    1. open the file before the loop and close it after. (recommended)
    2 perform file i/o in a normal loop and transfer data to a queue.

Maybe you are looking for