Re: [Flashcoders] using Bitmap for hitArea
BitmapData.hitTest: http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=1410.html Leandro Ferreira On Mon, Jun 22, 2009 at 19:21, Andrew Sinning wrote: > If I draw a circle using the Graphics and Shape classes, and then add the > shape to a sprite, I can use the sprite for the hitArea of another sprite > and it works just fine. Everything within the circle is a hit, everything > outside of it is a miss. > > However, if I create a sprite containing a Bitmap drawn from this same > circle and try to use this sprite for the hitArea, the entire rectangle > becomes the hit area. I've played around with different alpha-levels, using > white and black, and using the opaqueBackground setting. Nothing seems to > work. Am i missing something or is this a known limitation? > > I'm using AS3 under Flash CS3. > > Thanks! > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] using Bitmap for hitArea
If I draw a circle using the Graphics and Shape classes, and then add the shape to a sprite, I can use the sprite for the hitArea of another sprite and it works just fine. Everything within the circle is a hit, everything outside of it is a miss. However, if I create a sprite containing a Bitmap drawn from this same circle and try to use this sprite for the hitArea, the entire rectangle becomes the hit area. I've played around with different alpha-levels, using white and black, and using the opaqueBackground setting. Nothing seems to work. Am i missing something or is this a known limitation? I'm using AS3 under Flash CS3. Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Determining probablity of a random pick.
I see, that makes sense. Cheers. Jiri Paul Andrews wrote: Jiri wrote: Thank you i understand it. Could u please elloborate on the last part "..You can optimise this by using an array of pointers.." Do you mean that this; First calculated the range for each node. A = 0 - 5 B = 6 - 7 C = 8 - 10 Then store in an array like so? Array[0-5] = A Array[6-7] = B Array[8-10] = C Last step get a random number between 0 - 10 => for instance 5 //result is then return Array[5] as XML If this is what you mean, would this approach not take a 'relatively' big amount of memory? You don't have to store the node itself, just a reference to it, so no it wouldn't be a memory hog. It could even just be the numerical index of the node. Paul JIri Paul Andrews wrote: Jiri wrote: Hello list, I have an XMLList that can vary in length. I pick a random node each time using the simple method below: var tRandom:int = int(Math.random()*tXMLSource.nodes.length() ); return tXMLSource.nodes[tRandom] Now i would like to change it, so that I can specify a weight to each node. This weight would have to determine the probability the nodes get selected out when a random pick is being performed. Does anybody know how to build such an algorithm? Sum all of the node weights, then generate a random number within that range. Now you have to find the node corresponding to that number. This can be done by traversing the nodes in sequence. As you traverse the nodes sum the weight until the value generated is within the range - then you have the right node. You can optimise this by using an array of pointers, or keeping the weights in an external array, but that may be more or less interesting depending on the number of nodes involved and what optimisation you need. Paul Much appreciated, Jiri ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] ReferenceError: Error #1065 issue
Thanks Mario! I actually found the solution to this. It was my own mistake, of course. I've got a base level swf loading in a child swf which contains the super class and subclass mentioned below. Turns out the loading swf also uses the super class, and I hadn't recompiled it in the process. It was loading the older version of the super class into memory first, so the updated definition compiled into the child swf was not being used. Thanks again for your response, Bob -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of mario Sent: Saturday, June 20, 2009 4:52 PM To: Flash Coders List Subject: Re: [Flashcoders] ReferenceError: Error #1065 issue If you override that function like so, does it compile (to make sure the override is correct) and do you see the trace (to make sure the call is correct)? override protected function mthGetPDataTag(stgInput:String) :String { trace('call worked') return ''; } -- Mario Gonzalez http://onedayitwillmake.com Senior Developer | WDDG.com Leisle wrote: > Hi list, > > This should be simple, but for some reason refuses to cooperate. I'm working > in AS3, CS3. > I've got a super class (HsSegment) and a subclass (HsSegment_qtd1), both are > public. In the super class are the definitions for many methods, including > this definition: > > protected function mthGetPDataTag(stgInput:String):String > { > //...Do stuff and return a String... > } > > In the subclass I've got the call to this method: > var stgEg:String = mthGetPDataTag(stgInput); > > When testing in the IDE this works fine. When testing in the browser I get > a runtime error, > "ReferenceError: Error #1065: Variable > hs.segments.classes:HsSegment_qtd1::mthGetPDataTag is not defined." > > I've googled and found plenty of questions around this, but no answers, > other than 'make your classes public', which they are. > The other methods in the super class are defined and called essentially this > same way and work fine in both IDE and browser. What makes this one special? > > What am I missing? Any help is appreciated. > > Thanks, > Bob > > > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > __ Information from ESET NOD32 Antivirus, version of virus signature database 4172 (20090619) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Determining probablity of a random pick.
An easy way is to if say you have 3 objects in a list given a weight options[0].weight = 1; options[1].weight = 3; options[2].weight = 4; instead of having it have three selections, you could add the weights and make it have 8 to choose from that point to the option. choice[0]=0; choice[1]=1; choice[2]=1; choice[3]=1; choice[4]=2; choice[5]=2; choice[6]=2; choice[7]=2; Jiri wrote: Hello list, I have an XMLList that can vary in length. I pick a random node each time using the simple method below: var tRandom:int = int(Math.random()*tXMLSource.nodes.length() ); return tXMLSource.nodes[tRandom] Now i would like to change it, so that I can specify a weight to each node. This weight would have to determine the probability the nodes get selected out when a random pick is being performed. Does anybody know how to build such an algorithm? Much appreciated, Jiri ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Determining probablity of a random pick.
Jiri wrote: Thank you i understand it. Could u please elloborate on the last part "..You can optimise this by using an array of pointers.." Do you mean that this; First calculated the range for each node. A = 0 - 5 B = 6 - 7 C = 8 - 10 Then store in an array like so? Array[0-5] = A Array[6-7] = B Array[8-10] = C Last step get a random number between 0 - 10 => for instance 5 //result is then return Array[5] as XML If this is what you mean, would this approach not take a 'relatively' big amount of memory? You don't have to store the node itself, just a reference to it, so no it wouldn't be a memory hog. It could even just be the numerical index of the node. Paul JIri Paul Andrews wrote: Jiri wrote: Hello list, I have an XMLList that can vary in length. I pick a random node each time using the simple method below: var tRandom:int = int(Math.random()*tXMLSource.nodes.length() ); return tXMLSource.nodes[tRandom] Now i would like to change it, so that I can specify a weight to each node. This weight would have to determine the probability the nodes get selected out when a random pick is being performed. Does anybody know how to build such an algorithm? Sum all of the node weights, then generate a random number within that range. Now you have to find the node corresponding to that number. This can be done by traversing the nodes in sequence. As you traverse the nodes sum the weight until the value generated is within the range - then you have the right node. You can optimise this by using an array of pointers, or keeping the weights in an external array, but that may be more or less interesting depending on the number of nodes involved and what optimisation you need. Paul Much appreciated, Jiri ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Determining probablity of a random pick.
Thank you i understand it. Could u please elloborate on the last part "..You can optimise this by using an array of pointers.." Do you mean that this; First calculated the range for each node. A = 0 - 5 B = 6 - 7 C = 8 - 10 Then store in an array like so? Array[0-5] = A Array[6-7] = B Array[8-10] = C Last step get a random number between 0 - 10 => for instance 5 //result is then return Array[5] as XML If this is what you mean, would this approach not take a 'relatively' big amount of memory? JIri Paul Andrews wrote: Jiri wrote: Hello list, I have an XMLList that can vary in length. I pick a random node each time using the simple method below: var tRandom:int = int(Math.random()*tXMLSource.nodes.length() ); return tXMLSource.nodes[tRandom] Now i would like to change it, so that I can specify a weight to each node. This weight would have to determine the probability the nodes get selected out when a random pick is being performed. Does anybody know how to build such an algorithm? Sum all of the node weights, then generate a random number within that range. Now you have to find the node corresponding to that number. This can be done by traversing the nodes in sequence. As you traverse the nodes sum the weight until the value generated is within the range - then you have the right node. You can optimise this by using an array of pointers, or keeping the weights in an external array, but that may be more or less interesting depending on the number of nodes involved and what optimisation you need. Paul Much appreciated, Jiri ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Determining probablity of a random pick.
Jiri wrote: Hello list, I have an XMLList that can vary in length. I pick a random node each time using the simple method below: var tRandom:int = int(Math.random()*tXMLSource.nodes.length() ); return tXMLSource.nodes[tRandom] Now i would like to change it, so that I can specify a weight to each node. This weight would have to determine the probability the nodes get selected out when a random pick is being performed. Does anybody know how to build such an algorithm? Sum all of the node weights, then generate a random number within that range. Now you have to find the node corresponding to that number. This can be done by traversing the nodes in sequence. As you traverse the nodes sum the weight until the value generated is within the range - then you have the right node. You can optimise this by using an array of pointers, or keeping the weights in an external array, but that may be more or less interesting depending on the number of nodes involved and what optimisation you need. Paul Much appreciated, Jiri ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Determining probablity of a random pick.
Hello list, I have an XMLList that can vary in length. I pick a random node each time using the simple method below: var tRandom:int = int(Math.random()*tXMLSource.nodes.length() ); return tXMLSource.nodes[tRandom] Now i would like to change it, so that I can specify a weight to each node. This weight would have to determine the probability the nodes get selected out when a random pick is being performed. Does anybody know how to build such an algorithm? Much appreciated, Jiri ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] accessing embedded cue point names
cuePoint event object has "info" property, which is an object contains properties such as "name", "time", and "type". In your situation you would just fire some actions depending on the name of the cue point. Kenneth Kawamoto http://www.materiaprima.co.uk/ Sam Brown wrote: Hi list, Quick question that should be straightforward, but I'm having trouble finding the answer in the help docs: I've got a video with embedded event cue points in it.This is an FLV component with instance name myVid. I can fire events via myVid.addEventListner(MetadataEvent.CUE_POINT, doSomething); which works fine, but I want to listen directly for the individual cue points by name. Is there a CUE_POINT.NAME property or something similar that will allow me to fire events based on the cue point name:string? Any advice is greatly appreciated. Sam PS. should I embed the cue point as Navigation cue point as opposed to Event cue points? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders