You can pass a bitmap between two custom classes?

I have two custom as3, TriviaGame and TriviaQuestion classes, and I try to retrieve a bitmap stored in TriviaQuestion and have found it impossible to date.

It seems that the root of my problem, is that this bitmap is somehow void in my GetImage function, even if it is class that has been defined previously in ImageLoaded() data. The only time where I am able to access the information of the bitmap (in order to add it to the display) is inside ImageLoaded().

In TriviaQuestion.as, loading the image:

private function XMLLoadedHandler (e:Event):void
        {
            xml = new XML(e.target.data);
            
            // grab title
            titleFormat = new TextFormat( font, 25, color, true, null, null, null, null, "center" );
            titleText = CreateText( xml[0].attribute("title"), titleFormat, (stageProps.stageWidth/2), (0 + margins), (stageProps.stageWidth) );
            
            // get questions/answers
            var qList:XMLList = xml.item;
            totalQuestions = qList.length();
            questions = new Array();
            
            for ( var i:int = 0; i < totalQuestions; i++ )
            {
                var myItem:XML = xml.item[i];
                var temp:TriviaQuestion = new TriviaQuestion();
                
                // set question class data
                temp.SetQuestion( myItem.question );
                if ( "image" in myItem )
                {
                    temp.SetImageProps( myItem.image, myItem.image.attribute("position") );
                }
                var answers:XMLList = myItem.answer;
                temp.SetAnswers( answers );
                temp.SetHint( myItem.hint, xml[0].attribute("ptsPerHint") );
                temp.SetFact( myItem.fact );
                temp.SetPotentialPoints( xml[0].attribute("ptsPerQuestion") );
                
                questions[i] = temp;
            }
            
            AssembleQuestion();
        }

In TriviaQuestion.as, set the class data:

public function SetImageProps( url:String, attr:String ):void
         {
            imgLoader = new Loader;
            imgLoader.contentLoaderInfo.addEventListener( Event.COMPLETE, ImageLoaded, false, 0, true );
            imgLoader.load( new URLRequest( url ) );
            
            position = attr;
        }
        
        public function ImageLoaded(e:Event):void
        {
            bitmap = LoaderInfo(e.target).content as Bitmap;
        }

In TriviaGame.as MakeQuestionSprite()

private function MakeQuestionSprite( s:Shape ):void
         {
            if ( "image" in xml.item[currentQuestion] )
            {
                var myPos:String = questions[currentQuestion].GetPosition();
                var myImg:Bitmap = questions[currentQuestion].GetImage();
                errorText.text = "Img: " + myImg.width;
            }
            var myQ:String = questions[currentQuestion].GetQuestion();
            questionText = new TextField();
            questionFormat = new TextFormat( font, 15, color, null, null, null, null, null, "center" );
            
            if ( "image" in xml.item[currentQuestion] )
            {
                if ( myPos == "right" )
                {
                    myImg.x = stageProps.stageWidth - margins - myImg.width;
                    //myImg.y = margins + s.y + (s.height / 2);
                    //myImg.visible = true;
                    //questionText = CreateText( myQ, questionFormat, margins, myImg.y, (stageProps.stageWidth - margins - myImg.width) );
                }
                //questionSprite.addChild( myImg );
            }
            else
            {
                questionText = CreateText( myQ, questionFormat, margins, (margins + s.y + s.height / 2), (stageProps.stageWidth - margins) );
            }
            
            questionSprite.addChild( questionText ); 
        }


In TriviaQuestion.as, GetImage

public function GetImage ():Bitmap
         {
            var copy:Bitmap = new Bitmap( bitmap.bitmapData.clone() );
            return copy;
        }

You could try to copy your bitmap image until it's ready. When I did this test he kept fail with the same messages that you receive, even after a different syntax in many trials. But when I split the TriviaQuestion test class and added an event listener (see the text in bold below) for once the charger has been filled, then I was able to recover the new bitmap. My two examples classes are based on your examples:

TriviaGame

package {}
import flash.display.Sprite;
Import TriviaQuestion;
Import 12345678910111213import;
import flash.display.BitmapData;
import flash.display.DisplayObject;
import flash.display.Loader;
import flash.events.Event;

SerializableAttribute public class TriviaGame extends Sprite {}

questions of private var: Array;
private var q1:TriviaQuestion;

public void TriviaGame() {}
issues = new Array();
Q1 = new TriviaQuestion();
questions.push (Q1);

MakeQuestionSprite();
}

private void MakeQuestionSprite (): void {}
           var myTriviaQuestion:TriviaQuestion = issues [0];
myTriviaQuestion.addEventListener ("Ready", addNewBitmap);

this.addChild (myTriviaQuestion);
}

private void addNewBitmap(e:Event):void {}
var mybitmap:Bitmap = issues [0]. GetImage ();
MyBitmap.x = 400;
this.addChild (mybitmap);

}

} / / end of class
}

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

TriviaQuestion

package {}
Import 12345678910111213import;
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.LoaderInfo;
import flash.display.Sprite;
import flash.display.BitmapData;
   
SerializableAttribute public class TriviaQuestion extends Sprite {}
   
private var imgLoader:Loader;
public var bitmap2:Bitmap;
private var position: String;
private var _copy:Bitmap;
   
public void TriviaQuestion() {}
SetImageProps ("frog4.jpg");
}
   
public void SetImageProps (url: String, attr:String = "" "): void
{
imgLoader = new loader;
imgLoader.contentLoaderInfo.addEventListener (Event.COMPLETE, ImageLoaded, false, 0, true);
imgLoader.load (new URLRequest (url));
       
position = attr;

}
       
public void ImageLoaded(e:Event):void
{
bitmap2 = new bitmap;
bitmap2 = Bitmap (e.target.loader.content);
addFrog();
          this.dispatchEvent (new Event ("Ready"));
}

public function addFrog (): void {}
this.addChild (bitmap2);

var frog: Bitmap = GetImage ();
Frog.x = 200;
this.addChild (frog);
}
       
public function getBitmapData (): BitmapData {}
Return bitmap2.bitmapData.clone ();
}

public function getLoader (): {charger
Return imgLoader;
}

public void GetImage (): Bitmap
{
var copy: Bitmap = new Bitmap (bitmap2.bitmapData.clone ());
return the copy;
}

} //end of class
}

Post edited by: waterlovinguy

Tags: Adobe Animate

Similar Questions

  • can we do vMotion between two data center

    Dear team,

    Can we do vMotion between two data center (esxi5, x)

    Can we do SVMotion between two data center (esxi5, x)

    Note: it is not a physical data center, it is a virtual data center

    can we do vMotion between clusters (esxi5.x)

    can we do SVMotion between clusters (esxi5.x)

    concerning

    Mr. VMware

    Can we do vMotion between two data center (esxi5, x)

    NO, you can't.

    Can we do SVMotion between two data center (esxi5, x)

    Yes, as long as data warehouses are shared.

    can we do vMotion between clusters (esxi5.x)

    Yes, as they perform the same CPU families.

    can we do SVMotion between clusters (esxi5.x)

    Yes, as long as data warehouses are shared.

  • Can we do vMotion between two datacenter if VM is poweredoff

    Dear team,

    Can we do vMotion between two data center (esxi5, x)

    Can we do SVMotion between two data center (esxi5, x)

    Note: it is not a physical data center, it is a virtual data center

    can we do vMotion between clusters (esxi5.x)

    can we do SVMotion between clusters (esxi5.x)

    concerning

    Mr. VMware

    Can we do vMotion between two data center (esxi5, x)

    Yes.

    Can we do SVMotion between two data center (esxi5, x)

    Yes.

    can we do vMotion between clusters (esxi5.x)

    Yes.

    can we do SVMotion between clusters (esxi5.x)

    Yes.

  • How to send a message between two custom components

    I have a datagrid in a custom cuomponent that is.

    < mx:Canvas id = "customerGrid".
    Width = '100% '.
    Height = "350" >
    < customer: CustomerGrid / >
    < / mx:Canvas >

    < customer: CustomerDetail / >

    The < customer: CustomerDetail / > has a TextInput. How to send a message to < customer: CustomerGrid / > to < customer: CustomerDetail / > when you click the datagrid control. When a user clicks the selectedItem I want this detail to display in the TextInput, which is in another component.

    I'm looking in Restaurant Finder sample. He uses exactly as I wanted to do. However, it uses a kind of AccessibleText. Is there somewhat easier to implement.

    Thank you

    One way to do this is to use the property data, most of the components inherit and use links between the custom grid and the detail view.


    Width = '100% '.
    Height = "350" >

    Now, in the light of the foregoing, I assumed that CustomerGrid is actually extending DataGrid, if this isn't the case, you will need to add additional logic to CustomerGrid. You will need to define a public property to the value of the selected item in the DataGrid inside the CustomerGrid and make it Bindable (see docs: metadata that can be related).

    Inside the CustomerDetail, bind the TextInput property data, by setting the property in the data object to which you want to display.

    Say the selectedItem (in the DataGrid) has a customerName field, you would do something like that (inside CustomerDetail).

  • You can remove the gaps between songs in itunes 12.5.1.21

    How can I remove the gaps between songs itunes 12.5.1.21

    Unfortunately, user control in playback gapless disappeared several years ago.  There are different things you can try. You can use a different ripper to rip tracks omitting gaps (see XLD).  You can set crossfade overlap packed during the silence between tracks.

  • How can I synchronize time between two computers?

    If I have computers connected via a LAN, how can I get to synchronize their time of a computer authoritative? I do not fear that they have the true, but just time that they have the same time. I looked at this page here configure various things in regedit so that one is prepared to act as a time server authoritative:

    However, I'm not sure how to actually do other computers process as their source. As I know if you mention the date and time properties in windows, there is a section to automatically synchronize with an internet time server. This is where I would specify computers do not have authority to read the authoritative? And what I would put the server? My first thought was the IP address, but when I try that it just gives an error after trying for a little while.
    I do that with windows XP computers, although the layout setting date/time in windows 7 is basically the same.
    Any help would be appreciated.

    It is an interesting question.

    Of course, if your LAN is connected to the Internet, the obvious solution is to synchronize two computers at the same time source Internet, such as time.windows.com and time.nist.gov (see http://tf.nist.gov/tf-cgi/servers.cgi).

    The time real internal clocks (RTC) in most computers don't are not particularly accurate, but if you want to do is have two computers Sync to the same clock, put all these settings from registry return to their default values and see the response from Hans-Georg Michna here--> http://www.pcreview.co.uk/forums/sync-time-among-pcs-lan-ntp-t244334.html

    The "windowsservername" corresponds to the "display name" of the computer. Do right click my computer, select properties and select the "Computer name" tab

    If the computer name is not recognized, it is probably because the NetBIOS name resolution is not enabled.  To test, open a windows command prompt (start > run > cmd > OK) and type

    ping ComputerName {press Enter}

    Note that you do not use the two slashes back in the ping command.  For example, if the computers named Alice, Bob and Carol are on the local network, on computer, Alice, you would type

    Bob ping {press Enter}

    But if you try to synchronize the time on Alice using Bob as the time source, you could type

    NET time \\Bob/set

    To test the command net time, run it without parameters selected.  For example:

    NET time \\Bob

    You should get the following output (following comes from Windows 7, but it should be basically the same for XP):

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

    C:\Users\LemP>net time \\Bob
    Is currently at \\Bob 07/10/2013 14:30:30

    The command completed successfully.

    To enable the NetBIOS name resolution:

    • Open network connections (start > run > ncpa.cpl > OK)
    • Right-click on the icon for your network adapter, and then select Properties
    • Select "Internet (TCP/IP Protocol" and click on the button 'properties '.
    • Click on the button "Advanced".
    • Select the WINS tab
    • Select the medium radio button to "Enable NetBIOS over TCP/IP"
    • OK your way out
  • You can turn off text between frames?

    According to the guys of title, no indication on the deactivation of the sequences between the previously linked images enjoyed.

    D

    Try the SplitStory script. It divides a thread in individual images not coupled with (almost) the same content. ID will treat entire paragraph between two images like two paragraphs after the split, then you might find undesirable dashes at the top of a frame, and there could be the possibility of this casuing a reflow issue that could change the number of lines. I don't remember if the script made its way from the end of the beginning, or vice versa, which would affect this particular problem.

  • How to pass the parameter between two adapplications (remote application)

    Hi friendz,.
    Please help me...
    I use JDEV 11.1.2.2.0 version.
    My problem is the following,
    When I have two applications of mapping through the jar files.
    It works well, but I want to continue setting an application to another application...
    How can I do this?
    Thank you...
    -Rude-

    Edited by: Harsh1 December 10, 2012 19:10

    Hello

    Check this: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/52-taskflow-in-lib-169195.pdf

    Arun-

  • Communication between two custom components

    Hello

    I have a problem to get action in a custom component to cause a refresh of another custom component?

    My configuration is:

    < application >

    < component includeIn custom 1 "View1" >

    < component custom 2 id = "custom2" level = "{level}" "view2" includeIn >

    < component custom an includeIn 'View1' >

    < component includeIn custom B "view2" >

    < / application >

    I have a number of custom components load in my main application window.

    In the custom component 1, I have a drop down menu which determines levels 1 to 10.

    When the user chooses a new level, change an event is triggered and the dispathed to the main application that receives it in the UpdateDisplayHandler.

    Component event dispatcher custom 1:

    protected function level_changeHandler(event:IndexChangeEvent):Sub

    {

    var newDisplay:UpdateDisplay = new UpdateDisplay ("UpdateDisplay", level.selectedItem.value);

    dispatchEvent (newDisplay);

    }

    Main application manager:

    protected function updateDisplayHandler(event:UpdateDisplay):Sub

    {

    Level = event.level

    }

    Level information comes to the manager who updates the "level" variable correctly. So far so good.

    The variable "level" is can be linked and analyzed for the custom component 2.

    < components: custom2 id = level "custom2" = "{level}" / >

    The question is how to make my component custom 2 refresh(), reload() then it makes again based on new information of level?

    I will be grateful for any help on this matter.

    Karsten

    Is probably not the cleanest way, but he's going to move you quickly.

    public var levelNumber:int = new int;

    implement

    private var _levelNumber:int;

    public function get levelNumber (): int

    {

    Return _levelNumber;

    }

    public function set levelNumber(value:int):void

    {

    If (value! = _levelNumber)

    {

    _levelNumber = value;

    call the custom here update refresh method

    }

    }

    I don't know your usecase or your architecture so there are probably better ways.

    Maybe like this:

    The main application event handler:

    protectedfunction updateDisplayHandler(event:UpdateDisplay):void

    {//check if there is a change in level and exposes a public service on the part 2}

    If (level! = event.level)

    {

    Level = event.level;

    COMPONENT2.updateOrRefreshBasedOnNewLevelValue (Level);

    }

    }

    HTH,

    Claudiu

  • Can I synchronize Thunderbird between two computers? (The two Macs, same OS version)

    I want to (temporarily?) have two computers to have exactly the same Thunderbird environment, including the same local folders, all with the same content. The initial situation will be that I will migrate data Thunderbird to my iMac, settings, etc., for my MacBook Pro and iMac will go in stock. (Repairs/improvements, of the variety 'Out of the House for a few weeks'.) During this time, I'll use the MBP and want to access my folder "sent", as well as all records of archived messages. Then, I want to move all the news on the MBP to the iMac. My hope is that I can put things up to automatically synchronize the two sets of message files, keep the two machines in service for access to the electronic mail.

    Thanks, Wimsey

    The only way to do that sync constantly must have your saved somewhere Thunderbird profiles folder where computers will still have access to them. As a storage of access network for use in your home, or a cloud storage online.

    With the help of cloud online for this storage will theoretically what you want, but there will be problems with Thunderbird is able to access these files quickly, causing Thunderbird to freeze. So I do not recommend this.

    With respect to temporarily move to another computer, read this: move your profile folder

  • How can I share files between two computer that running 32-bit windows 8 and the second running 64-bit windows 8

    I am unable to share files between 2 computers 32-bit and 64-bit windows 8. Please tell me a solution.

    The number of bits of the processor is not influence it.  If you are having problems sharing files, the bit of the processor is just a coincidence.

    What is the error you get when you try to share a file? And what method do you use to share?  Homegroup?  Right-click to stock option?  Or something else?

  • How can I enter the "/" between two numbers without it dividing two numbers?

    I'm creating a form of estimate of our printing. In printing, a flyer side 2 color is referred to as "4/4". A color face a flyer is "4/0. I have a drop down menu that is using these options and then I use Index) Match for search costs associated with printing a brochure side 2 color (4/4). The slightest mistake of formula is to say that it does not find "4/4", and I think that its because it retains "4/4" because '1'. "." I tried the following:

    Change the format of text data

    Change the format of date/time data

    Editing the cell to = "4/4".

    The strange thing is it works sometimes - and then all of a sudden it no longer works. I'm willing to change it to "4\4" or "4 on 4" if I have too, but its amazing to me that there is no way to force numbers to display both the drop-down menu and the table cell to simply see "" 4/4 in the text and is not a division problem. ""»

    Any thoughts or ideas?

    Thank you.

    I think that building is something like this:

    = number + text("/") + number

    Sorry, but I don't use Pages, but you will probably discover what the operation is for the "text()".

  • You can survey objects to see if the class data were populated in a child method?

    Question,

    If a parent method is cast down to the child class, and then a method is used to update some data in the class data, that the data is visible with a probe on the wire coming from the object? Or is the data view of the data in the parent class data and not the child?

    I have a problem where the parent class is executed instead of the child's class and I can't understand why...

    Thanks for all the ideas.

    I don't know if I know more precisely what you're asking, but maybe this will help you.

    The default probe will show you the data that makes up the type of wire.  Thus, for children's classes it shows data childs and no ancestor.

    If it is a top-level class thread displays only the data for the parent class, it will inform you of the actual wire type, since we know children can spend as their parents.

    Now, I think that what you're asking, is if it is possible to see the data for children, the son of parents.  I don't know, but you should be able to make sensors for you show more information based on the actual type.

  • ___How calculate the scale between two objects (without ArtDirector Toolkit)?

    Normally, I'd use ArtDirector Toolkit, but I can not install it or software at the present time (too long to explain why) remove.

    In any case, I have several items on the scale, and I'll try to find a formula/calculation to determine the scale.

    Example - 1 item is 3,7486 "and I want that it 5,3231" - how to calculate the percentage of the scale to expand it?

    I know you smart popular forum can help!

    Thank you!

    142.00234754308275%

    Hugh Betcha wrote: normally I'd use ArtDirector Toolkit, but I can not install it or software at the present time (too long to explain why) remove.

    Alternatively, you can Google "scale percentage between two numbers" - gives a lot of info free/calculators

  • You can play with two players on the same conlsoe on modern war

    XXXXXXXXXXXXXX

    Hi Capcurt,

    Welcome to the Microsoft Answers site!

    You try to play the game live with 2 players on the same console?

    Unfortunately, you can not go online with two people on the same console. Modern Warfare 2 allows a user to sign in when you play in multiplayer.

    Modern Warfare 2 is a completely new game mode that supports 2-player cooperative play in single line of the solo campaign in history. To do this, you will need two machines.

    For better support, you can contact Xbox Forums.

    http://www.xbox360forum.com/Forum/

    Hope this information is useful.

    Amrita M

    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

Maybe you are looking for

  • Disk utility reports hurt his stats in recovery mode

    I have a 2 TB HD in my iMac which is only about 10% full.  Disk utility reports 1.81 TB free, just like in the finder get info tab.  My Time Machine backups are about 190 GB in size as well.  All of this is consistent.  When that I start by pressing

  • HP preferred integration bug?

    Integration attempt in trying to get the volume of a torus of revoling circle around the axis y. Central circle of distance from the origin R and radius r using slices. Standard simple calc problem often given to students. Works well on HP50 and TI-8

  • No Bluetooth mouse at startup

    I have an IMac which, for some unknown reason, insist on the use of a mouse bluetooth at startup. I don't have a bluetooth mouse! The consequence of this is that I can not connect to the machine more. How can I start the machine so that I can fix the

  • Long DST: failure HP Pavilion 15-b129wm Windows 8

    FAILURE ID: Q378rk-71f76t-mfpwxf - 61 403

  • Deleting some files...

    Is there a program available to help me decide what files can I delete?  These old or unused files.