Flint Particle System Forum - How to explode stageWidth Image or Rectangle? 2011-12-13T01:22:42+00:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher How to explode stageWidth Image or Rectangle? http://flintparticles.org/forum/comments.php?DiscussionID=397&Focus=1340#Comment_1340 2010-09-13T17:25:54+01:00 2011-12-13T01:22:42+00:00 mankica http://flintparticles.org/forum/account.php?u=408 This particle system is so great. I'm trying to learn how to use it. I have tried explode image example to explode image that has same width and height as stage. Actually I just need white empty ... I have tried explode image example to explode image that has same width and height as stage. Actually I just need white empty page that will explode. But I don't know how to change size of the image inside the code. So I made some big white image in Photoshop. About 1280pxX1024px but when the image is that big I get error
ArgumentError: Error #2015: Invalid BitmapData.
Is there a way to create big white rectangle of that size that will explode?
Thank you]]>
How to explode stageWidth Image or Rectangle? http://flintparticles.org/forum/comments.php?DiscussionID=397&Focus=1341#Comment_1341 2010-09-13T17:35:57+01:00 2011-12-13T01:22:42+00:00 radykal http://flintparticles.org/forum/account.php?u=403 Yes very easy. var shape:Shape = new Shape(); shape.graphics.beginFill(0xFFFFFF); shape.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); shape.graphics.endFill(); var ...

var shape:Shape = new Shape();
shape.graphics.beginFill(0xFFFFFF);
shape.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
shape.graphics.endFill();

var bmd:BitmapData = new BitmapData(shape.width, shape.height);
bmd.draw(shape);
]]>
How to explode stageWidth Image or Rectangle? http://flintparticles.org/forum/comments.php?DiscussionID=397&Focus=1342#Comment_1342 2010-09-13T17:59:21+01:00 2011-12-13T01:22:42+00:00 mankica http://flintparticles.org/forum/account.php?u=408 Thank you for your answer. But I have the same problem. When I put 500, 400px like this shape.graphics.drawRect(0, 0, 500, 400); it's working. But with stage.stageWidth, stage.stageHeight ... shape.graphics.drawRect(0, 0, 500, 400);
it's working. But with stage.stageWidth, stage.stageHeight dimensions I get the same error:
ArgumentError: Error #2015: Invalid BitmapData.]]>
How to explode stageWidth Image or Rectangle? http://flintparticles.org/forum/comments.php?DiscussionID=397&Focus=1343#Comment_1343 2010-09-13T18:01:14+01:00 2011-12-13T01:22:42+00:00 mankica http://flintparticles.org/forum/account.php?u=408 Also this is working shape.graphics.drawRect(0, 0, 1100, 700); and this is not working shape.graphics.drawRect(0, 0, 1100, 800); shape.graphics.drawRect(0, 0, 1100, 700);
and this is not working
shape.graphics.drawRect(0, 0, 1100, 800);]]>
How to explode stageWidth Image or Rectangle? http://flintparticles.org/forum/comments.php?DiscussionID=397&Focus=1344#Comment_1344 2010-09-13T18:13:11+01:00 2011-12-13T01:22:42+00:00 radykal http://flintparticles.org/forum/account.php?u=403 Then your stage is null. You can check this by tracing your stage. Do this: trace(stage); If it´s null, you have to set a Added_To_Stage listener.
You can check this by tracing your stage. Do this:

trace(stage);

If it´s null, you have to set a Added_To_Stage listener.]]>
How to explode stageWidth Image or Rectangle? http://flintparticles.org/forum/comments.php?DiscussionID=397&Focus=1345#Comment_1345 2010-09-13T18:42:13+01:00 2011-12-13T01:22:42+00:00 mankica http://flintparticles.org/forum/account.php?u=408 I just added this for testing. After : addChild( renderer ); emitter.start(); I added: renderer.addEventListener(Event.ADDED_TO_STAGE, added); function added():void { ... After :
addChild( renderer );
emitter.start();

I added:
renderer.addEventListener(Event.ADDED_TO_STAGE, added);
function added():void {
trace(stage.stageWidth);
}

But it doesn't run, like is not added to stage. Where do I need to put that ADDED_TO_STAGE listener?

Sorry for so many questions.]]>
How to explode stageWidth Image or Rectangle? http://flintparticles.org/forum/comments.php?DiscussionID=397&Focus=1346#Comment_1346 2010-09-13T21:20:23+01:00 2011-12-13T01:22:42+00:00 radykal http://flintparticles.org/forum/account.php?u=403 Not the renderer, the stage: stage.addEventListener(Event.ADDED_TO_STAGE, added); But honestly these are beginner questions and you want to use a particle engine??! You should learning more ...
stage.addEventListener(Event.ADDED_TO_STAGE, added);


But honestly these are beginner questions and you want to use a particle engine??! You should learning more the basic stuff of AS3 instead of using a particle engine, which is more for advanced developers.]]>
How to explode stageWidth Image or Rectangle? http://flintparticles.org/forum/comments.php?DiscussionID=397&Focus=1347#Comment_1347 2010-09-13T21:48:43+01:00 2011-12-13T01:22:42+00:00 mankica http://flintparticles.org/forum/account.php?u=408 stage.addEventListener(Event.ADDED_TO_STAGE, added); is first that I have tried and it didn't work. Sorry again that I have made a beginer question, I just recently turn to AS3. And when some ...
Sorry again that I have made a beginer question, I just recently turn to AS3. And when some things don't work as they should I start to be confused and do crazy stuff. (Learning harder because english is not my native language, and there are no books on my language).

Here is the full code. It's code from image explode example, I just added my modification, but it won't work.
If someone can make it work great, if not thank you for your time, I know that you are not obligated to answer my question, and I'm very grateful you did so far.


/*
* FLINT PARTICLE SYSTEM
* .....................
*
* Author: Richard Lord
* Copyright (c) Richard Lord 2008-2010
* http://flintparticles.org/
*
* Licence Agreement
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import flash.display.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.emitters.Emitter2D;
import org.flintparticles.twoD.particles.Particle2DUtils;
import org.flintparticles.twoD.renderers.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.common.actions.*;
import fl.motion.easing.*;

var bitmapData1:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0xFFFFFF00);
var txt:TextField = new TextField();
txt.autoSize = TextFieldAutoSize.LEFT;
var tf:TextFormat = new TextFormat();

var emitter:Emitter2D = new Emitter2D();
var shape:Shape = new Shape();
shape.graphics.beginFill(0xFFFFFF);
shape.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
shape.graphics.endFill();

var bmd:BitmapData = new BitmapData(shape.width, shape.height);
bmd.draw(shape);

var particles:Array = Particle2DUtils.createRectangleParticlesFromBitmapData( bmd, 10, emitter.particleFactory, 100, 0 );
emitter.addExistingParticles( particles, false );

var renderer:DisplayObjectRenderer = new DisplayObjectRenderer();
renderer.addEmitter( emitter );
addChild( renderer );
emitter.start();



stage.addEventListener(Event.ADDED_TO_STAGE, added);
stage.addEventListener( MouseEvent.CLICK, explode, false, 0, true );
function added():void {
trace(stage.stageWidth);
}
function explode( ev:MouseEvent ):void {


var p:Point = renderer.globalToLocal( new Point( ev.stageX, ev.stageY ) );

emitter.addAction( new Explosion( 10, 640, 340, 600 ) );

emitter.addAction( new Move() );
emitter.addAction( new DeathZone( new RectangleZone( -10, -10, stage.stageWidth+10, stage.stageHeight+10 ), true ) );

stage.removeEventListener( MouseEvent.CLICK, explode );
}]]>
How to explode stageWidth Image or Rectangle? http://flintparticles.org/forum/comments.php?DiscussionID=397&Focus=1348#Comment_1348 2010-09-13T21:58:54+01:00 2011-12-13T01:22:42+00:00 mankica http://flintparticles.org/forum/account.php?u=408 Just to mention, code works if the stage width and height are smaller or equal 1100x700px, otherwise it does not, even crashes flash How to explode stageWidth Image or Rectangle? http://flintparticles.org/forum/comments.php?DiscussionID=397&Focus=1349#Comment_1349 2010-09-14T00:05:32+01:00 2011-12-13T01:22:42+00:00 mankica http://flintparticles.org/forum/account.php?u=408 Found the problem. When rectangle particels are too small flash crashes. How to explode stageWidth Image or Rectangle? http://flintparticles.org/forum/comments.php?DiscussionID=397&Focus=1358#Comment_1358 2010-09-16T11:50:19+01:00 2010-09-16T11:51:53+01:00 Richard http://flintparticles.org/forum/account.php?u=1 Hi mankica You can simplify your code. This should work... var bitmapData1:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0xFFFFFFFF); var emitter:Emitter2D = new ...
You can simplify your code. This should work...

var bitmapData1:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0xFFFFFFFF);

var emitter:Emitter2D = new Emitter2D();

var particles:Array = Particle2DUtils.createRectangleParticlesFromBitmapData( bitmapData1, 10, emitter.particleFactory, 0, 0 );
emitter.addExistingParticles( particles, false );

var renderer:DisplayObjectRenderer = new DisplayObjectRenderer();
renderer.addEmitter( emitter );
addChild( renderer );
emitter.start();

stage.addEventListener( MouseEvent.CLICK, explode, false, 0, true );

function explode( ev:MouseEvent ):void {
var p:Point = renderer.globalToLocal( new Point( ev.stageX, ev.stageY ) );
emitter.addAction( new Explosion( 10, 640, 340, 600 ) );
emitter.addAction( new Move() );
emitter.addAction( new DeathZone( new RectangleZone( -10, -10, stage.stageWidth+10, stage.stageHeight+10 ), true ) );
stage.removeEventListener( MouseEvent.CLICK, explode );
}


This works for me (if a little slowly) at 2560 x 2048. When I double the size again to 5160x4096 it doesn't work. I don't get an error but Flash player just grinds to a halt.

At what point Flash can't cope will depend on the particular computer and the version of the Flash player. As you note, making the rectangle particles bigger reduces the number of rectangles and so improves performance.]]>